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