Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 167640 Details for
Bug 192452
sys-process/vixie-cron - Add mail from capability
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to implement MAILFROM feature
vixie-cron-4.1-mailfrom.patch (text/plain), 4.08 KB, created by
Heath Caldwell (RETIRED)
on 2008-10-08 18:22:05 UTC
(
hide
)
Description:
Patch to implement MAILFROM feature
Filename:
MIME Type:
Creator:
Heath Caldwell (RETIRED)
Created:
2008-10-08 18:22:05 UTC
Size:
4.08 KB
patch
obsolete
>diff -urp vixie-cron-4.1/config.h vixie-cron-4.1.new/config.h >--- vixie-cron-4.1/config.h 2008-10-08 09:27:54.000000000 -0700 >+++ vixie-cron-4.1.new/config.h 2008-10-08 10:21:25.000000000 -0700 >@@ -41,12 +41,13 @@ > * (hint: MAILTO= was added for this reason). > */ > >-#define MAILFMT "%s -FCronDaemon -odi -oem -oi -t" /*-*/ >+#define MAILFMT "%s -FCronDaemon -odi -oem -oi -t -f %s" /*-*/ > /* -Fx = Set full-name of sender > * -odi = Option Deliverymode Interactive > * -oem = Option Errors Mailedtosender > * -oi = Ignore "." alone on a line > * -t = Get recipient from headers >+ * -f %s = Envelope sender address > */ > #define MAILARG _PATH_SENDMAIL /*-*/ > >diff -urp vixie-cron-4.1/crontab.5 vixie-cron-4.1.new/crontab.5 >--- vixie-cron-4.1/crontab.5 2008-10-08 09:27:54.000000000 -0700 >+++ vixie-cron-4.1.new/crontab.5 2008-10-08 10:27:25.000000000 -0700 >@@ -75,7 +75,8 @@ sent to the user so named. If MAILTO is > mail will be sent. Otherwise mail is sent to the owner of the crontab. This > option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as > your mailer when you install cron -- /bin/mail doesn't do aliasing, and UUCP >-usually doesn't read its mail. >+usually doesn't read its mail. If MAILFROM is defined (and non-empty), it >+will be used as the envelope sender address, otherwise, ``root'' will be used. > .PP > The format of a cron command is very much the V7 standard, with a number of > upward-compatible extensions. Each line has five time and date fields, >diff -urp vixie-cron-4.1/do_command.c vixie-cron-4.1.new/do_command.c >--- vixie-cron-4.1/do_command.c 2008-10-08 09:27:54.000000000 -0700 >+++ vixie-cron-4.1.new/do_command.c 2008-10-08 10:20:39.000000000 -0700 >@@ -75,7 +75,7 @@ do_command(entry *e, user *u) { > static void > child_process(entry *e, user *u) { > int stdin_pipe[2], stdout_pipe[2]; >- char *input_data, *usernm, *mailto; >+ char *input_data, *usernm, *mailto, *mailfrom; > int children = 0; > int retcode = 0; > >@@ -97,6 +97,7 @@ child_process(entry *e, user *u) { > */ > usernm = e->pwd->pw_name; > mailto = env_get("MAILTO", e->envp); >+ mailfrom = env_get("MAILFROM", e->envp); > > /* our parent is watching for our death by catching SIGCHLD. we > * do not care to watch for our children's deaths this way -- we >@@ -429,6 +430,14 @@ child_process(entry *e, user *u) { > */ > mailto = usernm; > } >+ >+ /* get sender address. this is MAILFROM if set (and safe), >+ * root otherwise. >+ */ >+ if (!mailfrom || !*mailfrom || !safe_p(usernm, mailfrom)) { >+ mailfrom = calloc(5, sizeof(char)); >+ strcpy(mailfrom, "root"); >+ } > > /* if we are supposed to be mailing, MAILTO will > * be non-NULL. only in this case should we set >@@ -441,17 +450,17 @@ child_process(entry *e, user *u) { > char hostname[MAXHOSTNAMELEN]; > > gethostname(hostname, MAXHOSTNAMELEN); >- if (strlens(MAILFMT, MAILARG, NULL) + 1 >+ if (strlens(MAILFMT, MAILARG, mailfrom, NULL) + 1 > >= sizeof mailcmd) { > fprintf(stderr, "mailcmd too long\n"); > (void) _exit(ERROR_EXIT); > } >- (void)sprintf(mailcmd, MAILFMT, MAILARG); >+ (void)sprintf(mailcmd, MAILFMT, MAILARG, mailfrom); > if (!(mail = cron_popen(mailcmd, "w", e->pwd))) { > perror(mailcmd); > (void) _exit(ERROR_EXIT); > } >- fprintf(mail, "From: root (Cron Daemon)\n"); >+ fprintf(mail, "From: %s (Cron Daemon)\n", mailfrom); > fprintf(mail, "To: %s\n", mailto); > fprintf(mail, "Subject: Cron <%s@%s> %s\n", > usernm, first_word(hostname, "."), >diff -urp vixie-cron-4.1/FEATURES vixie-cron-4.1.new/FEATURES >--- vixie-cron-4.1/FEATURES 2008-10-08 09:27:54.000000000 -0700 >+++ vixie-cron-4.1.new/FEATURES 2008-10-08 10:29:35.000000000 -0700 >@@ -29,6 +29,9 @@ Features of ISC cron relative to BSD 4.[ > useful if you decide on BINMAIL when configuring cron.h, since binmail > doesn't know anything about aliasing. > >+ MAILFROM, if set, will be used as the envelope sender address when cron >+ mails the output of commands in that crontab. >+ > -- Weekdays can be specified by name. Case is not significant, but only > the first three letters should be specified. >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 192452
: 167640