diff options
author | Dmitry Morozovsky <marck@FreeBSD.org> | 2008-07-27 07:19:30 +0000 |
---|---|---|
committer | Dmitry Morozovsky <marck@FreeBSD.org> | 2008-07-27 07:19:30 +0000 |
commit | 9ee83bab5e09e7608f2a0ea4f479d8ab0455a6ab (patch) | |
tree | 709b9b693c18fc2c5f289d4977474e7df16ae8d2 | |
parent | d6761ba972d038018e9e883ef15316169b2fe7f7 (diff) |
Notes
-rw-r--r-- | usr.sbin/cron/cron/cron.8 | 20 | ||||
-rw-r--r-- | usr.sbin/cron/cron/cron.c | 7 | ||||
-rw-r--r-- | usr.sbin/cron/cron/cron.h | 6 | ||||
-rw-r--r-- | usr.sbin/cron/cron/do_command.c | 20 |
4 files changed, 36 insertions, 17 deletions
diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8 index b0d1a9136ebd..a5a29e9508dc 100644 --- a/usr.sbin/cron/cron/cron.8 +++ b/usr.sbin/cron/cron/cron.8 @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 17, 2007 +.Dd July 27, 2008 .Dt CRON 8 .Os .Sh NAME @@ -27,6 +27,7 @@ .Nm .Op Fl j Ar jitter .Op Fl J Ar rootjitter +.Op Fl m Ar mailto .Op Fl s .Op Fl o .Op Fl x Ar debugflag Ns Op , Ns Ar ... @@ -114,6 +115,23 @@ Enable time jitter for superuser jobs. The same as .Fl j except that it will affect jobs run by the superuser only. +.It Fl m Ar mailto +Overrides the default recipient for +.Nm +mail. +Each +.Xr crontab 5 +without +.Ev MAILTO +explicitly set will send mail to the +.Ar mailto +mailbox. +Sending mail will be disabled by default if +.Ar mailto +set to a null string, usually specified in a shell as +.Li '' +or +.Li \*q\*q . .It Fl s Enable special handling of situations when the GMT offset of the local timezone changes, such as the switches between the standard time and diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c index 671d9709039a..621f254cf376 100644 --- a/usr.sbin/cron/cron/cron.c +++ b/usr.sbin/cron/cron/cron.c @@ -53,7 +53,7 @@ usage() { char **dflags; fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] " - "[-s] [-o] [-x debugflag[,...]]\n"); + "[-m mailto] [-s] [-o] [-x debugflag[,...]]\n"); fprintf(stderr, "\ndebugflags: "); for(dflags = DebugFlagNames; *dflags; dflags++) { @@ -443,7 +443,7 @@ parse_args(argc, argv) int argch; char *endp; - while ((argch = getopt(argc, argv, "j:J:osx:")) != -1) { + while ((argch = getopt(argc, argv, "j:J:m:osx:")) != -1) { switch (argch) { case 'j': Jitter = strtoul(optarg, &endp, 10); @@ -457,6 +457,9 @@ parse_args(argc, argv) errx(ERROR_EXIT, "bad value for root jitter: %s", optarg); break; + case 'm': + defmailto = optarg; + break; case 'o': dst_enabled = 0; break; diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h index 6277719aa721..b80b9b0f20d5 100644 --- a/usr.sbin/cron/cron/cron.h +++ b/usr.sbin/cron/cron/cron.h @@ -268,7 +268,8 @@ char *DowNames[] = { NULL }; -char *ProgramName; +char *ProgramName, + *defmailto; int LineNumber; unsigned Jitter, RootJitter; @@ -285,7 +286,8 @@ char *DebugFlagNames[] = { /* sync with #defines */ extern char *copyright[], *MonthNames[], *DowNames[], - *ProgramName; + *ProgramName, + *defmailto; extern int LineNumber; extern unsigned Jitter, RootJitter; diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c index afc8317cde24..a208171b991c 100644 --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -459,18 +459,14 @@ child_process(e, u) /* get name of recipient. this is MAILTO if set to a * valid local username; USER otherwise. */ - if (mailto) { - /* MAILTO was present in the environment + if (mailto == NULL) { + /* MAILTO not present, set to USER, + * unless globally overriden. */ - if (!*mailto) { - /* ... but it's empty. set to NULL - */ - mailto = NULL; - } - } else { - /* MAILTO not present, set to USER. - */ - mailto = usernm; + if (defmailto) + mailto = defmailto; + else + mailto = usernm; } /* if we are supposed to be mailing, MAILTO will @@ -478,7 +474,7 @@ child_process(e, u) * up the mail command and subjects and stuff... */ - if (mailto) { + if (mailto && *mailto != '\0') { register char **env; auto char mailcmd[MAX_COMMAND]; auto char hostname[MAXHOSTNAMELEN]; |