]>
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>
45 # define TLSminc(a) (a)
50 #define INC_SWITCHES \
51 X("audit audit-file", 0, AUDSW) \
52 X("noaudit", 0, NAUDSW) \
53 X("changecur", 0, CHGSW) \
54 X("nochangecur", 0, NCHGSW) \
55 X("file name", 0, FILESW) \
56 X("form formatfile", 0, FORMSW) \
57 X("format string", 5, FMTSW) \
58 X("host hostname", 0, HOSTSW) \
59 X("user username", 0, USERSW) \
60 X("pack file", 0, PACKSW) \
61 X("nopack", 0, NPACKSW) \
62 X("port name/number", 0, PORTSW) \
63 X("silent", 0, SILSW) \
64 X("nosilent", 0, NSILSW) \
65 X("truncate", 0, TRNCSW) \
66 X("notruncate", 0, NTRNCSW) \
67 X("width columns", 0, WIDTHSW) \
68 X("version", 0, VERSIONSW) \
69 X("help", 0, HELPSW) \
70 X("snoop", 0, SNOOPSW) \
71 X("sasl", 0, SASLSW) \
72 X("nosasl", 0, NOSASLSW) \
73 X("saslmech", 0, SASLMECHSW) \
74 X("initialtls", TLSminc(-10), INITTLSSW) \
75 X("notls", TLSminc(-5), NOTLSSW) \
76 X("certverify", TLSminc(-10), CERTVERSW) \
77 X("nocertverify", TLSminc(-12), NOCERTVERSW) \
78 X("authservice", 0, AUTHSERVICESW) \
79 X("proxy command", 0, PROXYSW) \
81 #define X(sw, minchars, id) id,
82 DEFINE_SWITCH_ENUM(INC
);
85 #define X(sw, minchars, id) { sw, minchars, id },
86 DEFINE_SWITCH_ARRAY(INC
, switches
);
90 * flags for the mail source
96 static struct Maildir_entry
{
100 static int num_maildir_entries
= 0;
101 static int snoop
= 0;
103 extern char response
[];
108 static int mbx_style
= MMDF_FORMAT
;
109 static int pd
= NOTOK
;
114 static char *packfile
= NULL
;
115 static FILE *pf
= NULL
;
117 /* This is an attempt to simplify things by putting all the
118 * privilege ops into macros.
119 * *GROUPPRIVS() is related to handling the setgid MAIL property,
120 * and only applies if MAILGROUP is defined.
121 * Basically, SAVEGROUPPRIVS() is called right at the top of main()
122 * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
123 * do the obvious thing.
125 * There's probably a better implementation if we're allowed to use
126 * BSD-style setreuid() rather than using POSIX saved-ids.
127 * Anyway, if you're euid root it's a bit pointless to drop the group
130 * I'm pretty happy that the security is good provided we aren't setuid root.
131 * The only things we trust with group=mail privilege are lkfopen()
136 * For setting and returning to "mail" gid
139 static gid_t return_gid
;
140 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
141 #define DROPGROUPPRIVS() \
142 if (setegid(getgid()) != 0) { \
143 adios ("setegid", "unable to restore group to %ld", (long) getgid()); \
145 #define GETGROUPPRIVS() \
146 if (setegid(return_gid) != 0) { \
147 adios ("setegid", "unable to set group to %ld", (long) return_gid); \
149 #define SAVEGROUPPRIVS() return_gid = getegid()
151 /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
152 #define TRYDROPGROUPPRIVS()
153 #define DROPGROUPPRIVS()
154 #define GETGROUPPRIVS()
155 #define SAVEGROUPPRIVS()
156 #endif /* not MAILGROUP */
158 /* these variables have to be globals so that done() can correctly clean up the lockfile */
159 static int locked
= 0;
160 static char *newmail
;
166 char *map_name(char *);
168 static void inc_done(int) NORETURN
;
169 static int pop_action(char *);
170 static int pop_pack(char *);
171 static int map_count(void);
174 maildir_srt(const void *va
, const void *vb
)
176 const struct Maildir_entry
*a
= va
, *b
= vb
;
177 if (a
->mtime
> b
->mtime
)
179 if (a
->mtime
< b
->mtime
)
185 main (int argc
, char **argv
)
187 int chgflag
= 1, trnflag
= 1;
188 int noisy
= 1, width
= -1;
189 int hghnum
= 0, msgnum
= 0;
190 int sasl
= 0, tls
= 0, noverify
= 1;
191 int incerr
= 0; /* <0 if inc hits an error which means it should not truncate mailspool */
192 char *cp
, *maildir
= NULL
, *folder
= NULL
;
193 char *format
= NULL
, *form
= NULL
;
194 char *host
= NULL
, *port
= NULL
, *user
= NULL
, *proxy
= NULL
;
195 char *audfile
= NULL
, *from
= NULL
, *saslmech
= NULL
, *auth_svc
= NULL
;
196 char buf
[BUFSIZ
], **argp
, *nfs
, **arguments
;
197 struct msgs
*mp
= NULL
;
200 char b
[PATH_MAX
+ 1];
201 char *maildir_copy
= NULL
; /* copy of mail directory because the static gets overwritten */
204 char *MAILHOST_env_variable
;
207 /* absolutely the first thing we do is save our privileges,
208 * and drop them if we can.
213 if (nmh_init(argv
[0], 1)) { return 1; }
216 arguments
= getarguments (invo_name
, argc
, argv
, 1);
221 * use MAILHOST environment variable if present,
223 * If that fails, use the default (if any)
224 * provided by mts.conf in mts_init()
226 if ((MAILHOST_env_variable
= getenv("MAILHOST")) != NULL
)
227 pophost
= MAILHOST_env_variable
;
229 * If there is a valid "pophost" entry in mts.conf,
230 * then use it as the default host.
232 if (pophost
&& *pophost
)
235 while ((cp
= *argp
++)) {
237 switch (smatch (++cp
, switches
)) {
239 ambigsw (cp
, switches
);
242 adios (NULL
, "-%s unknown", cp
);
245 snprintf (buf
, sizeof(buf
), "%s [+folder] [switches]", invo_name
);
246 print_help (buf
, switches
, 1);
249 print_version(invo_name
);
253 if (!(cp
= *argp
++) || *cp
== '-')
254 adios (NULL
, "missing argument to %s", argp
[-2]);
255 audfile
= getcpy (m_maildir (cp
));
269 * The flag `trnflag' has the value:
271 * 2 if -truncate is given
272 * 1 by default (truncating is default)
273 * 0 if -notruncate is given
283 if (!(cp
= *argp
++) || *cp
== '-')
284 adios (NULL
, "missing argument to %s", argp
[-2]);
285 from
= path (cp
, TFILE
);
288 * If the truncate file is in default state,
289 * change to not truncate.
303 if (!(form
= *argp
++) || *form
== '-')
304 adios (NULL
, "missing argument to %s", argp
[-2]);
308 if (!(format
= *argp
++) || *format
== '-')
309 adios (NULL
, "missing argument to %s", argp
[-2]);
314 if (!(cp
= *argp
++) || *cp
== '-')
315 adios (NULL
, "missing argument to %s", argp
[-2]);
320 if (!(host
= *argp
++) || *host
== '-')
321 adios (NULL
, "missing argument to %s", argp
[-2]);
325 if (!(port
= *argp
++) || *port
== '-')
326 adios (NULL
, "missing argument to %s", argp
[-2]);
330 if (!(user
= *argp
++) || *user
== '-')
331 adios (NULL
, "missing argument to %s", argp
[-2]);
335 if (!(packfile
= *argp
++) || *packfile
== '-')
336 adios (NULL
, "missing argument to %s", argp
[-2]);
354 if (!(saslmech
= *argp
++) || *saslmech
== '-')
355 adios (NULL
, "missing argument to %s", argp
[-2]);
376 if (!(auth_svc
= *argp
++) || *auth_svc
== '-')
377 adios (NULL
, "missing argument to %s", argp
[-2]);
379 adios (NULL
, "not built with OAuth support");
384 if (!(proxy
= *argp
++) || *proxy
== '-')
385 adios (NULL
, "missing argument to %s", argp
[-2]);
389 if (*cp
== '+' || *cp
== '@') {
391 adios (NULL
, "only one folder at a time!");
393 folder
= pluspath (cp
);
395 adios (NULL
, "usage: %s [+folder] [switches]", invo_name
);
399 /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
400 * not DROPGROUPPRIVS().
405 /* guarantee dropping group priveleges; we might not have done so earlier */
409 * Where are we getting the new mail?
419 * Are we getting the mail from
422 if (inc_type
== INC_POP
) {
425 if (auth_svc
== NULL
) {
426 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
427 adios (NULL
, "must specify -authservice with -saslmech xoauth2");
431 adios (NULL
, "must specify -user with -saslmech xoauth2");
436 tlsflag
|= P_INITTLS
;
439 tlsflag
|= P_NOVERIFY
;
442 * initialize POP connection
444 if (pop_init (host
, port
, user
, proxy
, snoop
, sasl
, saslmech
,
445 tlsflag
, auth_svc
) == NOTOK
)
446 adios (NULL
, "%s", response
);
448 /* Check if there are any messages */
449 if (pop_stat (&nmsgs
, &nbytes
) == NOTOK
)
450 adios (NULL
, "%s", response
);
454 adios (NULL
, "no mail to incorporate");
459 * We will get the mail from a file
460 * (typically the standard maildrop)
463 if (inc_type
== INC_FILE
) {
466 else if ((newmail
= getenv ("MAILDROP")) && *newmail
)
467 newmail
= m_mailpath (newmail
);
468 else if ((newmail
= context_find ("maildrop")) && *newmail
)
469 newmail
= m_mailpath (newmail
);
471 newmail
= concat (MAILDIR
, "/", MAILFIL
, NULL
);
473 if (stat (newmail
, &s1
) == NOTOK
|| s1
.st_size
== 0)
474 adios (NULL
, "no mail to incorporate");
475 if (s1
.st_mode
& S_IFDIR
) {
481 cp
= concat (newmail
, "/new", NULL
);
482 if ((md
= opendir(cp
)) == NULL
)
483 adios (NULL
, "unable to open %s", cp
);
484 while ((de
= readdir (md
)) != NULL
) {
485 if (de
->d_name
[0] == '.')
487 if (i
>= num_maildir_entries
) {
488 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
489 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
490 num_maildir_entries
= 2*i
+16;
492 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
493 if (stat(Maildir
[i
].filename
, &ms
) != 0)
494 adios (Maildir
[i
].filename
, "couldn't get delivery time");
495 Maildir
[i
].mtime
= ms
.st_mtime
;
500 cp
= concat (newmail
, "/cur", NULL
);
501 if ((md
= opendir(cp
)) == NULL
)
502 adios (NULL
, "unable to open %s", cp
);
503 while ((de
= readdir (md
)) != NULL
) {
504 if (de
->d_name
[0] == '.')
506 if (i
>= num_maildir_entries
) {
507 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
508 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
509 num_maildir_entries
= 2*i
+16;
511 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
512 if (stat(Maildir
[i
].filename
, &ms
) != 0)
513 adios (Maildir
[i
].filename
, "couldn't get delivery time");
514 Maildir
[i
].mtime
= ms
.st_mtime
;
520 adios (NULL
, "no mail to incorporate");
521 num_maildir_entries
= i
;
522 qsort (Maildir
, num_maildir_entries
, sizeof(*Maildir
), maildir_srt
);
525 cp
= mh_xstrdup(newmail
);
529 /* skip the folder setup */
530 if ((inc_type
== INC_POP
) && packfile
)
533 if (!context_find ("path"))
534 free (path ("./", TFOLDER
));
536 folder
= getfolder (0);
537 maildir
= m_maildir (folder
);
538 maildir_copy
= mh_xstrdup(maildir
);
540 if (!folder_exists(maildir
)) {
541 /* If the folder doesn't exist, and we're given the -silent flag,
545 create_folder(maildir
, 0, done
);
550 if (chdir (maildir
) == NOTOK
)
551 adios (maildir
, "unable to change directory to");
553 /* read folder and create message structure */
554 if (!(mp
= folder_read (folder
, 0)))
555 adios (NULL
, "unable to read folder %s", folder
);
559 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
560 if (access (newmail
, W_OK
) != NOTOK
) {
563 SIGNAL (SIGHUP
, SIG_IGN
);
564 SIGNAL (SIGINT
, SIG_IGN
);
565 SIGNAL (SIGQUIT
, SIG_IGN
);
566 SIGNAL (SIGTERM
, SIG_IGN
);
569 GETGROUPPRIVS(); /* Reset gid to lock mail file */
570 in
= lkfopenspool (newmail
, "r");
573 adios (NULL
, "unable to lock and fopen %s", newmail
);
574 fstat (fileno(in
), &s1
);
577 if ((in
= fopen (newmail
, "r")) == NULL
)
578 adios (newmail
, "unable to read");
582 /* This shouldn't be necessary but it can't hurt. */
587 if ((i
= stat (audfile
, &st
)) == NOTOK
)
588 inform("Creating Receive-Audit: %s", audfile
);
589 if ((aud
= fopen (audfile
, "a")) == NULL
)
590 adios (audfile
, "unable to append to");
592 chmod (audfile
, m_gmprot ());
595 fprintf (aud
, "<<inc>> %s -ms %s\n", dtimenow(0), from
);
598 fprintf (aud
, "<<inc>> %s -host %s -user %s\n", dtimenow(0),
601 fprintf (aud
, "<<inc>> %s\n", dtimenow (0));
605 /* Get new format string */
606 nfs
= new_fs (form
, format
, FORMAT
);
609 printf ("Incorporating new mail into %s...\n\n", folder
);
615 * Get the mail from a POP server
617 if (inc_type
== INC_POP
) {
620 packfile
= path (packfile
, TFILE
);
621 if (stat (packfile
, &st
) == NOTOK
) {
623 adios (packfile
, "error on file");
624 cp
= concat ("Create file \"", packfile
, "\"? ", NULL
);
625 if (noisy
&& !read_yes_or_no_if_tty (cp
))
629 msgnum
= map_count ();
630 if ((pd
= mbx_open (packfile
, mbx_style
, getuid(), getgid(), m_gmprot()))
632 adios (packfile
, "unable to open");
633 if ((pf
= fdopen (pd
, "w+")) == NULL
)
634 adios (NULL
, "unable to fdopen %s", packfile
);
636 hghnum
= msgnum
= mp
->hghmsg
;
639 for (i
= 1; i
<= nmsgs
; i
++) {
640 charstring_t scanl
= NULL
;
646 fseek (pf
, 0L, SEEK_CUR
);
649 len
= strlen(mmdlm1
);
650 if (fwrite(mmdlm1
, 1, len
, pf
) < len
)
651 advise (mmdlm1
, "fwrite");
654 if (pop_retr (i
, pop_pack
) == NOTOK
)
655 adios (NULL
, "%s", response
);
657 fseek (pf
, 0L, SEEK_CUR
);
660 adios (packfile
, "write error on");
661 fseek (pf
, start
, SEEK_SET
);
663 cp
= mh_xstrdup(m_name (msgnum
));
664 if ((pf
= fopen (cp
, "w+")) == NULL
)
665 adios (cp
, "unable to write");
666 chmod (cp
, m_gmprot ());
669 if (pop_retr (i
, pop_action
) == NOTOK
)
670 adios (NULL
, "%s", response
);
673 adios (cp
, "write error on");
674 fseek (pf
, 0L, SEEK_SET
);
676 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
677 packfile
? 0 : msgnum
== mp
->hghmsg
+ 1 && chgflag
,
678 1, NULL
, stop
- start
, noisy
, &scanl
)) {
680 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
686 /* advise (cp, "unable to read"); already advised */
697 fputs (charstring_buffer (scanl
), aud
);
702 charstring_free (scanl
);
707 fseek (pf
, stop
, SEEK_SET
);
708 len
= strlen(mmdlm2
);
709 if (fwrite(mmdlm2
, 1, len
, pf
) < len
)
710 advise (mmdlm2
, "fwrite");
711 if (fflush (pf
) || ferror (pf
)) {
715 adios (packfile
, "write error on");
717 map_write (packfile
, pd
, 0, 0L, start
, stop
, pos
, size
, noisy
);
719 if (ferror(pf
) || fclose (pf
)) {
721 (void) m_unlink (cp
);
724 adios (cp
, "write error on");
729 if (trnflag
&& pop_dele (i
) == NOTOK
)
730 adios (NULL
, "%s", response
);
735 if (pop_quit () == NOTOK
)
736 adios (NULL
, "%s", response
);
738 mbx_close (packfile
, pd
);
744 * Get the mail from file (usually mail spool)
746 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
747 scan_detect_mbox_style (in
); /* the MAGIC invocation... */
748 hghnum
= msgnum
= mp
->hghmsg
;
750 charstring_t scanl
= NULL
;
752 /* create scanline for new message */
753 switch (incerr
= scan (in
, msgnum
+ 1, msgnum
+ 1, nfs
, width
,
754 msgnum
== hghnum
&& chgflag
, 1, NULL
, 0L, noisy
,
762 fputs ("inc aborted!\n", aud
);
763 inform("aborted!"); /* doesn't clean up locks! */
767 inform("BUG in %s, number out of range", invo_name
);
771 inform("BUG in %s, scan() botch (%d)", invo_name
, incerr
);
777 * Run the external program hook on the message.
780 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
781 (void)ext_hook("add-hook", b
, NULL
);
784 fputs (charstring_buffer (scanl
), aud
);
791 charstring_free (scanl
);
793 /* If we get here there was some sort of error from scan(),
794 * so stop processing anything more from the spool.
798 } else if (inc_type
== INC_FILE
) { /* Maildir inbox to process */
803 hghnum
= msgnum
= mp
->hghmsg
;
804 for (i
= 0; i
< num_maildir_entries
; i
++) {
805 charstring_t scanl
= NULL
;
809 sp
= Maildir
[i
].filename
;
810 cp
= mh_xstrdup(m_name (msgnum
));
812 if (!trnflag
|| link(sp
, cp
) == -1) {
813 static char buf
[65536];
816 if ((sf
= fopen (sp
, "r")) == NULL
)
817 adios (sp
, "unable to read for copy");
818 if ((pf
= fopen (cp
, "w+")) == NULL
)
819 adios (cp
, "unable to write for copy");
820 while ((nrd
= fread(buf
, 1, sizeof(buf
), sf
)) > 0)
821 if (fwrite(buf
, 1, nrd
, pf
) != nrd
)
823 if (ferror(sf
) || fflush(pf
) || ferror(pf
)) {
825 fclose(pf
); fclose(sf
); (void) m_unlink(cp
);
827 adios(cp
, "copy error %s -> %s", sp
, cp
);
832 if (pf
== NULL
&& (pf
= fopen (cp
, "r")) == NULL
)
833 adios (cp
, "not available");
834 chmod (cp
, m_gmprot ());
836 fseek (pf
, 0L, SEEK_SET
);
837 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
838 msgnum
== mp
->hghmsg
+ 1 && chgflag
,
839 1, NULL
, stop
- start
, noisy
, &scanl
)) {
841 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
847 /* advise (cp, "unable to read"); already advised */
858 * Run the external program hook on the message.
861 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
862 (void)ext_hook("add-hook", b
, NULL
);
865 fputs (charstring_buffer (scanl
), aud
);
870 charstring_free (scanl
);
872 if (ferror(pf
) || fclose (pf
)) {
874 (void) m_unlink (cp
);
876 adios (cp
, "write error on");
881 if (trnflag
&& m_unlink (sp
) == NOTOK
)
882 adios (sp
, "couldn't unlink");
883 free (sp
); /* Free Maildir[i]->filename */
887 free (Maildir
); /* From now on Maildir is just a flag - don't dref! */
892 if (incerr
< 0) { /* error */
894 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
895 (void) lkfclosespool (in
, newmail
); in
= NULL
;
896 DROPGROUPPRIVS(); /* And then return us to normal privileges */
898 fclose (in
); in
= NULL
;
900 adios (NULL
, "failed");
909 if ((inc_type
== INC_POP
) && packfile
)
913 * truncate file we are incorporating from
915 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
917 if (stat (newmail
, &st
) != NOTOK
&& s1
.st_mtime
!= st
.st_mtime
)
918 inform("new messages have arrived!\007");
921 if ((newfd
= creat (newmail
, 0600)) != NOTOK
)
924 admonish (newmail
, "error zero'ing");
925 (void) m_unlink(map_name(newmail
));
929 printf ("%s not zero'd\n", newmail
);
933 if (msgnum
== hghnum
) {
934 inform("no messages incorporated, continuing...");
937 * Lock the sequence file now, and loop to set the right flags
938 * in the folder structure
944 context_replace (pfolder
, folder
); /* update current folder */
946 if ((mp2
= folder_read(folder
, 1)) == NULL
) {
947 inform("Unable to reread folder %s, continuing...", folder
);
952 * Shouldn't happen, but just in case ...
955 if (msgnum
>= mp2
->hghoff
956 && !(mp2
= folder_realloc (mp2
, mp2
->lowoff
, msgnum
+ 1))) {
957 inform("unable to reallocate folder storage");
962 mp2
->curmsg
= hghnum
+ 1;
963 mp2
->hghmsg
= msgnum
;
965 if (mp2
->lowmsg
== 0)
967 if (chgflag
) /* sigh... */
968 seq_setcur (mp2
, mp2
->curmsg
);
970 for (i
= hghnum
+ 1; i
<= msgnum
; i
++) {
971 clear_msg_flags (mp2
, i
);
975 mp2
->msgflags
|= SEQMOD
;
976 seq_setunseen(mp2
, 0); /* Set the Unseen-Sequence */
977 seq_save(mp2
); /* Save the sequence file */
983 * unlock the mail spool
985 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
987 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
988 (void) lkfclosespool (in
, newmail
); in
= NULL
;
989 DROPGROUPPRIVS(); /* And then return us to normal privileges */
991 fclose (in
); in
= NULL
;
995 context_save (); /* save the context file */
1002 inc_done (int status
)
1005 if (packfile
&& pd
!= NOTOK
)
1006 mbx_close (packfile
, pd
);
1010 lkfclosespool(in
, newmail
);
1017 pop_action (char *s
)
1019 fprintf (pf
, "%s\n", s
);
1020 stop
+= strlen (s
) + 1;
1021 return 0; /* Is return value used? This was missing before 1999-07-15. */
1028 char buffer
[BUFSIZ
];
1030 snprintf (buffer
, sizeof(buffer
), "%s\n", s
);
1031 for ( ; (j
= stringdex (mmdlm1
, buffer
)) >= 0; buffer
[j
]++)
1033 for ( ; (j
= stringdex (mmdlm2
, buffer
)) >= 0; buffer
[j
]++)
1036 size
+= strlen (buffer
) + 1;
1037 return 0; /* Is return value used? This was missing before 1999-07-15. */
1048 if (stat (packfile
, &st
) == NOTOK
)
1050 if ((md
= open (cp
= map_name (packfile
), O_RDONLY
)) == NOTOK
1051 || map_chk (cp
, md
, &d
, (long) st
.st_size
, 1)) {