]>
diplodocus.org Git - nmh/blob - uip/inc.c
38ab236c4dd1dac6341b7859efa6bc1e6287071a
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_mktemp.h"
47 # define TLSminc(a) (a)
52 #define INC_SWITCHES \
53 X("audit audit-file", 0, AUDSW) \
54 X("noaudit", 0, NAUDSW) \
55 X("changecur", 0, CHGSW) \
56 X("nochangecur", 0, NCHGSW) \
57 X("file name", 0, FILESW) \
58 X("form formatfile", 0, FORMSW) \
59 X("format string", 5, FMTSW) \
60 X("host hostname", 0, HOSTSW) \
61 X("user username", 0, USERSW) \
62 X("pack file", 0, PACKSW) \
63 X("nopack", 0, NPACKSW) \
64 X("port name/number", 0, PORTSW) \
65 X("silent", 0, SILSW) \
66 X("nosilent", 0, NSILSW) \
67 X("truncate", 0, TRNCSW) \
68 X("notruncate", 0, NTRNCSW) \
69 X("width columns", 0, WIDTHSW) \
70 X("version", 0, VERSIONSW) \
71 X("help", 0, HELPSW) \
72 X("snoop", 0, SNOOPSW) \
73 X("sasl", 0, SASLSW) \
74 X("nosasl", 0, NOSASLSW) \
75 X("saslmech", 0, SASLMECHSW) \
76 X("initialtls", TLSminc(-10), INITTLSSW) \
77 X("notls", TLSminc(-5), NOTLSSW) \
78 X("certverify", TLSminc(-10), CERTVERSW) \
79 X("nocertverify", TLSminc(-12), NOCERTVERSW) \
80 X("authservice", 0, AUTHSERVICESW) \
81 X("proxy command", 0, PROXYSW) \
83 #define X(sw, minchars, id) id,
84 DEFINE_SWITCH_ENUM(INC
);
87 #define X(sw, minchars, id) { sw, minchars, id },
88 DEFINE_SWITCH_ARRAY(INC
, switches
);
92 * flags for the mail source
98 static struct Maildir_entry
{
102 static int num_maildir_entries
= 0;
103 static int snoop
= 0;
105 extern char response
[];
110 static int mbx_style
= MMDF_FORMAT
;
111 static int pd
= NOTOK
;
116 static char *packfile
= NULL
;
117 static FILE *pf
= NULL
;
119 /* This is an attempt to simplify things by putting all the
120 * privilege ops into macros.
121 * *GROUPPRIVS() is related to handling the setgid MAIL property,
122 * and only applies if MAILGROUP is defined.
123 * Basically, SAVEGROUPPRIVS() is called right at the top of main()
124 * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
125 * do the obvious thing.
127 * There's probably a better implementation if we're allowed to use
128 * BSD-style setreuid() rather than using POSIX saved-ids.
129 * Anyway, if you're euid root it's a bit pointless to drop the group
132 * I'm pretty happy that the security is good provided we aren't setuid root.
133 * The only things we trust with group=mail privilege are lkfopen()
138 * For setting and returning to "mail" gid
141 static gid_t return_gid
;
142 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
143 #define DROPGROUPPRIVS() \
144 if (setegid(getgid()) != 0) { \
145 adios ("setegid", "unable to restore group to %ld", (long) getgid()); \
147 #define GETGROUPPRIVS() \
148 if (setegid(return_gid) != 0) { \
149 adios ("setegid", "unable to set group to %ld", (long) return_gid); \
151 #define SAVEGROUPPRIVS() return_gid = getegid()
153 /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
154 #define TRYDROPGROUPPRIVS()
155 #define DROPGROUPPRIVS()
156 #define GETGROUPPRIVS()
157 #define SAVEGROUPPRIVS()
158 #endif /* not MAILGROUP */
160 /* these variables have to be globals so that done() can correctly clean up the lockfile */
161 static int locked
= 0;
162 static char *newmail
;
168 char *map_name(char *);
170 static void inc_done(int) NORETURN
;
171 static int pop_action(char *);
172 static int pop_pack(char *);
173 static int map_count(void);
176 maildir_srt(const void *va
, const void *vb
)
178 const struct Maildir_entry
*a
= va
, *b
= vb
;
179 if (a
->mtime
> b
->mtime
)
181 if (a
->mtime
< b
->mtime
)
187 main (int argc
, char **argv
)
193 int hghnum
= 0, msgnum
= 0;
194 bool sasl
, tls
, noverify
;
195 int incerr
= 0; /* <0 if inc hits an error which means it should not truncate mailspool */
196 char *cp
, *maildir
= NULL
, *folder
= NULL
;
197 char *format
= NULL
, *form
= NULL
;
198 char *host
= NULL
, *port
= NULL
, *user
= NULL
, *proxy
= NULL
;
199 char *audfile
= NULL
, *from
= NULL
, *saslmech
= NULL
, *auth_svc
= NULL
;
200 char buf
[BUFSIZ
], **argp
, *nfs
, **arguments
;
201 struct msgs
*mp
= NULL
;
204 char b
[PATH_MAX
+ 1];
205 char *maildir_copy
= NULL
; /* copy of mail directory because the static gets overwritten */
208 char *MAILHOST_env_variable
;
211 /* absolutely the first thing we do is save our privileges,
212 * and drop them if we can.
217 if (nmh_init(argv
[0], 1)) { return 1; }
220 arguments
= getarguments (invo_name
, argc
, argv
, 1);
225 * use MAILHOST environment variable if present,
227 * If that fails, use the default (if any)
228 * provided by mts.conf in mts_init()
230 if ((MAILHOST_env_variable
= getenv("MAILHOST")) != NULL
)
231 pophost
= MAILHOST_env_variable
;
233 * If there is a valid "pophost" entry in mts.conf,
234 * then use it as the default host.
236 if (pophost
&& *pophost
)
240 chgflag
= noisy
= noverify
= true;
241 while ((cp
= *argp
++)) {
243 switch (smatch (++cp
, switches
)) {
245 ambigsw (cp
, switches
);
248 adios (NULL
, "-%s unknown", cp
);
251 snprintf (buf
, sizeof(buf
), "%s [+folder] [switches]", invo_name
);
252 print_help (buf
, switches
, 1);
255 print_version(invo_name
);
259 if (!(cp
= *argp
++) || *cp
== '-')
260 adios (NULL
, "missing argument to %s", argp
[-2]);
261 audfile
= getcpy (m_maildir (cp
));
275 * The flag `trnflag' has the value:
277 * 2 if -truncate is given
278 * 1 by default (truncating is default)
279 * 0 if -notruncate is given
289 if (!(cp
= *argp
++) || *cp
== '-')
290 adios (NULL
, "missing argument to %s", argp
[-2]);
291 from
= path (cp
, TFILE
);
294 * If the truncate file is in default state,
295 * change to not truncate.
309 if (!(form
= *argp
++) || *form
== '-')
310 adios (NULL
, "missing argument to %s", argp
[-2]);
314 if (!(format
= *argp
++) || *format
== '-')
315 adios (NULL
, "missing argument to %s", argp
[-2]);
320 if (!(cp
= *argp
++) || *cp
== '-')
321 adios (NULL
, "missing argument to %s", argp
[-2]);
326 if (!(host
= *argp
++) || *host
== '-')
327 adios (NULL
, "missing argument to %s", argp
[-2]);
331 if (!(port
= *argp
++) || *port
== '-')
332 adios (NULL
, "missing argument to %s", argp
[-2]);
336 if (!(user
= *argp
++) || *user
== '-')
337 adios (NULL
, "missing argument to %s", argp
[-2]);
341 if (!(packfile
= *argp
++) || *packfile
== '-')
342 adios (NULL
, "missing argument to %s", argp
[-2]);
360 if (!(saslmech
= *argp
++) || *saslmech
== '-')
361 adios (NULL
, "missing argument to %s", argp
[-2]);
382 if (!(auth_svc
= *argp
++) || *auth_svc
== '-')
383 adios (NULL
, "missing argument to %s", argp
[-2]);
385 adios (NULL
, "not built with OAuth support");
390 if (!(proxy
= *argp
++) || *proxy
== '-')
391 adios (NULL
, "missing argument to %s", argp
[-2]);
395 if (*cp
== '+' || *cp
== '@') {
397 adios (NULL
, "only one folder at a time!");
399 folder
= pluspath (cp
);
401 adios (NULL
, "usage: %s [+folder] [switches]", invo_name
);
405 /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
406 * not DROPGROUPPRIVS().
411 /* guarantee dropping group privileges; we might not have done so earlier */
415 * Where are we getting the new mail?
425 * Are we getting the mail from
428 if (inc_type
== INC_POP
) {
431 if (auth_svc
== NULL
) {
432 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
433 adios (NULL
, "must specify -authservice with -saslmech xoauth2");
437 adios (NULL
, "must specify -user with -saslmech xoauth2");
442 tlsflag
|= P_INITTLS
;
445 tlsflag
|= P_NOVERIFY
;
448 * initialize POP connection
450 if (pop_init (host
, port
, user
, proxy
, snoop
, sasl
, saslmech
,
451 tlsflag
, auth_svc
) == NOTOK
)
452 adios (NULL
, "%s", response
);
454 /* Check if there are any messages */
455 if (pop_stat (&nmsgs
, &nbytes
) == NOTOK
)
456 adios (NULL
, "%s", response
);
460 adios (NULL
, "no mail to incorporate");
465 * We will get the mail from a file
466 * (typically the standard maildrop)
469 if (inc_type
== INC_FILE
) {
472 else if ((newmail
= getenv ("MAILDROP")) && *newmail
)
473 newmail
= m_mailpath (newmail
);
474 else if ((newmail
= context_find ("maildrop")) && *newmail
)
475 newmail
= m_mailpath (newmail
);
477 newmail
= concat (MAILDIR
, "/", MAILFIL
, NULL
);
479 if (stat (newmail
, &s1
) == NOTOK
|| s1
.st_size
== 0)
480 adios (NULL
, "no mail to incorporate");
481 if (s1
.st_mode
& S_IFDIR
) {
487 cp
= concat (newmail
, "/new", NULL
);
488 if ((md
= opendir(cp
)) == NULL
)
489 adios (NULL
, "unable to open %s", cp
);
490 while ((de
= readdir (md
)) != NULL
) {
491 if (de
->d_name
[0] == '.')
493 if (i
>= num_maildir_entries
) {
494 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
495 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
496 num_maildir_entries
= 2*i
+16;
498 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
499 if (stat(Maildir
[i
].filename
, &ms
) != 0)
500 adios (Maildir
[i
].filename
, "couldn't get delivery time");
501 Maildir
[i
].mtime
= ms
.st_mtime
;
506 cp
= concat (newmail
, "/cur", NULL
);
507 if ((md
= opendir(cp
)) == NULL
)
508 adios (NULL
, "unable to open %s", cp
);
509 while ((de
= readdir (md
)) != NULL
) {
510 if (de
->d_name
[0] == '.')
512 if (i
>= num_maildir_entries
) {
513 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
514 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
515 num_maildir_entries
= 2*i
+16;
517 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
518 if (stat(Maildir
[i
].filename
, &ms
) != 0)
519 adios (Maildir
[i
].filename
, "couldn't get delivery time");
520 Maildir
[i
].mtime
= ms
.st_mtime
;
526 adios (NULL
, "no mail to incorporate");
527 num_maildir_entries
= i
;
528 qsort (Maildir
, num_maildir_entries
, sizeof(*Maildir
), maildir_srt
);
531 cp
= mh_xstrdup(newmail
);
535 /* skip the folder setup */
536 if ((inc_type
== INC_POP
) && packfile
)
539 if (!context_find ("path"))
540 free (path ("./", TFOLDER
));
542 folder
= getfolder (0);
543 maildir
= m_maildir (folder
);
544 maildir_copy
= mh_xstrdup(maildir
);
546 if (!folder_exists(maildir
)) {
547 /* If the folder doesn't exist, and we're given the -silent flag,
551 create_folder(maildir
, 0, done
);
556 if (chdir (maildir
) == NOTOK
)
557 adios (maildir
, "unable to change directory to");
559 /* read folder and create message structure */
560 if (!(mp
= folder_read (folder
, 0)))
561 adios (NULL
, "unable to read folder %s", folder
);
565 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
566 if (access (newmail
, W_OK
) != NOTOK
) {
569 SIGNAL (SIGHUP
, SIG_IGN
);
570 SIGNAL (SIGINT
, SIG_IGN
);
571 SIGNAL (SIGQUIT
, SIG_IGN
);
572 SIGNAL (SIGTERM
, SIG_IGN
);
575 GETGROUPPRIVS(); /* Reset gid to lock mail file */
576 in
= lkfopenspool (newmail
, "r");
579 adios (NULL
, "unable to lock and fopen %s", newmail
);
580 fstat (fileno(in
), &s1
);
583 if ((in
= fopen (newmail
, "r")) == NULL
)
584 adios (newmail
, "unable to read");
588 /* This shouldn't be necessary but it can't hurt. */
593 if ((i
= stat (audfile
, &st
)) == NOTOK
)
594 inform("Creating Receive-Audit: %s", audfile
);
595 if ((aud
= fopen (audfile
, "a")) == NULL
)
596 adios (audfile
, "unable to append to");
598 chmod (audfile
, m_gmprot ());
601 fprintf (aud
, "<<inc>> %s -ms %s\n", dtimenow(0), from
);
604 fprintf (aud
, "<<inc>> %s -host %s -user %s\n", dtimenow(0),
607 fprintf (aud
, "<<inc>> %s\n", dtimenow (0));
611 /* Get new format string */
612 nfs
= new_fs (form
, format
, FORMAT
);
615 printf ("Incorporating new mail into %s...\n\n", folder
);
621 * Get the mail from a POP server
623 if (inc_type
== INC_POP
) {
626 packfile
= path (packfile
, TFILE
);
627 if (stat (packfile
, &st
) == NOTOK
) {
629 adios (packfile
, "error on file");
630 cp
= concat ("Create file \"", packfile
, "\"? ", NULL
);
631 if (noisy
&& !read_yes_or_no_if_tty (cp
))
635 msgnum
= map_count ();
636 if ((pd
= mbx_open (packfile
, mbx_style
, getuid(), getgid(), m_gmprot()))
638 adios (packfile
, "unable to open");
639 if ((pf
= fdopen (pd
, "w+")) == NULL
)
640 adios (NULL
, "unable to fdopen %s", packfile
);
642 hghnum
= msgnum
= mp
->hghmsg
;
645 for (i
= 1; i
<= nmsgs
; i
++) {
646 charstring_t scanl
= NULL
;
652 fseek (pf
, 0L, SEEK_CUR
);
655 len
= strlen(mmdlm1
);
656 if (fwrite(mmdlm1
, 1, len
, pf
) < len
)
657 advise (mmdlm1
, "fwrite");
660 if (pop_retr (i
, pop_pack
) == NOTOK
)
661 adios (NULL
, "%s", response
);
663 fseek (pf
, 0L, SEEK_CUR
);
666 adios (packfile
, "write error on");
667 fseek (pf
, start
, SEEK_SET
);
669 cp
= mh_xstrdup(m_name (msgnum
));
670 if ((pf
= fopen (cp
, "w+")) == NULL
)
671 adios (cp
, "unable to write");
672 chmod (cp
, m_gmprot ());
675 if (pop_retr (i
, pop_action
) == NOTOK
)
676 adios (NULL
, "%s", response
);
679 adios (cp
, "write error on");
680 fseek (pf
, 0L, SEEK_SET
);
682 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
683 packfile
? 0 : msgnum
== mp
->hghmsg
+ 1 && chgflag
,
684 1, NULL
, stop
- start
, noisy
, &scanl
)) {
686 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
692 /* advise (cp, "unable to read"); already advised */
703 fputs (charstring_buffer (scanl
), aud
);
708 charstring_free (scanl
);
713 fseek (pf
, stop
, SEEK_SET
);
714 len
= strlen(mmdlm2
);
715 if (fwrite(mmdlm2
, 1, len
, pf
) < len
)
716 advise (mmdlm2
, "fwrite");
717 if (fflush (pf
) || ferror (pf
)) {
721 adios (packfile
, "write error on");
723 map_write (packfile
, pd
, 0, 0L, start
, stop
, pos
, size
, noisy
);
725 if (ferror(pf
) || fclose (pf
)) {
727 (void) m_unlink (cp
);
730 adios (cp
, "write error on");
735 if (trnflag
&& pop_dele (i
) == NOTOK
)
736 adios (NULL
, "%s", response
);
741 if (pop_quit () == NOTOK
)
742 adios (NULL
, "%s", response
);
744 mbx_close (packfile
, pd
);
750 * Get the mail from file (usually mail spool)
752 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
753 scan_detect_mbox_style (in
); /* the MAGIC invocation... */
754 hghnum
= msgnum
= mp
->hghmsg
;
756 charstring_t scanl
= NULL
;
758 /* create scanline for new message */
759 switch (incerr
= scan (in
, msgnum
+ 1, msgnum
+ 1, nfs
, width
,
760 msgnum
== hghnum
&& chgflag
, 1, NULL
, 0L, noisy
,
768 fputs ("inc aborted!\n", aud
);
769 inform("aborted!"); /* doesn't clean up locks! */
773 inform("BUG in %s, number out of range", invo_name
);
777 inform("BUG in %s, scan() botch (%d)", invo_name
, incerr
);
783 * Run the external program hook on the message.
786 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
787 (void)ext_hook("add-hook", b
, NULL
);
790 fputs (charstring_buffer (scanl
), aud
);
797 charstring_free (scanl
);
799 /* If we get here there was some sort of error from scan(),
800 * so stop processing anything more from the spool.
804 } else if (inc_type
== INC_FILE
) { /* Maildir inbox to process */
809 hghnum
= msgnum
= mp
->hghmsg
;
810 for (i
= 0; i
< num_maildir_entries
; i
++) {
811 charstring_t scanl
= NULL
;
815 sp
= Maildir
[i
].filename
;
816 cp
= mh_xstrdup(m_name (msgnum
));
818 if (!trnflag
|| link(sp
, cp
) == -1) {
819 static char buf
[65536];
822 if ((sf
= fopen (sp
, "r")) == NULL
)
823 adios (sp
, "unable to read for copy");
824 if ((pf
= fopen (cp
, "w+")) == NULL
)
825 adios (cp
, "unable to write for copy");
826 while ((nrd
= fread(buf
, 1, sizeof(buf
), sf
)) > 0)
827 if (fwrite(buf
, 1, nrd
, pf
) != nrd
)
829 if (ferror(sf
) || fflush(pf
) || ferror(pf
)) {
831 fclose(pf
); fclose(sf
); (void) m_unlink(cp
);
833 adios(cp
, "copy error %s -> %s", sp
, cp
);
838 if (pf
== NULL
&& (pf
= fopen (cp
, "r")) == NULL
)
839 adios (cp
, "not available");
840 chmod (cp
, m_gmprot ());
842 fseek (pf
, 0L, SEEK_SET
);
843 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
844 msgnum
== mp
->hghmsg
+ 1 && chgflag
,
845 1, NULL
, stop
- start
, noisy
, &scanl
)) {
847 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
853 /* advise (cp, "unable to read"); already advised */
864 * Run the external program hook on the message.
867 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
868 (void)ext_hook("add-hook", b
, NULL
);
871 fputs (charstring_buffer (scanl
), aud
);
876 charstring_free (scanl
);
878 if (ferror(pf
) || fclose (pf
)) {
880 (void) m_unlink (cp
);
882 adios (cp
, "write error on");
887 if (trnflag
&& m_unlink (sp
) == NOTOK
)
888 adios (sp
, "couldn't unlink");
889 free (sp
); /* Free Maildir[i]->filename */
893 free (Maildir
); /* From now on Maildir is just a flag - don't dref! */
898 if (incerr
< 0) { /* error */
900 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
901 (void) lkfclosespool (in
, newmail
); in
= NULL
;
902 DROPGROUPPRIVS(); /* And then return us to normal privileges */
904 fclose (in
); in
= NULL
;
906 adios (NULL
, "failed");
915 if ((inc_type
== INC_POP
) && packfile
)
919 * truncate file we are incorporating from
921 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
923 if (stat (newmail
, &st
) != NOTOK
&& s1
.st_mtime
!= st
.st_mtime
)
924 inform("new messages have arrived!\007");
927 if ((newfd
= creat (newmail
, 0600)) != NOTOK
)
930 admonish (newmail
, "error zero'ing");
931 (void) m_unlink(map_name(newmail
));
935 printf ("%s not zero'd\n", newmail
);
939 if (msgnum
== hghnum
) {
940 inform("no messages incorporated, continuing...");
943 * Lock the sequence file now, and loop to set the right flags
944 * in the folder structure
950 context_replace (pfolder
, folder
); /* update current folder */
952 if ((mp2
= folder_read(folder
, 1)) == NULL
) {
953 inform("Unable to reread folder %s, continuing...", folder
);
958 * Shouldn't happen, but just in case ...
961 if (msgnum
>= mp2
->hghoff
962 && !(mp2
= folder_realloc (mp2
, mp2
->lowoff
, msgnum
+ 1))) {
963 inform("unable to reallocate folder storage");
968 mp2
->curmsg
= hghnum
+ 1;
969 mp2
->hghmsg
= msgnum
;
971 if (mp2
->lowmsg
== 0)
973 if (chgflag
) /* sigh... */
974 seq_setcur (mp2
, mp2
->curmsg
);
976 for (i
= hghnum
+ 1; i
<= msgnum
; i
++) {
977 clear_msg_flags (mp2
, i
);
981 mp2
->msgflags
|= SEQMOD
;
982 seq_setunseen(mp2
, 0); /* Set the Unseen-Sequence */
983 seq_save(mp2
); /* Save the sequence file */
989 * unlock the mail spool
991 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
993 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
994 (void) lkfclosespool (in
, newmail
); in
= NULL
;
995 DROPGROUPPRIVS(); /* And then return us to normal privileges */
997 fclose (in
); in
= NULL
;
1001 context_save (); /* save the context file */
1007 static void NORETURN
1008 inc_done (int status
)
1011 if (packfile
&& pd
!= NOTOK
)
1012 mbx_close (packfile
, pd
);
1016 lkfclosespool(in
, newmail
);
1023 pop_action (char *s
)
1025 fprintf (pf
, "%s\n", s
);
1026 stop
+= strlen (s
) + 1;
1027 return 0; /* Is return value used? This was missing before 1999-07-15. */
1034 char buffer
[BUFSIZ
];
1036 snprintf (buffer
, sizeof(buffer
), "%s\n", s
);
1037 for ( ; (j
= stringdex (mmdlm1
, buffer
)) >= 0; buffer
[j
]++)
1039 for ( ; (j
= stringdex (mmdlm2
, buffer
)) >= 0; buffer
[j
]++)
1042 size
+= strlen (buffer
) + 1;
1043 return 0; /* Is return value used? This was missing before 1999-07-15. */
1054 if (stat (packfile
, &st
) == NOTOK
)
1056 if ((md
= open (cp
= map_name (packfile
), O_RDONLY
)) == NOTOK
1057 || map_chk (cp
, md
, &d
, (long) st
.st_size
, 1)) {