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/fmt_new.h"
13 #include "sbr/m_name.h"
14 #include "sbr/m_getfld.h"
15 #include "sbr/concat.h"
16 #include "sbr/cpydgst.h"
17 #include "sbr/trimcpy.h"
19 #include "sbr/getcpy.h"
20 #include "sbr/m_convert.h"
21 #include "sbr/m_backup.h"
22 #include "sbr/folder_read.h"
23 #include "sbr/folder_free.h"
24 #include "sbr/context_find.h"
25 #include "sbr/brkstring.h"
26 #include "sbr/pidstatus.h"
27 #include "sbr/arglist.h"
28 #include "sbr/error.h"
29 #include "h/fmt_scan.h"
30 #include "h/fmt_compile.h"
31 #include "h/signals.h"
39 #ifdef HAVE_SYS_TIME_H
40 # include <sys/time.h>
48 #include "sbr/m_maildir.h"
49 #include "sbr/m_mktemp.h"
50 #include "sbr/message_id.h"
53 static int setup_oauth_params(char *[], int *, const char *, const char **);
54 #endif /* OAUTH_SUPPORT */
56 int debugsw
= 0; /* global */
64 char *altmsg
= NULL
; /* .. */
65 char *annotext
= NULL
;
66 char *distfile
= NULL
;
73 static void alert (char *, int);
74 static int tmp_fd (void);
75 static void anno (int, struct stat
*);
76 static void annoaux (int);
77 static int splitmsg (char **, int, char *, char *, struct stat
*, int);
78 static int sendaux (char **, int, char *, char *, struct stat
*);
79 static void handle_sendfrom(char **, int *, char *, const char *);
80 static int get_from_header_info(const char *, const char **, const char **, const char **);
81 static const char *get_message_header_info(FILE *, char *);
82 static void merge_profile_entry(const char *, const char *, char *[], int *);
83 static void armed_done (int) NORETURN
;
86 * Entry point into (back-end) routines to send message.
90 sendsbr (char **vec
, int vecp
, char *program
, char *draft
, struct stat
*st
,
91 int rename_drft
, const char *auth_svc
)
95 char buffer
[BUFSIZ
], file
[BUFSIZ
];
97 char **buildvec
, *buildprogram
;
98 char *volatile drft
= draft
;
99 /* nvecs is volatile to prevent warning from gcc about possible clobbering
101 volatile int nvecs
= vecp
;
102 int *nvecsp
= (int *) &nvecs
;
105 * Run the mimebuildproc (which is by default mhbuild) on the message
106 * with the addition of the "-auto" flag
109 switch (child
= fork()) {
111 adios("fork", "unable to");
115 buildvec
= argsplit(buildmimeproc
, &buildprogram
, &i
);
116 buildvec
[i
++] = "-auto";
118 buildvec
[i
++] = "-dist";
119 buildvec
[i
++] = (char *) drft
;
121 execvp(buildprogram
, buildvec
);
122 fprintf(stderr
, "unable to exec ");
123 perror(buildmimeproc
);
128 if (pidXwait(child
, buildmimeproc
))
133 set_done(armed_done
);
134 switch (setjmp (env
)) {
137 * If given -push and -unique (which is undocumented), then
138 * rename the draft file. I'm not quite sure why.
140 if (pushsw
&& unique
) {
141 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, NULL
);
143 die("unable to create temporary file");
145 if (rename (drft
, strncpy(file
, cp
, sizeof(file
))) == NOTOK
)
146 adios (file
, "unable to rename %s to", drft
);
151 * Add in any necessary profile entries for xoauth
157 if (setup_oauth_params(vec
, nvecsp
, auth_svc
, &errmsg
) != OK
) {
161 die("send built without OAUTH_SUPPORT, "
162 "so auth_svc %s is not supported", auth_svc
);
163 #endif /* OAUTH_SUPPORT */
167 * Rework the vec based on From: header in draft, as specified
168 * by sendfrom-address entries in profile.
170 if (context_find_prefix("sendfrom-")) {
171 handle_sendfrom(vec
, nvecsp
, draft
, auth_svc
);
175 * Check if we need to split the message into
176 * multiple messages of type "message/partial".
178 if (splitsw
>= 0 && !distfile
&& stat ((char *) drft
, &sts
) != NOTOK
179 && sts
.st_size
>= CPERMSG
) {
180 status
= splitmsg (vec
, nvecs
, program
, drft
,
181 st
, splitsw
) ? NOTOK
: OK
;
183 status
= sendaux (vec
, nvecs
, program
, drft
, st
) ? NOTOK
: OK
;
186 /* rename the original draft */
187 if (rename_drft
&& status
== OK
&&
188 rename (drft
, strncpy (buffer
, m_backup (drft
),
189 sizeof(buffer
))) == NOTOK
)
190 advise (buffer
, "unable to rename %s to", drft
);
200 (void) m_unlink (distfile
);
206 * Split large message into several messages of
207 * type "message/partial" and send them.
211 splitmsg (char **vec
, int vecp
, char *program
, char *drft
,
212 struct stat
*st
, int delay
)
214 int compnum
, nparts
, partno
, state
, status
;
217 char *cp
, *dp
, buffer
[NMH_BUFSIZ
], msgid
[BUFSIZ
];
218 char subject
[BUFSIZ
];
219 char name
[NAMESZ
], partnum
[BUFSIZ
];
221 m_getfld_state_t gstate
;
223 if ((in
= fopen (drft
, "r")) == NULL
)
224 adios (drft
, "unable to open for reading");
230 * Scan through the message and examine the various header fields,
231 * as well as locate the beginning of the message body.
233 gstate
= m_getfld_state_init(in
);
234 m_getfld_track_filepos2(&gstate
);
235 for (compnum
= 1;;) {
236 int bufsz
= sizeof buffer
;
237 switch (state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
)) {
243 * This header field is discarded.
245 if (!strcasecmp (name
, "Message-ID")) {
246 while (state
== FLDPLUS
) {
247 bufsz
= sizeof buffer
;
248 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
250 } else if (uprf (name
, XXX_FIELD_PRF
)
251 || !strcasecmp (name
, VRSN_FIELD
)
252 || !strcasecmp (name
, "Subject")
253 || !strcasecmp (name
, "Encrypted")) {
255 * These header fields are copied to the enclosed
256 * header of the first message in the collection
257 * of message/partials. For the "Subject" header
258 * field, we also record it, so that a modified
259 * version of it, can be copied to the header
260 * of each message/partial in the collection.
262 if (!strcasecmp (name
, "Subject")) {
263 strncpy (subject
, buffer
, BUFSIZ
);
264 trim_suffix_c(subject
, '\n');
267 dp
= add (concat (name
, ":", buffer
, NULL
), dp
);
268 while (state
== FLDPLUS
) {
269 bufsz
= sizeof buffer
;
270 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
271 dp
= add (buffer
, dp
);
275 * These header fields are copied to the header of
276 * each message/partial in the collection.
278 cp
= add (concat (name
, ":", buffer
, NULL
), cp
);
279 while (state
== FLDPLUS
) {
280 bufsz
= sizeof buffer
;
281 state
= m_getfld2(&gstate
, name
, buffer
, &bufsz
);
282 cp
= add (buffer
, cp
);
286 start
= ftell (in
) + 1;
295 die("message format error in component #%d", compnum
);
298 die("getfld () returned %d", state
);
303 m_getfld_state_destroy (&gstate
);
305 die("headers missing from draft");
309 while (fgets (buffer
, sizeof buffer
, in
)) {
312 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
318 /* Only one part, nothing to split */
324 return sendaux (vec
, vecp
, program
, drft
, st
);
328 printf ("Sending as %d Partial Messages\n", nparts
);
333 vec
[vecp
++] = "-partno";
334 vec
[vecp
++] = partnum
;
336 vec
[vecp
++] = "-queued";
339 snprintf (msgid
, sizeof(msgid
), "%s", message_id (clock
, 0));
341 fseek (in
, start
, SEEK_SET
);
342 for (partno
= 1; partno
<= nparts
; partno
++) {
346 char *cp
= m_mktemp2(drft
, invo_name
, NULL
, &out
);
348 die("unable to create temporary file");
350 strncpy(tmpdrf
, cp
, sizeof(tmpdrf
));
353 * Output the header fields
356 fprintf (out
, "Subject: %s (part %d of %d)\n", subject
, partno
, nparts
);
357 fprintf (out
, "%s: %s\n", VRSN_FIELD
, VRSN_VALUE
);
358 fprintf (out
, "%s: message/partial; id=\"%s\";\n", TYPE_FIELD
, msgid
);
359 fprintf (out
, "\tnumber=%d; total=%d\n", partno
, nparts
);
360 fprintf (out
, "%s: part %d of %d\n\n", DESCR_FIELD
, partno
, nparts
);
363 * If this is the first in the collection, output the
364 * header fields we are encapsulating at the beginning
365 * of the body of the first message.
370 fprintf (out
, "Message-ID: %s\n", msgid
);
378 if (!fgets (buffer
, sizeof buffer
, in
)) {
379 if (partno
== nparts
)
381 die("premature eof");
384 if ((pos
+= (len
= strlen (buffer
))) > CPERMSG
) {
385 fseek (in
, -len
, SEEK_CUR
);
393 adios (tmpdrf
, "error writing to");
397 if (!pushsw
&& verbsw
) {
402 /* Pause here, if a delay is specified */
403 if (delay
> 0 && 1 < partno
&& partno
<= nparts
) {
405 printf ("pausing %d seconds before sending part %d...\n",
409 sleep ((unsigned int) delay
);
412 snprintf (partnum
, sizeof(partnum
), "%d", partno
);
413 status
= sendaux (vec
, vecp
, program
, tmpdrf
, st
);
414 (void) m_unlink (tmpdrf
);
419 * This is so sendaux will only annotate
420 * the altmsg the first time it is called.
428 fclose (in
); /* close the draft */
434 * Annotate original message, and
435 * call `postproc' (which is passed down in "program") to send message.
439 sendaux (char **vec
, int vecp
, char *program
, char *drft
, struct stat
*st
)
443 char backup
[BUFSIZ
], buf
[BUFSIZ
];
445 fd
= pushsw
? tmp_fd () : NOTOK
;
449 if ((fd2
= tmp_fd ()) != NOTOK
) {
450 vec
[vecp
++] = "-idanno";
451 snprintf (buf
, sizeof(buf
), "%d", fd2
);
454 inform("unable to create temporary file in %s for "
455 "annotation list, continuing...", get_temp_dir());
459 if (distfile
&& distout (drft
, distfile
, backup
) == NOTOK
)
466 /* oops -- fork error */
467 adios ("fork", "unable to");
468 break; /* NOT REACHED */
472 * child process -- send it
474 * If fd is OK, then we are pushing and fd points to temp
475 * file, so capture anything on stdout and stderr there.
478 dup2 (fd
, fileno (stdout
));
479 dup2 (fd
, fileno (stderr
));
482 execvp (program
, vec
);
483 fprintf (stderr
, "unable to exec ");
489 * parent process -- wait for it
491 if ((status
= pidwait(child_id
, NOTOK
)) == OK
) {
492 if (annotext
&& fd2
!= NOTOK
)
496 * If postproc failed, and we have good fd (which means
497 * we pushed), then mail error message (and possibly the
498 * draft) back to the user.
504 inform("message not delivered to anyone");
506 if (annotext
&& fd2
!= NOTOK
)
509 (void) m_unlink (drft
);
510 if (rename (backup
, drft
) == NOTOK
)
511 advise (drft
, "unable to rename %s to", backup
);
522 * Mail error notification (and possibly a copy of the
523 * message) back to the user, using the mailproc
527 alert (char *file
, int out
)
538 /* oops -- fork error */
539 advise ("fork", "unable to");
543 /* child process -- send it */
544 SIGNAL (SIGHUP
, SIG_IGN
);
545 SIGNAL (SIGINT
, SIG_IGN
);
546 SIGNAL (SIGQUIT
, SIG_IGN
);
547 SIGNAL (SIGTERM
, SIG_IGN
);
549 if ((in
= open (file
, O_RDONLY
)) == NOTOK
) {
550 admonish (file
, "unable to re-open");
552 lseek(out
, 0, SEEK_END
);
553 strncpy (buf
, "\nMessage not delivered to anyone.\n", sizeof(buf
));
554 if (write (out
, buf
, strlen (buf
)) < 0) {
555 advise (file
, "write");
557 strncpy (buf
, "\n------- Unsent Draft\n\n", sizeof(buf
));
558 if (write (out
, buf
, strlen (buf
)) < 0) {
559 advise (file
, "write");
561 cpydgst (in
, out
, file
, "temporary file");
563 strncpy (buf
, "\n------- End of Unsent Draft\n", sizeof(buf
));
564 if (write (out
, buf
, strlen (buf
)) < 0) {
565 advise (file
, "write");
567 if (rename (file
, strncpy (buf
, m_backup (file
), sizeof(buf
))) == NOTOK
)
568 admonish (buf
, "unable to rename %s to", file
);
571 lseek(out
, 0, SEEK_SET
);
572 dup2 (out
, fileno (stdin
));
574 /* create subject for error notification */
575 snprintf (buf
, sizeof(buf
), "send failed on %s",
576 forwsw
? "enclosed draft" : file
);
578 arglist
= argsplit(mailproc
, &program
, &argp
);
580 arglist
[argp
++] = getusername();
581 arglist
[argp
++] = "-subject";
582 arglist
[argp
++] = buf
;
583 arglist
[argp
] = NULL
;
585 execvp (program
, arglist
);
586 fprintf (stderr
, "unable to exec ");
590 default: /* no waiting... */
602 if ((tfile
= m_mktemp2(NULL
, invo_name
, &fd
, NULL
)) == NULL
) return NOTOK
;
605 inform("temporary file %s selected", tfile
);
606 else if (m_unlink (tfile
) == NOTOK
)
607 advise (tfile
, "unable to remove");
614 anno (int fd
, struct stat
*st
)
618 static char *cwd
= NULL
;
622 (stat (altmsg
, &st2
) == NOTOK
623 || st
->st_mtime
!= st2
.st_mtime
624 || st
->st_dev
!= st2
.st_dev
625 || st
->st_ino
!= st2
.st_ino
)) {
627 inform("$mhaltmsg mismatch, continuing...");
631 child_id
= debugsw
? NOTOK
: fork ();
633 case NOTOK
: /* oops */
635 inform("unable to fork, so doing annotations by hand...");
637 cwd
= mh_xstrdup(pwd ());
641 /* block a few signals */
643 sigaddset (&set
, SIGHUP
);
644 sigaddset (&set
, SIGINT
);
645 sigaddset (&set
, SIGQUIT
);
646 sigaddset (&set
, SIGTERM
);
647 sigprocmask (SIG_BLOCK
, &set
, &oset
);
649 unregister_for_removal(0);
655 /* reset the signal mask */
656 sigprocmask (SIG_SETMASK
, &oset
, &set
);
658 if (chdir (cwd
) < 0) {
659 advise (cwd
, "chdir");
663 default: /* no waiting... */
673 int fd2
, fd3
, msgnum
;
674 char *cp
, *folder
, *maildir
;
675 char buffer
[BUFSIZ
], **ap
;
679 if ((folder
= getenv ("mhfolder")) == NULL
|| *folder
== 0) {
681 inform("$mhfolder not set, continuing...");
684 maildir
= m_maildir (folder
);
685 if (chdir (maildir
) == NOTOK
) {
687 admonish (maildir
, "unable to change directory to");
690 if (!(mp
= folder_read (folder
, 0))) {
692 inform("unable to read folder %s, continuing...", folder
);
696 /* check for empty folder */
697 if (mp
->nummsg
== 0) {
699 inform("no messages in %s, continuing...", folder
);
703 if ((cp
= getenv ("mhmessages")) == NULL
|| *cp
== 0) {
705 inform("$mhmessages not set, continuing...");
708 if (!debugsw
/* MOBY HACK... */
710 && (fd3
= open ("/dev/null", O_RDWR
)) != NOTOK
711 && (fd2
= dup (fileno (stderr
))) != NOTOK
) {
712 dup2 (fd3
, fileno (stderr
));
717 for (ap
= brkstring (cp
= mh_xstrdup(cp
), " ", NULL
); *ap
; ap
++)
721 dup2 (fd2
, fileno (stderr
));
722 if (mp
->numsel
== 0) {
724 inform("no messages to annotate, continuing...");
728 lseek(fd
, 0, SEEK_SET
);
729 if ((fp
= fdopen (fd
, "r")) == NULL
) {
731 inform("unable to fdopen annotation list, continuing...");
735 while (fgets (buffer
, sizeof(buffer
), fp
) != NULL
)
736 cp
= add (buffer
, cp
);
740 inform("annotate%s with %s: \"%s\"",
741 inplace
? " inplace" : "", annotext
, cp
);
742 for (msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++) {
743 if (is_selected(mp
, msgnum
)) {
745 inform("annotate message %d", msgnum
);
746 annotate (m_name (msgnum
), annotext
, cp
, inplace
, 1, -2, 0);
753 folder_free (mp
); /* free folder/message structure */
758 handle_sendfrom(char **vec
, int *vecp
, char *draft
, const char *auth_svc
)
760 const char *addr
, *host
;
763 /* Extract address and host from From: header line in draft. */
764 if (get_from_header_info(draft
, &addr
, &host
, &message
) != OK
) {
765 adios(draft
, "%s", message
);
768 /* Merge in any address or host specific switches to post(1) from profile. */
769 merge_profile_entry(addr
, host
, vec
, vecp
);
778 for (vp
= vec
; *vp
; ++vp
) {
779 if (strcmp(*vp
, "xoauth2") == 0) {
781 if (setup_oauth_params(vec
, vecp
, auth_svc
, &message
) != OK
) {
786 NMH_UNUSED(auth_svc
);
787 die("send built without OAUTH_SUPPORT, "
788 "so -saslmech xoauth2 is not supported");
789 #endif /* OAUTH_SUPPORT */
798 * For XOAUTH2, append profile entries so post can do the heavy lifting
801 setup_oauth_params(char *vec
[], int *vecp
, const char *auth_svc
,
802 const char **message
)
804 const char *saslmech
= NULL
, *user
= NULL
;
805 mh_oauth_service_info svc
;
809 /* Make sure we have all the information we need. */
810 for (i
= 1; i
< *vecp
; ++i
) {
811 /* Don't support abbreviated switches, to avoid collisions in the
812 future if new ones are added. */
813 if (! strcmp(vec
[i
-1], "-saslmech")) {
815 } else if (! strcmp(vec
[i
-1], "-user")) {
817 } else if (! strcmp(vec
[i
-1], "-authservice")) {
822 if (auth_svc
== NULL
) {
823 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
824 *message
= "must specify -authservice with -saslmech xoauth2";
829 *message
= "must specify -user with -saslmech xoauth2";
833 if (saslmech
&& ! strcasecmp(saslmech
, "xoauth2")) {
834 if (! mh_oauth_get_service_info(auth_svc
, &svc
, errbuf
,
836 die("Unable to retrieve oauth profile entries: %s",
839 vec
[(*vecp
)++] = mh_xstrdup("-authservice");
840 vec
[(*vecp
)++] = mh_xstrdup(auth_svc
);
841 vec
[(*vecp
)++] = mh_xstrdup("-oauthcredfile");
842 vec
[(*vecp
)++] = mh_oauth_cred_fn(auth_svc
);
843 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientid");
844 vec
[(*vecp
)++] = getcpy(svc
.client_id
);
845 vec
[(*vecp
)++] = mh_xstrdup("-oauthclientsecret");
846 vec
[(*vecp
)++] = getcpy(svc
.client_secret
);
847 vec
[(*vecp
)++] = mh_xstrdup("-oauthauthendpoint");
848 vec
[(*vecp
)++] = getcpy(svc
.auth_endpoint
);
849 vec
[(*vecp
)++] = mh_xstrdup("-oauthredirect");
850 vec
[(*vecp
)++] = getcpy(svc
.redirect_uri
);
851 vec
[(*vecp
)++] = mh_xstrdup("-oauthtokenendpoint");
852 vec
[(*vecp
)++] = getcpy(svc
.token_endpoint
);
853 vec
[(*vecp
)++] = mh_xstrdup("-oauthscope");
854 vec
[(*vecp
)++] = getcpy(svc
.scope
);
860 #endif /* OAUTH_SUPPORT */
864 * Extract user and domain from From: header line in draft.
867 get_from_header_info(const char *filename
, const char **addr
, const char **host
, const char **message
)
872 if (stat (filename
, &st
) == NOTOK
) {
873 *message
= "unable to stat draft file";
877 if ((in
= fopen (filename
, "r")) != NULL
) {
878 /* There must be a non-blank Envelope-From or {Resent-}Sender or
879 {Resent-}From header. */
880 char *addrformat
= "%(addr{Envelope-From})";
881 char *hostformat
= "%(host{Envelope-From})";
883 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
||
885 addrformat
= distfile
== NULL
? "%(addr{Sender})" : "%(addr{Resent-Sender})";
886 hostformat
= distfile
== NULL
? "%(host{Sender})" : "%(host{Resent-Sender})";
888 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
889 addrformat
= distfile
== NULL
? "%(addr{From})" : "%(addr{Resent-From})";
890 hostformat
= distfile
== NULL
? "%(host{From})" : "%(host{Resent-From})";
892 if ((*addr
= get_message_header_info (in
, addrformat
)) == NULL
) {
893 *message
= "unable to find sender address in";
900 /* Use the hostformat that corresponds to the successful addrformat. */
901 if ((*host
= get_message_header_info(in
, hostformat
)) == NULL
) {
902 *message
= "unable to find sender host";
911 *message
= "unable to open";
917 * Get formatted information from header of a message.
918 * Adapted from process_single_file() in uip/fmttest.c.
921 get_message_header_info(FILE *in
, char *format
)
927 m_getfld_state_t gstate
;
928 charstring_t buffer
= charstring_create(0);
931 dat
[0] = dat
[1] = dat
[4] = 0;
932 dat
[2] = fstat(fileno(in
), &st
) == 0 ? st
.st_size
: 0;
935 (void) fmt_compile(new_fs(NULL
, NULL
, format
), &fmt
, 1);
939 * Read in the message and process the header.
942 parsing_header
= true;
943 gstate
= m_getfld_state_init(in
);
945 char name
[NAMESZ
], rbuf
[NMH_BUFSIZ
];
946 int bufsz
= sizeof rbuf
;
947 int state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
952 int bucket
= fmt_addcomptext(name
, rbuf
);
955 while (state
== FLDPLUS
) {
957 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
958 fmt_appendcomp(bucket
, name
, rbuf
);
962 while (state
== FLDPLUS
) {
964 state
= m_getfld2(&gstate
, name
, rbuf
, &bufsz
);
969 parsing_header
= false;
971 } while (parsing_header
);
972 m_getfld_state_destroy(&gstate
);
974 fmt_scan(fmt
, buffer
, INT_MAX
, dat
, NULL
);
977 /* Trim trailing newline, if any. */
978 retval
= rtrim(charstring_buffer_copy((buffer
)));
979 charstring_free(buffer
);
989 * Look in profile for entry corresponding to addr or host, and add its contents to vec.
991 * Could do some of this automatically, by looking for:
992 * 1) access-$(mbox{from}) in oauth-svc file using mh_oauth_cred_load(), which isn't
993 * static and doesn't have side effects; free the result with mh_oauth_cred_free())
994 * 2) machine $(mbox{from}) in creds
995 * If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
996 * but that might not generalize for other svcs.
999 merge_profile_entry(const char *addr
, const char *host
, char *vec
[], int *vecp
)
1001 char *addr_entry
= concat("sendfrom-", addr
, NULL
);
1002 char *profile_entry
= context_find(addr_entry
);
1005 if (profile_entry
== NULL
) {
1006 /* No entry for the user. Look for one for the host. */
1007 char *host_entry
= concat("sendfrom-", host
, NULL
);
1009 profile_entry
= context_find(host_entry
);
1013 /* Use argsplit() to do the real work of splitting the args in the profile entry. */
1014 if (profile_entry
&& *profile_entry
) {
1017 char **profile_vec
= argsplit(profile_entry
, &file
, &profile_vecp
);
1020 for (i
= 0; i
< profile_vecp
; ++i
) {
1021 vec
[(*vecp
)++] = getcpy(profile_vec
[i
]);
1024 arglist_free(file
, profile_vec
);
1029 static void NORETURN
1030 armed_done (int status
)
1032 longjmp (env
, status
? status
: NOTOK
);