=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/send.c,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** src/usr.bin/mail/send.c 2014/01/17 18:42:30 1.23 --- src/usr.bin/mail/send.c 2015/01/20 16:59:07 1.24 *************** *** 1,4 **** ! /* $OpenBSD: send.c,v 1.23 2014/01/17 18:42:30 okan Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: send.c,v 1.24 2015/01/20 16:59:07 millert Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* *************** *** 279,289 **** */ int mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts, ! char *subject) { struct header head; head.h_to = to; head.h_subject = subject; head.h_cc = cc; head.h_bcc = bcc; --- 279,290 ---- */ int mail(struct name *to, struct name *cc, struct name *bcc, struct name *smopts, ! char *fromaddr, char *subject) { struct header head; head.h_to = to; + head.h_from = fromaddr; head.h_subject = subject; head.h_cc = cc; head.h_bcc = bcc; *************** *** 292,298 **** return(0); } - /* * Send mail to a bunch of user names. The interface is through * the mail routine below. --- 293,298 ---- *************** *** 304,309 **** --- 304,310 ---- struct header head; head.h_to = extract(str, GTO); + head.h_from = NULL; head.h_subject = NULL; head.h_cc = NULL; head.h_bcc = NULL; *************** *** 319,327 **** void mail1(struct header *hp, int printheaders) { ! char *cp; pid_t pid; - char **namelist; struct name *to; FILE *mtf; --- 320,329 ---- void mail1(struct header *hp, int printheaders) { ! char *cp, *envfrom = NULL; ! char *argv[8]; ! char **ap = argv; pid_t pid; struct name *to; FILE *mtf; *************** *** 365,382 **** fputs(". . . message lost, sorry.\n", stderr); return; } ! namelist = unpack(hp->h_smopts, to); if (debug) { - char **t; - fputs("Sendmail arguments:", stdout); ! for (t = namelist; *t != NULL; t++) ! printf(" \"%s\"", *t); putchar('\n'); goto out; } - if ((cp = value("record")) != NULL) - (void)savemail(expand(cp), mtf); /* * Fork, set up the temporary mail file as standard * input for "mail", and exec with the user list we generated --- 367,399 ---- fputs(". . . message lost, sorry.\n", stderr); return; } ! if ((cp = value("record")) != NULL) ! (void)savemail(expand(cp), mtf); ! ! /* Setup sendmail arguments. */ ! *ap++ = "send-mail"; ! *ap++ = "-i"; ! *ap++ = "-t"; ! cp = hp->h_from ? hp->h_from : value("from"); ! if (cp != NULL) { ! envfrom = skin(cp); ! *ap++ = "-f"; ! *ap++ = envfrom; ! if (envfrom == cp) ! envfrom = NULL; ! } ! if (value("metoo") != NULL) ! *ap++ = "-m"; ! if (value("verbose") != NULL) ! *ap++ = "-v"; ! *ap = NULL; if (debug) { fputs("Sendmail arguments:", stdout); ! for (ap = argv; *ap != NULL; ap++) ! printf(" \"%s\"", *ap); putchar('\n'); goto out; } /* * Fork, set up the temporary mail file as standard * input for "mail", and exec with the user list we generated *************** *** 403,412 **** cp = expand(cp); else cp = _PATH_SENDMAIL; ! execv(cp, namelist); warn("%s", cp); _exit(1); } if (value("verbose") != NULL) (void)wait_child(pid); else --- 420,430 ---- cp = expand(cp); else cp = _PATH_SENDMAIL; ! execv(cp, argv); warn("%s", cp); _exit(1); } + free(envfrom); if (value("verbose") != NULL) (void)wait_child(pid); else *************** *** 497,504 **** --- 515,526 ---- puthead(struct header *hp, FILE *fo, int w) { int gotcha; + char *from; gotcha = 0; + from = hp->h_from ? hp->h_from : value("from"); + if (from != NULL) + fprintf(fo, "From: %s\n", from), gotcha++; if (hp->h_to != NULL && w & GTO) fmt("To:", hp->h_to, fo, w&GCOMMA), gotcha++; if (hp->h_subject != NULL && w & GSUBJECT)