summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cron/cron/cron.820
-rw-r--r--usr.sbin/cron/cron/cron.c7
-rw-r--r--usr.sbin/cron/cron/cron.h6
-rw-r--r--usr.sbin/cron/cron/do_command.c20
4 files changed, 36 insertions, 17 deletions
diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8
index b0d1a91..5d5a8d9 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 June 29, 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 46d2fdf..101989c 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 35f75e8..e58cd85 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 b224880..f5ab5b5 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];
OpenPOWER on IntegriCloud