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/concat.h"
10 #include "sbr/cpydgst.h"
11 #include "sbr/trimcpy.h"
13 #include "sbr/getcpy.h"
14 #include "sbr/m_convert.h"
15 #include "sbr/m_backup.h"
16 #include "sbr/folder_read.h"
17 #include "sbr/folder_free.h"
18 #include "sbr/context_find.h"
19 #include "sbr/brkstring.h"
20 #include "sbr/pidstatus.h"
21 #include "sbr/arglist.h"
22 #include "sbr/error.h"
23 #include "h/fmt_scan.h"
24 #include "h/fmt_compile.h"
25 #include "h/signals.h"
33 #ifdef HAVE_SYS_TIME_H
34 # include <sys/time.h>
42 #include "sbr/m_maildir.h"
43 #include "sbr/m_mktemp.h"
44 #include "sbr/message_id.h"
47 static int setup_oauth_params(char *[], int *, const char *, const char **);
48 #endif /* OAUTH_SUPPORT */
50 int debugsw
= 0; /* global */
58 char *altmsg
= NULL
; /* .. */
59 char *annotext
= NULL
;
60 char *distfile
= NULL
;
67 static void alert (char *, int);
68 static int tmp_fd (void);
69 static void anno (int, struct stat
*);
70 static void annoaux (int);
71 static int splitmsg (char **, int, char *, char *, struct stat
*, int);
72 static int sendaux (char **, int, char *, char *, struct stat
*);
73 static void handle_sendfrom(char **, int *, char *, const char *);
74 static int get_from_header_info(const char *, const char **, const char **, const char **);
75 static const char *get_message_header_info(FILE *, char *);
76 static void merge_profile_entry(const char *, const char *, char *[], int *);
77 static void armed_done (int) NORETURN
;
80 * Entry point into (back-end) routines to send message.
84 sendsbr (char **vec
, int vecp
, char *program
, char *draft
, struct stat
*st
,
85 int rename_drft
, const char *auth_svc
)
89 char buffer
[BUFSIZ
], file
[BUFSIZ
];
91 char **buildvec
, *buildprogram
;
92 char *volatile drft
= draft
;
93 /* nvecs is volatile to prevent warning from gcc about possible clobbering
95 volatile int nvecs
= vecp
;
96 int *nvecsp
= (int *) &nvecs
;
99 * Run the mimebuildproc (which is by default mhbuild) on the message
100 * with the addition of the "-auto" flag
103 switch (child
= fork()) {
105 adios("fork", "unable to");
109 buildvec
= argsplit(buildmimeproc
, &buildprogram
, &i
);
110 buildvec
[i
++] = "-auto";
112 buildvec
[i
++] = "-dist";
113 buildvec
[i
++] = (char *) drft
;
115 execvp(buildprogram
, buildvec
);
116 fprintf(stderr
, "unable to exec ");
117 perror(buildmimeproc
);
122 if (pidXwait(child
, buildmimeproc
))
127 set_done(armed_done
);
128 switch (setjmp (env
)) {
131 * If given -push and -unique (which is undocumented), then
132 * rename the draft file. I'm not quite sure why.
134 if (pushsw
&& unique
) {
135 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, NULL
);
137 die("unable to create temporary file");
139 if (rename (drft
, strncpy(file
, cp
, sizeof(file
))) == NOTOK
)
140 adios (file
, "unable to rename %s to", drft
);
145 * Add in any necessary profile entries for xoauth
151 if (setup_oauth_params(vec
, nvecsp
, auth_svc
, &errmsg
) != OK
) {
155 die("send built without OAUTH_SUPPORT, "
156 "so auth_svc %s is not supported", auth_svc
);
157 #endif /* OAUTH_SUPPORT */
161 * Rework the vec based on From: header in draft, as specified
162 * by sendfrom-address entries in profile.
164 if (context_find_prefix("sendfrom-")) {
165 handle_sendfrom(vec
, nvecsp
, draft
, auth_svc
);
169 * Check if we need to split the message into
170 * multiple messages of type "message/partial".
172 if (splitsw
>= 0 && !distfile
&& stat ((char *) drft
, &sts
) != NOTOK
173 && sts
.st_size
>= CPERMSG
) {
174 status
= splitmsg (vec
, nvecs
, program
, drft
,
175 st
, splitsw
) ? NOTOK
: OK
;
177 status
= sendaux (vec
, nvecs
, program
, drft
, st
) ? NOTOK
: OK
;
180 /* rename the original draft */
181 if (rename_drft
&& status
== OK
&&
182 rename (drft
, strncpy (buffer
, m_backup (drft
),
183 sizeof(buffer
))) == NOTOK
)
184 advise (buffer
, "unable to rename %s to", drft
);
194 (void) m_unlink (distfile
);
200 * Split large message into several messages of
201 * type "message/partial" and send them.
205 splitmsg (char **vec
, int vecp
, char *program
, char *drft
,
206 struct stat
*st
, int delay
)
208 int compnum
, nparts
, partno
, state
, status
;
211 char *cp
, *dp
, buffer
[NMH_BUFSIZ
], msgid
[BUFSIZ
];
212 char subject
[BUFSIZ
];
213 char name
[NAMESZ
], partnum
[BUFSIZ
];
215 m_getfld_state_t gstate
;
217 if ((in
= fopen (drft
, "r")) == NULL
)
218 adios (drft
, "unable to open for reading");
224 * Scan through the message and examine the various header fields,
225 * as well as locate the beginning of the message body.
227 gstate
= m_getfld_state_init(in
);
228 m_getfld_track_filepos2(&gstate
);
229 for (compnum
= 1;;) {
230 int bufsz
= sizeof buffer
;
231 switch (state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
)) {
237 * This header field is discarded.
239 if (!strcasecmp (name
, "Message-ID")) {
240 while (state
== FLDPLUS
) {
241 bufsz
= sizeof buffer
;
242 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
244 } else if (uprf (name
, XXX_FIELD_PRF
)
245 || !strcasecmp (name
, VRSN_FIELD
)
246 || !strcasecmp (name
, "Subject")
247 || !strcasecmp (name
, "Encrypted")) {
249 * These header fields are copied to the enclosed
250 * header of the first message in the collection
251 * of message/partials. For the "Subject" header
252 * field, we also record it, so that a modified
253 * version of it, can be copied to the header
254 * of each message/partial in the collection.
256 if (!strcasecmp (name
, "Subject")) {
259 strncpy (subject
, buffer
, BUFSIZ
);
260 sublen
= strlen (subject
);
261 if (sublen
> 0 && subject
[sublen
- 1] == '\n')
262 subject
[sublen
- 1] = '\0';
265 dp
= add (concat (name
, ":", buffer
, NULL
), dp
);
266 while (state
== FLDPLUS
) {
267 bufsz
= sizeof buffer
;
268 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
269 dp
= add (buffer
, dp
);
273 * These header fields are copied to the header of
274 * each message/partial in the collection.
276 cp
= add (concat (name
, ":", buffer
, NULL
), cp
);
277 while (state
== FLDPLUS
) {
278 bufsz
= sizeof buffer
;
279 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
280 cp
= add (buffer
, cp
);
284 start
= ftell (in
) + 1;
293 die("message format error in component #%d", compnum
);
296 die("getfld () returned %d", state
);
301 m_getfld_state_destroy (&gstate
);
303 die("headers missing from draft");
307 while (fgets (buffer
, sizeof buffer
, in
)) {
310 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
316 /* Only one part, nothing to split */
322 return sendaux (vec
, vecp
, program
, drft
, st
);
326 printf ("Sending as %d Partial Messages\n", nparts
);
331 vec
[vecp
++] = "-partno";
332 vec
[vecp
++] = partnum
;
334 vec
[vecp
++] = "-queued";
337 snprintf (msgid
, sizeof(msgid
), "%s", message_id (clock
, 0));
339 fseek (in
, start
, SEEK_SET
);
340 for (partno
= 1; partno
<= nparts
; partno
++) {
344 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, &out
);
346 die("unable to create temporary file");
348 strncpy(tmpdrf
, cp
, sizeof(tmpdrf
));
351 * Output the header fields
354 fprintf (out
, "Subject: %s (part %d of %d)\n", subject
, partno
, nparts
);
355 fprintf (out
, "%s: %s\n", VRSN_FIELD
, VRSN_VALUE
);
356 fprintf (out
, "%s: message/partial; id=\"%s\";\n", TYPE_FIELD
, msgid
);
357 fprintf (out
, "\tnumber=%d; total=%d\n", partno
, nparts
);
358 fprintf (out
, "%s: part %d of %d\n\n", DESCR_FIELD
, partno
, nparts
);
361 * If this is the first in the collection, output the
362 * header fields we are encapsulating at the beginning
363 * of the body of the first message.
368 fprintf (out
, "Message-ID: %s\n", msgid
);
376 if (!fgets (buffer
, sizeof buffer
, in
)) {
377 if (partno
== nparts
)
379 die("premature eof");
382 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
383 fseek (in
, -len
, SEEK_CUR
);
391 adios (tmpdrf
, "error writing to");
395 if (!pushsw
&& verbsw
) {
400 /* Pause here, if a delay is specified */
401 if (delay
> 0 && 1 < partno
&& partno
<= nparts
) {
403 printf ("pausing %d seconds before sending part %d...\n",
407 sleep ((unsigned int) delay
);
410 snprintf (partnum
, sizeof(partnum
), "%d", partno
);
411 status
= sendaux (vec
, vecp
, program
, tmpdrf
, st
);
412 (void) m_unlink (tmpdrf
);
417 * This is so sendaux will only annotate
418 * the altmsg the first time it is called.
426 fclose (in
); /* close the draft */
432 * Annotate original message, and
433 * call `postproc' (which is passed down in "program") to send message.
437 sendaux (char **vec
, int vecp
, char *program
, char *drft
, struct stat
*st
)
441 char backup
[BUFSIZ
], buf
[BUFSIZ
];
443 fd
= pushsw
? tmp_fd () : NOTOK
;
447 if ((fd2
= tmp_fd ()) != NOTOK
) {
448 vec
[vecp
++] = "-idanno";
449 snprintf (buf
, sizeof(buf
), "%d", fd2
);
452 inform("unable to create temporary file in %s for "
453 "annotation list, continuing...", get_temp_dir());
457 if (distfile
&& distout (drft
, distfile
, backup
) == NOTOK
)
464 /* oops -- fork error */
465 adios ("fork", "unable to");
466 break; /* NOT REACHED */
470 * child process -- send it
472 * If fd is OK, then we are pushing and fd points to temp
473 * file, so capture anything on stdout and stderr there.
476 dup2 (fd
, fileno (stdout
));
477 dup2 (fd
, fileno (stderr
));
480 execvp (program
, vec
);
481 fprintf (stderr
, "unable to exec ");
487 * parent process -- wait for it
489 if ((status
= pidwait(child_id
, NOTOK
)) == OK
) {
490 if (annotext
&& fd2
!= NOTOK
)
494 * If postproc failed, and we have good fd (which means
495 * we pushed), then mail error message (and possibly the
496 * draft) back to the user.
502 inform("message not delivered to anyone");
504 if (annotext
&& fd2
!= NOTOK
)
507 (void) m_unlink (drft
);
508 if (rename (backup
, drft
) == NOTOK
)
509 advise (drft
, "unable to rename %s to", backup
);
520 * Mail error notification (and possibly a copy of the
521 * message) back to the user, using the mailproc
525 alert (char *file
, int out
)
536 /* oops -- fork error */
537 advise ("fork", "unable to");
541 /* child process -- send it */
542 SIGNAL (SIGHUP
, SIG_IGN
);
543 SIGNAL (SIGINT
, SIG_IGN
);
544 SIGNAL (SIGQUIT
, SIG_IGN
);
545 SIGNAL (SIGTERM
, SIG_IGN
);
547 if ((in
= open (file
, O_RDONLY
)) == NOTOK
) {
548 admonish (file
, "unable to re-open");
550 lseek(out
, 0, SEEK_END
);
551 strncpy (buf
, "\nMessage not delivered to anyone.\n", sizeof(buf
));
552 if (write (out
, buf
, strlen (buf
)) < 0) {
553 advise (file
, "write");
555 strncpy (buf
, "\n------- Unsent Draft\n\n", sizeof(buf
));
556 if (write (out
, buf
, strlen (buf
)) < 0) {
557 advise (file
, "write");
559 cpydgst (in
, out
, file
, "temporary file");
561 strncpy (buf
, "\n------- End of Unsent Draft\n", sizeof(buf
));
562 if (write (out
, buf
, strlen (buf
)) < 0) {
563 advise (file
, "write");
565 if (rename (file
, strncpy (buf
, m_backup (file
), sizeof(buf
))) == NOTOK
)
566 admonish (buf
, "unable to rename %s to", file
);
569 lseek(out
, 0, SEEK_SET
);
570 dup2 (out
, fileno (stdin
));
572 /* create subject for error notification */
573 snprintf (buf
, sizeof(buf
), "send failed on %s",
574 forwsw
? "enclosed draft" : file
);
576 arglist
= argsplit(mailproc
, &program
, &argp
);
578 arglist
[argp
++] = getusername();
579 arglist
[argp
++] = "-subject";
580 arglist
[argp
++] = buf
;
581 arglist
[argp
] = NULL
;
583 execvp (program
, arglist
);
584 fprintf (stderr
, "unable to exec ");
588 default: /* no waiting... */
600 if ((tfile
= m_mktemp2(NULL
, invo_name
, &fd
, NULL
)) == NULL
) return NOTOK
;
603 inform("temporary file %s selected", tfile
);
604 else if (m_unlink (tfile
) == NOTOK
)
605 advise (tfile
, "unable to remove");
612 anno (int fd
, struct stat
*st
)
616 static char *cwd
= NULL
;
620 (stat (altmsg
, &st2
) == NOTOK
621 || st
->st_mtime
!= st2
.st_mtime
622 || st
->st_dev
!= st2
.st_dev
623 || st
->st_ino
!= st2
.st_ino
)) {
625 inform("$mhaltmsg mismatch, continuing...");
629 child_id
= debugsw
? NOTOK
: fork ();
631 case NOTOK
: /* oops */
633 inform("unable to fork, so doing annotations by hand...");
635 cwd
= mh_xstrdup(pwd ());
639 /* block a few signals */
641 sigaddset (&set
, SIGHUP
);
642 sigaddset (&set
, SIGINT
);
643 sigaddset (&set
, SIGQUIT
);
644 sigaddset (&set
, SIGTERM
);
645 sigprocmask (SIG_BLOCK
, &set
, &oset
);
647 unregister_for_removal(0);
653 /* reset the signal mask */
654 sigprocmask (SIG_SETMASK
, &oset
, &set
);
656 if (chdir (cwd
) < 0) {
657 advise (cwd
, "chdir");
661 default: /* no waiting... */
671 int fd2
, fd3
, msgnum
;
672 char *cp
, *folder
, *maildir
;
673 char buffer
[BUFSIZ
], **ap
;
677 if ((folder
= getenv ("mhfolder")) == NULL
|| *folder
== 0) {
679 inform("$mhfolder not set, continuing...");
682 maildir
= m_maildir (folder
);
683 if (chdir (maildir
) == NOTOK
) {
685 admonish (maildir
, "unable to change directory to");
688 if (!(mp
= folder_read (folder
, 0))) {
690 inform("unable to read folder %s, continuing...", folder
);
694 /* check for empty folder */
695 if (mp
->nummsg
== 0) {
697 inform("no messages in %s, continuing...", folder
);
701 if ((cp
= getenv ("mhmessages")) == NULL
|| *cp
== 0) {
703 inform("$mhmessages not set, continuing...");
706 if (!debugsw
/* MOBY HACK... */
708 && (fd3
= open ("/dev/null", O_RDWR
)) != NOTOK
709 && (fd2
= dup (fileno (stderr
))) != NOTOK
) {
710 dup2 (fd3
, fileno (stderr
));
715 for (ap
= brkstring (cp
= mh_xstrdup(cp
), " ", NULL
); *ap
; ap
++)
719 dup2 (fd2
, fileno (stderr
));
720 if (mp
->numsel
== 0) {
722 inform("no messages to annotate, continuing...");
726 lseek(fd
, 0, SEEK_SET
);
727 if ((fp
= fdopen (fd
, "r")) == NULL
) {
729 inform("unable to fdopen annotation list, continuing...");
733 while (fgets (buffer
, sizeof(buffer
), fp
) != NULL
)
734 cp
= add (buffer
, cp
);
738 inform("annotate%s with %s: \"%s\"",
739 inplace
? " inplace" : "", annotext
, cp
);
740 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++) {
741 if (is_selected(mp
, msgnum
)) {
743 inform("annotate message %d", msgnum
);
744 annotate (m_name (msgnum
), annotext
, cp
, inplace
, 1, -2, 0);
751 folder_free (mp
); /* free folder/message structure */
756 handle_sendfrom(char **vec
, int *vecp
, char *draft
, const char *auth_svc
)
758 const char *addr
, *host
;
761 /* Extract address and host from From: header line in draft. */
762 if (get_from_header_info(draft
, &addr
, &host
, &message
) != OK
) {
763 adios(draft
, "%s", message
);
766 /* Merge in any address or host specific switches to post(1) from profile. */
767 merge_profile_entry(addr
, host
, vec
, vecp
);
776 for (vp
= vec
; *vp
; ++vp
) {
777 if (strcmp(*vp
, "xoauth2") == 0) {
779 if (setup_oauth_params(vec
, vecp
, auth_svc
, &message
) != OK
) {
784 NMH_UNUSED(auth_svc
);
785 die("send built without OAUTH_SUPPORT, "
786 "so -saslmech xoauth2 is not supported");
787 #endif /* OAUTH_SUPPORT */
796 * For XOAUTH2, append profile entries so post can do the heavy lifting
799 setup_oauth_params(char *vec
[], int *vecp
, const char *auth_svc
,
800 const char **message
)
802 const char *saslmech
= NULL
, *user
= NULL
;
803 mh_oauth_service_info svc
;
807 /* Make sure we have all the information we need. */
808 for (i
= 1; i
< *vecp
; ++i
) {
809 /* Don't support abbreviated switches, to avoid collisions in the
810 future if new ones are added. */
811 if (! strcmp(vec
[i
-1], "-saslmech")) {
813 } else if (! strcmp(vec
[i
-1], "-user")) {
815 } else if (! strcmp(vec
[i
-1], "-authservice")) {
820 if (auth_svc
== NULL
) {
821 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
822 *message
= "must specify -authservice with -saslmech xoauth2";
827 *message
= "must specify -user with -saslmech xoauth2";
831 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
832 if (! mh_oauth_get_service_info(auth_svc
, &svc
, errbuf
,
834 die("Unable to retrieve oauth profile entries: %s",
837 vec
[(*vecp
)++] = mh_xstrdup("-authservice");
838 vec
[(*vecp
)++] = mh_xstrdup(auth_svc
);
839 vec
[(*vecp
)++] = mh_xstrdup("-oauthcredfile");
840 vec
[(*vecp
)++] = mh_oauth_cred_fn(auth_svc
);
841 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientid");
842 vec
[(*vecp
)++] = getcpy(svc
.client_id
);
843 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientsecret");
844 vec
[(*vecp
)++] = getcpy(svc
.client_secret
);
845 vec
[(*vecp
)++] = mh_xstrdup("-oauthauthendpoint");
846 vec
[(*vecp
)++] = getcpy(svc
.auth_endpoint
);
847 vec
[(*vecp
)++] = mh_xstrdup("-oauthredirect");
848 vec
[(*vecp
)++] = getcpy(svc
.redirect_uri
);
849 vec
[(*vecp
)++] = mh_xstrdup("-oauthtokenendpoint");
850 vec
[(*vecp
)++] = getcpy(svc
.token_endpoint
);
851 vec
[(*vecp
)++] = mh_xstrdup("-oauthscope");
852 vec
[(*vecp
)++] = getcpy(svc
.scope
);
858 #endif /* OAUTH_SUPPORT */
862 * Extract user and domain from From: header line in draft.
865 get_from_header_info(const char *filename
, const char **addr
, const char **host
, const char **message
)
870 if (stat (filename
, &st
) == NOTOK
) {
871 *message
= "unable to stat draft file";
875 if ((in
= fopen (filename
, "r")) != NULL
) {
876 /* There must be a non-blank Envelope-From or {Resent-}Sender or
877 {Resent-}From header. */
878 char *addrformat
= "%(addr{Envelope-From})";
879 char *hostformat
= "%(host{Envelope-From})";
881 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
||
883 addrformat
= distfile
== NULL
? "%(addr{Sender})" : "%(addr{Resent-Sender})";
884 hostformat
= distfile
== NULL
? "%(host{Sender})" : "%(host{Resent-Sender})";
886 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
887 addrformat
= distfile
== NULL
? "%(addr{From})" : "%(addr{Resent-From})";
888 hostformat
= distfile
== NULL
? "%(host{From})" : "%(host{Resent-From})";
890 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
891 *message
= "unable to find sender address in";
898 /* Use the hostformat that corresponds to the successful addrformat. */
899 if ((*host
= get_message_header_info(in
, hostformat
)) == NULL
) {
900 *message
= "unable to find sender host";
909 *message
= "unable to open";
915 * Get formatted information from header of a message.
916 * Adapted from process_single_file() in uip/fmttest.c.
919 get_message_header_info(FILE *in
, char *format
)
925 m_getfld_state_t gstate
;
926 charstring_t buffer
= charstring_create(0);
929 dat
[0] = dat
[1] = dat
[4] = 0;
930 dat
[2] = fstat(fileno(in
), &st
) == 0 ? st
.st_size
: 0;
933 (void) fmt_compile(new_fs(NULL
, NULL
, format
), &fmt
, 1);
937 * Read in the message and process the header.
940 parsing_header
= true;
941 gstate
= m_getfld_state_init(in
);
943 char name
[NAMESZ
], rbuf
[NMH_BUFSIZ
];
944 int bufsz
= sizeof rbuf
;
945 int state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
950 int bucket
= fmt_addcomptext(name
, rbuf
);
953 while (state
== FLDPLUS
) {
955 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
956 fmt_appendcomp(bucket
, name
, rbuf
);
960 while (state
== FLDPLUS
) {
962 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
967 parsing_header
= false;
969 } while (parsing_header
);
970 m_getfld_state_destroy(&gstate
);
972 fmt_scan(fmt
, buffer
, INT_MAX
, dat
, NULL
);
975 /* Trim trailing newline, if any. */
976 retval
= rtrim(charstring_buffer_copy((buffer
)));
977 charstring_free(buffer
);
987 * Look in profile for entry corresponding to addr or host, and add its contents to vec.
989 * Could do some of this automatically, by looking for:
990 * 1) access-$(mbox{from}) in oauth-svc file using mh_oauth_cred_load(), which isn't
991 * static and doesn't have side effects; free the result with mh_oauth_cred_free())
992 * 2) machine $(mbox{from}) in creds
993 * If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
994 * but that might not generalize for other svcs.
997 merge_profile_entry(const char *addr
, const char *host
, char *vec
[], int *vecp
)
999 char *addr_entry
= concat("sendfrom-", addr
, NULL
);
1000 char *profile_entry
= context_find(addr_entry
);
1003 if (profile_entry
== NULL
) {
1004 /* No entry for the user. Look for one for the host. */
1005 char *host_entry
= concat("sendfrom-", host
, NULL
);
1007 profile_entry
= context_find(host_entry
);
1011 /* Use argsplit() to do the real work of splitting the args in the profile entry. */
1012 if (profile_entry
&& *profile_entry
) {
1015 char **profile_vec
= argsplit(profile_entry
, &file
, &profile_vecp
);
1018 for (i
= 0; i
< profile_vecp
; ++i
) {
1019 vec
[(*vecp
)++] = getcpy(profile_vec
[i
]);
1022 arglist_free(file
, profile_vec
);
1027 static void NORETURN
1028 armed_done (int status
)
1030 longjmp (env
, status
? status
: NOTOK
);