]> diplodocus.org Git - nmh/blob - uip/sendsbr.c
628b99d2be7c385a640a8f70df2bbb82a74017be
[nmh] / uip / sendsbr.c
1 /* sendsbr.c -- routines to help WhatNow/Send along
2 *
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.
6 */
7
8 #include "h/mh.h"
9 #include "sbr/fmt_new.h"
10 #include "sendsbr.h"
11 #include "distsbr.h"
12 #include "annosbr.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"
18 #include "sbr/uprf.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"
32 #include <setjmp.h>
33 #include <fcntl.h>
34 #include "h/mime.h"
35 #include "h/tws.h"
36 #include "h/utils.h"
37 #include "h/mts.h"
38
39 #ifdef HAVE_SYS_TIME_H
40 # include <sys/time.h>
41 #endif
42 #include <time.h>
43
44 #ifdef OAUTH_SUPPORT
45 #include "h/oauth.h"
46 #endif
47 #include "h/done.h"
48 #include "sbr/m_maildir.h"
49 #include "sbr/m_mktemp.h"
50 #include "sbr/message_id.h"
51
52 #ifdef OAUTH_SUPPORT
53 static int setup_oauth_params(char *[], int *, const char *, const char **);
54 #endif /* OAUTH_SUPPORT */
55
56 int debugsw = 0; /* global */
57 bool forwsw = true;
58 int inplace = 1;
59 bool pushsw;
60 bool unique;
61 bool verbsw;
62
63 char *altmsg = NULL; /* .. */
64 char *annotext = NULL;
65 char *distfile = NULL;
66
67 static jmp_buf env;
68
69 /*
70 * static prototypes
71 */
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 sendaux (char **, int, char *, char *, struct stat *);
77 static void handle_sendfrom(char **, int *, char *, const char *);
78 static int get_from_header_info(const char *, const char **, const char **, const char **);
79 static const char *get_message_header_info(FILE *, char *);
80 static void merge_profile_entry(const char *, const char *, char *[], int *);
81 static void armed_done (int) NORETURN;
82
83 /*
84 * Entry point into (back-end) routines to send message.
85 */
86
87 int
88 sendsbr (char **vec, int vecp, char *program, char *draft, struct stat *st,
89 int rename_drft, const char *auth_svc)
90 {
91 int status, i;
92 pid_t child;
93 char buffer[BUFSIZ], file[BUFSIZ];
94 char **buildvec, *buildprogram;
95 char *volatile drft = draft;
96 /* nvecs is volatile to prevent warning from gcc about possible clobbering
97 by longjmp. */
98 volatile int nvecs = vecp;
99 int *nvecsp = (int *) &nvecs;
100
101 /*
102 * Run the mimebuildproc (which is by default mhbuild) on the message
103 * with the addition of the "-auto" flag
104 */
105
106 switch (child = fork()) {
107 case NOTOK:
108 adios("fork", "unable to");
109 break;
110
111 case OK:
112 buildvec = argsplit(buildmimeproc, &buildprogram, &i);
113 buildvec[i++] = "-auto";
114 if (distfile)
115 buildvec[i++] = "-dist";
116 buildvec[i++] = (char *) drft;
117 buildvec[i] = NULL;
118 execvp(buildprogram, buildvec);
119 fprintf(stderr, "unable to exec ");
120 perror(buildmimeproc);
121 _exit(1);
122 break;
123
124 default:
125 if (pidXwait(child, buildmimeproc))
126 return NOTOK;
127 break;
128 }
129
130 set_done(armed_done);
131 switch (setjmp (env)) {
132 case OK:
133 /*
134 * If given -push and -unique (which is undocumented), then
135 * rename the draft file. I'm not quite sure why.
136 */
137 if (pushsw && unique) {
138 char *cp = m_mktemp2(drft, invo_name, NULL, NULL);
139 if (cp == NULL) {
140 die("unable to create temporary file");
141 }
142 if (rename (drft, strncpy(file, cp, sizeof(file) - 1)) ==
143 NOTOK)
144 adios (file, "unable to rename %s to", drft);
145 drft = file;
146 }
147
148 /*
149 * Add in any necessary profile entries for xoauth
150 */
151
152 if (auth_svc) {
153 #ifdef OAUTH_SUPPORT
154 const char *errmsg;
155 if (setup_oauth_params(vec, nvecsp, auth_svc, &errmsg) != OK) {
156 die("%s", errmsg);
157 }
158 #else
159 die("send built without OAUTH_SUPPORT, "
160 "so auth_svc %s is not supported", auth_svc);
161 #endif /* OAUTH_SUPPORT */
162 }
163
164 /*
165 * Rework the vec based on From: header in draft, as specified
166 * by sendfrom-address entries in profile.
167 */
168 if (context_find_prefix("sendfrom-")) {
169 handle_sendfrom(vec, nvecsp, draft, auth_svc);
170 }
171
172 status = sendaux (vec, nvecs, program, drft, st) ? NOTOK : OK;
173
174 /* rename the original draft */
175 if (rename_drft && status == OK &&
176 rename (drft, strncpy (buffer, m_backup (drft),
177 sizeof(buffer) - 1)) == NOTOK)
178 advise (buffer, "unable to rename %s to", drft);
179 break;
180
181 default:
182 status = DONE;
183 break;
184 }
185
186 set_done(exit);
187 if (distfile)
188 (void) m_unlink (distfile);
189
190 return status;
191 }
192
193
194 /*
195 * Annotate original message, and
196 * call `postproc' (which is passed down in "program") to send message.
197 */
198
199 static int
200 sendaux (char **vec, int vecp, char *program, char *drft, struct stat *st)
201 {
202 pid_t child_id;
203 int status, fd, fd2;
204 char backup[BUFSIZ], buf[BUFSIZ];
205
206 fd = pushsw ? tmp_fd () : NOTOK;
207 fd2 = NOTOK;
208
209 if (annotext) {
210 if ((fd2 = tmp_fd ()) != NOTOK) {
211 vec[vecp++] = "-idanno";
212 snprintf (buf, sizeof(buf), "%d", fd2);
213 vec[vecp++] = buf;
214 } else {
215 inform("unable to create temporary file in %s for "
216 "annotation list, continuing...", get_temp_dir());
217 }
218 }
219 vec[vecp++] = drft;
220 if (distfile && distout (drft, distfile, backup) == NOTOK)
221 done (1);
222 vec[vecp] = NULL;
223
224 child_id = fork();
225 switch (child_id) {
226 case -1:
227 /* oops -- fork error */
228 adios ("fork", "unable to");
229 break; /* NOT REACHED */
230
231 case 0:
232 /*
233 * child process -- send it
234 *
235 * If fd is OK, then we are pushing and fd points to temp
236 * file, so capture anything on stdout and stderr there.
237 */
238 if (fd != NOTOK) {
239 dup2 (fd, fileno (stdout));
240 dup2 (fd, fileno (stderr));
241 close (fd);
242 }
243 execvp (program, vec);
244 fprintf (stderr, "unable to exec ");
245 perror (postproc);
246 _exit(1);
247
248 default:
249 /*
250 * parent process -- wait for it
251 */
252 if ((status = pidwait(child_id, NOTOK)) == OK) {
253 if (annotext && fd2 != NOTOK)
254 anno (fd2, st);
255 } else {
256 /*
257 * If postproc failed, and we have good fd (which means
258 * we pushed), then mail error message (and possibly the
259 * draft) back to the user.
260 */
261 if (fd != NOTOK) {
262 alert (drft, fd);
263 close (fd);
264 } else {
265 inform("message not delivered to anyone");
266 }
267 if (annotext && fd2 != NOTOK)
268 close (fd2);
269 if (distfile) {
270 (void) m_unlink (drft);
271 if (rename (backup, drft) == NOTOK)
272 advise (drft, "unable to rename %s to", backup);
273 }
274 }
275 break;
276 }
277
278 return status;
279 }
280
281
282 /*
283 * Mail error notification (and possibly a copy of the
284 * message) back to the user, using the mailproc
285 */
286
287 static void
288 alert (char *file, int out)
289 {
290 pid_t child_id;
291 int in, argp;
292 char buf[BUFSIZ];
293 char *program;
294 char **arglist;
295
296 child_id = fork();
297 switch (child_id) {
298 case NOTOK:
299 /* oops -- fork error */
300 advise ("fork", "unable to");
301 /* FALLTHRU */
302
303 case OK:
304 /* child process -- send it */
305 SIGNAL (SIGHUP, SIG_IGN);
306 SIGNAL (SIGINT, SIG_IGN);
307 SIGNAL (SIGQUIT, SIG_IGN);
308 SIGNAL (SIGTERM, SIG_IGN);
309 if (forwsw) {
310 if ((in = open (file, O_RDONLY)) == NOTOK) {
311 admonish (file, "unable to re-open");
312 } else {
313 lseek(out, 0, SEEK_END);
314 strncpy (buf, "\nMessage not delivered to anyone.\n", sizeof(buf));
315 if (write (out, buf, strlen (buf)) < 0) {
316 advise (file, "write");
317 }
318 strncpy (buf, "\n------- Unsent Draft\n\n", sizeof(buf));
319 if (write (out, buf, strlen (buf)) < 0) {
320 advise (file, "write");
321 }
322 cpydgst (in, out, file, "temporary file");
323 close (in);
324 strncpy (buf, "\n------- End of Unsent Draft\n", sizeof(buf));
325 if (write (out, buf, strlen (buf)) < 0) {
326 advise (file, "write");
327 }
328 if (rename (file, strncpy (buf, m_backup (file),
329 sizeof(buf) - 1)) == NOTOK)
330 admonish (buf, "unable to rename %s to", file);
331 }
332 }
333 lseek(out, 0, SEEK_SET);
334 dup2 (out, fileno (stdin));
335 close (out);
336 /* create subject for error notification */
337 snprintf (buf, sizeof(buf), "send failed on %s",
338 forwsw ? "enclosed draft" : file);
339
340 arglist = argsplit(mailproc, &program, &argp);
341
342 arglist[argp++] = getusername(1);
343 arglist[argp++] = "-subject";
344 arglist[argp++] = buf;
345 arglist[argp] = NULL;
346
347 execvp (program, arglist);
348 fprintf (stderr, "unable to exec ");
349 perror (mailproc);
350 _exit(1);
351
352 default: /* no waiting... */
353 break;
354 }
355 }
356
357
358 static int
359 tmp_fd (void)
360 {
361 int fd;
362 char *tfile;
363
364 if ((tfile = m_mktemp2(NULL, invo_name, &fd, NULL)) == NULL) return NOTOK;
365
366 if (debugsw)
367 inform("temporary file %s selected", tfile);
368 else if (m_unlink (tfile) == NOTOK)
369 advise (tfile, "unable to remove");
370
371 return fd;
372 }
373
374
375 static void
376 anno (int fd, struct stat *st)
377 {
378 pid_t child_id;
379 sigset_t set, oset;
380 static char *cwd = NULL;
381 struct stat st2;
382
383 if (altmsg &&
384 (stat (altmsg, &st2) == NOTOK
385 || st->st_mtime != st2.st_mtime
386 || st->st_dev != st2.st_dev
387 || st->st_ino != st2.st_ino)) {
388 if (debugsw)
389 inform("$mhaltmsg mismatch, continuing...");
390 return;
391 }
392
393 child_id = debugsw ? NOTOK : fork ();
394 switch (child_id) {
395 case NOTOK: /* oops */
396 if (!debugsw)
397 inform("unable to fork, so doing annotations by hand...");
398 if (cwd == NULL)
399 cwd = mh_xstrdup(pwd ());
400 /* FALLTHRU */
401
402 case OK:
403 /* block a few signals */
404 sigemptyset (&set);
405 sigaddset (&set, SIGHUP);
406 sigaddset (&set, SIGINT);
407 sigaddset (&set, SIGQUIT);
408 sigaddset (&set, SIGTERM);
409 sigprocmask (SIG_BLOCK, &set, &oset);
410
411 unregister_for_removal(0);
412
413 annoaux (fd);
414 if (child_id == OK)
415 _exit (0);
416
417 /* reset the signal mask */
418 sigprocmask (SIG_SETMASK, &oset, &set);
419
420 if (chdir (cwd) < 0) {
421 advise (cwd, "chdir");
422 }
423 break;
424
425 default: /* no waiting... */
426 close (fd);
427 break;
428 }
429 }
430
431
432 static void
433 annoaux (int fd)
434 {
435 int fd2, fd3, msgnum;
436 char *cp, *folder, *maildir;
437 char buffer[BUFSIZ], **ap;
438 FILE *fp;
439 struct msgs *mp;
440
441 if ((folder = getenv ("mhfolder")) == NULL || *folder == 0) {
442 if (debugsw)
443 inform("$mhfolder not set, continuing...");
444 return;
445 }
446 maildir = m_maildir (folder);
447 if (chdir (maildir) == NOTOK) {
448 if (debugsw)
449 admonish (maildir, "unable to change directory to");
450 return;
451 }
452 if (!(mp = folder_read (folder, 0))) {
453 if (debugsw)
454 inform("unable to read folder %s, continuing...", folder);
455 return;
456 }
457
458 /* check for empty folder */
459 if (mp->nummsg == 0) {
460 if (debugsw)
461 inform("no messages in %s, continuing...", folder);
462 goto oops;
463 }
464
465 if ((cp = getenv ("mhmessages")) == NULL || *cp == 0) {
466 if (debugsw)
467 inform("$mhmessages not set, continuing...");
468 goto oops;
469 }
470 if (!debugsw /* MOBY HACK... */
471 && pushsw
472 && (fd3 = open ("/dev/null", O_RDWR)) != NOTOK
473 && (fd2 = dup (fileno (stderr))) != NOTOK) {
474 dup2 (fd3, fileno (stderr));
475 close (fd3);
476 }
477 else
478 fd2 = NOTOK;
479 for (ap = brkstring (cp = mh_xstrdup(cp), " ", NULL); *ap; ap++)
480 m_convert (mp, *ap);
481 free (cp);
482 if (fd2 != NOTOK)
483 dup2 (fd2, fileno (stderr));
484 if (mp->numsel == 0) {
485 if (debugsw)
486 inform("no messages to annotate, continuing...");
487 goto oops;
488 }
489
490 lseek(fd, 0, SEEK_SET);
491 if ((fp = fdopen (fd, "r")) == NULL) {
492 if (debugsw)
493 inform("unable to fdopen annotation list, continuing...");
494 goto oops;
495 }
496 cp = NULL;
497 while (fgets (buffer, sizeof(buffer), fp) != NULL)
498 cp = add (buffer, cp);
499 fclose (fp);
500
501 if (debugsw)
502 inform("annotate%s with %s: \"%s\"",
503 inplace ? " inplace" : "", annotext, cp);
504 for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
505 if (is_selected(mp, msgnum)) {
506 if (debugsw)
507 inform("annotate message %d", msgnum);
508 annotate (m_name (msgnum), annotext, cp, inplace, 1, -2, 0);
509 }
510 }
511
512 free (cp);
513
514 oops:
515 folder_free (mp); /* free folder/message structure */
516 }
517
518
519 static void
520 handle_sendfrom(char **vec, int *vecp, char *draft, const char *auth_svc)
521 {
522 const char *addr, *host;
523 const char *message;
524
525 /* Extract address and host from From: header line in draft. */
526 if (get_from_header_info(draft, &addr, &host, &message) != OK) {
527 adios(draft, "%s", message);
528 }
529
530 /* Merge in any address or host specific switches to post(1) from profile. */
531 merge_profile_entry(addr, host, vec, vecp);
532 free((void *) host);
533 free((void *) addr);
534
535 vec[*vecp] = NULL;
536
537 {
538 char **vp;
539
540 for (vp = vec; *vp; ++vp) {
541 if (strcmp(*vp, "xoauth2") == 0) {
542 #ifdef OAUTH_SUPPORT
543 if (setup_oauth_params(vec, vecp, auth_svc, &message) != OK) {
544 die("%s", message);
545 }
546 break;
547 #else
548 NMH_UNUSED(auth_svc);
549 die("send built without OAUTH_SUPPORT, "
550 "so -saslmech xoauth2 is not supported");
551 #endif /* OAUTH_SUPPORT */
552 }
553 }
554 }
555 }
556
557
558 #ifdef OAUTH_SUPPORT
559 /*
560 * For XOAUTH2, append profile entries so post can do the heavy lifting
561 */
562 static int
563 setup_oauth_params(char *vec[], int *vecp, const char *auth_svc,
564 const char **message)
565 {
566 const char *saslmech = NULL, *user = NULL;
567 mh_oauth_service_info svc;
568 char errbuf[256];
569 int i;
570
571 /* Make sure we have all the information we need. */
572 for (i = 1; i < *vecp; ++i) {
573 /* Don't support abbreviated switches, to avoid collisions in the
574 future if new ones are added. */
575 if (! strcmp(vec[i-1], "-saslmech")) {
576 saslmech = vec[i];
577 } else if (! strcmp(vec[i-1], "-user")) {
578 user = vec[i];
579 } else if (! strcmp(vec[i-1], "-authservice")) {
580 auth_svc = vec[i];
581 }
582 }
583
584 if (auth_svc == NULL) {
585 if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
586 *message = "must specify -authservice with -saslmech xoauth2";
587 return NOTOK;
588 }
589 } else {
590 if (user == NULL) {
591 *message = "must specify -user with -saslmech xoauth2";
592 return NOTOK;
593 }
594
595 if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
596 if (! mh_oauth_get_service_info(auth_svc, &svc, errbuf,
597 sizeof(errbuf)))
598 die("Unable to retrieve oauth profile entries: %s",
599 errbuf);
600
601 vec[(*vecp)++] = mh_xstrdup("-authservice");
602 vec[(*vecp)++] = mh_xstrdup(auth_svc);
603 vec[(*vecp)++] = mh_xstrdup("-oauthcredfile");
604 vec[(*vecp)++] = mh_oauth_cred_fn(auth_svc);
605 vec[(*vecp)++] = mh_xstrdup("-oauthclientid");
606 vec[(*vecp)++] = getcpy(svc.client_id);
607 vec[(*vecp)++] = mh_xstrdup("-oauthclientsecret");
608 vec[(*vecp)++] = getcpy(svc.client_secret);
609 vec[(*vecp)++] = mh_xstrdup("-oauthauthendpoint");
610 vec[(*vecp)++] = getcpy(svc.auth_endpoint);
611 vec[(*vecp)++] = mh_xstrdup("-oauthredirect");
612 vec[(*vecp)++] = getcpy(svc.redirect_uri);
613 vec[(*vecp)++] = mh_xstrdup("-oauthtokenendpoint");
614 vec[(*vecp)++] = getcpy(svc.token_endpoint);
615 vec[(*vecp)++] = mh_xstrdup("-oauthscope");
616 vec[(*vecp)++] = getcpy(svc.scope);
617 }
618 }
619
620 return 0;
621 }
622 #endif /* OAUTH_SUPPORT */
623
624
625 /*
626 * Extract user and domain from From: header line in draft.
627 */
628 static int
629 get_from_header_info(const char *filename, const char **addr, const char **host, const char **message)
630 {
631 struct stat st;
632 FILE *in;
633
634 if (stat (filename, &st) == NOTOK) {
635 *message = "unable to stat draft file";
636 return NOTOK;
637 }
638
639 if ((in = fopen (filename, "r")) != NULL) {
640 /* There must be a non-blank Envelope-From or {Resent-}Sender or
641 {Resent-}From header. */
642 char *addrformat = "%(addr{Envelope-From})";
643 char *hostformat = "%(host{Envelope-From})";
644
645 if ((*addr = get_message_header_info (in, addrformat)) == NULL ||
646 !**addr) {
647 addrformat = distfile == NULL ? "%(addr{Sender})" : "%(addr{Resent-Sender})";
648 hostformat = distfile == NULL ? "%(host{Sender})" : "%(host{Resent-Sender})";
649
650 if ((*addr = get_message_header_info (in, addrformat)) == NULL) {
651 addrformat = distfile == NULL ? "%(addr{From})" : "%(addr{Resent-From})";
652 hostformat = distfile == NULL ? "%(host{From})" : "%(host{Resent-From})";
653
654 if ((*addr = get_message_header_info (in, addrformat)) == NULL) {
655 *message = "unable to find sender address in";
656 fclose(in);
657 return NOTOK;
658 }
659 }
660 }
661
662 /* Use the hostformat that corresponds to the successful addrformat. */
663 if ((*host = get_message_header_info(in, hostformat)) == NULL) {
664 *message = "unable to find sender host";
665 fclose(in);
666 return NOTOK;
667 }
668 fclose(in);
669
670 return OK;
671 }
672
673 *message = "unable to open";
674 return NOTOK;
675 }
676
677
678 /*
679 * Get formatted information from header of a message.
680 * Adapted from process_single_file() in uip/fmttest.c.
681 */
682 static const char *
683 get_message_header_info(FILE *in, char *format)
684 {
685 int dat[5];
686 struct format *fmt;
687 struct stat st;
688 bool parsing_header;
689 m_getfld_state_t gstate;
690 charstring_t buffer = charstring_create(0);
691 char *retval;
692
693 dat[0] = dat[1] = dat[4] = 0;
694 dat[2] = fstat(fileno(in), &st) == 0 ? st.st_size : 0;
695 dat[3] = INT_MAX;
696
697 (void) fmt_compile(new_fs(NULL, NULL, format), &fmt, 1);
698 free_fs();
699
700 /*
701 * Read in the message and process the header.
702 */
703 rewind (in);
704 parsing_header = true;
705 gstate = m_getfld_state_init(in);
706 do {
707 char name[NAMESZ], rbuf[NMH_BUFSIZ];
708 int bufsz = sizeof rbuf;
709 int state = m_getfld2(&gstate, name, rbuf, &bufsz);
710
711 switch (state) {
712 case FLD:
713 case FLDPLUS: {
714 int bucket = fmt_addcomptext(name, rbuf);
715
716 if (bucket != -1) {
717 while (state == FLDPLUS) {
718 bufsz = sizeof rbuf;
719 state = m_getfld2(&gstate, name, rbuf, &bufsz);
720 fmt_appendcomp(bucket, name, rbuf);
721 }
722 }
723
724 while (state == FLDPLUS) {
725 bufsz = sizeof rbuf;
726 state = m_getfld2(&gstate, name, rbuf, &bufsz);
727 }
728 break;
729 }
730 default:
731 parsing_header = false;
732 }
733 } while (parsing_header);
734 m_getfld_state_destroy(&gstate);
735
736 fmt_scan(fmt, buffer, INT_MAX, dat, NULL);
737 fmt_free(fmt, 1);
738
739 /* Trim trailing newline, if any. */
740 retval = rtrim(charstring_buffer_copy((buffer)));
741 charstring_free(buffer);
742 if (*retval)
743 return retval;
744
745 free(retval);
746 return NULL;
747 }
748
749
750 /*
751 * Look in profile for entry corresponding to addr or host, and add its contents to vec.
752 *
753 * Could do some of this automatically, by looking for:
754 * 1) access-$(mbox{from}) in oauth-svc file using mh_oauth_cred_load(), which isn't
755 * static and doesn't have side effects; free the result with mh_oauth_cred_free())
756 * 2) machine $(mbox{from}) in creds
757 * If no -server passed in from profile or commandline, could use smtp.<svc>.com for gmail,
758 * but that might not generalize for other svcs.
759 */
760 static void
761 merge_profile_entry(const char *addr, const char *host, char *vec[], int *vecp)
762 {
763 char *addr_entry = concat("sendfrom-", addr, NULL);
764 char *profile_entry = context_find(addr_entry);
765
766 free(addr_entry);
767 if (profile_entry == NULL) {
768 /* No entry for the user. Look for one for the host. */
769 char *host_entry = concat("sendfrom-", host, NULL);
770
771 profile_entry = context_find(host_entry);
772 free(host_entry);
773 }
774
775 /* Use argsplit() to do the real work of splitting the args in the profile entry. */
776 if (profile_entry && *profile_entry) {
777 int profile_vecp;
778 char *file;
779 char **profile_vec = argsplit(profile_entry, &file, &profile_vecp);
780 int i;
781
782 for (i = 0; i < profile_vecp; ++i) {
783 vec[(*vecp)++] = getcpy(profile_vec[i]);
784 }
785
786 arglist_free(file, profile_vec);
787 }
788 }
789
790
791 static void NORETURN
792 armed_done (int status)
793 {
794 longjmp (env, status ? status : NOTOK);
795 }