]>
diplodocus.org Git - nmh/blob - uip/inc.c
1 /* inc.c -- incorporate messages from a maildrop into a folder
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
10 * Thu Feb 12 21:00 CST 2015 Marcin Cieslak <saper@saper.info>
11 * Replaced setgid() calls with setegid() so that it works with dot
12 * locking on FreeBSD. setegid() should be supported on modern POSIX
15 * Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
16 * Added hpux hacks to set and reset gid to be "mail" as needed. The reset
17 * is necessary so inc'ed mail is the group of the inc'er, rather than
18 * "mail". We setgid to egid only when [un]locking the mail file. This
19 * is also a major security precaution which will not be explained here.
21 * Fri Feb 7 16:04:57 PST 1992 John Romine <bug-mh@ics.uci.edu>
22 * NB: I'm not 100% sure that this setgid stuff is secure even now.
24 * See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid
25 * attribute. Running setuid root is probably not a terribly good idea, though.
26 * -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 04/1998
28 * Peter Maydell's patch slightly modified for nmh 0.28-pre2.
29 * Ruud de Rooij <ruud@debian.org> Wed, 22 Jul 1998 13:24:22 +0200
36 #include <h/dropsbr.h>
38 #include <h/fmt_scan.h>
39 #include <h/scansbr.h>
40 #include <h/signals.h>
43 #include "../sbr/lock_file.h"
44 #include "../sbr/m_maildir.h"
45 #include "../sbr/m_mktemp.h"
48 # define TLSminc(a) (a)
53 #define INC_SWITCHES \
54 X("audit audit-file", 0, AUDSW) \
55 X("noaudit", 0, NAUDSW) \
56 X("changecur", 0, CHGSW) \
57 X("nochangecur", 0, NCHGSW) \
58 X("file name", 0, FILESW) \
59 X("form formatfile", 0, FORMSW) \
60 X("format string", 5, FMTSW) \
61 X("host hostname", 0, HOSTSW) \
62 X("user username", 0, USERSW) \
63 X("pack file", 0, PACKSW) \
64 X("nopack", 0, NPACKSW) \
65 X("port name/number", 0, PORTSW) \
66 X("silent", 0, SILSW) \
67 X("nosilent", 0, NSILSW) \
68 X("truncate", 0, TRNCSW) \
69 X("notruncate", 0, NTRNCSW) \
70 X("width columns", 0, WIDTHSW) \
71 X("version", 0, VERSIONSW) \
72 X("help", 0, HELPSW) \
73 X("snoop", 0, SNOOPSW) \
74 X("sasl", 0, SASLSW) \
75 X("nosasl", 0, NOSASLSW) \
76 X("saslmech", 0, SASLMECHSW) \
77 X("initialtls", TLSminc(-10), INITTLSSW) \
78 X("notls", TLSminc(-5), NOTLSSW) \
79 X("certverify", TLSminc(-10), CERTVERSW) \
80 X("nocertverify", TLSminc(-12), NOCERTVERSW) \
81 X("authservice", 0, AUTHSERVICESW) \
82 X("proxy command", 0, PROXYSW) \
84 #define X(sw, minchars, id) id,
85 DEFINE_SWITCH_ENUM(INC
);
88 #define X(sw, minchars, id) { sw, minchars, id },
89 DEFINE_SWITCH_ARRAY(INC
, switches
);
93 * flags for the mail source
99 static struct Maildir_entry
{
103 static int num_maildir_entries
= 0;
104 static int snoop
= 0;
106 extern char response
[];
111 static int mbx_style
= MMDF_FORMAT
;
112 static int pd
= NOTOK
;
117 static char *packfile
= NULL
;
118 static FILE *pf
= NULL
;
120 /* This is an attempt to simplify things by putting all the
121 * privilege ops into macros.
122 * *GROUPPRIVS() is related to handling the setgid MAIL property,
123 * and only applies if MAILGROUP is defined.
124 * Basically, SAVEGROUPPRIVS() is called right at the top of main()
125 * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
126 * do the obvious thing.
128 * There's probably a better implementation if we're allowed to use
129 * BSD-style setreuid() rather than using POSIX saved-ids.
130 * Anyway, if you're euid root it's a bit pointless to drop the group
133 * I'm pretty happy that the security is good provided we aren't setuid root.
134 * The only things we trust with group=mail privilege are lkfopen()
139 * For setting and returning to "mail" gid
142 static gid_t return_gid
;
143 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
144 #define DROPGROUPPRIVS() \
145 if (setegid(getgid()) != 0) { \
146 adios ("setegid", "unable to restore group to %ld", (long) getgid()); \
148 #define GETGROUPPRIVS() \
149 if (setegid(return_gid) != 0) { \
150 adios ("setegid", "unable to set group to %ld", (long) return_gid); \
152 #define SAVEGROUPPRIVS() return_gid = getegid()
154 /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
155 #define TRYDROPGROUPPRIVS()
156 #define DROPGROUPPRIVS()
157 #define GETGROUPPRIVS()
158 #define SAVEGROUPPRIVS()
159 #endif /* not MAILGROUP */
161 /* these variables have to be globals so that done() can correctly clean up the lockfile */
162 static int locked
= 0;
163 static char *newmail
;
169 char *map_name(char *);
171 static void inc_done(int) NORETURN
;
172 static int pop_action(char *);
173 static int pop_pack(char *);
174 static int map_count(void);
177 maildir_srt(const void *va
, const void *vb
)
179 const struct Maildir_entry
*a
= va
, *b
= vb
;
180 if (a
->mtime
> b
->mtime
)
182 if (a
->mtime
< b
->mtime
)
188 main (int argc
, char **argv
)
194 int hghnum
= 0, msgnum
= 0;
195 bool sasl
, tls
, noverify
;
196 int incerr
= 0; /* <0 if inc hits an error which means it should not truncate mailspool */
197 char *cp
, *maildir
= NULL
, *folder
= NULL
;
198 char *format
= NULL
, *form
= NULL
;
199 char *host
= NULL
, *port
= NULL
, *user
= NULL
, *proxy
= NULL
;
200 char *audfile
= NULL
, *from
= NULL
, *saslmech
= NULL
, *auth_svc
= NULL
;
201 char buf
[BUFSIZ
], **argp
, *nfs
, **arguments
;
202 struct msgs
*mp
= NULL
;
205 char b
[PATH_MAX
+ 1];
206 char *maildir_copy
= NULL
; /* copy of mail directory because the static gets overwritten */
209 char *MAILHOST_env_variable
;
212 /* absolutely the first thing we do is save our privileges,
213 * and drop them if we can.
218 if (nmh_init(argv
[0], 1)) { return 1; }
221 arguments
= getarguments (invo_name
, argc
, argv
, 1);
226 * use MAILHOST environment variable if present,
228 * If that fails, use the default (if any)
229 * provided by mts.conf in mts_init()
231 if ((MAILHOST_env_variable
= getenv("MAILHOST")) != NULL
)
232 pophost
= MAILHOST_env_variable
;
234 * If there is a valid "pophost" entry in mts.conf,
235 * then use it as the default host.
237 if (pophost
&& *pophost
)
241 chgflag
= noisy
= noverify
= true;
242 while ((cp
= *argp
++)) {
244 switch (smatch (++cp
, switches
)) {
246 ambigsw (cp
, switches
);
249 adios (NULL
, "-%s unknown", cp
);
252 snprintf (buf
, sizeof(buf
), "%s [+folder] [switches]", invo_name
);
253 print_help (buf
, switches
, 1);
256 print_version(invo_name
);
260 if (!(cp
= *argp
++) || *cp
== '-')
261 adios (NULL
, "missing argument to %s", argp
[-2]);
262 audfile
= getcpy (m_maildir (cp
));
276 * The flag `trnflag' has the value:
278 * 2 if -truncate is given
279 * 1 by default (truncating is default)
280 * 0 if -notruncate is given
290 if (!(cp
= *argp
++) || *cp
== '-')
291 adios (NULL
, "missing argument to %s", argp
[-2]);
292 from
= path (cp
, TFILE
);
295 * If the truncate file is in default state,
296 * change to not truncate.
310 if (!(form
= *argp
++) || *form
== '-')
311 adios (NULL
, "missing argument to %s", argp
[-2]);
315 if (!(format
= *argp
++) || *format
== '-')
316 adios (NULL
, "missing argument to %s", argp
[-2]);
321 if (!(cp
= *argp
++) || *cp
== '-')
322 adios (NULL
, "missing argument to %s", argp
[-2]);
327 if (!(host
= *argp
++) || *host
== '-')
328 adios (NULL
, "missing argument to %s", argp
[-2]);
332 if (!(port
= *argp
++) || *port
== '-')
333 adios (NULL
, "missing argument to %s", argp
[-2]);
337 if (!(user
= *argp
++) || *user
== '-')
338 adios (NULL
, "missing argument to %s", argp
[-2]);
342 if (!(packfile
= *argp
++) || *packfile
== '-')
343 adios (NULL
, "missing argument to %s", argp
[-2]);
361 if (!(saslmech
= *argp
++) || *saslmech
== '-')
362 adios (NULL
, "missing argument to %s", argp
[-2]);
383 if (!(auth_svc
= *argp
++) || *auth_svc
== '-')
384 adios (NULL
, "missing argument to %s", argp
[-2]);
386 adios (NULL
, "not built with OAuth support");
391 if (!(proxy
= *argp
++) || *proxy
== '-')
392 adios (NULL
, "missing argument to %s", argp
[-2]);
396 if (*cp
== '+' || *cp
== '@') {
398 adios (NULL
, "only one folder at a time!");
400 folder
= pluspath (cp
);
402 adios (NULL
, "usage: %s [+folder] [switches]", invo_name
);
406 /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
407 * not DROPGROUPPRIVS().
412 /* guarantee dropping group privileges; we might not have done so earlier */
416 * Where are we getting the new mail?
426 * Are we getting the mail from
429 if (inc_type
== INC_POP
) {
432 if (auth_svc
== NULL
) {
433 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
434 adios (NULL
, "must specify -authservice with -saslmech xoauth2");
438 adios (NULL
, "must specify -user with -saslmech xoauth2");
443 tlsflag
|= P_INITTLS
;
446 tlsflag
|= P_NOVERIFY
;
449 * initialize POP connection
451 if (pop_init (host
, port
, user
, proxy
, snoop
, sasl
, saslmech
,
452 tlsflag
, auth_svc
) == NOTOK
)
453 adios (NULL
, "%s", response
);
455 /* Check if there are any messages */
456 if (pop_stat (&nmsgs
, &nbytes
) == NOTOK
)
457 adios (NULL
, "%s", response
);
461 adios (NULL
, "no mail to incorporate");
466 * We will get the mail from a file
467 * (typically the standard maildrop)
470 if (inc_type
== INC_FILE
) {
473 else if ((newmail
= getenv ("MAILDROP")) && *newmail
)
474 newmail
= m_mailpath (newmail
);
475 else if ((newmail
= context_find ("maildrop")) && *newmail
)
476 newmail
= m_mailpath (newmail
);
478 newmail
= concat (MAILDIR
, "/", MAILFIL
, NULL
);
480 if (stat (newmail
, &s1
) == NOTOK
|| s1
.st_size
== 0)
481 adios (NULL
, "no mail to incorporate");
482 if (s1
.st_mode
& S_IFDIR
) {
488 cp
= concat (newmail
, "/new", NULL
);
489 if ((md
= opendir(cp
)) == NULL
)
490 adios (NULL
, "unable to open %s", cp
);
491 while ((de
= readdir (md
)) != NULL
) {
492 if (de
->d_name
[0] == '.')
494 if (i
>= num_maildir_entries
) {
495 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
496 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
497 num_maildir_entries
= 2*i
+16;
499 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
500 if (stat(Maildir
[i
].filename
, &ms
) != 0)
501 adios (Maildir
[i
].filename
, "couldn't get delivery time");
502 Maildir
[i
].mtime
= ms
.st_mtime
;
507 cp
= concat (newmail
, "/cur", NULL
);
508 if ((md
= opendir(cp
)) == NULL
)
509 adios (NULL
, "unable to open %s", cp
);
510 while ((de
= readdir (md
)) != NULL
) {
511 if (de
->d_name
[0] == '.')
513 if (i
>= num_maildir_entries
) {
514 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
515 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
516 num_maildir_entries
= 2*i
+16;
518 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
519 if (stat(Maildir
[i
].filename
, &ms
) != 0)
520 adios (Maildir
[i
].filename
, "couldn't get delivery time");
521 Maildir
[i
].mtime
= ms
.st_mtime
;
527 adios (NULL
, "no mail to incorporate");
528 num_maildir_entries
= i
;
529 qsort (Maildir
, num_maildir_entries
, sizeof(*Maildir
), maildir_srt
);
532 cp
= mh_xstrdup(newmail
);
536 /* skip the folder setup */
537 if ((inc_type
== INC_POP
) && packfile
)
540 if (!context_find ("path"))
541 free (path ("./", TFOLDER
));
543 folder
= getfolder (0);
544 maildir
= m_maildir (folder
);
545 maildir_copy
= mh_xstrdup(maildir
);
547 if (!folder_exists(maildir
)) {
548 /* If the folder doesn't exist, and we're given the -silent flag,
552 create_folder(maildir
, 0, done
);
557 if (chdir (maildir
) == NOTOK
)
558 adios (maildir
, "unable to change directory to");
560 /* read folder and create message structure */
561 if (!(mp
= folder_read (folder
, 0)))
562 adios (NULL
, "unable to read folder %s", folder
);
566 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
567 if (access (newmail
, W_OK
) != NOTOK
) {
570 SIGNAL (SIGHUP
, SIG_IGN
);
571 SIGNAL (SIGINT
, SIG_IGN
);
572 SIGNAL (SIGQUIT
, SIG_IGN
);
573 SIGNAL (SIGTERM
, SIG_IGN
);
576 GETGROUPPRIVS(); /* Reset gid to lock mail file */
577 in
= lkfopenspool (newmail
, "r");
580 adios (NULL
, "unable to lock and fopen %s", newmail
);
581 fstat (fileno(in
), &s1
);
584 if ((in
= fopen (newmail
, "r")) == NULL
)
585 adios (newmail
, "unable to read");
589 /* This shouldn't be necessary but it can't hurt. */
594 if ((i
= stat (audfile
, &st
)) == NOTOK
)
595 inform("Creating Receive-Audit: %s", audfile
);
596 if ((aud
= fopen (audfile
, "a")) == NULL
)
597 adios (audfile
, "unable to append to");
599 chmod (audfile
, m_gmprot ());
602 fprintf (aud
, "<<inc>> %s -ms %s\n", dtimenow(0), from
);
605 fprintf (aud
, "<<inc>> %s -host %s -user %s\n", dtimenow(0),
608 fprintf (aud
, "<<inc>> %s\n", dtimenow (0));
612 /* Get new format string */
613 nfs
= new_fs (form
, format
, FORMAT
);
616 printf ("Incorporating new mail into %s...\n\n", folder
);
622 * Get the mail from a POP server
624 if (inc_type
== INC_POP
) {
627 packfile
= path (packfile
, TFILE
);
628 if (stat (packfile
, &st
) == NOTOK
) {
630 adios (packfile
, "error on file");
631 cp
= concat ("Create file \"", packfile
, "\"? ", NULL
);
632 if (noisy
&& !read_yes_or_no_if_tty (cp
))
636 msgnum
= map_count ();
637 if ((pd
= mbx_open (packfile
, mbx_style
, getuid(), getgid(), m_gmprot()))
639 adios (packfile
, "unable to open");
640 if ((pf
= fdopen (pd
, "w+")) == NULL
)
641 adios (NULL
, "unable to fdopen %s", packfile
);
643 hghnum
= msgnum
= mp
->hghmsg
;
646 for (i
= 1; i
<= nmsgs
; i
++) {
647 charstring_t scanl
= NULL
;
653 fseek (pf
, 0L, SEEK_CUR
);
656 len
= strlen(mmdlm1
);
657 if (fwrite(mmdlm1
, 1, len
, pf
) < len
)
658 advise (mmdlm1
, "fwrite");
661 if (pop_retr (i
, pop_pack
) == NOTOK
)
662 adios (NULL
, "%s", response
);
664 fseek (pf
, 0L, SEEK_CUR
);
667 adios (packfile
, "write error on");
668 fseek (pf
, start
, SEEK_SET
);
670 cp
= mh_xstrdup(m_name (msgnum
));
671 if ((pf
= fopen (cp
, "w+")) == NULL
)
672 adios (cp
, "unable to write");
673 chmod (cp
, m_gmprot ());
676 if (pop_retr (i
, pop_action
) == NOTOK
)
677 adios (NULL
, "%s", response
);
680 adios (cp
, "write error on");
681 fseek (pf
, 0L, SEEK_SET
);
683 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
684 packfile
? 0 : msgnum
== mp
->hghmsg
+ 1 && chgflag
,
685 1, NULL
, stop
- start
, noisy
, &scanl
)) {
687 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
693 /* advise (cp, "unable to read"); already advised */
704 fputs (charstring_buffer (scanl
), aud
);
709 charstring_free (scanl
);
714 fseek (pf
, stop
, SEEK_SET
);
715 len
= strlen(mmdlm2
);
716 if (fwrite(mmdlm2
, 1, len
, pf
) < len
)
717 advise (mmdlm2
, "fwrite");
718 if (fflush (pf
) || ferror (pf
)) {
722 adios (packfile
, "write error on");
724 map_write (packfile
, pd
, 0, 0L, start
, stop
, pos
, size
, noisy
);
726 if (ferror(pf
) || fclose (pf
)) {
728 (void) m_unlink (cp
);
731 adios (cp
, "write error on");
736 if (trnflag
&& pop_dele (i
) == NOTOK
)
737 adios (NULL
, "%s", response
);
742 if (pop_quit () == NOTOK
)
743 adios (NULL
, "%s", response
);
745 mbx_close (packfile
, pd
);
751 * Get the mail from file (usually mail spool)
753 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
754 scan_detect_mbox_style (in
); /* the MAGIC invocation... */
755 hghnum
= msgnum
= mp
->hghmsg
;
757 charstring_t scanl
= NULL
;
759 /* create scanline for new message */
760 switch (incerr
= scan (in
, msgnum
+ 1, msgnum
+ 1, nfs
, width
,
761 msgnum
== hghnum
&& chgflag
, 1, NULL
, 0L, noisy
,
769 fputs ("inc aborted!\n", aud
);
770 inform("aborted!"); /* doesn't clean up locks! */
774 inform("BUG in %s, number out of range", invo_name
);
778 inform("BUG in %s, scan() botch (%d)", invo_name
, incerr
);
784 * Run the external program hook on the message.
787 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
788 (void)ext_hook("add-hook", b
, NULL
);
791 fputs (charstring_buffer (scanl
), aud
);
798 charstring_free (scanl
);
800 /* If we get here there was some sort of error from scan(),
801 * so stop processing anything more from the spool.
805 } else if (inc_type
== INC_FILE
) { /* Maildir inbox to process */
810 hghnum
= msgnum
= mp
->hghmsg
;
811 for (i
= 0; i
< num_maildir_entries
; i
++) {
812 charstring_t scanl
= NULL
;
816 sp
= Maildir
[i
].filename
;
817 cp
= mh_xstrdup(m_name (msgnum
));
819 if (!trnflag
|| link(sp
, cp
) == -1) {
820 static char buf
[65536];
823 if ((sf
= fopen (sp
, "r")) == NULL
)
824 adios (sp
, "unable to read for copy");
825 if ((pf
= fopen (cp
, "w+")) == NULL
)
826 adios (cp
, "unable to write for copy");
827 while ((nrd
= fread(buf
, 1, sizeof(buf
), sf
)) > 0)
828 if (fwrite(buf
, 1, nrd
, pf
) != nrd
)
830 if (ferror(sf
) || fflush(pf
) || ferror(pf
)) {
832 fclose(pf
); fclose(sf
); (void) m_unlink(cp
);
834 adios(cp
, "copy error %s -> %s", sp
, cp
);
839 if (pf
== NULL
&& (pf
= fopen (cp
, "r")) == NULL
)
840 adios (cp
, "not available");
841 chmod (cp
, m_gmprot ());
843 fseek (pf
, 0L, SEEK_SET
);
844 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
845 msgnum
== mp
->hghmsg
+ 1 && chgflag
,
846 1, NULL
, stop
- start
, noisy
, &scanl
)) {
848 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
854 /* advise (cp, "unable to read"); already advised */
865 * Run the external program hook on the message.
868 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
869 (void)ext_hook("add-hook", b
, NULL
);
872 fputs (charstring_buffer (scanl
), aud
);
877 charstring_free (scanl
);
879 if (ferror(pf
) || fclose (pf
)) {
881 (void) m_unlink (cp
);
883 adios (cp
, "write error on");
888 if (trnflag
&& m_unlink (sp
) == NOTOK
)
889 adios (sp
, "couldn't unlink");
890 free (sp
); /* Free Maildir[i]->filename */
894 free (Maildir
); /* From now on Maildir is just a flag - don't dref! */
899 if (incerr
< 0) { /* error */
901 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
902 (void) lkfclosespool (in
, newmail
); in
= NULL
;
903 DROPGROUPPRIVS(); /* And then return us to normal privileges */
905 fclose (in
); in
= NULL
;
907 adios (NULL
, "failed");
916 if ((inc_type
== INC_POP
) && packfile
)
920 * truncate file we are incorporating from
922 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
924 if (stat (newmail
, &st
) != NOTOK
&& s1
.st_mtime
!= st
.st_mtime
)
925 inform("new messages have arrived!\007");
928 if ((newfd
= creat (newmail
, 0600)) != NOTOK
)
931 admonish (newmail
, "error zero'ing");
932 (void) m_unlink(map_name(newmail
));
936 printf ("%s not zero'd\n", newmail
);
940 if (msgnum
== hghnum
) {
941 inform("no messages incorporated, continuing...");
944 * Lock the sequence file now, and loop to set the right flags
945 * in the folder structure
951 context_replace (pfolder
, folder
); /* update current folder */
953 if ((mp2
= folder_read(folder
, 1)) == NULL
) {
954 inform("Unable to reread folder %s, continuing...", folder
);
959 * Shouldn't happen, but just in case ...
962 if (msgnum
>= mp2
->hghoff
963 && !(mp2
= folder_realloc (mp2
, mp2
->lowoff
, msgnum
+ 1))) {
964 inform("unable to reallocate folder storage");
969 mp2
->curmsg
= hghnum
+ 1;
970 mp2
->hghmsg
= msgnum
;
972 if (mp2
->lowmsg
== 0)
974 if (chgflag
) /* sigh... */
975 seq_setcur (mp2
, mp2
->curmsg
);
977 for (i
= hghnum
+ 1; i
<= msgnum
; i
++) {
978 clear_msg_flags (mp2
, i
);
982 mp2
->msgflags
|= SEQMOD
;
983 seq_setunseen(mp2
, 0); /* Set the Unseen-Sequence */
984 seq_save(mp2
); /* Save the sequence file */
990 * unlock the mail spool
992 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
994 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
995 (void) lkfclosespool (in
, newmail
); in
= NULL
;
996 DROPGROUPPRIVS(); /* And then return us to normal privileges */
998 fclose (in
); in
= NULL
;
1002 context_save (); /* save the context file */
1008 static void NORETURN
1009 inc_done (int status
)
1012 if (packfile
&& pd
!= NOTOK
)
1013 mbx_close (packfile
, pd
);
1017 lkfclosespool(in
, newmail
);
1024 pop_action (char *s
)
1026 fprintf (pf
, "%s\n", s
);
1027 stop
+= strlen (s
) + 1;
1028 return 0; /* Is return value used? This was missing before 1999-07-15. */
1035 char buffer
[BUFSIZ
];
1037 snprintf (buffer
, sizeof(buffer
), "%s\n", s
);
1038 for ( ; (j
= stringdex (mmdlm1
, buffer
)) >= 0; buffer
[j
]++)
1040 for ( ; (j
= stringdex (mmdlm2
, buffer
)) >= 0; buffer
[j
]++)
1043 size
+= strlen (buffer
) + 1;
1044 return 0; /* Is return value used? This was missing before 1999-07-15. */
1055 if (stat (packfile
, &st
) == NOTOK
)
1057 if ((md
= open (cp
= map_name (packfile
), O_RDONLY
)) == NOTOK
1058 || map_chk (cp
, md
, &d
, (long) st
.st_size
, 1)) {