]>
Commit | Line | Data |
---|---|---|
cac267c0 | 1 | diff -U 3 anacron-2.3.oud/runjob.c anacron-2.3/runjob.c |
2 | --- anacron-2.3.oud/runjob.c 2000-06-21 01:12:18.000000000 +0200 | |
3 | +++ anacron-2.3/runjob.c 2004-07-09 19:05:22.314056376 +0200 | |
4 | @@ -83,6 +83,18 @@ | |
5 | return ps->pw_name; | |
6 | } | |
7 | ||
8 | +static char * | |
9 | +mailto() | |
10 | +{ | |
11 | + char *alias; | |
12 | + | |
13 | + alias = getenv("MAILTO"); | |
14 | + if (alias == NULL || strlen(alias) == 0) | |
15 | + return username(); | |
16 | + else | |
17 | + return alias; | |
18 | +} | |
19 | + | |
20 | static void | |
21 | xputenv(const char *s) | |
22 | { | |
23 | @@ -109,7 +121,6 @@ | |
24 | run_job(const job_rec *jr) | |
25 | /* This is called to start the job, after the fork */ | |
26 | { | |
27 | - setup_env(jr); | |
28 | /* setup stdout and stderr */ | |
29 | xclose(1); | |
30 | xclose(2); | |
31 | @@ -173,7 +184,7 @@ | |
32 | * options, which don't seem to be appropriate here. | |
33 | * Hopefully, this will keep all the MTAs happy. */ | |
34 | execl(SENDMAIL, SENDMAIL, "-FAnacron", "-odi", | |
35 | - username(), (char *)NULL); | |
36 | + mailto(), (char *)NULL); | |
37 | die_e("Can't exec " SENDMAIL); | |
38 | } | |
39 | /* parent */ | |
40 | @@ -208,6 +219,9 @@ | |
41 | pid_t pid; | |
42 | int fd; | |
43 | ||
44 | + /* import environment for mailto() to work properly */ | |
45 | + setup_env(jr); | |
46 | + | |
47 | /* create temporary file for stdout and stderr of the job */ | |
48 | fd = jr->output_fd = temp_file(); | |
49 | /* write mail header */ | |
50 | @@ -215,7 +229,7 @@ | |
51 | xwrite(fd, username()); | |
52 | xwrite(fd, " (Anacron)\n"); | |
53 | xwrite(fd, "To: "); | |
54 | - xwrite(fd, username()); | |
55 | + xwrite(fd, mailto()); | |
56 | xwrite(fd, "\n"); | |
57 | xwrite(fd, "Subject: Anacron job '"); | |
58 | xwrite(fd, jr->ident); |