]>
diplodocus.org Git - nmh/blob - uip/post.c
2 * post.c -- enter messages into the mail transport system
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
11 #include <h/signals.h>
12 #include <h/addrsbr.h>
13 #include <h/aliasbr.h>
14 #include <h/dropsbr.h>
20 #ifdef HAVE_SYS_TIME_H
21 # include <sys/time.h>
25 #include <mts/smtp/smtp.h>
28 # define SASLminc(a) (a)
29 #else /* CYRUS_SASL */
30 # define SASLminc(a) 0
31 #endif /* CYRUS_SASL */
34 # define TLSminc(a) (a)
35 #else /* TLS_SUPPORT */
37 #endif /* TLS_SUPPORT */
40 # define OAUTHminc(a) (a)
41 #else /* OAUTH_SUPPORT */
42 # define OAUTHminc(a) 0
43 #endif /* OAUTH_SUPPORT */
45 #define FCCS 10 /* max number of fccs allowed */
47 /* In the following array of structures, the numeric second field of the
48 structures (minchars) is apparently used like this:
50 -# : Switch can be abbreviated to # characters; switch hidden in -help.
51 0 : Switch can't be abbreviated; switch shown in -help.
52 # : Switch can be abbreviated to # characters; switch shown in -help. */
54 #define POST_SWITCHES \
55 X("alias aliasfile", 0, ALIASW) \
56 X("check", -5, CHKSW) /* interface from whom */ \
57 X("nocheck", -7, NCHKSW) /* interface from whom */ \
58 X("debug", -5, DEBUGSW) \
59 X("dist", -4, DISTSW) /* interface from dist */ \
60 X("filter filterfile", 0, FILTSW) \
61 X("nofilter", 0, NFILTSW) \
62 X("format", 0, FRMTSW) \
63 X("noformat", 0, NFRMTSW) \
64 X("library directory", -7, LIBSW) /* interface from send, whom */ \
65 X("mime", 0, MIMESW) \
66 X("nomime", 0, NMIMESW) \
67 X("msgid", 0, MSGDSW) \
68 X("nomsgid", 0, NMSGDSW) \
69 X("verbose", 0, VERBSW) \
70 X("noverbose", 0, NVERBSW) \
71 X("watch", 0, WATCSW) \
72 X("nowatch", 0, NWATCSW) \
73 X("whom", -4, WHOMSW) /* interface from whom */ \
74 X("width columns", 0, WIDTHSW) \
75 X("version", 0, VERSIONSW) \
76 X("help", 0, HELPSW) \
77 X("dashstuffing", -12, BITSTUFFSW) /* should we dashstuff BCC messages? */ \
78 X("nodashstuffing", -14, NBITSTUFFSW) \
79 X("idanno number", -6, ANNOSW) /* interface from send */ \
80 X("client host", -6, CLIESW) \
81 X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
82 X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
83 X("partno", -6, PARTSW) \
84 X("sasl", SASLminc(4), SASLSW) \
85 X("nosasl", SASLminc(6), NOSASLSW) \
86 X("saslmech", SASLminc(5), SASLMECHSW) \
87 X("user", SASLminc(-4), USERSW) \
88 X("port server submission port name/number", 4, PORTSW) \
89 X("tls", TLSminc(-3), TLSSW) \
90 X("initialtls", TLSminc(-10), INITTLSSW) \
91 X("notls", TLSminc(-5), NTLSSW) \
92 X("fileproc", -4, FILEPROCSW) \
93 X("mhlproc", -3, MHLPROCSW) \
94 X("sendmail program", 0, MTSSM) \
95 X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
96 X("credentials legacy|file:filename", 0, CREDENTIALSSW) \
97 X("messageid localname|random", 2, MESSAGEIDSW) \
98 X("authservice auth-service-name", OAUTHminc(-11), AUTHSERVICESW) \
99 X("oauthcredfile credential-file", OAUTHminc(-7), OAUTHCREDFILESW) \
100 X("oauthclientid client-id", OAUTHminc(-12), OAUTHCLIDSW) \
101 X("oauthclientsecret client-secret", OAUTHminc(-12), OAUTHCLSECSW) \
102 X("oauthauthendpoint authentication-endpoint", OAUTHminc(-6), OAUTHAUTHENDSW) \
103 X("oauthredirect redirect-uri", OAUTHminc(-6), OAUTHREDIRSW) \
104 X("oauthtokenendpoint token-endpoint", OAUTHminc(-6), OAUTHTOKENDSW) \
105 X("oauthscope scope", OAUTHminc(-6), OAUTHSCOPESW) \
107 #define X(sw, minchars, id) id,
108 DEFINE_SWITCH_ENUM(POST
);
111 #define X(sw, minchars, id) { sw, minchars, id },
112 DEFINE_SWITCH_ARRAY(POST
, switches
);
117 * Mapping between command-line switches and profile entries, communicated
118 * from 'send'. We use a service name of 'post' internally.
121 static struct oauth_profile
{
122 const char *profname
;
125 } oauthswitches
[] = {
126 { "oauth-%s-credential-file", OAUTHCREDFILESW
, NULL
},
127 { "oauth-%s-client_id", OAUTHCLIDSW
, NULL
},
128 { "oauth-%s-client_secret", OAUTHCLSECSW
, NULL
},
129 { "oauth-%s-auth_endpoint", OAUTHAUTHENDSW
, NULL
},
130 { "oauth-%s-redirect_uri", OAUTHREDIRSW
, NULL
},
131 { "oauth-%s-token_endpoint", OAUTHTOKENDSW
, NULL
},
132 { "oauth-%s-scope", OAUTHSCOPESW
, NULL
},
143 * flags for headers->flags
145 #define HNOP 0x0000 /* just used to keep .set around */
146 #define HBAD 0x0001 /* bad header - don't let it through */
147 #define HADR 0x0002 /* header has an address field */
148 #define HSUB 0x0004 /* Subject: header */
149 #define HTRY 0x0008 /* try to send to addrs on header */
150 #define HBCC 0x0010 /* don't output this header, unless MTS_SENDMAIL_PIPE */
151 #define HMNG 0x0020 /* munge this header */
152 #define HNGR 0x0040 /* no groups allowed in this header */
153 #define HFCC 0x0080 /* FCC: type header */
154 #define HNIL 0x0100 /* okay for this header not to have addrs */
155 #define HIGN 0x0200 /* ignore this header */
156 #define HDCC 0x0400 /* another undocumented feature */
157 #define HONE 0x0800 /* Only (zero or) one address allowed */
158 #define HEFM 0x1000 /* Envelope-From: header */
161 * flags for headers->set
163 #define MFRM 0x0001 /* we've seen a From: */
164 #define MDAT 0x0002 /* we've seen a Date: */
165 #define MRFM 0x0004 /* we've seen a Resent-From: */
166 #define MVIS 0x0008 /* we've seen sighted addrs */
167 #define MINV 0x0010 /* we've seen blind addrs */
168 #define MSND 0x0020 /* we've seen a Sender: */
169 #define MRSN 0x0040 /* We've seen a Resent-Sendr:*/
170 #define MEFM 0x0080 /* We've seen Envelope-From: */
173 static struct headers NHeaders
[] = {
174 { "Return-Path", HBAD
, 0 },
175 { "Received", HBAD
, 0 },
176 { "Reply-To", HADR
|HNGR
, 0 },
177 { "From", HADR
|HNGR
, MFRM
},
178 { "Sender", HADR
|HNGR
|HONE
, MSND
},
180 { "Subject", HSUB
, 0 },
181 { "To", HADR
|HTRY
, MVIS
},
182 { "cc", HADR
|HTRY
, MVIS
},
183 { "Bcc", HADR
|HTRY
|HBCC
|HNIL
, MINV
},
184 { "Dcc", HADR
|HTRY
|HDCC
|HNIL
, MVIS
}, /* sorta cc & bcc combined */
185 { "Message-ID", HBAD
, 0 },
187 { "Envelope-From", HADR
|HONE
|HEFM
, MEFM
},
191 static struct headers RHeaders
[] = {
192 { "Resent-Reply-To", HADR
|HNGR
, 0 },
193 { "Resent-From", HADR
|HNGR
, MRFM
},
194 { "Resent-Sender", HADR
|HNGR
, MRSN
},
195 { "Resent-Date", HBAD
, 0 },
196 { "Resent-Subject", HSUB
, 0 },
197 { "Resent-To", HADR
|HTRY
, MVIS
},
198 { "Resent-cc", HADR
|HTRY
, MVIS
},
199 { "Resent-Bcc", HADR
|HTRY
|HBCC
, MINV
},
200 { "Resent-Message-ID", HBAD
, 0 },
201 { "Resent-Fcc", HFCC
, 0 },
202 { "Reply-To", HADR
, 0 },
203 { "From", HADR
|HNGR
, MFRM
},
204 { "Sender", HADR
|HNGR
, MSND
},
205 { "Date", HNOP
, MDAT
},
206 { "To", HADR
|HNIL
, 0 },
207 { "cc", HADR
|HNIL
, 0 },
208 { "Bcc", HADR
|HTRY
|HBCC
|HNIL
, 0 },
210 { "Envelope-From", HADR
|HONE
|HEFM
, MEFM
},
214 static short fccind
= 0; /* index into fccfold[] */
215 static short outputlinelen
= OUTPUTLINELEN
;
217 static int pfd
= NOTOK
; /* fd to write annotation list to */
218 static int recipients
= 0; /* how many people will get a copy */
219 static int unkadr
= 0; /* how many of those were unknown */
220 static int badadr
= 0; /* number of bad addrs */
221 static int badmsg
= 0; /* message has bad semantics */
222 static int verbose
= 0; /* spell it out */
223 static int format
= 1; /* format addresses */
224 static int mime
= 0; /* use MIME-style encapsulations for Bcc */
225 static int msgid
= 0; /* add msgid */
226 static int debug
= 0; /* debugging post */
227 static int watch
= 0; /* watch the delivery process */
228 static int whomsw
= 0; /* we are whom not post */
229 static int checksw
= 0; /* whom -check */
230 static int linepos
=0; /* putadr()'s position on the line */
231 static int nameoutput
=0; /* putadr() has output header name */
232 static int sasl
=0; /* Use SASL auth for SMTP */
233 static char *saslmech
=NULL
; /* Force use of particular SASL mech */
234 static char *user
=NULL
; /* Authenticate as this user */
235 static char *port
="submission"; /* Name of server port for SMTP submission */
236 static int tls
=-1; /* Use TLS for encryption */
237 static int fromcount
=0; /* Count of addresses on From: header */
238 static int seensender
=0; /* Have we seen a Sender: header? */
240 static unsigned msgflags
= 0; /* what we've seen */
244 static int msgstate
= NORMAL
;
246 static time_t tclock
= 0; /* the time we started (more or less) */
248 static SIGNAL_HANDLER hstat
, istat
, qstat
, tstat
;
250 static char tmpfil
[BUFSIZ
];
251 static char bccfil
[BUFSIZ
];
253 static char from
[BUFSIZ
]; /* my network address */
254 static char sender
[BUFSIZ
]; /* my Sender: header */
255 static char efrom
[BUFSIZ
]; /* my Envelope-From: header */
256 static char fullfrom
[BUFSIZ
]; /* full contents of From header */
257 static char *filter
= NULL
; /* the filter for BCC'ing */
258 static char *subject
= NULL
; /* the subject field for BCC'ing */
259 static char *fccfold
[FCCS
]; /* foldernames for FCC'ing */
261 static struct headers
*hdrtab
; /* table for the message we're doing */
263 static struct mailname localaddrs
; /* local addrs */
264 static struct mailname netaddrs
; /* network addrs */
265 static struct mailname uuaddrs
; /* uucp addrs */
266 static struct mailname tmpaddrs
; /* temporary queue */
268 static int snoop
= 0;
269 static char *clientsw
= NULL
;
270 static char *serversw
= NULL
;
272 static char prefix
[] = "----- =_aaaaaaaaaa";
274 static char *partno
= NULL
;
279 static void putfmt (char *, char *, FILE *);
280 static void start_headers (void);
281 static void finish_headers (FILE *);
282 static int get_header (char *, struct headers
*);
283 static int putadr (char *, char *, struct mailname
*, FILE *, unsigned int);
284 static void putgrp (char *, char *, FILE *, unsigned int);
285 static int insert (struct mailname
*);
286 static void pl (void);
287 static void anno (void);
288 static int annoaux (struct mailname
*);
289 static void insert_fcc (struct headers
*, char *);
290 static void make_bcc_file (int);
291 static void verify_all_addresses (int, char *, int, char *);
292 static void chkadr (void);
293 static void sigon (void);
294 static void sigoff (void);
295 static void p_refile (char *);
296 static void fcc (char *, char *);
297 static void die (char *, char *, ...);
298 static void post (char *, int, int, char *, int, char *);
299 static void do_text (char *file
, int fd
);
300 static void do_an_address (struct mailname
*, int);
301 static void do_addresses (int, int);
302 static int find_prefix (void);
306 main (int argc
, char **argv
)
308 int state
, compnum
, dashstuff
= 0, swnum
, oauth_flag
= 0;
309 char *cp
, *msg
= NULL
, **argp
, **arguments
, *envelope
;
310 char buf
[BUFSIZ
], name
[NAMESZ
], *auth_svc
= NULL
;
312 m_getfld_state_t gstate
= 0;
314 if (nmh_init(argv
[0], 0 /* use context_foil() */)) { return 1; }
317 arguments
= getarguments (invo_name
, argc
, argv
, 0);
320 while ((cp
= *argp
++)) {
322 switch ((swnum
= smatch (++cp
, switches
))) {
324 ambigsw (cp
, switches
);
327 adios (NULL
, "-%s unknown", cp
);
330 snprintf (buf
, sizeof(buf
), "%s [switches] file", invo_name
);
331 print_help (buf
, switches
, 0);
334 print_version(invo_name
);
338 if (!(cp
= *argp
++) || *cp
== '-')
339 adios (NULL
, "missing argument to %s", argp
[-2]);
340 /* create a minimal context */
341 if (context_foil (cp
) == -1)
346 if (!(cp
= *argp
++) || *cp
== '-')
347 adios (NULL
, "missing argument to %s", argp
[-2]);
348 if ((state
= alias (cp
)) != AK_OK
)
349 adios (NULL
, "aliasing error in %s - %s",
350 cp
, akerror (state
));
369 if (!(filter
= *argp
++) || *filter
== '-')
370 adios (NULL
, "missing argument to %s", argp
[-2]);
425 if (!(cp
= *argp
++) || *cp
== '-')
426 adios (NULL
, "missing argument to %s", argp
[-2]);
427 if ((outputlinelen
= atoi (cp
)) < 10)
428 adios (NULL
, "impossible width %d", outputlinelen
);
432 if (!(cp
= *argp
++) || *cp
== '-')
433 adios (NULL
, "missing argument to %s", argp
[-2]);
434 if ((pfd
= atoi (cp
)) <= 2)
435 adios (NULL
, "bad argument %s %s", argp
[-2], cp
);
439 if (!(clientsw
= *argp
++) || *clientsw
== '-')
440 adios (NULL
, "missing argument to %s", argp
[-2]);
443 if (!(serversw
= *argp
++) || *serversw
== '-')
444 adios (NULL
, "missing argument to %s", argp
[-2]);
451 if (!(partno
= *argp
++) || *partno
== '-')
452 adios (NULL
, "missing argument to %s", argp
[-2]);
464 if (!(saslmech
= *argp
++) || *saslmech
== '-')
465 adios (NULL
, "missing argument to %s", argp
[-2]);
469 if (!(auth_svc
= *argp
++) || *auth_svc
== '-')
470 adios (NULL
, "missing argument to %s", argp
[-2]);
474 case OAUTHCREDFILESW
:
484 if (!(cp
= *argp
++) || *cp
== '-')
485 adios (NULL
, "missing argument to %s", argp
[-2]);
487 for (i
= 0; oauthswitches
[i
].profname
!= NULL
; i
++) {
488 if (oauthswitches
[i
].switchnum
== swnum
) {
489 oauthswitches
[i
].value
= cp
;
494 if (oauthswitches
[i
].profname
== NULL
)
495 adios (NULL
, "internal error: cannot map switch %s "
496 "to profile entry", argp
[-2]);
503 if (!(user
= *argp
++) || *user
== '-')
504 adios (NULL
, "missing argument to %s", argp
[-2]);
508 if (!(port
= *argp
++) || *port
== '-')
509 adios (NULL
, "missing argument to %s", argp
[-2]);
525 if (!(cp
= *argp
++) || *cp
== '-')
526 adios (NULL
, "missing argument to %s", argp
[-2]);
531 if (!(cp
= *argp
++) || *cp
== '-')
532 adios (NULL
, "missing argument to %s", argp
[-2]);
537 if (!(cp
= *argp
++) || *cp
== '-')
538 adios (NULL
, "missing argument to %s", argp
[-2]);
543 if (!(cp
= *argp
++) || *cp
== '-')
544 adios (NULL
, "missing argument to %s", argp
[-2]);
545 save_mts_method (cp
);
548 case CREDENTIALSSW
: {
549 if (!(cp
= *argp
++) || *cp
== '-')
550 adios (NULL
, "missing argument to %s", argp
[-2]);
551 add_profile_entry ("credentials", cp
);
556 if (!(cp
= *argp
++) || *cp
== '-')
557 adios (NULL
, "missing argument to %s", argp
[-2]);
558 if (save_message_id_style (cp
) != 0)
559 adios (NULL
, "unsupported messageid \"%s\"", cp
);
564 adios (NULL
, "only one message at a time!");
572 adios (NULL
, "usage: %s [switches] file", invo_name
);
574 if (outputlinelen
< 10)
575 adios (NULL
, "impossible width %d", outputlinelen
);
577 if ((in
= fopen (msg
, "r")) == NULL
)
578 adios (msg
, "unable to open");
586 if ((out
= fopen ("/dev/null", "w")) == NULL
)
587 adios ("/dev/null", "unable to open");
589 char *cp
= m_mktemp2(NULL
, invo_name
, NULL
, &out
);
591 adios(NULL
, "unable to create temporary file in %s",
594 strncpy(tmpfil
, cp
, sizeof(tmpfil
));
598 hdrtab
= msgstate
== NORMAL
? NHeaders
: RHeaders
;
600 for (compnum
= 1;;) {
601 int bufsz
= sizeof buf
;
602 switch (state
= m_getfld (&gstate
, name
, buf
, &bufsz
, in
)) {
606 cp
= add (buf
, NULL
);
607 while (state
== FLDPLUS
) {
609 state
= m_getfld (&gstate
, name
, buf
, &bufsz
, in
);
612 putfmt (name
, cp
, out
);
617 finish_headers (out
);
620 fprintf (out
, "\n%s", buf
);
621 while (state
== BODY
) {
623 state
= m_getfld (&gstate
, name
, buf
, &bufsz
, in
);
629 finish_headers (out
);
634 adios (NULL
, "message format error in component #%d", compnum
);
637 adios (NULL
, "getfld() returned %d", state
);
641 m_getfld_state_destroy (&gstate
);
655 * Here's how we decide which address to use as the envelope-from
658 * - If we were given an Envelope-From header, use that.
659 * - If we were given a Sender: address, use that.
660 * - Otherwise, use the address on the From: line
663 if (msgflags
& MEFM
) {
665 } else if (seensender
) {
674 * The user didn't specify any of the tls switches. Try to
675 * help them by implying -initialtls if they're using port 465
676 * (smtps, until IANA revoked that registration in 1998).
678 tls
= ! strcmp (port
, "465") || ! strcasecmp (port
, "smtps")
681 #else /* ! TLS_SUPPORT */
683 #endif /* ! TLS_SUPPORT */
687 * If we were given any oauth flags, store the appropriate profile
688 * entries and make sure an authservice was given (we have to do this
689 * here because we aren't guaranteed the authservice will be given on
690 * the command line before the other OAuth flags are given).
697 if (auth_svc
== NULL
) {
698 adios(NULL
, "No authentication service given with -authservice");
701 for (i
= 0; oauthswitches
[i
].profname
!= NULL
; i
++) {
702 if (oauthswitches
[i
].value
!= NULL
) {
703 snprintf(sbuf
, sizeof(sbuf
),
704 oauthswitches
[i
].profname
, auth_svc
);
705 sbuf
[sizeof(sbuf
) - 1] = '\0';
706 add_profile_entry(sbuf
, oauthswitches
[i
].value
);
711 /* If we are doing a "whom" check */
713 /* This won't work with MTS_SENDMAIL_PIPE. */
714 verify_all_addresses (1, envelope
, oauth_flag
, auth_svc
);
718 if (msgflags
& MINV
) {
719 make_bcc_file (dashstuff
);
720 if (msgflags
& MVIS
) {
721 if (sm_mts
!= MTS_SENDMAIL_PIPE
) {
722 /* It would be nice to have support to call
723 verify_all_addresses with MTS_SENDMAIL_PIPE, but
724 that might require running sendmail as root. Note
725 that spost didn't verify addresses. */
726 verify_all_addresses (verbose
, envelope
, oauth_flag
, auth_svc
);
728 post (tmpfil
, 0, verbose
, envelope
, oauth_flag
, auth_svc
);
730 post (bccfil
, 1, verbose
, envelope
, oauth_flag
, auth_svc
);
731 (void) m_unlink (bccfil
);
733 post (tmpfil
, 0, isatty (1), envelope
, oauth_flag
, auth_svc
);
737 (void) m_unlink (tmpfil
);
741 printf ("Partial Message #%s Processed\n", partno
);
743 printf ("Message Processed\n");
756 putfmt (char *name
, char *str
, FILE *out
)
758 int count
, grp
, i
, keep
;
760 char namep
[BUFSIZ
], error
[BUFSIZ
];
761 struct mailname
*mp
= NULL
, *np
= NULL
;
764 while (*str
== ' ' || *str
== '\t')
767 if (msgstate
== NORMAL
&& uprf (name
, "resent")) {
768 advise (NULL
, "illegal header line -- %s:", name
);
773 if ((i
= get_header (name
, hdrtab
)) == NOTOK
) {
774 if (strncasecmp (name
, "nmh-", 4)) {
775 fprintf (out
, "%s: %s", name
, str
);
777 /* Filter out all Nmh-* headers, because Norm asked. They
778 should never have reached this point. Warn about any
779 that are non-empty. */
780 if (strcmp (str
, "\n")) {
781 char *newline
= strchr (str
, '\n');
782 if (newline
) *newline
= '\0';
784 advise (NULL
, "ignoring header line -- %s: %s", name
, str
);
793 if (hdr
->flags
& HIGN
) {
796 if (hdr
->flags
& HBAD
) {
797 advise (NULL
, "illegal header line -- %s:", name
);
801 msgflags
|= (hdr
->set
& ~(MVIS
| MINV
));
803 if (hdr
->flags
& HSUB
)
804 subject
= subject
? add (str
, add ("\t", subject
)) : getcpy (str
);
805 if (hdr
->flags
& HFCC
) {
806 if ((cp
= strrchr(str
, '\n')))
808 for (pp
= str
; (cp
= strchr(pp
, ',')); pp
= cp
) {
810 insert_fcc (hdr
, pp
);
812 insert_fcc (hdr
, pp
);
816 if (!(hdr
->flags
& HADR
)) {
817 fprintf (out
, "%s: %s", name
, str
);
821 tmpaddrs
.m_next
= NULL
;
822 for (count
= 0; (cp
= getname (str
)); count
++)
823 if ((mp
= getm (cp
, NULL
, 0, error
, sizeof(error
)))) {
827 tmpaddrs
.m_next
= mp
;
831 admonish(cp
, "%s", error
);
832 if (hdr
->flags
& HTRY
)
839 if (hdr
->flags
& HNIL
)
840 fprintf (out
, "%s: %s", name
, str
);
843 * Sender (or Resent-Sender) can have only one address
845 if ((msgstate
== RESENT
) ? (hdr
->set
& MRSN
)
846 : (hdr
->set
& MSND
)) {
847 advise (NULL
, "%s: field requires one address", name
);
851 advise (NULL
, "%s: field requires at least one address", name
);
858 if (count
> 1 && (hdr
->flags
& HONE
)) {
859 advise (NULL
, "%s: field only permits one address", name
);
864 nameoutput
= linepos
= 0;
865 snprintf (namep
, sizeof(namep
), "%s%s",
866 (hdr
->flags
& HMNG
) ? "Original-" : "", name
);
868 for (grp
= 0, mp
= tmpaddrs
.m_next
; mp
; mp
= np
)
869 if (mp
->m_nohost
) { /* also used to test (hdr->flags & HTRY) */
870 /* The address doesn't include a host, so it might be an alias. */
871 pp
= akvalue (mp
->m_mbox
); /* do mh alias substitution */
872 qp
= akvisible () ? mp
->m_mbox
: "";
875 putgrp (namep
, np
->m_gname
, out
, hdr
->flags
);
876 while ((cp
= getname (pp
))) {
877 if (!(mp
= getm (cp
, NULL
, 0, error
, sizeof(error
)))) {
878 admonish(cp
, "%s", error
);
884 * If it's a From: or Resent-From: header, save the address
885 * for later possible use (as the envelope address for SMTP)
888 if ((msgstate
== RESENT
) ? (hdr
->set
& MRFM
)
889 : (hdr
->set
& MFRM
)) {
890 strncpy(from
, auxformat(mp
, 0), sizeof(from
) - 1);
891 from
[sizeof(from
) - 1] = '\0';
896 * Also save the Sender: or Resent-Sender: header as well
899 if ((msgstate
== RESENT
) ? (hdr
->set
& MRSN
)
900 : (hdr
->set
& MSND
)) {
901 strncpy(sender
, auxformat(mp
, 0), sizeof(sender
) - 1);
902 sender
[sizeof(sender
) - 1] = '\0';
907 * ALSO ... save Envelope-From
910 if (hdr
->set
& MEFM
) {
911 strncpy(efrom
, auxformat(mp
, 0), sizeof(efrom
) - 1);
912 efrom
[sizeof(efrom
) - 1] = '\0';
915 if (hdr
->flags
& HBCC
)
918 mp
->m_ingrp
= np
->m_ingrp
;
921 putgrp (namep
, mp
->m_gname
, out
, hdr
->flags
);
923 if (sm_mts
== MTS_SENDMAIL_PIPE
) {
924 /* Catch this before sendmail chokes with:
925 "553 List:; syntax illegal for recipient
927 If we wanted to, we could expand out blind
928 aliases and put them in Bcc:, but then
929 they'd have the Blind-Carbon-Copy
932 "blind lists not compatible with"
938 if (putadr (namep
, qp
, mp
, out
, hdr
->flags
))
939 msgflags
|= (hdr
->set
& (MVIS
| MINV
));
948 /* Address includes a host, so no alias substitution is needed. */
951 * If it's a From: or Resent-From header, save the address
952 * for later possible use (as the envelope address for SMTP)
955 if ((msgstate
== RESENT
) ? (hdr
->set
& MRFM
)
956 : (hdr
->set
& MFRM
)) {
957 strncpy(from
, auxformat(mp
, 0), sizeof(from
) - 1);
962 * Also save the Sender: header as well
965 if ((msgstate
== RESENT
) ? (hdr
->set
& MRSN
)
966 : (hdr
->set
& MSND
)) {
967 strncpy(sender
, auxformat(mp
, 0), sizeof(sender
) - 1);
968 sender
[sizeof(sender
) - 1] = '\0';
973 * ALSO ... save Envelope-From
976 if (hdr
->set
& MEFM
) {
977 strncpy(efrom
, auxformat(mp
, 0), sizeof(efrom
) - 1);
978 efrom
[sizeof(efrom
) - 1] = '\0';
981 if (hdr
->flags
& HBCC
)
984 putgrp (namep
, mp
->m_gname
, out
, hdr
->flags
);
987 keep
= putadr (namep
, "", mp
, out
, hdr
->flags
);
991 msgflags
|= (hdr
->set
& (MVIS
| MINV
));
998 * If this is a From:/Resent-From: header, save the full thing for
999 * later in case we need it for use when constructing a Bcc draft message
1002 if ((msgstate
== RESENT
) ? (hdr
->set
& MRFM
) : (hdr
->set
& MFRM
)) {
1003 strncpy(fullfrom
, str
, sizeof(fullfrom
));
1004 fullfrom
[sizeof(fullfrom
) - 1] = 0;
1006 * Strip off any trailing newlines
1009 while (strlen(fullfrom
) > 0 && fullfrom
[strlen(fullfrom
) - 1] == '\n') {
1010 fullfrom
[strlen(fullfrom
) - 1] = '\0';
1014 if (grp
> 0 && (hdr
->flags
& HNGR
)) {
1015 advise (NULL
, "%s: field does not allow groups", name
);
1025 start_headers (void)
1030 * Probably not necessary, but just in case ...
1041 * Now that we've outputted the header fields in the draft
1042 * message, we will now output any remaining header fields
1043 * that we need to add/create.
1047 finish_headers (FILE *out
)
1051 if (!(msgflags
& MFRM
)) {
1053 * A From: header is now required in the draft.
1055 advise (NULL
, "message has no From: header");
1056 advise (NULL
, "See default components files for examples");
1061 if (fromcount
> 1 && (seensender
== 0 && !(msgflags
& MEFM
))) {
1062 advise (NULL
, "A Sender: or Envelope-From: header is required "
1063 "with multiple\nFrom: addresses");
1071 fprintf (out
, "Date: %s\n", dtime (&tclock
, 0));
1073 fprintf (out
, "Message-ID: %s\n", message_id (tclock
, 0));
1075 * If we have multiple From: addresses, make sure we have an
1076 * Sender: header. If we don't have one, then generate one
1077 * from Envelope-From: (which in this case, cannot be blank)
1080 if (fromcount
> 1 && seensender
== 0) {
1081 if (efrom
[0] == '\0') {
1082 advise (NULL
, "Envelope-From cannot be blank when there "
1083 "is multiple From: addresses\nand no Sender: "
1087 fprintf (out
, "Sender: %s\n", efrom
);
1091 if (!(msgflags
& MVIS
))
1092 fprintf (out
, "Bcc: Blind Distribution List: ;\n");
1096 if (!(msgflags
& MDAT
)) {
1097 advise (NULL
, "message has no Date: header");
1100 if (!(msgflags
& MFRM
)) {
1101 advise (NULL
, "message has no From: header");
1104 if (!(msgflags
& MRFM
)) {
1105 advise (NULL
, "message has no Resent-From: header");
1106 advise (NULL
, "See default components files for examples");
1110 if (fromcount
> 1 && (seensender
== 0 && !(msgflags
& MEFM
))) {
1111 advise (NULL
, "A Resent-Sender: or Envelope-From: header is "
1112 "required with multiple\nResent-From: addresses");
1120 fprintf (out
, "Resent-Date: %s\n", dtime (&tclock
, 0));
1122 fprintf (out
, "Resent-Message-ID: %s\n",
1123 message_id (tclock
, 0));
1125 * If we have multiple Resent-From: addresses, make sure we have an
1126 * Resent-Sender: header. If we don't have one, then generate one
1127 * from Envelope-From (which in this case, cannot be blank)
1130 if (fromcount
> 1 && seensender
== 0) {
1131 if (efrom
[0] == '\0') {
1132 advise (NULL
, "Envelope-From cannot be blank when there "
1133 "is multiple Resent-From: addresses and no "
1134 "Resent-Sender: header");
1137 fprintf (out
, "Resent-Sender: %s\n", efrom
);
1141 if (!(msgflags
& MVIS
))
1142 fprintf (out
, "Resent-Bcc: Blind Re-Distribution List: ;\n");
1147 adios (NULL
, "re-format message and try again");
1149 adios (NULL
, "no addressees");
1154 get_header (char *header
, struct headers
*table
)
1158 for (h
= table
; h
->value
; h
++)
1159 if (!strcasecmp (header
? header
: "", h
->value
? h
->value
: ""))
1167 putadr (char *name
, char *aka
, struct mailname
*mp
, FILE *out
, unsigned int flags
)
1171 char buffer
[BUFSIZ
];
1173 if (mp
->m_mbox
== NULL
|| ((flags
& HTRY
) && !insert (mp
)))
1175 if (sm_mts
!= MTS_SENDMAIL_PIPE
&&
1176 ((flags
& (HBCC
| HDCC
| HEFM
)) || mp
->m_ingrp
))
1180 fprintf (out
, "%s: ", name
);
1181 linepos
+= (nameoutput
= strlen (name
) + 2);
1184 if (*aka
&& mp
->m_type
!= UUCPHOST
&& !mp
->m_pers
)
1185 mp
->m_pers
= getcpy (aka
);
1188 snprintf (buffer
, sizeof(buffer
), "%s;", mp
->m_gname
);
1191 cp
= adrformat (mp
);
1198 if (linepos
!= nameoutput
) {
1199 if (len
+ linepos
+ 2 > outputlinelen
)
1200 fprintf (out
, ",\n%*s", linepos
= nameoutput
, "");
1210 return (flags
& HTRY
);
1215 putgrp (char *name
, char *group
, FILE *out
, unsigned int flags
)
1220 if (sm_mts
!= MTS_SENDMAIL_PIPE
&& (flags
& HBCC
))
1224 fprintf (out
, "%s: ", name
);
1225 linepos
+= (nameoutput
= strlen (name
) + 2);
1228 cp
= concat (group
, ";", NULL
);
1231 if (linepos
> nameoutput
) {
1232 if (len
+ linepos
+ 2 > outputlinelen
) {
1233 fprintf (out
, ",\n%*s", nameoutput
, "");
1234 linepos
= nameoutput
;
1248 insert (struct mailname
*np
)
1250 struct mailname
*mp
;
1252 if (np
->m_mbox
== NULL
)
1255 for (mp
= np
->m_type
== LOCALHOST
? &localaddrs
1256 : np
->m_type
== UUCPHOST
? &uuaddrs
1260 if (!strcasecmp (np
->m_host
? np
->m_host
: "",
1261 mp
->m_next
->m_host
? mp
->m_next
->m_host
: "") &&
1262 !strcasecmp (np
->m_mbox
? np
->m_mbox
: "",
1263 mp
->m_next
->m_mbox
? mp
->m_next
->m_mbox
: "") &&
1264 np
->m_bcc
== mp
->m_next
->m_bcc
)
1277 struct mailname
*mp
;
1279 printf ("-------\n\t-- Addresses --\nlocal:\t");
1280 for (mp
= localaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1281 printf ("%s%s%s", mp
->m_mbox
,
1282 mp
->m_bcc
? "[BCC]" : "",
1283 mp
->m_next
? ",\n\t" : "");
1285 printf ("\nnet:\t");
1286 for (mp
= netaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1287 printf ("%s%s@%s%s%s", mp
->m_path
? mp
->m_path
: "",
1288 mp
->m_mbox
, mp
->m_host
,
1289 mp
->m_bcc
? "[BCC]" : "",
1290 mp
->m_next
? ",\n\t" : "");
1292 printf ("\nuucp:\t");
1293 for (mp
= uuaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1294 printf ("%s!%s%s%s", mp
->m_host
, mp
->m_mbox
,
1295 mp
->m_bcc
? "[BCC]" : "",
1296 mp
->m_next
? ",\n\t" : "");
1298 printf ("\n\t-- Folder Copies --\nfcc:\t");
1299 for (i
= 0; i
< fccind
; i
++)
1300 printf ("%s%s", fccfold
[i
], i
+ 1 < fccind
? ",\n\t" : "");
1308 struct mailname
*mp
;
1310 for (mp
= localaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1311 if (annoaux (mp
) == NOTOK
)
1314 for (mp
= netaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1315 if (annoaux (mp
) == NOTOK
)
1318 for (mp
= uuaddrs
.m_next
; mp
; mp
= mp
->m_next
)
1319 if (annoaux (mp
) == NOTOK
)
1329 annoaux (struct mailname
*mp
)
1332 char buffer
[BUFSIZ
];
1334 snprintf (buffer
, sizeof(buffer
), "%s\n", adrformat (mp
));
1335 i
= strlen (buffer
);
1337 return (write (pfd
, buffer
, i
) == i
? OK
: NOTOK
);
1342 insert_fcc (struct headers
*hdr
, char *pp
)
1346 for (cp
= pp
; isspace ((unsigned char) *cp
); cp
++)
1348 for (pp
+= strlen (pp
) - 1; pp
> cp
&& isspace ((unsigned char) *pp
); pp
--)
1356 adios (NULL
, "too many %ss", hdr
->value
);
1357 fccfold
[fccind
++] = getcpy (cp
);
1365 make_bcc_file (int dashstuff
)
1371 char *tfile
= NULL
, *program
;
1373 if ((tfile
= m_mktemp2(NULL
, "bccs", NULL
, &out
)) == NULL
) {
1374 adios(NULL
, "unable to create temporary file in %s", get_temp_dir());
1376 strncpy (bccfil
, tfile
, sizeof(bccfil
));
1378 fprintf (out
, "From: %s\n", fullfrom
);
1379 fprintf (out
, "Date: %s\n", dtime (&tclock
, 0));
1381 fprintf (out
, "Message-ID: %s\n", message_id (tclock
, 0));
1383 fprintf (out
, "Subject: %s", subject
);
1384 fprintf (out
, "BCC:\n");
1387 * Use MIME encapsulation for Bcc messages
1393 * Check if any lines in the message clash with the
1394 * prefix for the MIME multipart separator. If there
1395 * is a clash, increment one of the letters in the
1396 * prefix and check again.
1398 if ((cp
= strchr(prefix
, 'a')) == NULL
)
1399 adios (NULL
, "lost prefix start");
1400 while (find_prefix () == NOTOK
) {
1405 adios (NULL
, "can't find a unique delimiter string");
1410 fprintf (out
, "%s: %s\n%s: multipart/digest; boundary=\"",
1411 VRSN_FIELD
, VRSN_VALUE
, TYPE_FIELD
);
1412 fprintf (out
, "%s\"\n\n--%s\n\n", prefix
, prefix
);
1414 fprintf (out
, "\n------- Blind-Carbon-Copy\n\n");
1420 * Do mhl filtering of Bcc messages instead
1421 * of MIME encapsulation.
1423 if (filter
!= NULL
) {
1424 for (i
= 0; (child_id
= fork()) == NOTOK
&& i
< 5; i
++)
1428 adios ("fork", "unable to");
1431 dup2 (fileno (out
), 1);
1433 vec
= argsplit(mhlproc
, &program
, &i
);
1434 vec
[i
++] = "-forward";
1439 /* was the flag -[no]dashstuffing specified? */
1441 vec
[i
++] = "-dashstuffing";
1442 else if (dashstuff
< 0)
1443 vec
[i
++] = "-nodashstuffing";
1446 execvp (program
, vec
);
1447 fprintf (stderr
, "unable to exec ");
1452 pidXwait (child_id
, mhlproc
);
1456 if ((fd
= open (tmpfil
, O_RDONLY
)) == NOTOK
)
1457 adios (tmpfil
, "unable to re-open");
1460 * If using MIME encapsulation, or if the -nodashstuffing
1461 * flag was given, then just copy message. Else do
1462 * RFC934 quoting (dashstuffing).
1464 if (mime
|| dashstuff
< 0)
1465 cpydata (fd
, fileno (out
), tmpfil
, bccfil
);
1467 cpydgst (fd
, fileno (out
), tmpfil
, bccfil
);
1471 fseek (out
, 0L, SEEK_END
);
1473 fprintf (out
, "\n--%s--\n", prefix
);
1475 fprintf (out
, "\n------- End of Blind-Carbon-Copy\n");
1481 * Scan message to check if any lines clash with
1482 * the prefix of the MIME multipart separator.
1489 char buffer
[BUFSIZ
];
1492 if ((in
= fopen (tmpfil
, "r")) == NULL
)
1493 adios (tmpfil
, "unable to re-open");
1495 while (fgets (buffer
, sizeof(buffer
) - 1, in
))
1496 if (buffer
[0] == '-' && buffer
[1] == '-') {
1499 for (cp
= buffer
+ strlen (buffer
) - 1; cp
>= buffer
; cp
--)
1500 if (!isspace ((unsigned char) *cp
))
1503 if (strcmp (buffer
+ 2, prefix
) == 0) {
1514 #define plural(x) (x == 1 ? "" : "s")
1519 if (badadr
&& unkadr
)
1520 die (NULL
, "%d address%s unparsable, %d addressee%s undeliverable",
1521 badadr
, plural (badadr
), unkadr
, plural (badadr
));
1523 die (NULL
, "%d address%s unparsable", badadr
, plural (badadr
));
1525 die (NULL
, "%d addressee%s undeliverable", unkadr
, plural (unkadr
));
1530 do_addresses (int bccque
, int talk
)
1534 struct mailname
*lp
;
1537 for (lp
= localaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1538 if (lp
->m_bcc
? bccque
: !bccque
) {
1540 printf (" -- Local Recipients --\n");
1541 do_an_address (lp
, talk
);
1546 for (lp
= uuaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1547 if (lp
->m_bcc
? bccque
: !bccque
) {
1549 printf (" -- UUCP Recipients --\n");
1550 do_an_address (lp
, talk
);
1555 for (lp
= netaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1556 if (lp
->m_bcc
? bccque
: !bccque
) {
1558 printf (" -- Network Recipients --\n");
1559 do_an_address (lp
, talk
);
1565 if (rp_isbad (retval
= sm_waend ()))
1566 die (NULL
, "problem ending addresses; %s", rp_string (retval
));
1571 * MTS-SPECIFIC INTERACTION
1576 * SENDMAIL/SMTP routines
1580 post (char *file
, int bccque
, int talk
, char *envelope
, int oauth_flag
,
1588 if (msgflags
& MINV
)
1589 printf (" -- Posting for %s Recipients --\n",
1590 bccque
? "Blind" : "Sighted");
1592 printf (" -- Posting for All Recipients --\n");
1597 if (sm_mts
== MTS_SENDMAIL_PIPE
) {
1598 char **argp
, *program
;
1601 for (i
= 0; (child_id
= fork()) == NOTOK
&& i
< 5; i
++)
1605 adios ("fork", "unable to");
1608 if (freopen( file
, "r", stdin
) == NULL
) {
1609 adios (file
, "can't reopen for sendmail");
1612 argp
= argsplit(sendmail
, &program
, &argc
);
1613 argp
[argc
++] = "-t"; /* read msg for recipients */
1614 argp
[argc
++] = "-i"; /* don't stop on "." */
1616 argp
[argc
++] = "-bv";
1618 argp
[argc
++] = "-v";
1621 execv (program
, argp
);
1622 adios (sendmail
, "can't exec");
1625 pidXwait (child_id
, NULL
);
1629 if (rp_isbad (retval
= sm_init (clientsw
, serversw
, port
, watch
,
1630 verbose
, snoop
, sasl
, saslmech
, user
,
1631 oauth_flag
? auth_svc
: NULL
, tls
))
1632 || rp_isbad (retval
= sm_winit (envelope
)))
1633 die (NULL
, "problem initializing server; %s", rp_string (retval
));
1635 do_addresses (bccque
, talk
&& verbose
);
1636 if ((fd
= open (file
, O_RDONLY
)) == NOTOK
)
1637 die (file
, "unable to re-open");
1642 sm_end (!(msgflags
& MINV
) || bccque
? OK
: DONE
);
1646 if (msgflags
& MINV
)
1647 printf (" -- %s Recipient Copies Posted --\n",
1648 bccque
? "Blind" : "Sighted");
1650 printf (" -- Recipient Copies Posted --\n");
1658 /* Address Verification */
1661 verify_all_addresses (int talk
, char *envelope
, int oauth_flag
, char *auth_svc
)
1664 struct mailname
*lp
;
1668 if (!whomsw
|| checksw
)
1669 if (rp_isbad (retval
= sm_init (clientsw
, serversw
, port
, watch
,
1670 verbose
, snoop
, sasl
, saslmech
, user
,
1671 oauth_flag
? auth_svc
: NULL
, tls
))
1672 || rp_isbad (retval
= sm_winit (envelope
)))
1673 die (NULL
, "problem initializing server; %s", rp_string (retval
));
1675 if (talk
&& !whomsw
)
1676 printf (" -- Address Verification --\n");
1677 if (talk
&& localaddrs
.m_next
)
1678 printf (" -- Local Recipients --\n");
1679 for (lp
= localaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1680 do_an_address (lp
, talk
);
1682 if (talk
&& uuaddrs
.m_next
)
1683 printf (" -- UUCP Recipients --\n");
1684 for (lp
= uuaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1685 do_an_address (lp
, talk
);
1687 if (talk
&& netaddrs
.m_next
)
1688 printf (" -- Network Recipients --\n");
1689 for (lp
= netaddrs
.m_next
; lp
; lp
= lp
->m_next
)
1690 do_an_address (lp
, talk
);
1693 if (talk
&& !whomsw
)
1694 printf (" -- Address Verification Successful --\n");
1696 if (!whomsw
|| checksw
)
1705 do_an_address (struct mailname
*lp
, int talk
)
1711 switch (lp
->m_type
) {
1715 strncpy (addr
, mbox
, sizeof(addr
));
1719 mbox
= auxformat (lp
, 0);
1721 snprintf (addr
, sizeof(addr
), "%s!%s", lp
->m_host
, lp
->m_mbox
);
1724 default: /* let SendMail decide if the host is bad */
1727 snprintf (addr
, sizeof(addr
), "%s at %s", mbox
, host
);
1732 printf (" %s%s", addr
, whomsw
&& lp
->m_bcc
? "[BCC]" : "");
1734 if (whomsw
&& !checksw
) {
1742 switch (retval
= sm_wadr (mbox
, host
,
1743 lp
->m_type
!= UUCPHOST
? lp
->m_path
: NULL
)) {
1746 printf ("address ok\n");
1752 fprintf (stderr
, " %s: ", addr
);
1753 fprintf (talk
? stdout
: stderr
, "loses; %s\n",
1754 rp_string (retval
));
1760 fprintf (stderr
, " %s: ", addr
);
1761 die (NULL
, "unexpected response; %s", rp_string (retval
));
1769 do_text (char *file
, int fd
)
1774 lseek (fd
, (off_t
) 0, SEEK_SET
);
1776 while ((state
= read (fd
, buf
, sizeof(buf
))) > 0) {
1777 if (rp_isbad (retval
= sm_wtxt (buf
, state
)))
1778 die (NULL
, "problem writing text; %s\n", rp_string (retval
));
1782 die (file
, "problem reading from");
1784 switch (retval
= sm_wtend ()) {
1790 die (NULL
, "posting failed; %s", rp_string (retval
));
1793 die (NULL
, "unexpected response; %s", rp_string (retval
));
1807 (void) m_unlink (tmpfil
);
1808 if (msgflags
& MINV
)
1809 (void) m_unlink (bccfil
);
1811 if (!whomsw
|| checksw
)
1824 hstat
= SIGNAL2 (SIGHUP
, sigser
);
1825 istat
= SIGNAL2 (SIGINT
, sigser
);
1826 qstat
= SIGNAL2 (SIGQUIT
, sigser
);
1827 tstat
= SIGNAL2 (SIGTERM
, sigser
);
1837 SIGNAL (SIGHUP
, hstat
);
1838 SIGNAL (SIGINT
, istat
);
1839 SIGNAL (SIGQUIT
, qstat
);
1840 SIGNAL (SIGTERM
, tstat
);
1848 p_refile (char *file
)
1856 printf (" -- Filing Folder Copies --\n");
1857 for (i
= 0; i
< fccind
; i
++)
1858 fcc (file
, fccfold
[i
]);
1860 printf (" -- Folder Copies Filed --\n");
1865 * Call the `fileproc' to add the file to the folder.
1869 fcc (char *file
, char *folder
)
1872 int i
, status
, argp
;
1874 char **arglist
, *program
;
1877 printf (" %sFcc %s: ", msgstate
== RESENT
? "Resent-" : "", folder
);
1880 for (i
= 0; (child_id
= fork ()) == NOTOK
&& i
< 5; i
++)
1886 fprintf (stderr
, " %sFcc %s: ",
1887 msgstate
== RESENT
? "Resent-" : "", folder
);
1888 fprintf (verbose
? stdout
: stderr
, "no forks, so not ok\n");
1892 /* see if we need to add `+' */
1893 snprintf (fold
, sizeof(fold
), "%s%s",
1894 *folder
== '+' || *folder
== '@' ? "" : "+", folder
);
1896 /* now exec the fileproc */
1898 arglist
= argsplit(fileproc
, &program
, &argp
);
1899 arglist
[argp
++] = "-link";
1900 arglist
[argp
++] = "-file";
1901 arglist
[argp
++] = file
;
1902 arglist
[argp
++] = fold
;
1903 arglist
[argp
] = NULL
;
1904 execvp (program
, arglist
);
1908 if ((status
= pidwait (child_id
, OK
))) {
1910 fprintf (stderr
, " %sFcc %s: ",
1911 msgstate
== RESENT
? "Resent-" : "", folder
);
1912 pidstatus (status
, verbose
? stdout
: stderr
, NULL
);
1915 printf ("folder ok\n");
1927 die (char *what
, char *fmt
, ...)
1931 (void) m_unlink (tmpfil
);
1932 if (msgflags
& MINV
)
1933 (void) m_unlink (bccfil
);
1935 if (!whomsw
|| checksw
)
1939 advertise (what
, NULL
, fmt
, ap
);