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.
12 #include "sbr/m_name.h"
13 #include "sbr/m_getfld.h"
14 #include "sbr/concat.h"
15 #include "sbr/cpydgst.h"
16 #include "sbr/trimcpy.h"
18 #include "sbr/getcpy.h"
19 #include "sbr/m_convert.h"
20 #include "sbr/m_backup.h"
21 #include "sbr/folder_read.h"
22 #include "sbr/folder_free.h"
23 #include "sbr/context_find.h"
24 #include "sbr/brkstring.h"
25 #include "sbr/pidstatus.h"
26 #include "sbr/arglist.h"
27 #include "sbr/error.h"
28 #include "h/fmt_scan.h"
29 #include "h/fmt_compile.h"
30 #include "h/signals.h"
38 #ifdef HAVE_SYS_TIME_H
39 # include <sys/time.h>
47 #include "sbr/m_maildir.h"
48 #include "sbr/m_mktemp.h"
49 #include "sbr/message_id.h"
52 static int setup_oauth_params(char *[], int *, const char *, const char **);
53 #endif /* OAUTH_SUPPORT */
55 int debugsw
= 0; /* global */
63 char *altmsg
= NULL
; /* .. */
64 char *annotext
= NULL
;
65 char *distfile
= NULL
;
72 static void alert (char *, int);
73 static int tmp_fd (void);
74 static void anno (int, struct stat
*);
75 static void annoaux (int);
76 static int splitmsg (char **, int, char *, char *, struct stat
*, int);
77 static int sendaux (char **, int, char *, char *, struct stat
*);
78 static void handle_sendfrom(char **, int *, char *, const char *);
79 static int get_from_header_info(const char *, const char **, const char **, const char **);
80 static const char *get_message_header_info(FILE *, char *);
81 static void merge_profile_entry(const char *, const char *, char *[], int *);
82 static void armed_done (int) NORETURN
;
85 * Entry point into (back-end) routines to send message.
89 sendsbr (char **vec
, int vecp
, char *program
, char *draft
, struct stat
*st
,
90 int rename_drft
, const char *auth_svc
)
94 char buffer
[BUFSIZ
], file
[BUFSIZ
];
96 char **buildvec
, *buildprogram
;
97 char *volatile drft
= draft
;
98 /* nvecs is volatile to prevent warning from gcc about possible clobbering
100 volatile int nvecs
= vecp
;
101 int *nvecsp
= (int *) &nvecs
;
104 * Run the mimebuildproc (which is by default mhbuild) on the message
105 * with the addition of the "-auto" flag
108 switch (child
= fork()) {
110 adios("fork", "unable to");
114 buildvec
= argsplit(buildmimeproc
, &buildprogram
, &i
);
115 buildvec
[i
++] = "-auto";
117 buildvec
[i
++] = "-dist";
118 buildvec
[i
++] = (char *) drft
;
120 execvp(buildprogram
, buildvec
);
121 fprintf(stderr
, "unable to exec ");
122 perror(buildmimeproc
);
127 if (pidXwait(child
, buildmimeproc
))
132 set_done(armed_done
);
133 switch (setjmp (env
)) {
136 * If given -push and -unique (which is undocumented), then
137 * rename the draft file. I'm not quite sure why.
139 if (pushsw
&& unique
) {
140 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, NULL
);
142 die("unable to create temporary file");
144 if (rename (drft
, strncpy(file
, cp
, sizeof(file
))) == NOTOK
)
145 adios (file
, "unable to rename %s to", drft
);
150 * Add in any necessary profile entries for xoauth
156 if (setup_oauth_params(vec
, nvecsp
, auth_svc
, &errmsg
) != OK
) {
160 die("send built without OAUTH_SUPPORT, "
161 "so auth_svc %s is not supported", auth_svc
);
162 #endif /* OAUTH_SUPPORT */
166 * Rework the vec based on From: header in draft, as specified
167 * by sendfrom-address entries in profile.
169 if (context_find_prefix("sendfrom-")) {
170 handle_sendfrom(vec
, nvecsp
, draft
, auth_svc
);
174 * Check if we need to split the message into
175 * multiple messages of type "message/partial".
177 if (splitsw
>= 0 && !distfile
&& stat ((char *) drft
, &sts
) != NOTOK
178 && sts
.st_size
>= CPERMSG
) {
179 status
= splitmsg (vec
, nvecs
, program
, drft
,
180 st
, splitsw
) ? NOTOK
: OK
;
182 status
= sendaux (vec
, nvecs
, program
, drft
, st
) ? NOTOK
: OK
;
185 /* rename the original draft */
186 if (rename_drft
&& status
== OK
&&
187 rename (drft
, strncpy (buffer
, m_backup (drft
),
188 sizeof(buffer
))) == NOTOK
)
189 advise (buffer
, "unable to rename %s to", drft
);
199 (void) m_unlink (distfile
);
205 * Split large message into several messages of
206 * type "message/partial" and send them.
210 splitmsg (char **vec
, int vecp
, char *program
, char *drft
,
211 struct stat
*st
, int delay
)
213 int compnum
, nparts
, partno
, state
, status
;
216 char *cp
, *dp
, buffer
[NMH_BUFSIZ
], msgid
[BUFSIZ
];
217 char subject
[BUFSIZ
];
218 char name
[NAMESZ
], partnum
[BUFSIZ
];
220 m_getfld_state_t gstate
;
222 if ((in
= fopen (drft
, "r")) == NULL
)
223 adios (drft
, "unable to open for reading");
229 * Scan through the message and examine the various header fields,
230 * as well as locate the beginning of the message body.
232 gstate
= m_getfld_state_init(in
);
233 m_getfld_track_filepos2(&gstate
);
234 for (compnum
= 1;;) {
235 int bufsz
= sizeof buffer
;
236 switch (state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
)) {
242 * This header field is discarded.
244 if (!strcasecmp (name
, "Message-ID")) {
245 while (state
== FLDPLUS
) {
246 bufsz
= sizeof buffer
;
247 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
249 } else if (uprf (name
, XXX_FIELD_PRF
)
250 || !strcasecmp (name
, VRSN_FIELD
)
251 || !strcasecmp (name
, "Subject")
252 || !strcasecmp (name
, "Encrypted")) {
254 * These header fields are copied to the enclosed
255 * header of the first message in the collection
256 * of message/partials. For the "Subject" header
257 * field, we also record it, so that a modified
258 * version of it, can be copied to the header
259 * of each message/partial in the collection.
261 if (!strcasecmp (name
, "Subject")) {
264 strncpy (subject
, buffer
, BUFSIZ
);
265 sublen
= strlen (subject
);
266 if (sublen
> 0 && subject
[sublen
- 1] == '\n')
267 subject
[sublen
- 1] = '\0';
270 dp
= add (concat (name
, ":", buffer
, NULL
), dp
);
271 while (state
== FLDPLUS
) {
272 bufsz
= sizeof buffer
;
273 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
274 dp
= add (buffer
, dp
);
278 * These header fields are copied to the header of
279 * each message/partial in the collection.
281 cp
= add (concat (name
, ":", buffer
, NULL
), cp
);
282 while (state
== FLDPLUS
) {
283 bufsz
= sizeof buffer
;
284 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
285 cp
= add (buffer
, cp
);
289 start
= ftell (in
) + 1;
298 die("message format error in component #%d", compnum
);
301 die("getfld () returned %d", state
);
306 m_getfld_state_destroy (&gstate
);
308 die("headers missing from draft");
312 while (fgets (buffer
, sizeof buffer
, in
)) {
315 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
321 /* Only one part, nothing to split */
327 return sendaux (vec
, vecp
, program
, drft
, st
);
331 printf ("Sending as %d Partial Messages\n", nparts
);
336 vec
[vecp
++] = "-partno";
337 vec
[vecp
++] = partnum
;
339 vec
[vecp
++] = "-queued";
342 snprintf (msgid
, sizeof(msgid
), "%s", message_id (clock
, 0));
344 fseek (in
, start
, SEEK_SET
);
345 for (partno
= 1; partno
<= nparts
; partno
++) {
349 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, &out
);
351 die("unable to create temporary file");
353 strncpy(tmpdrf
, cp
, sizeof(tmpdrf
));
356 * Output the header fields
359 fprintf (out
, "Subject: %s (part %d of %d)\n", subject
, partno
, nparts
);
360 fprintf (out
, "%s: %s\n", VRSN_FIELD
, VRSN_VALUE
);
361 fprintf (out
, "%s: message/partial; id=\"%s\";\n", TYPE_FIELD
, msgid
);
362 fprintf (out
, "\tnumber=%d; total=%d\n", partno
, nparts
);
363 fprintf (out
, "%s: part %d of %d\n\n", DESCR_FIELD
, partno
, nparts
);
366 * If this is the first in the collection, output the
367 * header fields we are encapsulating at the beginning
368 * of the body of the first message.
373 fprintf (out
, "Message-ID: %s\n", msgid
);
381 if (!fgets (buffer
, sizeof buffer
, in
)) {
382 if (partno
== nparts
)
384 die("premature eof");
387 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
388 fseek (in
, -len
, SEEK_CUR
);
396 adios (tmpdrf
, "error writing to");
400 if (!pushsw
&& verbsw
) {
405 /* Pause here, if a delay is specified */
406 if (delay
> 0 && 1 < partno
&& partno
<= nparts
) {
408 printf ("pausing %d seconds before sending part %d...\n",
412 sleep ((unsigned int) delay
);
415 snprintf (partnum
, sizeof(partnum
), "%d", partno
);
416 status
= sendaux (vec
, vecp
, program
, tmpdrf
, st
);
417 (void) m_unlink (tmpdrf
);
422 * This is so sendaux will only annotate
423 * the altmsg the first time it is called.
431 fclose (in
); /* close the draft */
437 * Annotate original message, and
438 * call `postproc' (which is passed down in "program") to send message.
442 sendaux (char **vec
, int vecp
, char *program
, char *drft
, struct stat
*st
)
446 char backup
[BUFSIZ
], buf
[BUFSIZ
];
448 fd
= pushsw
? tmp_fd () : NOTOK
;
452 if ((fd2
= tmp_fd ()) != NOTOK
) {
453 vec
[vecp
++] = "-idanno";
454 snprintf (buf
, sizeof(buf
), "%d", fd2
);
457 inform("unable to create temporary file in %s for "
458 "annotation list, continuing...", get_temp_dir());
462 if (distfile
&& distout (drft
, distfile
, backup
) == NOTOK
)
469 /* oops -- fork error */
470 adios ("fork", "unable to");
471 break; /* NOT REACHED */
475 * child process -- send it
477 * If fd is OK, then we are pushing and fd points to temp
478 * file, so capture anything on stdout and stderr there.
481 dup2 (fd
, fileno (stdout
));
482 dup2 (fd
, fileno (stderr
));
485 execvp (program
, vec
);
486 fprintf (stderr
, "unable to exec ");
492 * parent process -- wait for it
494 if ((status
= pidwait(child_id
, NOTOK
)) == OK
) {
495 if (annotext
&& fd2
!= NOTOK
)
499 * If postproc failed, and we have good fd (which means
500 * we pushed), then mail error message (and possibly the
501 * draft) back to the user.
507 inform("message not delivered to anyone");
509 if (annotext
&& fd2
!= NOTOK
)
512 (void) m_unlink (drft
);
513 if (rename (backup
, drft
) == NOTOK
)
514 advise (drft
, "unable to rename %s to", backup
);
525 * Mail error notification (and possibly a copy of the
526 * message) back to the user, using the mailproc
530 alert (char *file
, int out
)
541 /* oops -- fork error */
542 advise ("fork", "unable to");
546 /* child process -- send it */
547 SIGNAL (SIGHUP
, SIG_IGN
);
548 SIGNAL (SIGINT
, SIG_IGN
);
549 SIGNAL (SIGQUIT
, SIG_IGN
);
550 SIGNAL (SIGTERM
, SIG_IGN
);
552 if ((in
= open (file
, O_RDONLY
)) == NOTOK
) {
553 admonish (file
, "unable to re-open");
555 lseek(out
, 0, SEEK_END
);
556 strncpy (buf
, "\nMessage not delivered to anyone.\n", sizeof(buf
));
557 if (write (out
, buf
, strlen (buf
)) < 0) {
558 advise (file
, "write");
560 strncpy (buf
, "\n------- Unsent Draft\n\n", sizeof(buf
));
561 if (write (out
, buf
, strlen (buf
)) < 0) {
562 advise (file
, "write");
564 cpydgst (in
, out
, file
, "temporary file");
566 strncpy (buf
, "\n------- End of Unsent Draft\n", sizeof(buf
));
567 if (write (out
, buf
, strlen (buf
)) < 0) {
568 advise (file
, "write");
570 if (rename (file
, strncpy (buf
, m_backup (file
), sizeof(buf
))) == NOTOK
)
571 admonish (buf
, "unable to rename %s to", file
);
574 lseek(out
, 0, SEEK_SET
);
575 dup2 (out
, fileno (stdin
));
577 /* create subject for error notification */
578 snprintf (buf
, sizeof(buf
), "send failed on %s",
579 forwsw
? "enclosed draft" : file
);
581 arglist
= argsplit(mailproc
, &program
, &argp
);
583 arglist
[argp
++] = getusername();
584 arglist
[argp
++] = "-subject";
585 arglist
[argp
++] = buf
;
586 arglist
[argp
] = NULL
;
588 execvp (program
, arglist
);
589 fprintf (stderr
, "unable to exec ");
593 default: /* no waiting... */
605 if ((tfile
= m_mktemp2(NULL
, invo_name
, &fd
, NULL
)) == NULL
) return NOTOK
;
608 inform("temporary file %s selected", tfile
);
609 else if (m_unlink (tfile
) == NOTOK
)
610 advise (tfile
, "unable to remove");
617 anno (int fd
, struct stat
*st
)
621 static char *cwd
= NULL
;
625 (stat (altmsg
, &st2
) == NOTOK
626 || st
->st_mtime
!= st2
.st_mtime
627 || st
->st_dev
!= st2
.st_dev
628 || st
->st_ino
!= st2
.st_ino
)) {
630 inform("$mhaltmsg mismatch, continuing...");
634 child_id
= debugsw
? NOTOK
: fork ();
636 case NOTOK
: /* oops */
638 inform("unable to fork, so doing annotations by hand...");
640 cwd
= mh_xstrdup(pwd ());
644 /* block a few signals */
646 sigaddset (&set
, SIGHUP
);
647 sigaddset (&set
, SIGINT
);
648 sigaddset (&set
, SIGQUIT
);
649 sigaddset (&set
, SIGTERM
);
650 sigprocmask (SIG_BLOCK
, &set
, &oset
);
652 unregister_for_removal(0);
658 /* reset the signal mask */
659 sigprocmask (SIG_SETMASK
, &oset
, &set
);
661 if (chdir (cwd
) < 0) {
662 advise (cwd
, "chdir");
666 default: /* no waiting... */
676 int fd2
, fd3
, msgnum
;
677 char *cp
, *folder
, *maildir
;
678 char buffer
[BUFSIZ
], **ap
;
682 if ((folder
= getenv ("mhfolder")) == NULL
|| *folder
== 0) {
684 inform("$mhfolder not set, continuing...");
687 maildir
= m_maildir (folder
);
688 if (chdir (maildir
) == NOTOK
) {
690 admonish (maildir
, "unable to change directory to");
693 if (!(mp
= folder_read (folder
, 0))) {
695 inform("unable to read folder %s, continuing...", folder
);
699 /* check for empty folder */
700 if (mp
->nummsg
== 0) {
702 inform("no messages in %s, continuing...", folder
);
706 if ((cp
= getenv ("mhmessages")) == NULL
|| *cp
== 0) {
708 inform("$mhmessages not set, continuing...");
711 if (!debugsw
/* MOBY HACK... */
713 && (fd3
= open ("/dev/null", O_RDWR
)) != NOTOK
714 && (fd2
= dup (fileno (stderr
))) != NOTOK
) {
715 dup2 (fd3
, fileno (stderr
));
720 for (ap
= brkstring (cp
= mh_xstrdup(cp
), " ", NULL
); *ap
; ap
++)
724 dup2 (fd2
, fileno (stderr
));
725 if (mp
->numsel
== 0) {
727 inform("no messages to annotate, continuing...");
731 lseek(fd
, 0, SEEK_SET
);
732 if ((fp
= fdopen (fd
, "r")) == NULL
) {
734 inform("unable to fdopen annotation list, continuing...");
738 while (fgets (buffer
, sizeof(buffer
), fp
) != NULL
)
739 cp
= add (buffer
, cp
);
743 inform("annotate%s with %s: \"%s\"",
744 inplace
? " inplace" : "", annotext
, cp
);
745 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++) {
746 if (is_selected(mp
, msgnum
)) {
748 inform("annotate message %d", msgnum
);
749 annotate (m_name (msgnum
), annotext
, cp
, inplace
, 1, -2, 0);
756 folder_free (mp
); /* free folder/message structure */
761 handle_sendfrom(char **vec
, int *vecp
, char *draft
, const char *auth_svc
)
763 const char *addr
, *host
;
766 /* Extract address and host from From: header line in draft. */
767 if (get_from_header_info(draft
, &addr
, &host
, &message
) != OK
) {
768 adios(draft
, "%s", message
);
771 /* Merge in any address or host specific switches to post(1) from profile. */
772 merge_profile_entry(addr
, host
, vec
, vecp
);
781 for (vp
= vec
; *vp
; ++vp
) {
782 if (strcmp(*vp
, "xoauth2") == 0) {
784 if (setup_oauth_params(vec
, vecp
, auth_svc
, &message
) != OK
) {
789 NMH_UNUSED(auth_svc
);
790 die("send built without OAUTH_SUPPORT, "
791 "so -saslmech xoauth2 is not supported");
792 #endif /* OAUTH_SUPPORT */
801 * For XOAUTH2, append profile entries so post can do the heavy lifting
804 setup_oauth_params(char *vec
[], int *vecp
, const char *auth_svc
,
805 const char **message
)
807 const char *saslmech
= NULL
, *user
= NULL
;
808 mh_oauth_service_info svc
;
812 /* Make sure we have all the information we need. */
813 for (i
= 1; i
< *vecp
; ++i
) {
814 /* Don't support abbreviated switches, to avoid collisions in the
815 future if new ones are added. */
816 if (! strcmp(vec
[i
-1], "-saslmech")) {
818 } else if (! strcmp(vec
[i
-1], "-user")) {
820 } else if (! strcmp(vec
[i
-1], "-authservice")) {
825 if (auth_svc
== NULL
) {
826 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
827 *message
= "must specify -authservice with -saslmech xoauth2";
832 *message
= "must specify -user with -saslmech xoauth2";
836 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
837 if (! mh_oauth_get_service_info(auth_svc
, &svc
, errbuf
,
839 die("Unable to retrieve oauth profile entries: %s",
842 vec
[(*vecp
)++] = mh_xstrdup("-authservice");
843 vec
[(*vecp
)++] = mh_xstrdup(auth_svc
);
844 vec
[(*vecp
)++] = mh_xstrdup("-oauthcredfile");
845 vec
[(*vecp
)++] = mh_oauth_cred_fn(auth_svc
);
846 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientid");
847 vec
[(*vecp
)++] = getcpy(svc
.client_id
);
848 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientsecret");
849 vec
[(*vecp
)++] = getcpy(svc
.client_secret
);
850 vec
[(*vecp
)++] = mh_xstrdup("-oauthauthendpoint");
851 vec
[(*vecp
)++] = getcpy(svc
.auth_endpoint
);
852 vec
[(*vecp
)++] = mh_xstrdup("-oauthredirect");
853 vec
[(*vecp
)++] = getcpy(svc
.redirect_uri
);
854 vec
[(*vecp
)++] = mh_xstrdup("-oauthtokenendpoint");
855 vec
[(*vecp
)++] = getcpy(svc
.token_endpoint
);
856 vec
[(*vecp
)++] = mh_xstrdup("-oauthscope");
857 vec
[(*vecp
)++] = getcpy(svc
.scope
);
863 #endif /* OAUTH_SUPPORT */
867 * Extract user and domain from From: header line in draft.
870 get_from_header_info(const char *filename
, const char **addr
, const char **host
, const char **message
)
875 if (stat (filename
, &st
) == NOTOK
) {
876 *message
= "unable to stat draft file";
880 if ((in
= fopen (filename
, "r")) != NULL
) {
881 /* There must be a non-blank Envelope-From or {Resent-}Sender or
882 {Resent-}From header. */
883 char *addrformat
= "%(addr{Envelope-From})";
884 char *hostformat
= "%(host{Envelope-From})";
886 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
||
888 addrformat
= distfile
== NULL
? "%(addr{Sender})" : "%(addr{Resent-Sender})";
889 hostformat
= distfile
== NULL
? "%(host{Sender})" : "%(host{Resent-Sender})";
891 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
892 addrformat
= distfile
== NULL
? "%(addr{From})" : "%(addr{Resent-From})";
893 hostformat
= distfile
== NULL
? "%(host{From})" : "%(host{Resent-From})";
895 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
896 *message
= "unable to find sender address in";
903 /* Use the hostformat that corresponds to the successful addrformat. */
904 if ((*host
= get_message_header_info(in
, hostformat
)) == NULL
) {
905 *message
= "unable to find sender host";
914 *message
= "unable to open";
920 * Get formatted information from header of a message.
921 * Adapted from process_single_file() in uip/fmttest.c.
924 get_message_header_info(FILE *in
, char *format
)
930 m_getfld_state_t gstate
;
931 charstring_t buffer
= charstring_create(0);
934 dat
[0] = dat
[1] = dat
[4] = 0;
935 dat
[2] = fstat(fileno(in
), &st
) == 0 ? st
.st_size
: 0;
938 (void) fmt_compile(new_fs(NULL
, NULL
, format
), &fmt
, 1);
942 * Read in the message and process the header.
945 parsing_header
= true;
946 gstate
= m_getfld_state_init(in
);
948 char name
[NAMESZ
], rbuf
[NMH_BUFSIZ
];
949 int bufsz
= sizeof rbuf
;
950 int state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
955 int bucket
= fmt_addcomptext(name
, rbuf
);
958 while (state
== FLDPLUS
) {
960 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
961 fmt_appendcomp(bucket
, name
, rbuf
);
965 while (state
== FLDPLUS
) {
967 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
972 parsing_header
= false;
974 } while (parsing_header
);
975 m_getfld_state_destroy(&gstate
);
977 fmt_scan(fmt
, buffer
, INT_MAX
, dat
, NULL
);
980 /* Trim trailing newline, if any. */
981 retval
= rtrim(charstring_buffer_copy((buffer
)));
982 charstring_free(buffer
);
992 * Look in profile for entry corresponding to addr or host, and add its contents to vec.
994 * Could do some of this automatically, by looking for:
995 * 1) access-$(mbox{from}) in oauth-svc file using mh_oauth_cred_load(), which isn't
996 * static and doesn't have side effects; free the result with mh_oauth_cred_free())
997 * 2) machine $(mbox{from}) in creds
998 * If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
999 * but that might not generalize for other svcs.
1002 merge_profile_entry(const char *addr
, const char *host
, char *vec
[], int *vecp
)
1004 char *addr_entry
= concat("sendfrom-", addr
, NULL
);
1005 char *profile_entry
= context_find(addr_entry
);
1008 if (profile_entry
== NULL
) {
1009 /* No entry for the user. Look for one for the host. */
1010 char *host_entry
= concat("sendfrom-", host
, NULL
);
1012 profile_entry
= context_find(host_entry
);
1016 /* Use argsplit() to do the real work of splitting the args in the profile entry. */
1017 if (profile_entry
&& *profile_entry
) {
1020 char **profile_vec
= argsplit(profile_entry
, &file
, &profile_vecp
);
1023 for (i
= 0; i
< profile_vecp
; ++i
) {
1024 vec
[(*vecp
)++] = getcpy(profile_vec
[i
]);
1027 arglist_free(file
, profile_vec
);
1032 static void NORETURN
1033 armed_done (int status
)
1035 longjmp (env
, status
? status
: NOTOK
);