1 /* sendsbr.c -- routines to help WhatNow/Send along
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.
9 #include "sbr/cpydgst.h"
10 #include "sbr/trimcpy.h"
12 #include "sbr/getcpy.h"
13 #include "sbr/m_convert.h"
14 #include "sbr/m_backup.h"
15 #include "sbr/folder_read.h"
16 #include "sbr/folder_free.h"
17 #include "sbr/context_find.h"
18 #include "sbr/brkstring.h"
19 #include "sbr/pidstatus.h"
20 #include "sbr/arglist.h"
21 #include "sbr/error.h"
22 #include "h/fmt_scan.h"
23 #include "h/fmt_compile.h"
24 #include "h/signals.h"
32 #ifdef HAVE_SYS_TIME_H
33 # include <sys/time.h>
41 #include "sbr/m_maildir.h"
42 #include "sbr/m_mktemp.h"
43 #include "sbr/message_id.h"
46 static int setup_oauth_params(char *[], int *, const char *, const char **);
47 #endif /* OAUTH_SUPPORT */
49 int debugsw
= 0; /* global */
57 char *altmsg
= NULL
; /* .. */
58 char *annotext
= NULL
;
59 char *distfile
= NULL
;
66 static void alert (char *, int);
67 static int tmp_fd (void);
68 static void anno (int, struct stat
*);
69 static void annoaux (int);
70 static int splitmsg (char **, int, char *, char *, struct stat
*, int);
71 static int sendaux (char **, int, char *, char *, struct stat
*);
72 static void handle_sendfrom(char **, int *, char *, const char *);
73 static int get_from_header_info(const char *, const char **, const char **, const char **);
74 static const char *get_message_header_info(FILE *, char *);
75 static void merge_profile_entry(const char *, const char *, char *[], int *);
76 static void armed_done (int) NORETURN
;
79 * Entry point into (back-end) routines to send message.
83 sendsbr (char **vec
, int vecp
, char *program
, char *draft
, struct stat
*st
,
84 int rename_drft
, const char *auth_svc
)
88 char buffer
[BUFSIZ
], file
[BUFSIZ
];
90 char **buildvec
, *buildprogram
;
91 char *volatile drft
= draft
;
92 /* nvecs is volatile to prevent warning from gcc about possible clobbering
94 volatile int nvecs
= vecp
;
95 int *nvecsp
= (int *) &nvecs
;
98 * Run the mimebuildproc (which is by default mhbuild) on the message
99 * with the addition of the "-auto" flag
102 switch (child
= fork()) {
104 adios("fork", "unable to");
108 buildvec
= argsplit(buildmimeproc
, &buildprogram
, &i
);
109 buildvec
[i
++] = "-auto";
111 buildvec
[i
++] = "-dist";
112 buildvec
[i
++] = (char *) drft
;
114 execvp(buildprogram
, buildvec
);
115 fprintf(stderr
, "unable to exec ");
116 perror(buildmimeproc
);
121 if (pidXwait(child
, buildmimeproc
))
126 set_done(armed_done
);
127 switch (setjmp (env
)) {
130 * If given -push and -unique (which is undocumented), then
131 * rename the draft file. I'm not quite sure why.
133 if (pushsw
&& unique
) {
134 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, NULL
);
136 die("unable to create temporary file");
138 if (rename (drft
, strncpy(file
, cp
, sizeof(file
))) == NOTOK
)
139 adios (file
, "unable to rename %s to", drft
);
144 * Add in any necessary profile entries for xoauth
150 if (setup_oauth_params(vec
, nvecsp
, auth_svc
, &errmsg
) != OK
) {
154 die("send built without OAUTH_SUPPORT, "
155 "so auth_svc %s is not supported", auth_svc
);
156 #endif /* OAUTH_SUPPORT */
160 * Rework the vec based on From: header in draft, as specified
161 * by sendfrom-address entries in profile.
163 if (context_find_prefix("sendfrom-")) {
164 handle_sendfrom(vec
, nvecsp
, draft
, auth_svc
);
168 * Check if we need to split the message into
169 * multiple messages of type "message/partial".
171 if (splitsw
>= 0 && !distfile
&& stat ((char *) drft
, &sts
) != NOTOK
172 && sts
.st_size
>= CPERMSG
) {
173 status
= splitmsg (vec
, nvecs
, program
, drft
,
174 st
, splitsw
) ? NOTOK
: OK
;
176 status
= sendaux (vec
, nvecs
, program
, drft
, st
) ? NOTOK
: OK
;
179 /* rename the original draft */
180 if (rename_drft
&& status
== OK
&&
181 rename (drft
, strncpy (buffer
, m_backup (drft
),
182 sizeof(buffer
))) == NOTOK
)
183 advise (buffer
, "unable to rename %s to", drft
);
193 (void) m_unlink (distfile
);
199 * Split large message into several messages of
200 * type "message/partial" and send them.
204 splitmsg (char **vec
, int vecp
, char *program
, char *drft
,
205 struct stat
*st
, int delay
)
207 int compnum
, nparts
, partno
, state
, status
;
210 char *cp
, *dp
, buffer
[NMH_BUFSIZ
], msgid
[BUFSIZ
];
211 char subject
[BUFSIZ
];
212 char name
[NAMESZ
], partnum
[BUFSIZ
];
214 m_getfld_state_t gstate
;
216 if ((in
= fopen (drft
, "r")) == NULL
)
217 adios (drft
, "unable to open for reading");
223 * Scan through the message and examine the various header fields,
224 * as well as locate the beginning of the message body.
226 gstate
= m_getfld_state_init(in
);
227 m_getfld_track_filepos2(&gstate
);
228 for (compnum
= 1;;) {
229 int bufsz
= sizeof buffer
;
230 switch (state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
)) {
236 * This header field is discarded.
238 if (!strcasecmp (name
, "Message-ID")) {
239 while (state
== FLDPLUS
) {
240 bufsz
= sizeof buffer
;
241 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
243 } else if (uprf (name
, XXX_FIELD_PRF
)
244 || !strcasecmp (name
, VRSN_FIELD
)
245 || !strcasecmp (name
, "Subject")
246 || !strcasecmp (name
, "Encrypted")) {
248 * These header fields are copied to the enclosed
249 * header of the first message in the collection
250 * of message/partials. For the "Subject" header
251 * field, we also record it, so that a modified
252 * version of it, can be copied to the header
253 * of each message/partial in the collection.
255 if (!strcasecmp (name
, "Subject")) {
258 strncpy (subject
, buffer
, BUFSIZ
);
259 sublen
= strlen (subject
);
260 if (sublen
> 0 && subject
[sublen
- 1] == '\n')
261 subject
[sublen
- 1] = '\0';
264 dp
= add (concat (name
, ":", buffer
, NULL
), dp
);
265 while (state
== FLDPLUS
) {
266 bufsz
= sizeof buffer
;
267 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
268 dp
= add (buffer
, dp
);
272 * These header fields are copied to the header of
273 * each message/partial in the collection.
275 cp
= add (concat (name
, ":", buffer
, NULL
), cp
);
276 while (state
== FLDPLUS
) {
277 bufsz
= sizeof buffer
;
278 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
279 cp
= add (buffer
, cp
);
283 start
= ftell (in
) + 1;
292 die("message format error in component #%d", compnum
);
295 die("getfld () returned %d", state
);
300 m_getfld_state_destroy (&gstate
);
302 die("headers missing from draft");
306 while (fgets (buffer
, sizeof buffer
, in
)) {
309 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
315 /* Only one part, nothing to split */
321 return sendaux (vec
, vecp
, program
, drft
, st
);
325 printf ("Sending as %d Partial Messages\n", nparts
);
330 vec
[vecp
++] = "-partno";
331 vec
[vecp
++] = partnum
;
333 vec
[vecp
++] = "-queued";
336 snprintf (msgid
, sizeof(msgid
), "%s", message_id (clock
, 0));
338 fseek (in
, start
, SEEK_SET
);
339 for (partno
= 1; partno
<= nparts
; partno
++) {
343 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, &out
);
345 die("unable to create temporary file");
347 strncpy(tmpdrf
, cp
, sizeof(tmpdrf
));
350 * Output the header fields
353 fprintf (out
, "Subject: %s (part %d of %d)\n", subject
, partno
, nparts
);
354 fprintf (out
, "%s: %s\n", VRSN_FIELD
, VRSN_VALUE
);
355 fprintf (out
, "%s: message/partial; id=\"%s\";\n", TYPE_FIELD
, msgid
);
356 fprintf (out
, "\tnumber=%d; total=%d\n", partno
, nparts
);
357 fprintf (out
, "%s: part %d of %d\n\n", DESCR_FIELD
, partno
, nparts
);
360 * If this is the first in the collection, output the
361 * header fields we are encapsulating at the beginning
362 * of the body of the first message.
367 fprintf (out
, "Message-ID: %s\n", msgid
);
375 if (!fgets (buffer
, sizeof buffer
, in
)) {
376 if (partno
== nparts
)
378 die("premature eof");
381 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
382 fseek (in
, -len
, SEEK_CUR
);
390 adios (tmpdrf
, "error writing to");
394 if (!pushsw
&& verbsw
) {
399 /* Pause here, if a delay is specified */
400 if (delay
> 0 && 1 < partno
&& partno
<= nparts
) {
402 printf ("pausing %d seconds before sending part %d...\n",
406 sleep ((unsigned int) delay
);
409 snprintf (partnum
, sizeof(partnum
), "%d", partno
);
410 status
= sendaux (vec
, vecp
, program
, tmpdrf
, st
);
411 (void) m_unlink (tmpdrf
);
416 * This is so sendaux will only annotate
417 * the altmsg the first time it is called.
425 fclose (in
); /* close the draft */
431 * Annotate original message, and
432 * call `postproc' (which is passed down in "program") to send message.
436 sendaux (char **vec
, int vecp
, char *program
, char *drft
, struct stat
*st
)
440 char backup
[BUFSIZ
], buf
[BUFSIZ
];
442 fd
= pushsw
? tmp_fd () : NOTOK
;
446 if ((fd2
= tmp_fd ()) != NOTOK
) {
447 vec
[vecp
++] = "-idanno";
448 snprintf (buf
, sizeof(buf
), "%d", fd2
);
451 inform("unable to create temporary file in %s for "
452 "annotation list, continuing...", get_temp_dir());
456 if (distfile
&& distout (drft
, distfile
, backup
) == NOTOK
)
463 /* oops -- fork error */
464 adios ("fork", "unable to");
465 break; /* NOT REACHED */
469 * child process -- send it
471 * If fd is OK, then we are pushing and fd points to temp
472 * file, so capture anything on stdout and stderr there.
475 dup2 (fd
, fileno (stdout
));
476 dup2 (fd
, fileno (stderr
));
479 execvp (program
, vec
);
480 fprintf (stderr
, "unable to exec ");
486 * parent process -- wait for it
488 if ((status
= pidwait(child_id
, NOTOK
)) == OK
) {
489 if (annotext
&& fd2
!= NOTOK
)
493 * If postproc failed, and we have good fd (which means
494 * we pushed), then mail error message (and possibly the
495 * draft) back to the user.
501 inform("message not delivered to anyone");
503 if (annotext
&& fd2
!= NOTOK
)
506 (void) m_unlink (drft
);
507 if (rename (backup
, drft
) == NOTOK
)
508 advise (drft
, "unable to rename %s to", backup
);
519 * Mail error notification (and possibly a copy of the
520 * message) back to the user, using the mailproc
524 alert (char *file
, int out
)
535 /* oops -- fork error */
536 advise ("fork", "unable to");
540 /* child process -- send it */
541 SIGNAL (SIGHUP
, SIG_IGN
);
542 SIGNAL (SIGINT
, SIG_IGN
);
543 SIGNAL (SIGQUIT
, SIG_IGN
);
544 SIGNAL (SIGTERM
, SIG_IGN
);
546 if ((in
= open (file
, O_RDONLY
)) == NOTOK
) {
547 admonish (file
, "unable to re-open");
549 lseek(out
, 0, SEEK_END
);
550 strncpy (buf
, "\nMessage not delivered to anyone.\n", sizeof(buf
));
551 if (write (out
, buf
, strlen (buf
)) < 0) {
552 advise (file
, "write");
554 strncpy (buf
, "\n------- Unsent Draft\n\n", sizeof(buf
));
555 if (write (out
, buf
, strlen (buf
)) < 0) {
556 advise (file
, "write");
558 cpydgst (in
, out
, file
, "temporary file");
560 strncpy (buf
, "\n------- End of Unsent Draft\n", sizeof(buf
));
561 if (write (out
, buf
, strlen (buf
)) < 0) {
562 advise (file
, "write");
564 if (rename (file
, strncpy (buf
, m_backup (file
), sizeof(buf
))) == NOTOK
)
565 admonish (buf
, "unable to rename %s to", file
);
568 lseek(out
, 0, SEEK_SET
);
569 dup2 (out
, fileno (stdin
));
571 /* create subject for error notification */
572 snprintf (buf
, sizeof(buf
), "send failed on %s",
573 forwsw
? "enclosed draft" : file
);
575 arglist
= argsplit(mailproc
, &program
, &argp
);
577 arglist
[argp
++] = getusername();
578 arglist
[argp
++] = "-subject";
579 arglist
[argp
++] = buf
;
580 arglist
[argp
] = NULL
;
582 execvp (program
, arglist
);
583 fprintf (stderr
, "unable to exec ");
587 default: /* no waiting... */
599 if ((tfile
= m_mktemp2(NULL
, invo_name
, &fd
, NULL
)) == NULL
) return NOTOK
;
602 inform("temporary file %s selected", tfile
);
603 else if (m_unlink (tfile
) == NOTOK
)
604 advise (tfile
, "unable to remove");
611 anno (int fd
, struct stat
*st
)
615 static char *cwd
= NULL
;
619 (stat (altmsg
, &st2
) == NOTOK
620 || st
->st_mtime
!= st2
.st_mtime
621 || st
->st_dev
!= st2
.st_dev
622 || st
->st_ino
!= st2
.st_ino
)) {
624 inform("$mhaltmsg mismatch, continuing...");
628 child_id
= debugsw
? NOTOK
: fork ();
630 case NOTOK
: /* oops */
632 inform("unable to fork, so doing annotations by hand...");
634 cwd
= mh_xstrdup(pwd ());
638 /* block a few signals */
640 sigaddset (&set
, SIGHUP
);
641 sigaddset (&set
, SIGINT
);
642 sigaddset (&set
, SIGQUIT
);
643 sigaddset (&set
, SIGTERM
);
644 sigprocmask (SIG_BLOCK
, &set
, &oset
);
646 unregister_for_removal(0);
652 /* reset the signal mask */
653 sigprocmask (SIG_SETMASK
, &oset
, &set
);
655 if (chdir (cwd
) < 0) {
656 advise (cwd
, "chdir");
660 default: /* no waiting... */
670 int fd2
, fd3
, msgnum
;
671 char *cp
, *folder
, *maildir
;
672 char buffer
[BUFSIZ
], **ap
;
676 if ((folder
= getenv ("mhfolder")) == NULL
|| *folder
== 0) {
678 inform("$mhfolder not set, continuing...");
681 maildir
= m_maildir (folder
);
682 if (chdir (maildir
) == NOTOK
) {
684 admonish (maildir
, "unable to change directory to");
687 if (!(mp
= folder_read (folder
, 0))) {
689 inform("unable to read folder %s, continuing...", folder
);
693 /* check for empty folder */
694 if (mp
->nummsg
== 0) {
696 inform("no messages in %s, continuing...", folder
);
700 if ((cp
= getenv ("mhmessages")) == NULL
|| *cp
== 0) {
702 inform("$mhmessages not set, continuing...");
705 if (!debugsw
/* MOBY HACK... */
707 && (fd3
= open ("/dev/null", O_RDWR
)) != NOTOK
708 && (fd2
= dup (fileno (stderr
))) != NOTOK
) {
709 dup2 (fd3
, fileno (stderr
));
714 for (ap
= brkstring (cp
= mh_xstrdup(cp
), " ", NULL
); *ap
; ap
++)
718 dup2 (fd2
, fileno (stderr
));
719 if (mp
->numsel
== 0) {
721 inform("no messages to annotate, continuing...");
725 lseek(fd
, 0, SEEK_SET
);
726 if ((fp
= fdopen (fd
, "r")) == NULL
) {
728 inform("unable to fdopen annotation list, continuing...");
732 while (fgets (buffer
, sizeof(buffer
), fp
) != NULL
)
733 cp
= add (buffer
, cp
);
737 inform("annotate%s with %s: \"%s\"",
738 inplace
? " inplace" : "", annotext
, cp
);
739 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++) {
740 if (is_selected(mp
, msgnum
)) {
742 inform("annotate message %d", msgnum
);
743 annotate (m_name (msgnum
), annotext
, cp
, inplace
, 1, -2, 0);
750 folder_free (mp
); /* free folder/message structure */
755 handle_sendfrom(char **vec
, int *vecp
, char *draft
, const char *auth_svc
)
757 const char *addr
, *host
;
760 /* Extract address and host from From: header line in draft. */
761 if (get_from_header_info(draft
, &addr
, &host
, &message
) != OK
) {
762 adios(draft
, "%s", message
);
765 /* Merge in any address or host specific switches to post(1) from profile. */
766 merge_profile_entry(addr
, host
, vec
, vecp
);
775 for (vp
= vec
; *vp
; ++vp
) {
776 if (strcmp(*vp
, "xoauth2") == 0) {
778 if (setup_oauth_params(vec
, vecp
, auth_svc
, &message
) != OK
) {
783 NMH_UNUSED(auth_svc
);
784 die("send built without OAUTH_SUPPORT, "
785 "so -saslmech xoauth2 is not supported");
786 #endif /* OAUTH_SUPPORT */
795 * For XOAUTH2, append profile entries so post can do the heavy lifting
798 setup_oauth_params(char *vec
[], int *vecp
, const char *auth_svc
,
799 const char **message
)
801 const char *saslmech
= NULL
, *user
= NULL
;
802 mh_oauth_service_info svc
;
806 /* Make sure we have all the information we need. */
807 for (i
= 1; i
< *vecp
; ++i
) {
808 /* Don't support abbreviated switches, to avoid collisions in the
809 future if new ones are added. */
810 if (! strcmp(vec
[i
-1], "-saslmech")) {
812 } else if (! strcmp(vec
[i
-1], "-user")) {
814 } else if (! strcmp(vec
[i
-1], "-authservice")) {
819 if (auth_svc
== NULL
) {
820 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
821 *message
= "must specify -authservice with -saslmech xoauth2";
826 *message
= "must specify -user with -saslmech xoauth2";
830 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
831 if (! mh_oauth_get_service_info(auth_svc
, &svc
, errbuf
,
833 die("Unable to retrieve oauth profile entries: %s",
836 vec
[(*vecp
)++] = mh_xstrdup("-authservice");
837 vec
[(*vecp
)++] = mh_xstrdup(auth_svc
);
838 vec
[(*vecp
)++] = mh_xstrdup("-oauthcredfile");
839 vec
[(*vecp
)++] = mh_oauth_cred_fn(auth_svc
);
840 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientid");
841 vec
[(*vecp
)++] = getcpy(svc
.client_id
);
842 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientsecret");
843 vec
[(*vecp
)++] = getcpy(svc
.client_secret
);
844 vec
[(*vecp
)++] = mh_xstrdup("-oauthauthendpoint");
845 vec
[(*vecp
)++] = getcpy(svc
.auth_endpoint
);
846 vec
[(*vecp
)++] = mh_xstrdup("-oauthredirect");
847 vec
[(*vecp
)++] = getcpy(svc
.redirect_uri
);
848 vec
[(*vecp
)++] = mh_xstrdup("-oauthtokenendpoint");
849 vec
[(*vecp
)++] = getcpy(svc
.token_endpoint
);
850 vec
[(*vecp
)++] = mh_xstrdup("-oauthscope");
851 vec
[(*vecp
)++] = getcpy(svc
.scope
);
857 #endif /* OAUTH_SUPPORT */
861 * Extract user and domain from From: header line in draft.
864 get_from_header_info(const char *filename
, const char **addr
, const char **host
, const char **message
)
869 if (stat (filename
, &st
) == NOTOK
) {
870 *message
= "unable to stat draft file";
874 if ((in
= fopen (filename
, "r")) != NULL
) {
875 /* There must be a non-blank Envelope-From or {Resent-}Sender or
876 {Resent-}From header. */
877 char *addrformat
= "%(addr{Envelope-From})";
878 char *hostformat
= "%(host{Envelope-From})";
880 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
||
882 addrformat
= distfile
== NULL
? "%(addr{Sender})" : "%(addr{Resent-Sender})";
883 hostformat
= distfile
== NULL
? "%(host{Sender})" : "%(host{Resent-Sender})";
885 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
886 addrformat
= distfile
== NULL
? "%(addr{From})" : "%(addr{Resent-From})";
887 hostformat
= distfile
== NULL
? "%(host{From})" : "%(host{Resent-From})";
889 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
890 *message
= "unable to find sender address in";
897 /* Use the hostformat that corresponds to the successful addrformat. */
898 if ((*host
= get_message_header_info(in
, hostformat
)) == NULL
) {
899 *message
= "unable to find sender host";
908 *message
= "unable to open";
914 * Get formatted information from header of a message.
915 * Adapted from process_single_file() in uip/fmttest.c.
918 get_message_header_info(FILE *in
, char *format
)
924 m_getfld_state_t gstate
;
925 charstring_t buffer
= charstring_create(0);
928 dat
[0] = dat
[1] = dat
[4] = 0;
929 dat
[2] = fstat(fileno(in
), &st
) == 0 ? st
.st_size
: 0;
932 (void) fmt_compile(new_fs(NULL
, NULL
, format
), &fmt
, 1);
936 * Read in the message and process the header.
939 parsing_header
= true;
940 gstate
= m_getfld_state_init(in
);
942 char name
[NAMESZ
], rbuf
[NMH_BUFSIZ
];
943 int bufsz
= sizeof rbuf
;
944 int state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
949 int bucket
= fmt_addcomptext(name
, rbuf
);
952 while (state
== FLDPLUS
) {
954 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
955 fmt_appendcomp(bucket
, name
, rbuf
);
959 while (state
== FLDPLUS
) {
961 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
966 parsing_header
= false;
968 } while (parsing_header
);
969 m_getfld_state_destroy(&gstate
);
971 fmt_scan(fmt
, buffer
, INT_MAX
, dat
, NULL
);
974 /* Trim trailing newline, if any. */
975 retval
= rtrim(charstring_buffer_copy((buffer
)));
976 charstring_free(buffer
);
986 * Look in profile for entry corresponding to addr or host, and add its contents to vec.
988 * Could do some of this automatically, by looking for:
989 * 1) access-$(mbox{from}) in oauth-svc file using mh_oauth_cred_load(), which isn't
990 * static and doesn't have side effects; free the result with mh_oauth_cred_free())
991 * 2) machine $(mbox{from}) in creds
992 * If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
993 * but that might not generalize for other svcs.
996 merge_profile_entry(const char *addr
, const char *host
, char *vec
[], int *vecp
)
998 char *addr_entry
= concat("sendfrom-", addr
, NULL
);
999 char *profile_entry
= context_find(addr_entry
);
1002 if (profile_entry
== NULL
) {
1003 /* No entry for the user. Look for one for the host. */
1004 char *host_entry
= concat("sendfrom-", host
, NULL
);
1006 profile_entry
= context_find(host_entry
);
1010 /* Use argsplit() to do the real work of splitting the args in the profile entry. */
1011 if (profile_entry
&& *profile_entry
) {
1014 char **profile_vec
= argsplit(profile_entry
, &file
, &profile_vecp
);
1017 for (i
= 0; i
< profile_vecp
; ++i
) {
1018 vec
[(*vecp
)++] = getcpy(profile_vec
[i
]);
1021 arglist_free(file
, profile_vec
);
1026 static void NORETURN
1027 armed_done (int status
)
1029 longjmp (env
, status
? status
: NOTOK
);