|
Lines 75-81
do_command(entry *e, user *u) {
Link Here
|
| 75 |
static void |
75 |
static void |
| 76 |
child_process(entry *e, user *u) { |
76 |
child_process(entry *e, user *u) { |
| 77 |
int stdin_pipe[2], stdout_pipe[2]; |
77 |
int stdin_pipe[2], stdout_pipe[2]; |
| 78 |
char *input_data, *usernm, *mailto; |
78 |
char *input_data, *usernm, *mailto, *mailfrom; |
| 79 |
int children = 0; |
79 |
int children = 0; |
| 80 |
int retcode = 0; |
80 |
int retcode = 0; |
| 81 |
|
81 |
|
|
Lines 97-102
child_process(entry *e, user *u) {
Link Here
|
| 97 |
*/ |
97 |
*/ |
| 98 |
usernm = e->pwd->pw_name; |
98 |
usernm = e->pwd->pw_name; |
| 99 |
mailto = env_get("MAILTO", e->envp); |
99 |
mailto = env_get("MAILTO", e->envp); |
|
|
100 |
mailfrom = env_get("MAILFROM", e->envp); |
| 100 |
|
101 |
|
| 101 |
/* our parent is watching for our death by catching SIGCHLD. we |
102 |
/* our parent is watching for our death by catching SIGCHLD. we |
| 102 |
* do not care to watch for our children's deaths this way -- we |
103 |
* do not care to watch for our children's deaths this way -- we |
|
Lines 429-434
child_process(entry *e, user *u) {
Link Here
|
| 429 |
*/ |
430 |
*/ |
| 430 |
mailto = usernm; |
431 |
mailto = usernm; |
| 431 |
} |
432 |
} |
|
|
433 |
|
| 434 |
/* get sender address. this is MAILFROM if set (and safe), |
| 435 |
* root otherwise. |
| 436 |
*/ |
| 437 |
if (!mailfrom || !*mailfrom || !safe_p(usernm, mailfrom)) { |
| 438 |
mailfrom = calloc(5, sizeof(char)); |
| 439 |
strcpy(mailfrom, "root"); |
| 440 |
} |
| 432 |
|
441 |
|
| 433 |
/* if we are supposed to be mailing, MAILTO will |
442 |
/* if we are supposed to be mailing, MAILTO will |
| 434 |
* be non-NULL. only in this case should we set |
443 |
* be non-NULL. only in this case should we set |
|
Lines 441-457
child_process(entry *e, user *u) {
Link Here
|
| 441 |
char hostname[MAXHOSTNAMELEN]; |
450 |
char hostname[MAXHOSTNAMELEN]; |
| 442 |
|
451 |
|
| 443 |
gethostname(hostname, MAXHOSTNAMELEN); |
452 |
gethostname(hostname, MAXHOSTNAMELEN); |
| 444 |
if (strlens(MAILFMT, MAILARG, NULL) + 1 |
453 |
if (strlens(MAILFMT, MAILARG, mailfrom, NULL) + 1 |
| 445 |
>= sizeof mailcmd) { |
454 |
>= sizeof mailcmd) { |
| 446 |
fprintf(stderr, "mailcmd too long\n"); |
455 |
fprintf(stderr, "mailcmd too long\n"); |
| 447 |
(void) _exit(ERROR_EXIT); |
456 |
(void) _exit(ERROR_EXIT); |
| 448 |
} |
457 |
} |
| 449 |
(void)sprintf(mailcmd, MAILFMT, MAILARG); |
458 |
(void)sprintf(mailcmd, MAILFMT, MAILARG, mailfrom); |
| 450 |
if (!(mail = cron_popen(mailcmd, "w", e->pwd))) { |
459 |
if (!(mail = cron_popen(mailcmd, "w", e->pwd))) { |
| 451 |
perror(mailcmd); |
460 |
perror(mailcmd); |
| 452 |
(void) _exit(ERROR_EXIT); |
461 |
(void) _exit(ERROR_EXIT); |
| 453 |
} |
462 |
} |
| 454 |
fprintf(mail, "From: root (Cron Daemon)\n"); |
463 |
fprintf(mail, "From: %s (Cron Daemon)\n", mailfrom); |
| 455 |
fprintf(mail, "To: %s\n", mailto); |
464 |
fprintf(mail, "To: %s\n", mailto); |
| 456 |
fprintf(mail, "Subject: Cron <%s@%s> %s\n", |
465 |
fprintf(mail, "Subject: Cron <%s@%s> %s\n", |
| 457 |
usernm, first_word(hostname, "."), |
466 |
usernm, first_word(hostname, "."), |