CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sat Apr 18 19:32:20 UTC 2020 Modified Files: src/external/bsd/cron/dist: cron.c crontab.5 do_command.c entry.c externs.h funcs.h job.c structs.h user.c Log Message: Add -s (SINGLE_JOB) from OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/cron/dist/cron.c \ src/external/bsd/cron/dist/entry.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/cron/dist/crontab.5 cvs rdiff -u -r1.14 -r1.15 src/external/bsd/cron/dist/do_command.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/externs.h \ src/external/bsd/cron/dist/job.c src/external/bsd/cron/dist/user.c cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/funcs.h cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/structs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.10 src/external/bsd/cron/dist/cron.c:1.11 --- src/external/bsd/cron/dist/cron.c:1.10 Fri Jun 9 13:36:30 2017 +++ src/external/bsd/cron/dist/cron.c Sat Apr 18 15:32:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.10 2017/06/09 17:36:30 christos Exp $ */ +/* $NetBSD: cron.c,v 1.11 2020/04/18 19:32:19 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: cron.c,v 1.10 2017/06/09 17:36:30 christos Exp $"); +__RCSID("$NetBSD: cron.c,v 1.11 2020/04/18 19:32:19 christos Exp $"); #endif #endif @@ -532,6 +532,7 @@ sigchld_reaper(void) { Debug(DPROC, ("[%ld] sigchld...pid #%ld died, stat=%d\n", (long)getpid(), (long)pid, WEXITSTATUS(waiter))); + job_exit(pid); break; } } Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.10 src/external/bsd/cron/dist/entry.c:1.11 --- src/external/bsd/cron/dist/entry.c:1.10 Sat Jul 28 09:55:08 2018 +++ src/external/bsd/cron/dist/entry.c Sat Apr 18 15:32:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $ */ +/* $OpenBSD: entry.c,v 1.51 2020/04/16 17:51:56 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $"); +__RCSID("$NetBSD: entry.c,v 1.11 2020/04/18 19:32:19 christos Exp $"); #endif #endif @@ -361,6 +361,14 @@ load_entry(FILE *file, void (*error_func } e->flags |= DONT_LOG; break; + case 's': + /* only allow the user to set the option once */ + if ((e->flags & SINGLE_JOB) == SINGLE_JOB) { +ecode = e_option; +goto eof; + } + e->flags |= SINGLE_JOB; + break; default: ecode = e_option; goto eof; Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.9 src/external/bsd/cron/dist/crontab.5:1.10 --- src/external/bsd/cron/dist/crontab.5:1.9 Fri Apr 17 15:42:14 2020 +++ src/external/bsd/cron/dist/crontab.5 Sat Apr 18 15:32:19 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: crontab.5,v 1.9 2020/04/17 19:42:14 pgoyette Exp $ +.\" $NetBSD: crontab.5,v 1.10 2020/04/18 19:32:19 christos Exp $ .\" .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved @@ -227,6 +227,13 @@ option is an attempt to cure potentially .Xr cron 8 . .It Fl q Ar command Execution will not be logged. +.It Fl s Ar command +Only a single instance of +.Ar command +will be run concurrently. +Additional instances of +.Ar command +will not be scheduled until the earlier one completes. .El .Pp Commands are executed by Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.14 src/external/bsd/cron/dist/do_command.c:1.15 --- src/external/bsd/cron/dist/do_command.c:1.14 Sat Aug 3 03:06:47 2019 +++ src/external/bsd/cron/dist/do_command.c Sat Apr 18 15:32:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.15 2020/04/18 19:32:19 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.15 2020/04/18 19:32:19 christos Exp $"); #endif #endif @@ -35,7 +35,7 @@ __RCSID("$NetBSD: do_command.c,v 1.14 20 static int child_process(entry *); static int safe_p(const char *, const char *); -void +pid_t do_command(entry *e, user *u) { int retval; @@ -66,9 +66,14 @@ do_command(entry *e, user *u) { break; default: /* parent process */ + if ((e->flags & SINGLE_JOB) == 0) + jobpid = -1; break; }
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: pgoyette Date: Fri Apr 17 19:42:14 UTC 2020 Modified Files: src/external/bsd/cron/dist: crontab.5 Log Message: Move the range example (for 8-11) to follow the range definition, and to preceed the random (?) discussion (and the corresponding random example) To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/crontab.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.8 src/external/bsd/cron/dist/crontab.5:1.9 --- src/external/bsd/cron/dist/crontab.5:1.8 Fri Apr 17 18:39:31 2020 +++ src/external/bsd/cron/dist/crontab.5 Fri Apr 17 19:42:14 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: crontab.5,v 1.8 2020/04/17 18:39:31 christos Exp $ +.\" $NetBSD: crontab.5,v 1.9 2020/04/17 19:42:14 pgoyette Exp $ .\" .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved @@ -141,6 +141,10 @@ or Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. +For example, +8\(en11 for an +.Ar hour +entry specifies execution at hours 8, 9, 10 and 11. .Pp A field may begin with a question mark .Pq Sq \&? , @@ -159,10 +163,6 @@ As just one example, this feature can be number of hosts from contacting a server simultaneously and overloading it by staggering the time at which a download script is executed. -For example, -8\(en11 for an -.Ar hour -entry specifies execution at hours 8, 9, 10 and 11. .Pp Step values can be used in conjunction with ranges (but not random ranges which represent a single number).
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri Apr 17 18:39:31 UTC 2020 Modified Files: src/external/bsd/cron/dist: crontab.5 Log Message: Put back the ? syntax accidentally removed when syncing with the OpenBSD man page. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/crontab.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.7 src/external/bsd/cron/dist/crontab.5:1.8 --- src/external/bsd/cron/dist/crontab.5:1.7 Fri Jun 15 19:15:56 2018 +++ src/external/bsd/cron/dist/crontab.5 Fri Apr 17 14:39:31 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: crontab.5,v 1.7 2018/06/15 23:15:56 wiz Exp $ +.\" $NetBSD: crontab.5,v 1.8 2020/04/17 18:39:31 christos Exp $ .\" .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved @@ -21,7 +21,7 @@ .\" .\" $OpenBSD: crontab.5,v 1.36 2018/06/13 13:27:37 jmc Exp $ .\" -.Dd June 14, 2018 +.Dd April 17, 2020 .Dt CRONTAB 5 .Os .Sh NAME @@ -141,12 +141,31 @@ or Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. +.Pp +A field may begin with a question mark +.Pq Sq \&? , +which indicates a single value randomly selected when the crontab +file is read. +If the field contains only a question mark, the value is randomly +selected from the range of all possible values for the field. +If the question mark precedes a range, the value is randomly selected +from the range. +For example, +.Dq ? ?2-5 * * * +specifies that a task will be performed daily between 2:00am and +and 5:59am at a time randomly selected when the crontab file is +first read. +As just one example, this feature can be used to prevent a large +number of hosts from contacting a server simultaneously and +overloading it by staggering the time at which a download script +is executed. For example, 8\(en11 for an .Ar hour entry specifies execution at hours 8, 9, 10 and 11. .Pp -Step values can be used in conjunction with ranges. +Step values can be used in conjunction with ranges (but not random ranges +which represent a single number). Following a range with .No / Ns Ar number specifies skips of
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: kre Date: Sat Jul 28 13:55:09 UTC 2018 Modified Files: src/external/bsd/cron/dist: entry.c Log Message: Add some more "crappy error detection" - the low value of the range of random_with_range() must not be negative (or now we are doing unsigned modulus we might generate a very big result). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/cron/dist/entry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.9 src/external/bsd/cron/dist/entry.c:1.10 --- src/external/bsd/cron/dist/entry.c:1.9 Sat Jul 28 13:51:26 2018 +++ src/external/bsd/cron/dist/entry.c Sat Jul 28 13:55:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $ */ +/* $NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $"); +__RCSID("$NetBSD: entry.c,v 1.10 2018/07/28 13:55:08 kre Exp $"); #endif #endif @@ -468,7 +468,7 @@ random_with_range(int low, int high) { /* Kind of crappy error detection, but... */ - if (low >= high) + if (low < 0 || low >= high) return low; else return (int)(arc4random() % (unsigned)((high - low + 1) + low));
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: kre Date: Sat Jul 28 13:51:26 UTC 2018 Modified Files: src/external/bsd/cron/dist: entry.c Log Message: Fix from Michael Kaufmann in PR bin/53476 Do modulus using unsigned arith, and then convert the result to int, rather than converting the arc4random() result to int (which might be negative) and performing a modulus on that (with a potentially negative answer). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/entry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.8 src/external/bsd/cron/dist/entry.c:1.9 --- src/external/bsd/cron/dist/entry.c:1.8 Thu Jun 14 22:04:28 2018 +++ src/external/bsd/cron/dist/entry.c Sat Jul 28 13:51:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.8 2018/06/14 22:04:28 christos Exp $ */ +/* $NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: entry.c,v 1.8 2018/06/14 22:04:28 christos Exp $"); +__RCSID("$NetBSD: entry.c,v 1.9 2018/07/28 13:51:26 kre Exp $"); #endif #endif @@ -471,7 +471,7 @@ random_with_range(int low, int high) if (low >= high) return low; else - return (int)arc4random() % (high - low + 1) + low; + return (int)(arc4random() % (unsigned)((high - low + 1) + low)); } static int
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: wiz Date: Fri Jun 15 23:15:56 UTC 2018 Modified Files: src/external/bsd/cron/dist: crontab.5 Log Message: Fix Dd argument. Remove unnecessary whitespace. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/crontab.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.6 src/external/bsd/cron/dist/crontab.5:1.7 --- src/external/bsd/cron/dist/crontab.5:1.6 Thu Jun 14 22:02:57 2018 +++ src/external/bsd/cron/dist/crontab.5 Fri Jun 15 23:15:56 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: crontab.5,v 1.6 2018/06/14 22:02:57 christos Exp $ +.\" $NetBSD: crontab.5,v 1.7 2018/06/15 23:15:56 wiz Exp $ .\" .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved @@ -21,7 +21,7 @@ .\" .\" $OpenBSD: crontab.5,v 1.36 2018/06/13 13:27:37 jmc Exp $ .\" -.Dd June 14 2018 +.Dd June 14, 2018 .Dt CRONTAB 5 .Os .Sh NAME @@ -261,7 +261,7 @@ The variable can be set to an alternate time zone in order to affect when the job is run. Note that this only affects the scheduling of the job, not the time zone -that the job perceives when it is run. +that the job perceives when it is run. If .Ev CRON_TZ is defined but empty @@ -277,7 +277,7 @@ On a heavily loaded system, or on a syst jobs will sometimes start later than originally intended, and by skipping non-critical jobs because of delays, system load can be lightened. -If +If .Ev CRON_WITHIN is defined but empty .Pq Ev CRON_WITHIN Ns = Ns \&"" ,
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Jun 14 22:04:28 UTC 2018 Modified Files: src/external/bsd/cron/dist: do_command.c entry.c funcs.h popen.c structs.h Log Message: Add -n (don't send mail if command exited normally) option. From OpenBSD via Job Snidjers. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/bsd/cron/dist/do_command.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/entry.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/funcs.h \ src/external/bsd/cron/dist/popen.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/structs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.12 src/external/bsd/cron/dist/do_command.c:1.13 --- src/external/bsd/cron/dist/do_command.c:1.12 Sat Feb 3 22:37:59 2018 +++ src/external/bsd/cron/dist/do_command.c Thu Jun 14 18:04:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.12 2018/02/04 03:37:59 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.13 2018/06/14 22:04:28 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.12 2018/02/04 03:37:59 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.13 2018/06/14 22:04:28 christos Exp $"); #endif #endif @@ -50,7 +50,9 @@ do_command(entry *e, user *u) { * vfork() is unsuitable, since we have much to do, and the parent * needs to be able to run off and fork other processes. */ - switch (fork()) { + + pid_t jobpid; + switch (jobpid = fork()) { case -1: log_it("CRON", getpid(), "error", "can't fork"); break; @@ -144,7 +146,7 @@ write_data(char *volatile input_data, in static int read_data(entry *e, const char *mailto, const char *usernm, char **envp, -int *stdout_pipe) +int *stdout_pipe, pid_t jobpid) { FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); FILE *mail = NULL; @@ -241,14 +243,43 @@ read_data(entry *e, const char *mailto, */ if (mailto) { - Debug(DPROC, ("[%ld] closing pipe to mail\n", (long)getpid())); - /* Note: the pclose will probably see - * the termination of the grandchild - * in addition to the mail process, since - * it (the grandchild) is likely to exit - * after closing its stdout. - */ - status = cron_pclose(mail); + if (e->flags & MAIL_WHEN_ERR) { + int jstatus = -1; + if (jobpid <= 0) +log_it("CRON", getpid(), "error", +"no job pid"); + else { +while (waitpid(jobpid, , WNOHANG) == -1) + if (errno != EINTR) { + log_it("CRON", getpid(), + "error", "no job pid"); + break; + } + } + /* If everything went well, and -n was set, _and_ we + * have mail, we won't be mailing... so shoot the + * messenger! + */ + if (WIFEXITED(jstatus) && WEXITSTATUS(jstatus) == 0) { +Debug(DPROC, ("[%ld] aborting pipe to mail\n", +(long)getpid())); +status = cron_pabort(mail); +mailto = NULL; + } + } + + if (mailto) { + Debug(DPROC, ("[%ld] closing pipe to mail\n", + (long)getpid())); + /* Note: the pclose will probably see + * the termination of the grandchild + * in addition to the mail process, since + * it (the grandchild) is likely to exit + * after closing its stdout. + */ + status = cron_pclose(mail); + mail = NULL; + } (void) signal(SIGCHLD, oldchld); } @@ -273,15 +304,16 @@ out: extern char **environ; static int exec_user_command(entry *e, char **envp, char *usernm, int *stdin_pipe, -int *stdout_pipe) +int *stdout_pipe, pid_t *jobpid) { char *homedir; - char * volatile *ep = envp; + char * volatile *ep; - switch (vfork()) { + switch (*jobpid = vfork()) { case -1: return -1; case 0: + ep = envp; Debug(DPROC, ("[%ld] grandchild process vfork()'ed\n", (long)getpid())); @@ -455,6 +487,7 @@ child_process(entry *e) { struct sigaction sact; char **envp = e->envp; int retval = OK_EXIT; + pid_t jobpid = 0; Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd)); @@ -538,7 +571,8 @@ child_process(entry *e) { /* fork again, this time so we can exec the user's command. */ - if (exec_user_command(e, envp, usernm, stdin_pipe, stdout_pipe) == -1) { + if (exec_user_command(e, envp, usernm, stdin_pipe, stdout_pipe, + ) == -1) { retval = ERROR_EXIT; goto child_process_end; } @@ -595,7 +629,7 @@ child_process(entry *e) { Debug(DPROC, ("[%ld] child reading output from grandchild\n", (long)getpid())); - retval = read_data(e, mailto, usernm, envp, stdout_pipe); + retval = read_data(e, mailto, usernm, envp, stdout_pipe, jobpid); if (retval) goto child_process_end; Index: src/external/bsd/cron/dist/entry.c diff
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Jun 14 22:02:57 UTC 2018 Modified Files: src/external/bsd/cron/dist: crontab.5 Log Message: Replace with the OpenBSD man page. It removes some historical comparisons that are not very useful (and trully if any they belong to a separate section instead of being interspersed in the document), and organizes and formats the information better. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/crontab.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.5 src/external/bsd/cron/dist/crontab.5:1.6 --- src/external/bsd/cron/dist/crontab.5:1.5 Tue Mar 18 14:20:36 2014 +++ src/external/bsd/cron/dist/crontab.5 Thu Jun 14 18:02:57 2018 @@ -1,25 +1,27 @@ -.\" $NetBSD: crontab.5,v 1.5 2014/03/18 18:20:36 riastradh Exp $ +.\" $NetBSD: crontab.5,v 1.6 2018/06/14 22:02:57 christos Exp $ .\" .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie .\" * All rights reserved -.\" * -.\" * Distribute freely, except: don't remove my name from the source or -.\" * documentation (don't take credit for my work), mark your changes (don't -.\" * get me blamed for your possible bugs), don't alter or remove this -.\" * notice. May be sold if buildable source is provided to buyer. No -.\" * warrantee of any kind, express or implied, is included with this -.\" * software; use at your own risk, responsibility for damages (if any) to -.\" * anyone resulting from the use of this software rests entirely with the -.\" * user. -.\" * -.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and -.\" * I'll try to keep a version up to date. I can be reached as follows: -.\" * Paul Vixieuunet!decwrl!vixie!paul .\" */ .\" -.\" Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp +.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (c) 1997,2000 by Internet Software Consortium, Inc. .\" -.Dd July 15, 2010 +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" $OpenBSD: crontab.5,v 1.36 2018/06/13 13:27:37 jmc Exp $ +.\" +.Dd June 14 2018 .Dt CRONTAB 5 .Os .Sh NAME @@ -31,274 +33,302 @@ A file contains instructions to the .Xr cron 8 daemon of the general form: -.Dq run this command at this time on this date . -Each user has their own crontab, and commands in any given crontab -will be executed as the user who owns the crontab. -Uucp and News will usually have their own crontabs, eliminating -the need for explicitly running -.Xr su 1 -as part of a cron command. -.Pp -Blank lines and leading spaces and tabs are ignored. -Lines whose first non-space character is a pound-sign -.Pq Sq # +.Dq at these times on these dates run this command . +There may be a system +.Nm +and each user may have their own +.Nm . +Commands in any given +.Nm +will be +executed either as the user who owns the +.Nm +or, in the case of the system +.Nm crontab , +as the user specified on the command line. +.Pp +While a +.Nm +is a text file, it is not intended to be directly edited. +Creation, modification, and removal of a +.Nm +should be done using +.Xr crontab 1 . +.Pp +Blank lines, leading spaces, and tabs are ignored. +Lines whose first non-space character is a pound sign +.Pq Ql # are comments, and are ignored. -Note that comments are not allowed on the same line as cron commands, since +Note that comments are not allowed on the same line as +.Xr cron 8 +commands, since they will be taken to be part of the command. Similarly, comments are not allowed on the same line as environment variable settings. .Pp -An active line in a crontab will be either an environment setting -or a cron command. -An environment setting is of the form, -.Bd -literal -name = value -.Ed -where the spaces around the equal-sign -.Pq Sq = +An active line in a +.Nm +is either an environment variable setting or a +.Xr cron 8 +command. +.Pp +Environment variable settings create the environment +any command in the +.Nm +is run in. +An environment variable setting is of the form: +.Pp +.Dl name = value +.Pp +The spaces around the equal sign +.Pq Ql = are optional, and any
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: htodd Date: Tue Mar 6 21:21:27 UTC 2018 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: Fix typo in function name. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.14 src/external/bsd/cron/dist/crontab.c:1.15 --- src/external/bsd/cron/dist/crontab.c:1.14 Fri Jun 9 17:36:30 2017 +++ src/external/bsd/cron/dist/crontab.c Tue Mar 6 21:21:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.14 2017/06/09 17:36:30 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.15 2018/03/06 21:21:27 htodd Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: crontab.c,v 1.14 2017/06/09 17:36:30 christos Exp $"); +__RCSID("$NetBSD: crontab.c,v 1.15 2018/03/06 21:21:27 htodd Exp $"); #endif #endif @@ -66,7 +66,7 @@ static void list_cmd(void), static int replace_cmd(void); static int allowed(const char *, const char *, const char *); static int in_file(const char *, FILE *, int); -static int relinguish_priv(void); +static int relinquish_priv(void); static int regain_priv(void); static __dead void @@ -265,7 +265,7 @@ parse_args(int argc, char *argv[]) { * the race. */ - if (relinguish_priv() < OK) { + if (relinquish_priv() < OK) { err(ERROR_EXIT, "swapping uids"); } if (!(NewCrontab = fopen(Filename, "r"))) { @@ -689,7 +689,7 @@ replace_cmd(void) { "# (%s installed on %-24.24s)\n", Filename, ctime()); (void)fprintf(tmp, "# (Cron version %s -- %s)\n", CRON_VERSION, - "$NetBSD: crontab.c,v 1.14 2017/06/09 17:36:30 christos Exp $"); + "$NetBSD: crontab.c,v 1.15 2018/03/06 21:21:27 htodd Exp $"); /* copy the crontab to the tmp */ @@ -882,7 +882,7 @@ in_file(const char *string, FILE *file, #ifdef HAVE_SAVED_UIDS -static int relinguish_priv(void) { +static int relinquish_priv(void) { return (setegid(rgid) || seteuid(ruid)) ? -1 : 0; } @@ -892,7 +892,7 @@ static int regain_priv(void) { #else /*HAVE_SAVED_UIDS*/ -static int relinguish_priv(void) { +static int relinquish_priv(void) { return (setregid(egid, rgid) || setreuid(euid, ruid)) ? -1 : 0; }
CVS commit: src/external/bsd/cron/bin/cron
Module Name:src Committed By: mrg Date: Wed Feb 7 06:17:07 UTC 2018 Modified Files: src/external/bsd/cron/bin/cron: Makefile Log Message: update for GCC 6: do_process has vfork() vs clobber issues To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/bin/cron/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/cron/Makefile diff -u src/external/bsd/cron/bin/cron/Makefile:1.6 src/external/bsd/cron/bin/cron/Makefile:1.7 --- src/external/bsd/cron/bin/cron/Makefile:1.6 Wed Jun 14 17:37:40 2017 +++ src/external/bsd/cron/bin/cron/Makefile Wed Feb 7 06:17:07 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2017/06/14 17:37:40 christos Exp $ +# $NetBSD: Makefile,v 1.7 2018/02/07 06:17:07 mrg Exp $ .include @@ -19,5 +19,6 @@ LDADD+= -lpam ${PAM_STATIC_LDADD} .endif CWARNFLAGS.clang+= -Wno-string-plus-int +CWARNFLAGS.gcc+= -Wno-error=clobbered .include
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sun Feb 4 03:37:59 UTC 2018 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: split out the child runner. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.11 src/external/bsd/cron/dist/do_command.c:1.12 --- src/external/bsd/cron/dist/do_command.c:1.11 Wed Sep 27 22:32:51 2017 +++ src/external/bsd/cron/dist/do_command.c Sat Feb 3 22:37:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.11 2017/09/28 02:32:51 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.12 2018/02/04 03:37:59 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.11 2017/09/28 02:32:51 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.12 2018/02/04 03:37:59 christos Exp $"); #endif #endif @@ -272,101 +272,15 @@ out: extern char **environ; static int -child_process(entry *e) { - int stdin_pipe[2], stdout_pipe[2]; - char * volatile input_data; - char *homedir, *usernm, * volatile mailto; - struct sigaction sact; - char **envp = e->envp; - int retval = OK_EXIT; - - Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd)); - - setproctitle("running job"); - - /* discover some useful and important environment settings - */ - usernm = e->pwd->pw_name; - mailto = env_get("MAILTO", envp); - - memset(, 0, sizeof(sact)); - sigemptyset(_mask); - sact.sa_flags = 0; -#ifdef SA_RESTART - sact.sa_flags |= SA_RESTART; -#endif - sact.sa_handler = sigchld_handler; - (void) sigaction(SIGCHLD, , NULL); - - /* create some pipes to talk to our future child - */ - if (pipe(stdin_pipe) == -1) /* child's stdin */ - log_it("CRON", getpid(), "error", "create child stdin pipe"); - if (pipe(stdout_pipe) == -1) /* child's stdout */ - log_it("CRON", getpid(), "error", "create child stdout pipe"); - - /* since we are a forked process, we can diddle the command string - * we were passed -- nobody else is going to use it again, right? - * - * if a % is present in the command, previous characters are the - * command, and subsequent characters are the additional input to - * the command. An escaped % will have the escape character stripped - * from it. Subsequent %'s will be transformed into newlines, - * but that happens later. - */ - /*local*/{ - int escaped = FALSE; - int ch; - char *p; - - /* translation: - * \% -> % - * % -> end of command, following is command input. - * \x -> \x for all x != % - */ - input_data = p = e->cmd; - while ((ch = *input_data++) != '\0') { - if (escaped) { -if (ch != '%') - *p++ = '\\'; - } else { -if (ch == '%') { - break; -} - } - - if (!(escaped = (ch == '\\'))) { -*p++ = (char)ch; - } - } - if (ch == '\0') { - /* move pointer back, so that code below - * won't think we encountered % sequence */ - input_data--; - } - if (escaped) - *p++ = '\\'; - - *p = '\0'; - } - -#ifdef USE_PAM - if (!cron_pam_start(usernm)) - return ERROR_EXIT; - - if (!(envp = cron_pam_getenvlist(envp))) { - retval = ERROR_EXIT; - goto child_process_end; - } -#endif +exec_user_command(entry *e, char **envp, char *usernm, int *stdin_pipe, +int *stdout_pipe) +{ + char *homedir; + char * volatile *ep = envp; - /* fork again, this time so we can exec the user's command. - */ switch (vfork()) { case -1: - retval = ERROR_EXIT; - goto child_process_end; - /*NOTREACHED*/ + return -1; case 0: Debug(DPROC, ("[%ld] grandchild process vfork()'ed\n", (long)getpid())); @@ -456,7 +370,7 @@ child_process(entry *e) { */ if (env_get("PATH", envp) == NULL && environ != NULL) { if ((p = getenv("PATH")) != NULL) - envp = env_set(envp, p); + ep = env_set(envp, p); } } #else @@ -489,7 +403,7 @@ child_process(entry *e) { } /* we aren't root after this... */ #endif /* LOGIN_CAP */ - homedir = env_get("HOME", envp); + homedir = env_get("HOME", __UNVOLATILE(ep)); if (chdir(homedir) != 0) { syslog(LOG_ERR, "chdir(%s) $HOME failed for %s: %m", homedir, e->pwd->pw_name); @@ -511,7 +425,7 @@ child_process(entry *e) { * Exec the command. */ { - char *shell = env_get("SHELL", envp); + char *shell = env_get("SHELL", __UNVOLATILE(ep)); # if DEBUGGING if (DebugFlags & DTEST) { @@ -526,12 +440,110 @@ child_process(entry *e) { warn("execl: couldn't exec `%s'", shell); _exit(ERROR_EXIT); } - break; + return 0; default: /* parent process */ - break; + return 0; + } +} + +static int +child_process(entry *e) { + int
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Sep 28 02:32:51 UTC 2017 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: Remove debugging log statement To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.10 src/external/bsd/cron/dist/do_command.c:1.11 --- src/external/bsd/cron/dist/do_command.c:1.10 Mon Sep 25 04:30:46 2017 +++ src/external/bsd/cron/dist/do_command.c Wed Sep 27 22:32:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.10 2017/09/25 08:30:46 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.11 2017/09/28 02:32:51 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.10 2017/09/25 08:30:46 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.11 2017/09/28 02:32:51 christos Exp $"); #endif #endif @@ -208,7 +208,6 @@ read_data(entry *e, const char *mailto, retval = ERROR_EXIT; goto out; } - log_itx(usernm, getpid(), "MAIL", "opened pipe `%s'", mailcmd); (void)fprintf(mail, "From: root (Cron Daemon)\n"); (void)fprintf(mail, "To: %s\n", mailto); (void)fprintf(mail, "Subject: Cron <%s@%s> %s\n",
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Mon Sep 25 08:30:46 UTC 2017 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: Factor out the read and write data code from the huge child_process function. When we create a pipe to read data, restore the sigchld signal handler since pclose expects to wait for the child (to avoid spurious error reporting later). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.9 src/external/bsd/cron/dist/do_command.c:1.10 --- src/external/bsd/cron/dist/do_command.c:1.9 Thu Aug 17 04:53:00 2017 +++ src/external/bsd/cron/dist/do_command.c Mon Sep 25 04:30:46 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.9 2017/08/17 08:53:00 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.10 2017/09/25 08:30:46 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.9 2017/08/17 08:53:00 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.10 2017/09/25 08:30:46 christos Exp $"); #endif #endif @@ -87,6 +87,190 @@ sigchld_handler(int signo) { } } +static void +write_data(char *volatile input_data, int *stdin_pipe, int *stdout_pipe) +{ + FILE *out = fdopen(stdin_pipe[WRITE_PIPE], "w"); + int need_newline = FALSE; + int escaped = FALSE; + int ch; + + Debug(DPROC, ("[%ld] child2 sending data to grandchild\n", + (long)getpid())); + +#ifdef USE_PAM + cron_pam_child_close(); +#else + log_close(); +#endif + + /* close the pipe we don't use, since we inherited it and + * are part of its reference count now. + */ + (void)close(stdout_pipe[READ_PIPE]); + + /* translation: + * \% -> % + * % -> \n + * \x -> \x for all x != % + */ + while ((ch = *input_data++) != '\0') { + if (escaped) { + if (ch != '%') +(void)putc('\\', out); + } else { + if (ch == '%') +ch = '\n'; + } + + if (!(escaped = (ch == '\\'))) { + (void)putc(ch, out); + need_newline = (ch != '\n'); + } + } + if (escaped) + (void)putc('\\', out); + if (need_newline) + (void)putc('\n', out); + + /* close the pipe, causing an EOF condition. fclose causes + * stdin_pipe[WRITE_PIPE] to be closed, too. + */ + (void)fclose(out); + + Debug(DPROC, ("[%ld] child2 done sending to grandchild\n", + (long)getpid())); +} + +static int +read_data(entry *e, const char *mailto, const char *usernm, char **envp, +int *stdout_pipe) +{ + FILE *in = fdopen(stdout_pipe[READ_PIPE], "r"); + FILE *mail = NULL; + int bytes = 1; + int status = 0; + int ch = getc(in); + int retval = 0; + sig_t oldchld = NULL; + + if (ch == EOF) + goto out; + + Debug(DPROC|DEXT, ("[%ld] got data (%x:%c) from grandchild\n", + (long)getpid(), ch, ch)); + + /* 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) { + /* ... but it's empty. set to NULL + */ + mailto = NULL; + } + } else { + /* MAILTO not present, set to USER. + */ + mailto = usernm; + } + + /* + * Unsafe, disable mailing. + */ + if (!safe_p(usernm, mailto)) + mailto = NULL; + + /* if we are supposed to be mailing, MAILTO will + * be non-NULL. only in this case should we set + * up the mail command and subjects and stuff... + */ + + if (mailto) { + char **env; + char mailcmd[MAX_COMMAND]; + char hostname[MAXHOSTNAMELEN + 1]; + + (void)gethostname(hostname, MAXHOSTNAMELEN); + if (strlens(MAILFMT, MAILARG, NULL) + 1 >= sizeof mailcmd) { + log_it(usernm, getpid(), "MAIL", "mailcmd too long"); + retval = ERROR_EXIT; + goto out; + } + (void)snprintf(mailcmd, sizeof(mailcmd), MAILFMT, MAILARG); + oldchld = signal(SIGCHLD, SIG_DFL); + if (!(mail = cron_popen(mailcmd, "w", e->pwd))) { + log_itx(usernm, getpid(), "MAIL", + "cannot run `%s'", mailcmd); + (void) signal(SIGCHLD, oldchld); + retval = ERROR_EXIT; + goto out; + } + log_itx(usernm, getpid(), "MAIL", "opened pipe `%s'", mailcmd); + (void)fprintf(mail, "From: root (Cron Daemon)\n"); + (void)fprintf(mail, "To: %s\n", mailto); + (void)fprintf(mail, "Subject: Cron <%s@%s> %s\n", + usernm, hostname, e->cmd); + (void)fprintf(mail, "Auto-Submitted: auto-generated\n"); +#ifdef MAIL_DATE + (void)fprintf(mail, "Date: %s\n", arpadate()); +#endif /*MAIL_DATE*/ + for (env = envp; *env; env++) + (void)fprintf(mail, "X-Cron-Env: <%s>\n", *env); + (void)fprintf(mail, "\n"); + + /* this was the first char from the pipe + */ + (void)putc(ch, mail); + } + + /* we have to read the input pipe no matter whether + * we mail or not, but
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Aug 17 08:53:01 UTC 2017 Modified Files: src/external/bsd/cron/dist: do_command.c funcs.h misc.c Log Message: - since we use log_it for cron_pclose() use log_it for cron_popen() too so we can see the reason it failed. - add log_itx() that takes a format and use it. - simplify with asprintf() To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/do_command.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/funcs.h \ src/external/bsd/cron/dist/misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.8 src/external/bsd/cron/dist/do_command.c:1.9 --- src/external/bsd/cron/dist/do_command.c:1.8 Fri Jun 9 13:36:30 2017 +++ src/external/bsd/cron/dist/do_command.c Thu Aug 17 04:53:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.8 2017/06/09 17:36:30 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.9 2017/08/17 08:53:00 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.8 2017/06/09 17:36:30 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.9 2017/08/17 08:53:00 christos Exp $"); #endif #endif @@ -484,14 +484,16 @@ child_process(entry *e) { (void)gethostname(hostname, MAXHOSTNAMELEN); if (strlens(MAILFMT, MAILARG, NULL) + 1 >= sizeof mailcmd) { - warnx("mailcmd too long"); + log_it(usernm, getpid(), "MAIL", + "mailcmd too long"); retval = ERROR_EXIT; goto child_process_end; } (void)snprintf(mailcmd, sizeof(mailcmd), MAILFMT, MAILARG); if (!(mail = cron_popen(mailcmd, "w", e->pwd))) { - warn("cannot run `%s'", mailcmd); + log_itx(usernm, getpid(), "MAIL", + "cannot run `%s'", mailcmd); retval = ERROR_EXIT; goto child_process_end; } @@ -549,13 +551,10 @@ child_process(entry *e) { * what's going on. */ if (mailto && status) { -char buf[MAX_TEMPSTR]; - -(void)snprintf(buf, sizeof(buf), - "mailed %d byte%s of output but got status 0x%04x\n", - bytes, (bytes==1)?"":"s", - status); -log_it(usernm, getpid(), "MAIL", buf); +log_itx(usernm, getpid(), "MAIL", +"mailed %d byte%s of output but got status" +" %#04x", bytes, bytes == 1 ? "" : "s", +status); } } /*if data from grandchild*/ Index: src/external/bsd/cron/dist/funcs.h diff -u src/external/bsd/cron/dist/funcs.h:1.4 src/external/bsd/cron/dist/funcs.h:1.5 --- src/external/bsd/cron/dist/funcs.h:1.4 Fri Jun 9 13:36:30 2017 +++ src/external/bsd/cron/dist/funcs.h Thu Aug 17 04:53:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: funcs.h,v 1.4 2017/06/09 17:36:30 christos Exp $ */ +/* $NetBSD: funcs.h,v 1.5 2017/08/17 08:53:00 christos Exp $ */ /* * Id: funcs.h,v 1.9 2004/01/23 18:56:42 vixie Exp @@ -44,6 +44,11 @@ void set_cron_uid(void), log_it(const char *, int, const char *, const char *), log_close(void); + +void + log_itx(const char *, int, const char *, const char *, ...) + __printflike(4, 5); + int job_runqueue(void), set_debug_flags(const char *), get_char(FILE *), Index: src/external/bsd/cron/dist/misc.c diff -u src/external/bsd/cron/dist/misc.c:1.4 src/external/bsd/cron/dist/misc.c:1.5 --- src/external/bsd/cron/dist/misc.c:1.4 Fri Jun 9 13:36:30 2017 +++ src/external/bsd/cron/dist/misc.c Thu Aug 17 04:53:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.4 2017/06/09 17:36:30 christos Exp $ */ +/* $NetBSD: misc.c,v 1.5 2017/08/17 08:53:00 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: misc.c,v 1.16 2004/01/23 18:56:43 vixie Exp"; #else -__RCSID("$NetBSD: misc.c,v 1.4 2017/06/09 17:36:30 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.5 2017/08/17 08:53:00 christos Exp $"); #endif #endif @@ -312,18 +312,16 @@ acquire_daemonlock(int closeflag) { pidfile = _PATH_CRON_PID; /* Initial mode is 0600 to prevent flock() race/DoS. */ if ((fd = open(pidfile, O_RDWR|O_CREAT, 0600)) == -1) { - (void)snprintf(buf, sizeof(buf), -"can't open or create %s: %s", -pidfile, strerror(errno)); - log_it("CRON", getpid(), "DEATH", buf); - errx(ERROR_EXIT, "%s", buf); + log_itx("CRON", getpid(), "DEATH", + "can't open or create %s: %s", + pidfile, strerror(errno)); + exit(ERROR_EXIT); } /* fd must be > STDERR since we dup fd 0-2 to /dev/null */ if (fd <= STDERR) { if (dup2(fd, STDERR + 1) < 0) { -snprintf(buf, sizeof buf, +log_itx("CRON", getpid(), "DEATH", "can't dup pid fd: %s", strerror(errno)); -log_it("CRON", getpid(), "DEATH", buf);
CVS commit: src/external/bsd/cron/bin/cron
Module Name:src Committed By: christos Date: Wed Jun 14 17:37:40 UTC 2017 Modified Files: src/external/bsd/cron/bin/cron: Makefile Log Message: unbreak static build To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/bin/cron/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/cron/Makefile diff -u src/external/bsd/cron/bin/cron/Makefile:1.5 src/external/bsd/cron/bin/cron/Makefile:1.6 --- src/external/bsd/cron/bin/cron/Makefile:1.5 Wed Jun 14 13:11:39 2017 +++ src/external/bsd/cron/bin/cron/Makefile Wed Jun 14 13:37:40 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2017/06/14 17:11:39 kamil Exp $ +# $NetBSD: Makefile,v 1.6 2017/06/14 17:37:40 christos Exp $ .include @@ -14,8 +14,8 @@ MAN= cron.8 .if (${MKPAM} != "no") SRCS+= pam_auth.c CPPFLAGS+= -DUSE_PAM -DPADD+= ${LIBPAM} -LDADD+= -lpam +DPADD+= ${LIBPAM} ${PAM_STATIC_DPADD} +LDADD+= -lpam ${PAM_STATIC_LDADD} .endif CWARNFLAGS.clang+= -Wno-string-plus-int
CVS commit: src/external/bsd/cron/bin/cron
Module Name:src Committed By: kamil Date: Wed Jun 14 17:11:39 UTC 2017 Modified Files: src/external/bsd/cron/bin/cron: Makefile Log Message: Unbreak MKPAM=no build Make cron(8) linkage with PAM conditional. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/bin/cron/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/cron/Makefile diff -u src/external/bsd/cron/bin/cron/Makefile:1.4 src/external/bsd/cron/bin/cron/Makefile:1.5 --- src/external/bsd/cron/bin/cron/Makefile:1.4 Fri Jun 9 17:36:29 2017 +++ src/external/bsd/cron/bin/cron/Makefile Wed Jun 14 17:11:39 2017 @@ -1,14 +1,23 @@ -# $NetBSD: Makefile,v 1.4 2017/06/09 17:36:29 christos Exp $ +# $NetBSD: Makefile,v 1.5 2017/06/14 17:11:39 kamil Exp $ + +.include BINDIR= /usr/sbin PROG= cron SRCS= cron.c database.c do_command.c entry.c env.c job.c \ - misc.c pam_auth.c popen.c pw_dup.c user.c -CPPFLAGS+=-I${.CURDIR} -DLOGIN_CAP -DUSE_PAM -DPADD+=${LIBPAM} ${LIBUTIL} -LDADD+=-lpam -lutil + misc.c popen.c pw_dup.c user.c +CPPFLAGS+=-I${.CURDIR} -DLOGIN_CAP +DPADD+= ${LIBUTIL} +LDADD+= -lutil MAN= cron.8 +.if (${MKPAM} != "no") +SRCS+= pam_auth.c +CPPFLAGS+= -DUSE_PAM +DPADD+= ${LIBPAM} +LDADD+= -lpam +.endif + CWARNFLAGS.clang+= -Wno-string-plus-int .include
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: joerg Date: Sun Jun 11 20:38:17 UTC 2017 Modified Files: src/external/bsd/cron/dist: pam_auth.c Log Message: Do not partially initialize a static variable. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/bsd/cron/dist/pam_auth.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/pam_auth.c diff -u src/external/bsd/cron/dist/pam_auth.c:1.1 src/external/bsd/cron/dist/pam_auth.c:1.2 --- src/external/bsd/cron/dist/pam_auth.c:1.1 Fri Jun 9 17:36:30 2017 +++ src/external/bsd/cron/dist/pam_auth.c Sun Jun 11 20:38:17 2017 @@ -5,7 +5,7 @@ #include static pam_handle_t *pamh = NULL; -static const struct pam_conv cron_conv = { 0 }; +static const struct pam_conv cron_conv; int cron_pam_start (const char *username)
CVS commit: src/external/bsd/cron
Module Name:src Committed By: christos Date: Fri Jun 9 17:36:30 UTC 2017 Modified Files: src/external/bsd/cron/bin/cron: Makefile src/external/bsd/cron/bin/crontab: Makefile src/external/bsd/cron/dist: Makefile config.h cron.c crontab.c database.c do_command.c funcs.h misc.c popen.c Added Files: src/external/bsd/cron/dist: closeall.c pam_auth.c Log Message: Apply selected patches from OpenWall: http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/vixie-cron/ 1. Add PAM support. 2. Sanitize children process reaping 3. futimens when we have an fd 4. close_all for crontab(8) 5. use a table for spool dirs instead of duplicating code. 6. handle errors from process_exit() 7. Add ENABLE_FIX_DIRECTORIES ifdef and enable it by default for compat 8. Avoid using fd's < STDERR Not applied: 1. no xfork (no setresuid) 2. did not do the lstat before open. 3. did not enable cron group To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/bin/cron/Makefile cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/bin/crontab/Makefile cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/Makefile cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/dist/closeall.c \ src/external/bsd/cron/dist/pam_auth.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/config.h \ src/external/bsd/cron/dist/popen.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/cron/dist/cron.c cvs rdiff -u -r1.13 -r1.14 src/external/bsd/cron/dist/crontab.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/database.c cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/do_command.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/funcs.h \ src/external/bsd/cron/dist/misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/cron/Makefile diff -u src/external/bsd/cron/bin/cron/Makefile:1.3 src/external/bsd/cron/bin/cron/Makefile:1.4 --- src/external/bsd/cron/bin/cron/Makefile:1.3 Fri Jun 22 16:32:34 2012 +++ src/external/bsd/cron/bin/cron/Makefile Fri Jun 9 13:36:29 2017 @@ -1,11 +1,12 @@ -# $NetBSD: Makefile,v 1.3 2012/06/22 20:32:34 abs Exp $ +# $NetBSD: Makefile,v 1.4 2017/06/09 17:36:29 christos Exp $ BINDIR= /usr/sbin PROG= cron SRCS= cron.c database.c do_command.c entry.c env.c job.c \ - misc.c popen.c pw_dup.c user.c -CPPFLAGS+=-I${.CURDIR} -DLOGIN_CAP -LDADD+=-lutil + misc.c pam_auth.c popen.c pw_dup.c user.c +CPPFLAGS+=-I${.CURDIR} -DLOGIN_CAP -DUSE_PAM +DPADD+=${LIBPAM} ${LIBUTIL} +LDADD+=-lpam -lutil MAN= cron.8 CWARNFLAGS.clang+= -Wno-string-plus-int Index: src/external/bsd/cron/bin/crontab/Makefile diff -u src/external/bsd/cron/bin/crontab/Makefile:1.2 src/external/bsd/cron/bin/crontab/Makefile:1.3 --- src/external/bsd/cron/bin/crontab/Makefile:1.2 Fri May 7 17:54:07 2010 +++ src/external/bsd/cron/bin/crontab/Makefile Fri Jun 9 13:36:29 2017 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2010/05/07 21:54:07 christos Exp $ +# $NetBSD: Makefile,v 1.3 2017/06/09 17:36:29 christos Exp $ .include USE_FORT?= yes # setuid PROG= crontab -SRCS= crontab.c misc.c entry.c env.c pw_dup.c +SRCS= crontab.c misc.c entry.c env.c pw_dup.c closeall.c CPPFLAGS+=-I${.CURDIR} -DDEBUGGING=1 BINOWN =root BINMODE=4555 Index: src/external/bsd/cron/dist/Makefile diff -u src/external/bsd/cron/dist/Makefile:1.2 src/external/bsd/cron/dist/Makefile:1.3 --- src/external/bsd/cron/dist/Makefile:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/Makefile Fri Jun 9 13:36:30 2017 @@ -86,14 +86,14 @@ MANPAGES = bitstring.3 crontab.5 crontab HEADERS = bitstring.h cron.h config.h pathnames.h externs.h \ macros.h structs.h funcs.h globals.h SOURCES = cron.c crontab.c database.c do_command.c entry.c \ - env.c job.c user.c popen.c misc.c pw_dup.c + env.c job.c user.c popen.c misc.c pam_auth.c pw_dup.c SHAR_SOURCE = $(INFOS) $(MANPAGES) Makefile $(HEADERS) $(SOURCES) LINT_CRON = cron.c database.c user.c entry.c \ misc.c job.c do_command.c env.c popen.c pw_dup.c LINT_CRONTAB = crontab.c misc.c entry.c env.c CRON_OBJ = cron.o database.o user.o entry.o job.o do_command.o \ misc.o env.o popen.o pw_dup.o -CRONTAB_OBJ = crontab.o misc.o entry.o env.o pw_dup.o +CRONTAB_OBJ = crontab.o misc.o entry.o env.o pw_dup.o closeall.o all : cron crontab Index: src/external/bsd/cron/dist/config.h diff -u src/external/bsd/cron/dist/config.h:1.4 src/external/bsd/cron/dist/config.h:1.5 --- src/external/bsd/cron/dist/config.h:1.4 Sat Nov 3 11:39:23 2012 +++ src/external/bsd/cron/dist/config.h Fri Jun 9 13:36:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.4 2012/11/03 15:39:23 christos Exp $ */ +/* $NetBSD: config.h,v 1.5 2017/06/09 17:36:30 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -94,6 +94,7 @@ #define HAVE_FCHOWN /*-*/ #define HAVE_UTIMES /*-*/ #define HAVE_UTIMENSAT +#define
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Dec 17 22:36:48 UTC 2015 Modified Files: src/external/bsd/cron/dist: do_command.c funcs.h misc.c Log Message: I am having the last_word: Print the full hostname. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/do_command.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/funcs.h \ src/external/bsd/cron/dist/misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.6 src/external/bsd/cron/dist/do_command.c:1.7 --- src/external/bsd/cron/dist/do_command.c:1.6 Fri Sep 5 17:32:37 2014 +++ src/external/bsd/cron/dist/do_command.c Thu Dec 17 17:36:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.7 2015/12/17 22:36:48 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $"); +__RCSID("$NetBSD: do_command.c,v 1.7 2015/12/17 22:36:48 christos Exp $"); #endif #endif @@ -454,7 +454,7 @@ child_process(entry *e) { (void)fprintf(mail, "To: %s\n", mailto); (void)fprintf(mail, "Subject: Cron <%s@%s> %s\n", -usernm, first_word(hostname, "."), e->cmd); +usernm, hostname, e->cmd); (void)fprintf(mail, "Auto-Submitted: auto-generated\n"); #ifdef MAIL_DATE Index: src/external/bsd/cron/dist/funcs.h diff -u src/external/bsd/cron/dist/funcs.h:1.2 src/external/bsd/cron/dist/funcs.h:1.3 --- src/external/bsd/cron/dist/funcs.h:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/funcs.h Thu Dec 17 17:36:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: funcs.h,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: funcs.h,v 1.3 2015/12/17 22:36:48 christos Exp $ */ /* * Id: funcs.h,v 1.9 2004/01/23 18:56:42 vixie Exp @@ -59,7 +59,6 @@ size_t strlens(const char *, ...); char *env_get(const char *, char **), *arpadate(time_t *), *mkprints(char *, size_t), - *first_word(char *, const char *), **env_init(void), **env_copy(char **), **env_set(char **, char *); Index: src/external/bsd/cron/dist/misc.c diff -u src/external/bsd/cron/dist/misc.c:1.2 src/external/bsd/cron/dist/misc.c:1.3 --- src/external/bsd/cron/dist/misc.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/misc.c Thu Dec 17 17:36:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: misc.c,v 1.3 2015/12/17 22:36:48 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = "Id: misc.c,v 1.16 2004/01/23 18:56:43 vixie Exp"; #else -__RCSID("$NetBSD: misc.c,v 1.2 2010/05/06 18:53:17 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.3 2015/12/17 22:36:48 christos Exp $"); #endif #endif @@ -497,41 +497,6 @@ log_close(void) { #endif /*SYSLOG*/ } -/* char *first_word(char *s, char *t) - * return pointer to first word - * parameters: - * s - string we want the first word of - * t - terminators, implicitly including \0 - * warnings: - * (1) this routine is fairly slow - * (2) it returns a pointer to static storage - */ -char * -first_word(char *s, const char *t) { - static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */ - static int retsel = 0; - char *rb, *rp; - - /* select a return buffer */ - retsel = 1-retsel; - rb = [retsel][0]; - rp = rb; - - /* skip any leading terminators */ - while (*s && (NULL != strchr(t, *s))) { - s++; - } - - /* copy until next terminator or full buffer */ - while (*s && (NULL == strchr(t, *s)) && (rp < [MAX_TEMPSTR])) { - *rp++ = *s++; - } - - /* finish the return-string and return it */ - *rp = '\0'; - return (rb); -} - /* warning: * heavily ascii-dependent. */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri Nov 20 23:43:52 UTC 2015 Modified Files: src/external/bsd/cron/dist: entry.c Log Message: fix type To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/entry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.6 src/external/bsd/cron/dist/entry.c:1.7 --- src/external/bsd/cron/dist/entry.c:1.6 Fri Sep 5 17:32:37 2014 +++ src/external/bsd/cron/dist/entry.c Fri Nov 20 18:43:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.6 2014/09/05 21:32:37 christos Exp $ */ +/* $NetBSD: entry.c,v 1.7 2015/11/20 23:43:52 christos Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = "Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp"; #else -__RCSID("$NetBSD: entry.c,v 1.6 2014/09/05 21:32:37 christos Exp $"); +__RCSID("$NetBSD: entry.c,v 1.7 2015/11/20 23:43:52 christos Exp $"); #endif #endif @@ -420,7 +420,7 @@ get_list(bitstr_t *bits, int low, int hi /* clear the bit string, since the default is 'off'. */ - bit_nclear(bits, 0, (high-low+1)); + bit_nclear(bits, 0, (size_t)(high-low+1)); /* process all ranges */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: joerg Date: Sun Jan 4 18:45:17 UTC 2015 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: bail is dead. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.12 src/external/bsd/cron/dist/crontab.c:1.13 --- src/external/bsd/cron/dist/crontab.c:1.12 Mon Dec 15 16:45:26 2014 +++ src/external/bsd/cron/dist/crontab.c Sun Jan 4 18:45:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.12 2014/12/15 16:45:26 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.13 2015/01/04 18:45:17 joerg Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.12 2014/12/15 16:45:26 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.13 2015/01/04 18:45:17 joerg Exp $); #endif #endif @@ -612,7 +612,7 @@ cleanTempFile(void) } } -static void +static __dead void bail(int signo) { @@ -682,7 +682,7 @@ replace_cmd(void) { # (%s installed on %-24.24s)\n, Filename, ctime(now)); (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, - $NetBSD: crontab.c,v 1.12 2014/12/15 16:45:26 christos Exp $); + $NetBSD: crontab.c,v 1.13 2015/01/04 18:45:17 joerg Exp $); /* copy the crontab to the tmp */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Mon Dec 15 16:45:26 UTC 2014 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: - Don't allow bypassing file size limits with crontabs from stdin. - Allow signals while reading the user crontab file; doing crontab - does not let you abort otherwise, and doing ^Z, kill %1 leaves turds in /var/cron/tabs To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.11 src/external/bsd/cron/dist/crontab.c:1.12 --- src/external/bsd/cron/dist/crontab.c:1.11 Sun Sep 7 09:34:12 2014 +++ src/external/bsd/cron/dist/crontab.c Mon Dec 15 11:45:26 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.11 2014/09/07 13:34:12 joerg Exp $ */ +/* $NetBSD: crontab.c,v 1.12 2014/12/15 16:45:26 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.11 2014/09/07 13:34:12 joerg Exp $); +__RCSID($NetBSD: crontab.c,v 1.12 2014/12/15 16:45:26 christos Exp $); #endif #endif @@ -169,7 +169,7 @@ compare_time(const struct stat *st, cons { struct timespec ts1[2]; get_time(st, ts1); - + return ts1[1].tv_sec == ts2[1].tv_sec #if defined(HAVE_UTIMENSAT) ts1[1].tv_nsec == ts2[1].tv_nsec @@ -286,7 +286,7 @@ skip_header(int *pch, FILE *f) { int ch; int x; - + /* ignore the top few comments since we probably put them there. */ for (x = 0; x NHEADER_LINES; x++) { @@ -554,15 +554,81 @@ edit_cmd(void) { log_it(RealUser, Pid, END EDIT, User); } +static size_t +getmaxtabsize(void) +{ + char n2[MAX_FNAME]; + FILE *fmaxtabsize; + size_t maxtabsize; + + /* Make sure that the crontab is not an unreasonable size. + * + * XXX This is subject to a race condition--the user could + * add stuff to the file after we've checked the size but + * before we slurp it in and write it out. We can't just move + * the test to test the temp file we later create, because by + * that time we've already filled up the crontab disk. Probably + * the right thing to do is to do a bytecount in the copy loop + * rather than stating the file we're about to read. + */ + (void)snprintf(n2, sizeof(n2), %s/%s, CRONDIR, MAXTABSIZE_FILE); + if ((fmaxtabsize = fopen(n2, r)) != NULL) { + if (fgets(n2, (int)sizeof(n2), fmaxtabsize) == NULL) { + maxtabsize = 0; + } else { + maxtabsize = (size_t)atoi(n2); + } + (void)fclose(fmaxtabsize); + } else { + maxtabsize = MAXTABSIZE_DEFAULT; + } + return maxtabsize; +} + +static int +checkmaxtabsize(FILE *fp, size_t maxtabsize) +{ + struct stat statbuf; + + if (fstat(fileno(fp), statbuf)) { + warn(error stat'ing crontab input); + return 0; + } + if ((uintmax_t)statbuf.st_size (uintmax_t)maxtabsize) { + warnx(%ju bytes is larger than the maximum size of %ju bytes, + (uintmax_t)statbuf.st_size, (uintmax_t)maxtabsize); + return 0; + } + return 1; +} + +static void +cleanTempFile(void) +{ + + if (TempFilename[0]) { + (void) unlink(TempFilename); + TempFilename[0] = '\0'; + } +} + +static void +bail(int signo) +{ + + cleanTempFile(); + errx(ERROR_EXIT, Exiting on signal %d, signo); +} + /* returns 0 on success * -1 on syntax error * -2 on install error */ static int replace_cmd(void) { - char n[MAX_FNAME], n2[MAX_FNAME], envstr[MAX_ENVSTR]; + char n[MAX_FNAME], envstr[MAX_ENVSTR]; int lastch; - FILE *tmp, *fmaxtabsize; + FILE *tmp = NULL; int ch, eof, fd; int error = 0; entry *e; @@ -570,8 +636,7 @@ replace_cmd(void) { uid_t file_owner; time_t now = time(NULL); char **envp = env_init(); - size_t maxtabsize; - struct stat statbuf; + size_t i, maxtabsize; if (envp == NULL) { warn(Cannot allocate memory.); @@ -584,71 +649,62 @@ replace_cmd(void) { warnx(path too long); return (-2); } + + /* Interruptible while doing I/O */ + ohup = signal(SIGHUP, bail); + oint = signal(SIGINT, bail); + oquit = signal(SIGQUIT, bail); + oabrt = signal(SIGABRT, bail); + if ((fd = mkstemp(TempFilename)) == -1 || !(tmp = fdopen(fd, w+))) { warn(cannot create `%s', TempFilename); - if (fd != -1) { + if (fd != -1) (void)close(fd); - (void)unlink(TempFilename); - } - TempFilename[0] = '\0'; - return (-2); + error = -2; + goto done; } - ohup = signal(SIGHUP, SIG_IGN); - oint = signal(SIGINT, SIG_IGN); - oquit = signal(SIGQUIT, SIG_IGN); - oabrt = signal(SIGABRT, SIG_IGN); - - /* Make sure that the crontab is not an unreasonable size. - * - * XXX This is subject to a race condition--the user could - * add stuff to the file after we've checked the size but - * before we slurp it in and write it out. We can't just move - * the test
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: joerg Date: Sun Sep 7 13:34:12 UTC 2014 Modified Files: src/external/bsd/cron/dist: cron.c crontab.c Log Message: Mark usage and quit as dead. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/cron.c cvs rdiff -u -r1.10 -r1.11 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.8 src/external/bsd/cron/dist/cron.c:1.9 --- src/external/bsd/cron/dist/cron.c:1.8 Fri Sep 5 21:32:37 2014 +++ src/external/bsd/cron/dist/cron.c Sun Sep 7 13:34:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $ */ +/* $NetBSD: cron.c,v 1.9 2014/09/07 13:34:12 joerg Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.9 2014/09/07 13:34:12 joerg Exp $); #endif #endif @@ -35,7 +35,7 @@ __RCSID($NetBSD: cron.c,v 1.8 2014/09/0 enum timejump { negative, small, medium, large }; -static void usage(void), +static void usage(void) __dead, run_reboot_jobs(cron_db *), find_jobs(time_t, cron_db *, int, int), set_time(int), @@ -43,7 +43,7 @@ static void usage(void), sigchld_handler(int), sighup_handler(int), sigchld_reaper(void), - quit(int), + quit(int) __dead, parse_args(int c, char *v[]); static volatile sig_atomic_t got_sighup, got_sigchld; Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.10 src/external/bsd/cron/dist/crontab.c:1.11 --- src/external/bsd/cron/dist/crontab.c:1.10 Sat Sep 6 12:18:49 2014 +++ src/external/bsd/cron/dist/crontab.c Sun Sep 7 13:34:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.11 2014/09/07 13:34:12 joerg Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.11 2014/09/07 13:34:12 joerg Exp $); #endif #endif @@ -69,7 +69,7 @@ static int in_file(const char *, FILE static int relinguish_priv(void); static int regain_priv(void); -static void +static __dead void usage(const char *msg) { (void)fprintf(stderr, %s: usage error: %s\n, getprogname(), msg); (void)fprintf(stderr, usage:\t%s [-u user] file\n, getprogname()); @@ -639,7 +639,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.11 2014/09/07 13:34:12 joerg Exp $); /* copy the crontab to the tmp */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: tron Date: Sun Sep 7 13:35:27 UTC 2014 Modified Files: src/external/bsd/cron/dist: env.c Log Message: Make crontab(1) work again which got broken by the last commit. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/env.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/env.c diff -u src/external/bsd/cron/dist/env.c:1.3 src/external/bsd/cron/dist/env.c:1.4 --- src/external/bsd/cron/dist/env.c:1.3 Fri Sep 5 21:32:37 2014 +++ src/external/bsd/cron/dist/env.c Sun Sep 7 13:35:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: env.c,v 1.3 2014/09/05 21:32:37 christos Exp $ */ +/* $NetBSD: env.c,v 1.4 2014/09/07 13:35:27 tron Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: env.c,v 1.10 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: env.c,v 1.3 2014/09/05 21:32:37 christos Exp $); +__RCSID($NetBSD: env.c,v 1.4 2014/09/07 13:35:27 tron Exp $); #endif #endif @@ -58,9 +58,9 @@ env_copy(char **envp) { for (count = 0; envp[count] != NULL; count++) continue; p = malloc((count + 1) * sizeof(*p)); /* 1 for the NULL */ - if (p != NULL) - return NULL; - for (i = 0; i count; i++) + if (p == NULL) + return NULL; + for (i = 0; i count; i++) { if ((p[i] = strdup(envp[i])) == NULL) { save_errno = errno; for (count = 0; count i; count++) @@ -69,6 +69,7 @@ env_copy(char **envp) { errno = save_errno; return NULL; } + } p[count] = NULL; return p; }
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sat Sep 6 12:18:49 UTC 2014 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: store lastch to an int so that EOF is handled properly. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.9 src/external/bsd/cron/dist/crontab.c:1.10 --- src/external/bsd/cron/dist/crontab.c:1.9 Fri Sep 5 17:32:37 2014 +++ src/external/bsd/cron/dist/crontab.c Sat Sep 6 08:18:49 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $); #endif #endif @@ -560,7 +560,8 @@ edit_cmd(void) { */ static int replace_cmd(void) { - char n[MAX_FNAME], n2[MAX_FNAME], envstr[MAX_ENVSTR], lastch; + char n[MAX_FNAME], n2[MAX_FNAME], envstr[MAX_ENVSTR]; + int lastch; FILE *tmp, *fmaxtabsize; int ch, eof, fd; int error = 0; @@ -638,7 +639,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.10 2014/09/06 12:18:49 christos Exp $); /* copy the crontab to the tmp */ @@ -648,7 +649,7 @@ replace_cmd(void) { while (EOF != (ch = get_char(NewCrontab))) (void)putc(lastch = (char)ch, tmp); - if (lastch != (char)EOF lastch != '\n') { + if (lastch != EOF lastch != '\n') { warnx(missing trailing newline in `%s', Filename); error = -1; goto done;
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri Sep 5 20:55:11 UTC 2014 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: Rewind the file before we install it so that we can check it. Before this fix, no checks were made and you could install crap. XXX: pullup 7 To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.7 src/external/bsd/cron/dist/crontab.c:1.8 --- src/external/bsd/cron/dist/crontab.c:1.7 Sat Nov 3 13:33:01 2012 +++ src/external/bsd/cron/dist/crontab.c Fri Sep 5 16:55:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $); #endif #endif @@ -638,7 +638,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $); /* copy the crontab to the tmp */ @@ -680,6 +680,7 @@ replace_cmd(void) { */ Set_LineNum(1 - NHEADER_LINES); CheckErrorCount = 0; eof = FALSE; + rewind(tmp); while (!CheckErrorCount !eof) { switch (load_env(envstr, tmp)) { case ERR:
CVS commit: src/external/bsd/cron
Module Name:src Committed By: christos Date: Fri Sep 5 21:32:37 UTC 2014 Modified Files: src/external/bsd/cron/bin: Makefile.inc src/external/bsd/cron/dist: cron.c crontab.c do_command.c entry.c env.c popen.c Log Message: WARNS=6 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/bin/Makefile.inc cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/cron.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/cron/dist/crontab.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/do_command.c \ src/external/bsd/cron/dist/entry.c cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/env.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/popen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/Makefile.inc diff -u src/external/bsd/cron/bin/Makefile.inc:1.2 src/external/bsd/cron/bin/Makefile.inc:1.3 --- src/external/bsd/cron/bin/Makefile.inc:1.2 Fri Sep 16 12:41:20 2011 +++ src/external/bsd/cron/bin/Makefile.inc Fri Sep 5 17:32:37 2014 @@ -1,5 +1,5 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/09/16 16:41:20 joerg Exp $ +# $NetBSD: Makefile.inc,v 1.3 2014/09/05 21:32:37 christos Exp $ .PATH: ${.PARSEDIR}/../dist -WARNS?= 4 -CWARNFLAGS+= -Wno-missing-noreturn +WARNS?= 6 +#CPPFLAGS+= -DDEBUGGING Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.7 src/external/bsd/cron/dist/cron.c:1.8 --- src/external/bsd/cron/dist/cron.c:1.7 Sat Oct 2 08:22:20 2010 +++ src/external/bsd/cron/dist/cron.c Fri Sep 5 17:32:37 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $ */ +/* $NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $); +__RCSID($NetBSD: cron.c,v 1.8 2014/09/05 21:32:37 christos Exp $); #endif #endif @@ -39,7 +39,7 @@ static void usage(void), run_reboot_jobs(cron_db *), find_jobs(time_t, cron_db *, int, int), set_time(int), - cron_sleep(int), + cron_sleep(time_t), sigchld_handler(int), sighup_handler(int), sigchld_reaper(void), @@ -131,7 +131,7 @@ main(int argc, char *argv[]) { * clockTime: is the time when set_time was last called. */ for (;;) { - int timeDiff; + time_t timeDiff; enum timejump wakeupKind; /* ... wait for the time (in minutes) to change ... */ @@ -169,8 +169,8 @@ main(int argc, char *argv[]) { * (wokeup late) run jobs for each virtual * minute until caught up. */ -Debug(DSCH, ([%ld], normal case %d minutes to go\n, -(long)getpid(), timeDiff)); +Debug(DSCH, ([%jd], normal case %jd minutes to go\n, +(intmax_t)getpid(), (intmax_t)timeDiff)); do { if (job_runqueue()) (void)sleep(10); @@ -192,8 +192,8 @@ main(int argc, char *argv[]) { * have a chance to run, and we do our * housekeeping. */ -Debug(DSCH, ([%ld], DST begins %d minutes to go\n, -(long)getpid(), timeDiff)); +Debug(DSCH, ([%jd], DST begins %jd minutes to go\n, +(intmax_t)getpid(), (intmax_t)timeDiff)); /* run wildcard jobs for current minute */ find_jobs(timeRunning, database, TRUE, FALSE); @@ -218,8 +218,8 @@ main(int argc, char *argv[]) { * not be repeated. Virtual time does not * change until we are caught up. */ -Debug(DSCH, ([%ld], DST ends %d minutes to go\n, -(long)getpid(), timeDiff)); +Debug(DSCH, ([%jd], DST ends %jd minutes to go\n, +(intmax_t)getpid(), (intmax_t)timeDiff)); find_jobs(timeRunning, database, TRUE, FALSE); break; default: @@ -458,7 +458,7 @@ set_time(int initialize) { * Try to just hit the next minute. */ static void -cron_sleep(int target) { +cron_sleep(time_t target) { time_t t1, t2; int seconds_to_wait; Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.8 src/external/bsd/cron/dist/crontab.c:1.9 --- src/external/bsd/cron/dist/crontab.c:1.8 Fri Sep 5 16:55:11 2014 +++ src/external/bsd/cron/dist/crontab.c Fri Sep 5 17:32:37 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.8 2014/09/05 20:55:11 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.9 2014/09/05 21:32:37 christos Exp $); #endif #endif @@ -613,7 +613,7 @@ replace_cmd(void) { if (fgets(n2, (int)sizeof(n2), fmaxtabsize) == NULL) { maxtabsize = 0; } else { - maxtabsize =
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: skrll Date: Tue Jun 24 09:17:54 UTC 2014 Modified Files: src/external/bsd/cron/dist: entry.c Log Message: PR/48944: cron ignores '?' (question mark) time field Fix the obvious merge botch. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/entry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.4 src/external/bsd/cron/dist/entry.c:1.5 --- src/external/bsd/cron/dist/entry.c:1.4 Thu Jul 15 20:03:28 2010 +++ src/external/bsd/cron/dist/entry.c Tue Jun 24 09:17:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.4 2010/07/15 20:03:28 christos Exp $ */ +/* $NetBSD: entry.c,v 1.5 2014/06/24 09:17:54 skrll Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: entry.c,v 1.4 2010/07/15 20:03:28 christos Exp $); +__RCSID($NetBSD: entry.c,v 1.5 2014/06/24 09:17:54 skrll Exp $); #endif #endif @@ -479,7 +479,6 @@ get_range(bitstr_t *bits, int low, int h if (ch == EOF) return (EOF); } else if (ch == '?') { - } else if (ch == '?') { qmark = TRUE; ch = get_char(file); if (ch == EOF)
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Mon Jun 23 01:00:48 UTC 2014 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: even more detailed logging To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.4 src/external/bsd/cron/dist/do_command.c:1.5 --- src/external/bsd/cron/dist/do_command.c:1.4 Sat Jun 21 00:33:53 2014 +++ src/external/bsd/cron/dist/do_command.c Sun Jun 22 21:00:48 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.4 2014/06/21 04:33:53 dholland Exp $ */ +/* $NetBSD: do_command.c,v 1.5 2014/06/23 01:00:48 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: do_command.c,v 1.4 2014/06/21 04:33:53 dholland Exp $); +__RCSID($NetBSD: do_command.c,v 1.5 2014/06/23 01:00:48 christos Exp $); #endif #endif @@ -71,7 +71,7 @@ static void child_process(entry *e) { int stdin_pipe[2], stdout_pipe[2]; char * volatile input_data; - char *usernm, * volatile mailto; + char *homedir, *usernm, * volatile mailto; int children = 0; Debug(DPROC, ([%ld] child_process('%s')\n, (long)getpid(), e-cmd)); @@ -243,33 +243,33 @@ child_process(entry *e) { } #else if (setgid(e-pwd-pw_gid) != 0) { - syslog(LOG_ERR, setgid failed for %s, - e-pwd-pw_name); + syslog(LOG_ERR, setgid(%d) failed for %s: %m, + e-pwd-pw_gid, e-pwd-pw_name); _exit(ERROR_EXIT); } if (initgroups(usernm, e-pwd-pw_gid) != 0) { - syslog(LOG_ERR, initgroups failed for %s, - e-pwd-pw_name); + syslog(LOG_ERR, initgroups(%s, %d) failed for %s: %m, + usernm, e-pwd-pw_gid, e-pwd-pw_name); _exit(ERROR_EXIT); } #if (defined(BSD)) (BSD = 199103) if (setlogin(usernm) 0) { - syslog(LOG_ERR, setlogin() failure for %s: %m, - e-pwd-pw_name); + syslog(LOG_ERR, setlogin(%s) failure for %s: %m, + usernm, e-pwd-pw_name); _exit(ERROR_EXIT); } #endif /* BSD */ if (setuid(e-pwd-pw_uid) != 0) { - syslog(LOG_ERR, setuid failed for %s, - e-pwd-pw_name); + syslog(LOG_ERR, setuid(%d) failed for %s: %m, + e-pwd-pw_uid, e-pwd-pw_name); _exit(ERROR_EXIT); } /* we aren't root after this... */ #endif /* LOGIN_CAP */ - - if (chdir(env_get(HOME, e-envp)) != 0) { - syslog(LOG_ERR, chdir $HOME failed for %s, - e-pwd-pw_name); + homedir = env_get(HOME, e-envp); + if (chdir(homedir) != 0) { + syslog(LOG_ERR, chdir(%s) $HOME failed for %s: %m, + homedir, e-pwd-pw_name); _exit(ERROR_EXIT); }
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: dholland Date: Sat Jun 21 04:33:53 UTC 2014 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: Log some actual information on various failures, so you can tell what happened. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.3 src/external/bsd/cron/dist/do_command.c:1.4 --- src/external/bsd/cron/dist/do_command.c:1.3 Sun Jul 17 01:14:25 2011 +++ src/external/bsd/cron/dist/do_command.c Sat Jun 21 04:33:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.3 2011/07/17 01:14:25 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.4 2014/06/21 04:33:53 dholland Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: do_command.c,v 1.3 2011/07/17 01:14:25 christos Exp $); +__RCSID($NetBSD: do_command.c,v 1.4 2014/06/21 04:33:53 dholland Exp $); #endif #endif @@ -243,28 +243,33 @@ child_process(entry *e) { } #else if (setgid(e-pwd-pw_gid) != 0) { - syslog(LOG_ERR, setgid failed); + syslog(LOG_ERR, setgid failed for %s, + e-pwd-pw_name); _exit(ERROR_EXIT); } if (initgroups(usernm, e-pwd-pw_gid) != 0) { - syslog(LOG_ERR, initgroups failed); + syslog(LOG_ERR, initgroups failed for %s, + e-pwd-pw_name); _exit(ERROR_EXIT); } #if (defined(BSD)) (BSD = 199103) if (setlogin(usernm) 0) { - syslog(LOG_ERR, setlogin() failure: %m); + syslog(LOG_ERR, setlogin() failure for %s: %m, + e-pwd-pw_name); _exit(ERROR_EXIT); } #endif /* BSD */ if (setuid(e-pwd-pw_uid) != 0) { - syslog(LOG_ERR, setuid failed); + syslog(LOG_ERR, setuid failed for %s, + e-pwd-pw_name); _exit(ERROR_EXIT); } /* we aren't root after this... */ #endif /* LOGIN_CAP */ if (chdir(env_get(HOME, e-envp)) != 0) { - syslog(LOG_ERR, chdir $HOME failed); + syslog(LOG_ERR, chdir $HOME failed for %s, + e-pwd-pw_name); _exit(ERROR_EXIT); }
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Mon Dec 24 19:30:46 UTC 2012 Modified Files: src/external/bsd/cron/dist: database.c Log Message: PR/47362: Brian Marcotte: cron is too restrictive on file permissions Allow file being writable by owner. XXX: pullup to 6. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/bsd/cron/dist/database.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/database.c diff -u src/external/bsd/cron/dist/database.c:1.7 src/external/bsd/cron/dist/database.c:1.8 --- src/external/bsd/cron/dist/database.c:1.7 Fri Oct 14 10:38:20 2011 +++ src/external/bsd/cron/dist/database.c Mon Dec 24 14:30:46 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: database.c,v 1.7 2011/10/14 14:38:20 christos Exp $ */ +/* $NetBSD: database.c,v 1.8 2012/12/24 19:30:46 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: database.c,v 1.7 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: database.c,v 1.7 2011/10/14 14:38:20 christos Exp $); +__RCSID($NetBSD: database.c,v 1.8 2012/12/24 19:30:46 christos Exp $); #endif #endif @@ -237,7 +237,7 @@ process_crontab(const char *uname, const { struct passwd *pw = NULL; int crontab_fd = OK - 1; - mode_t eqmode = 0600, badmode = 0; + mode_t eqmode = 0400, badmode = 0; user *u; if (fname == NULL) { @@ -272,7 +272,7 @@ process_crontab(const char *uname, const log_it(fname, getpid(), NOT REGULAR, tabname); goto next_crontab; } - if ((eqmode (statbuf-st_mode 0) != eqmode) || + if ((eqmode (statbuf-st_mode 07577) != eqmode) || (badmode (statbuf-st_mode badmode) != 0)) { log_it(fname, getpid(), BAD FILE MODE, tabname); goto next_crontab;
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sat Nov 3 15:39:24 UTC 2012 Modified Files: src/external/bsd/cron/dist: config.h crontab.c Log Message: use utimensat(2) and correct and centralize file times handling. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/config.h cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/config.h diff -u src/external/bsd/cron/dist/config.h:1.3 src/external/bsd/cron/dist/config.h:1.4 --- src/external/bsd/cron/dist/config.h:1.3 Fri May 7 16:43:27 2010 +++ src/external/bsd/cron/dist/config.h Sat Nov 3 11:39:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.3 2010/05/07 20:43:27 christos Exp $ */ +/* $NetBSD: config.h,v 1.4 2012/11/03 15:39:23 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -93,6 +93,8 @@ #define HAVE_TM_GMTOFF /*-*/ #define HAVE_FCHOWN /*-*/ #define HAVE_UTIMES /*-*/ +#define HAVE_UTIMENSAT +#define _INCOMPLETE_XOPEN_C063 /* if your OS supports a BSD-style login.conf file */ /* #define LOGIN_CAP */ Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.5 src/external/bsd/cron/dist/crontab.c:1.6 --- src/external/bsd/cron/dist/crontab.c:1.5 Sun Mar 4 13:38:31 2012 +++ src/external/bsd/cron/dist/crontab.c Sat Nov 3 11:39:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.5 2012/03/04 18:38:31 tron Exp $ */ +/* $NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.5 2012/03/04 18:38:31 tron Exp $); +__RCSID($NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $); #endif #endif @@ -138,6 +138,48 @@ main(int argc, char *argv[]) { } static void +get_time(const struct stat *st, struct timespec *ts) +{ + ts[0].tv_sec = st-st_atime; + ts[0].tv_nsec = st-st_atimensec; + ts[1].tv_sec = st-st_mtime; + ts[1].tv_nsec = st-st_mtimensec; +} + +static int +change_time(const char *name, const struct timespec *ts) +{ +#if defined(HAVE_UTIMENSAT) + return utimensat(AT_FDCWD, name, ts, 0); +#elif defined(HAVE_UTIMES) + struct timeval tv[2]; + TIMESPEC_TO_TIMEVAL(tv[0], ts[0]); + TIMESPEC_TO_TIMEVAL(tv[1], ts[1]); + return utimes(name, tvs); +#else + struct utimebuf ut; + ut.actime = tv[0].tv_sec; + ut.modtime = tv[1].tv_sec; + return utime(name, ut); +#endif +} + +static int +compare_time(const struct stat *st, const struct timespec *ts2) +{ + struct timespec ts1[2]; + get_time(st, ts1); + + return ts1[1].tv_sec == ts2[1].tv_sec +#if defined(HAVE_UTIMENSAT) + ts1[1].tv_nsec == ts2[1].tv_nsec +#elif defined(HAVE_UTIMES) + ts1[1].tv_nsec / 1000 = ts2[1].tv_nsec / 1000 +#endif + ; +} + +static void parse_args(int argc, char *argv[]) { int argch; @@ -322,10 +364,9 @@ edit_cmd(void) { int ch, t, x; sig_t oint, oabrt, oquit, ohup; struct stat statbuf; - struct utimbuf utimebuf; - long mtimensec; WAIT_T waiter; PID_T pid, xpid; + struct timespec ts[2]; log_it(RealUser, Pid, BEGIN EDIT, User); if (!glue_strings(n, sizeof n, SPOOL_DIR, User, '/')) { @@ -345,9 +386,7 @@ edit_cmd(void) { warn(cannot stat crontab file); goto fatal; } - utimebuf.actime = statbuf.st_atime; - utimebuf.modtime = statbuf.st_mtime; - mtimensec = statbuf.st_mtimensec; + get_time(statbuf, ts); /* Turn off signals. */ ohup = signal(SIGHUP, SIG_IGN); @@ -390,7 +429,8 @@ edit_cmd(void) { if (fflush(NewCrontab) OK) { err(ERROR_EXIT, cannot flush output for `%s', Filename); } - (void)utime(Filename, utimebuf); + if (change_time(Filename, ts) == -1) + err(ERROR_EXIT, cannot set time info for `%s', Filename); again: rewind(NewCrontab); if (ferror(NewCrontab)) { @@ -473,8 +513,7 @@ edit_cmd(void) { warn(cannot stat `%s', Filename); goto fatal; } - if (utimebuf.modtime == statbuf.st_mtime - mtimensec == statbuf.st_mtimensec) { + if (compare_time(statbuf, ts)) { warnx(no changes made to crontab); goto remove; } @@ -599,7 +638,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.5 2012/03/04 18:38:31 tron Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $); /* copy the crontab to the tmp */ @@ -717,18 +756,13 @@ done: static void poke_daemon(void) { -#ifdef HAVE_UTIMES - struct timeval tvs[2]; - struct timezone tz; - - (void) gettimeofday(tvs[0], tz); - tvs[1] =
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sat Nov 3 17:33:01 UTC 2012 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: make the utime and utimes cases work too. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.6 src/external/bsd/cron/dist/crontab.c:1.7 --- src/external/bsd/cron/dist/crontab.c:1.6 Sat Nov 3 11:39:23 2012 +++ src/external/bsd/cron/dist/crontab.c Sat Nov 3 13:33:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $); #endif #endif @@ -155,11 +155,11 @@ change_time(const char *name, const stru struct timeval tv[2]; TIMESPEC_TO_TIMEVAL(tv[0], ts[0]); TIMESPEC_TO_TIMEVAL(tv[1], ts[1]); - return utimes(name, tvs); + return utimes(name, tv); #else - struct utimebuf ut; - ut.actime = tv[0].tv_sec; - ut.modtime = tv[1].tv_sec; + struct utimbuf ut; + ut.actime = ts[0].tv_sec; + ut.modtime = ts[1].tv_sec; return utime(name, ut); #endif } @@ -174,7 +174,7 @@ compare_time(const struct stat *st, cons #if defined(HAVE_UTIMENSAT) ts1[1].tv_nsec == ts2[1].tv_nsec #elif defined(HAVE_UTIMES) - ts1[1].tv_nsec / 1000 = ts2[1].tv_nsec / 1000 + ts1[1].tv_nsec / 1000 == ts2[1].tv_nsec / 1000 #endif ; } @@ -638,7 +638,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.6 2012/11/03 15:39:23 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.7 2012/11/03 17:33:01 christos Exp $); /* copy the crontab to the tmp */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri Mar 2 19:26:40 UTC 2012 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: PR/46127: Holger Weiss: crontab file fails for unprivileged users XXX: Pullup to 6 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.3 src/external/bsd/cron/dist/crontab.c:1.4 --- src/external/bsd/cron/dist/crontab.c:1.3 Tue May 18 17:47:43 2010 +++ src/external/bsd/cron/dist/crontab.c Fri Mar 2 14:26:40 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.4 2012/03/02 19:26:40 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.4 2012/03/02 19:26:40 christos Exp $); #endif #endif @@ -66,7 +66,8 @@ static void list_cmd(void), static int replace_cmd(void); static int allowed(const char *, const char *, const char *); static int in_file(const char *, FILE *, int); -static int swap_uids(void); +static int relinguish_priv(void); +static int regain_priv(void); static void usage(const char *msg) { @@ -80,6 +81,9 @@ usage(const char *msg) { exit(ERROR_EXIT); } +static uid_t euid, ruid; +static gid_t egid, rgid; + int main(int argc, char *argv[]) { int exitstatus; @@ -88,6 +92,14 @@ main(int argc, char *argv[]) { Pid = getpid(); (void)setlocale(LC_ALL, ); + euid = geteuid(); + egid = getegid(); + ruid = getuid(); + rgid = getgid(); + + if (euid == ruid || euid) + err(ERROR_EXIT, Not installed setuid root); + (void)setvbuf(stderr, NULL, _IOLBF, 0); parse_args(argc, argv); /* sets many globals, opens a file */ set_cron_cwd(); @@ -211,13 +223,13 @@ parse_args(int argc, char *argv[]) { * the race. */ - if (swap_uids() OK) { + if (relinguish_priv() OK) { err(ERROR_EXIT, swapping uids); } if (!(NewCrontab = fopen(Filename, r))) { err(ERROR_EXIT, cannot open `%s', Filename); } - if (swap_uids() OK) { + if (regain_priv() OK) { err(ERROR_EXIT, swapping uids back); } } @@ -587,7 +599,7 @@ replace_cmd(void) { */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.4 2012/03/02 19:26:40 christos Exp $); /* copy the crontab to the tmp */ @@ -772,25 +784,21 @@ in_file(const char *string, FILE *file, #ifdef HAVE_SAVED_UIDS -static int swap_uids(void) { - return ((setegid(getgid()) || seteuid(getuid())) ? -1 : 0); +static int relinguish_priv(void) { + return (setegid(rgid) || seteuid(ruid)) ? -1 : 0; } -#if 0 -static int swap_uids_back(void) { - return ((setegid(getgid()) || seteuid(getuid())) ? -1 : 0); + +static int regain_priv(void) { + return (setegid(egid) || seteuid(euid)) ? -1 : 0; } -#endif #else /*HAVE_SAVED_UIDS*/ -static int swap_uids(void) { - return ((setregid(getegid(), getgid()) || setreuid(geteuid(), getuid())) - ? -1 : 0); +static int relinguish_priv(void) { + return (setregid(egid, rgid) || setreuid(euid, ruid)) ? -1 : 0; } -#if 0 -static int swap_uids_back(void) { - return (swap_uids()); +static int regain_priv(void) { + return (setregid(rgid, egid) || setreuid(ruid, euid)) ? -1 : 0; } -#endif #endif /*HAVE_SAVED_UIDS*/
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri Oct 14 14:38:21 UTC 2011 Modified Files: src/external/bsd/cron/dist: database.c Log Message: simplify the bad extension code, by dsl. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/database.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/database.c diff -u src/external/bsd/cron/dist/database.c:1.6 src/external/bsd/cron/dist/database.c:1.7 --- src/external/bsd/cron/dist/database.c:1.6 Thu Oct 13 12:58:30 2011 +++ src/external/bsd/cron/dist/database.c Fri Oct 14 10:38:20 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: database.c,v 1.6 2011/10/13 16:58:30 joerg Exp $ */ +/* $NetBSD: database.c,v 1.7 2011/10/14 14:38:20 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: database.c,v 1.7 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: database.c,v 1.6 2011/10/13 16:58:30 joerg Exp $); +__RCSID($NetBSD: database.c,v 1.7 2011/10/14 14:38:20 christos Exp $); #endif #endif @@ -63,7 +63,7 @@ process_dir(const char *dname, struct st * Homage to... */ static const char *junk[] = { - .rpmsave, .rpmorig, .rpmnew, + rpmsave, rpmorig, rpmnew, }; /* avoid file names beginning with .. this is good @@ -93,11 +93,11 @@ process_dir(const char *dname, struct st (void)strlcpy(fname, dp-d_name, sizeof(fname)); - /* ... or look leftover crap */ + /* ... or look for blacklisted extensions */ for (i = 0; i __arraycount(junk); i++) { char *p; - if ((p = strstr(fname, junk[i])) != NULL - p[strlen(junk[i]) - 1] == '\0') + if ((p = strrchr(fname, '.')) != NULL + strcmp(p + 1, junk[i]) == 0) break; } if (i != __arraycount(junk))
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: joerg Date: Thu Oct 13 16:58:30 UTC 2011 Modified Files: src/external/bsd/cron/dist: database.c Log Message: Kill redundant () To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/database.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/database.c diff -u src/external/bsd/cron/dist/database.c:1.5 src/external/bsd/cron/dist/database.c:1.6 --- src/external/bsd/cron/dist/database.c:1.5 Wed Oct 12 19:48:24 2011 +++ src/external/bsd/cron/dist/database.c Thu Oct 13 16:58:30 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: database.c,v 1.5 2011/10/12 19:48:24 christos Exp $ */ +/* $NetBSD: database.c,v 1.6 2011/10/13 16:58:30 joerg Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: database.c,v 1.7 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: database.c,v 1.5 2011/10/12 19:48:24 christos Exp $); +__RCSID($NetBSD: database.c,v 1.6 2011/10/13 16:58:30 joerg Exp $); #endif #endif @@ -88,7 +88,7 @@ process_dir(const char *dname, struct st } /* ... or ending with ~ ... */ - if ((dp-d_name[len - 1] == '~')) + if (dp-d_name[len - 1] == '~') continue; (void)strlcpy(fname, dp-d_name, sizeof(fname));
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Wed Oct 12 16:39:48 UTC 2011 Modified Files: src/external/bsd/cron/dist: cron.8 database.c pathnames.h Log Message: process files in /etc/cron.d/ To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/cron.8 \ src/external/bsd/cron/dist/database.c \ src/external/bsd/cron/dist/pathnames.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.8 diff -u src/external/bsd/cron/dist/cron.8:1.3 src/external/bsd/cron/dist/cron.8:1.4 --- src/external/bsd/cron/dist/cron.8:1.3 Sat May 8 07:55:01 2010 +++ src/external/bsd/cron/dist/cron.8 Wed Oct 12 12:39:48 2011 @@ -1,8 +1,8 @@ -.\ $NetBSD: cron.8,v 1.3 2010/05/08 11:55:01 wiz Exp $ +.\ $NetBSD: cron.8,v 1.4 2011/10/12 16:39:48 christos Exp $ .\ .\ Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp .\ -.Dd May 5, 2010 +.Dd October 12, 2011 .Dt CRON 8 .Os .Sh NAME @@ -33,6 +33,40 @@ also searches for .Pa /etc/crontab which is in a different format (see .Xr crontab 5 ) . +Finally +.Nm +looks for crontabs in +.Pa /etc/cron.d +if it exists, and executes each file as a crontab. +.Pp +When +.Nm +looks in a directory for crontabs (either in +.Pa /var/cron/tabs +or +.Pa /etc/cron.d ) +it will not process files that: +.Bl -dash -compact -offset indent +.It +Start with a +.Sq \. +or a +.Sq # . +.It +End with a +.Sq ~ +or with +.Dq .rpmsave , +.Dq .rpmorig , +or +.Dq .rpmnew . +.It +Are of zero length. +.It +Their length is greater than +.Dv MAXNAMLEN . +.El +.Pp .Nm then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. @@ -57,7 +91,9 @@ Additionally, .Nm checks each minute to see if its spool directory's modtime (or the modtime on -.Pa /etc/crontab ) +.Pa /etc/crontab +or +.Pa /etc/cron.d ) has changed, and if it has, .Nm will then examine the modtime on all crontabs and reload those which have @@ -131,7 +167,9 @@ Naturally this is not relevant if cron w .Nm spool directory .It Pa /etc/crontab -system crontab +system crontab file +.It Pa /etc/cron.d/ +system crontab directory .It Pa /var/log/cron log file for cron events .El Index: src/external/bsd/cron/dist/database.c diff -u src/external/bsd/cron/dist/database.c:1.3 src/external/bsd/cron/dist/database.c:1.4 --- src/external/bsd/cron/dist/database.c:1.3 Thu Jul 15 16:04:14 2010 +++ src/external/bsd/cron/dist/database.c Wed Oct 12 12:39:48 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: database.c,v 1.3 2010/07/15 20:04:14 christos Exp $ */ +/* $NetBSD: database.c,v 1.4 2011/10/12 16:39:48 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: database.c,v 1.7 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: database.c,v 1.3 2010/07/15 20:04:14 christos Exp $); +__RCSID($NetBSD: database.c,v 1.4 2011/10/12 16:39:48 christos Exp $); #endif #endif @@ -40,13 +40,87 @@ static void process_crontab(const char const char *, struct stat *, cron_db *, cron_db *); +static void +process_dir(const char *dname, struct stat *st, int sys, cron_db *new_db, +cron_db *old_db) +{ + DIR *dir; + DIR_T *dp; + + /* we used to keep this dir open all the time, for the sake of + * efficiency. however, we need to close it in every fork, and + * we fork a lot more often than the mtime of the dir changes. + */ + if (!(dir = opendir(dname))) { + log_it(CRON, getpid(), OPENDIR FAILED, dname); + (void) exit(ERROR_EXIT); + } + + while (NULL != (dp = readdir(dir))) { + char fname[MAXNAMLEN+1], tabname[MAXNAMLEN+1]; + size_t i, len; + /* + * Homage to... + */ + static const char *junk[] = { + .rpmsave, .rpmorig, .rpmnew, + }; + + /* avoid file names beginning with .. this is good + * because we would otherwise waste two guaranteed calls + * to getpwnam() for . and .., and there shouldn't be + * hidden files in here anyway (in the non system case). + */ + if (dp-d_name[0] == '.') + continue; + + /* ignore files starting with # ... */ + if (dp-d_name[0] == '#') + continue; + + len = strlen(dp-d_name); + + /* ... or too big or to small ... */ + if (len == 0 || len = sizeof(fname)) { + log_it(dp-d_name, getpid(), ORPHAN, + name too short or long); + continue; + } + + /* ... or ending with ~ ... */ + if ((dp-d_name[len - 1] == '~')) + continue; + + (void)strlcpy(fname, dp-d_name, sizeof(fname)); + + /* ... or look leftover crap */ + for (i = 0; i __arraycount(junk); i++) { + char *p; + if ((p = strstr(fname, junk[len])) != NULL + p[strlen(junk[len]) - 1] == '\0') +break; + } + if (i != __arraycount(junk)) + continue; + + if (!glue_strings(tabname, sizeof tabname, dname, fname, '/')) { + log_it(fname, getpid(), ORPHAN, + could not glue strings); +
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Wed Oct 12 19:48:24 UTC 2011 Modified Files: src/external/bsd/cron/dist: database.c Log Message: renamed len - i but did not fix it everywhere. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/database.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/database.c diff -u src/external/bsd/cron/dist/database.c:1.4 src/external/bsd/cron/dist/database.c:1.5 --- src/external/bsd/cron/dist/database.c:1.4 Wed Oct 12 12:39:48 2011 +++ src/external/bsd/cron/dist/database.c Wed Oct 12 15:48:24 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: database.c,v 1.4 2011/10/12 16:39:48 christos Exp $ */ +/* $NetBSD: database.c,v 1.5 2011/10/12 19:48:24 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: database.c,v 1.7 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: database.c,v 1.4 2011/10/12 16:39:48 christos Exp $); +__RCSID($NetBSD: database.c,v 1.5 2011/10/12 19:48:24 christos Exp $); #endif #endif @@ -96,8 +96,8 @@ process_dir(const char *dname, struct st /* ... or look leftover crap */ for (i = 0; i __arraycount(junk); i++) { char *p; - if ((p = strstr(fname, junk[len])) != NULL - p[strlen(junk[len]) - 1] == '\0') + if ((p = strstr(fname, junk[i])) != NULL + p[strlen(junk[i]) - 1] == '\0') break; } if (i != __arraycount(junk))
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: wiz Date: Wed Oct 12 22:50:31 UTC 2011 Modified Files: src/external/bsd/cron/dist: cron.8 Log Message: Remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/cron.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.8 diff -u src/external/bsd/cron/dist/cron.8:1.4 src/external/bsd/cron/dist/cron.8:1.5 --- src/external/bsd/cron/dist/cron.8:1.4 Wed Oct 12 16:39:48 2011 +++ src/external/bsd/cron/dist/cron.8 Wed Oct 12 22:50:31 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: cron.8,v 1.4 2011/10/12 16:39:48 christos Exp $ +.\ $NetBSD: cron.8,v 1.5 2011/10/12 22:50:31 wiz Exp $ .\ .\ Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp .\ @@ -48,13 +48,13 @@ or it will not process files that: .Bl -dash -compact -offset indent .It -Start with a -.Sq \. +Start with a +.Sq \. or a .Sq # . .It End with a -.Sq ~ +.Sq ~ or with .Dq .rpmsave , .Dq .rpmorig , @@ -91,7 +91,7 @@ Additionally, .Nm checks each minute to see if its spool directory's modtime (or the modtime on -.Pa /etc/crontab +.Pa /etc/crontab or .Pa /etc/cron.d ) has changed, and if it has,
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sun Jul 17 01:14:25 UTC 2011 Modified Files: src/external/bsd/cron/dist: do_command.c Log Message: calling setlogin() once is good enough. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/do_command.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/do_command.c diff -u src/external/bsd/cron/dist/do_command.c:1.2 src/external/bsd/cron/dist/do_command.c:1.3 --- src/external/bsd/cron/dist/do_command.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/do_command.c Sat Jul 16 21:14:25 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: do_command.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: do_command.c,v 1.3 2011/07/17 01:14:25 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: do_command.c,v 1.2 2010/05/06 18:53:17 christos Exp $); +__RCSID($NetBSD: do_command.c,v 1.3 2011/07/17 01:14:25 christos Exp $); #endif #endif @@ -255,8 +255,6 @@ syslog(LOG_ERR, setlogin() failure: %m); _exit(ERROR_EXIT); } - - setlogin(usernm); #endif /* BSD */ if (setuid(e-pwd-pw_uid) != 0) { syslog(LOG_ERR, setuid failed);
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sun Jul 17 01:16:46 UTC 2011 Modified Files: src/external/bsd/cron/dist: popen.c Log Message: - exit with ERROR_EXIT consistently - don't use warnx() for things that set errno - check result of setlogin() - don't call setlogin() without calling setsid() should fix kernel warnings like: cron (pid N) changing logname from root to USER cron (pid M) changing logname from USER to root To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/popen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/popen.c diff -u src/external/bsd/cron/dist/popen.c:1.2 src/external/bsd/cron/dist/popen.c:1.3 --- src/external/bsd/cron/dist/popen.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/popen.c Sat Jul 16 21:16:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: popen.c,v 1.3 2011/07/17 01:16:46 christos Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -44,7 +44,7 @@ static sccsid[] = @(#)popen.c 8.3 (Berkeley) 4/6/94; static char rcsid[] = Id: popen.c,v 1.6 2003/02/16 04:40:01 vixie Exp; #else -__RCSID($NetBSD: popen.c,v 1.2 2010/05/06 18:53:17 christos Exp $); +__RCSID($NetBSD: popen.c,v 1.3 2011/07/17 01:16:46 christos Exp $); #endif #endif /* not lint */ @@ -98,26 +98,32 @@ /* NOTREACHED */ case 0:/* child */ if (pw) { + if (setsid() == -1) +warn(setsid() failed for %s, pw-pw_name); #ifdef LOGIN_CAP - if (setusercontext(0, pw, pw-pw_uid, LOGIN_SETALL) 0) { -warnx(setusercontext failed for %s, + if (setusercontext(0, pw, pw-pw_uid, LOGIN_SETALL) 0) + { +warn(setusercontext() failed for %s, pw-pw_name); _exit(ERROR_EXIT); } #else if (setgid(pw-pw_gid) 0 || initgroups(pw-pw_name, pw-pw_gid) 0) { -warnx(unable to set groups for %s, +warn(unable to set groups for %s, pw-pw_name); -_exit(1); +_exit(ERROR_EXIT); } #if (defined(BSD)) (BSD = 199103) - setlogin(pw-pw_name); + if (setlogin(pw-pw_name) 0) { +warn(setlogin() failed for %s, +pw-pw_name); +_exit(ERROR_EXIT); + } #endif /* BSD */ if (setuid(pw-pw_uid)) { -warnx(unable to set uid for %s, -pw-pw_name); -_exit(1); +warn(unable to set uid for %s, pw-pw_name); +_exit(ERROR_EXIT); } #endif /* LOGIN_CAP */ } @@ -136,7 +142,7 @@ (void)close(pdes[1]); } (void)execvp(argv[0], argv); - _exit(1); + _exit(ERROR_EXIT); } /* parent; assume fdopen can't fail... */
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: tron Date: Sat Oct 2 12:22:20 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.c Log Message: Use setenv(3) instead of putenv(3) because the later doesn't accept string constants anymore. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/cron/dist/cron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.6 src/external/bsd/cron/dist/cron.c:1.7 --- src/external/bsd/cron/dist/cron.c:1.6 Tue May 18 21:49:51 2010 +++ src/external/bsd/cron/dist/cron.c Sat Oct 2 12:22:20 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.6 2010/05/18 21:49:51 christos Exp $ */ +/* $NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.6 2010/05/18 21:49:51 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.7 2010/10/02 12:22:20 tron Exp $); #endif #endif @@ -93,7 +93,7 @@ set_cron_uid(); set_cron_cwd(); - if (putenv(PATH=_PATH_DEFPATH) 0) { + if (setenv(PATH, _PATH_DEFPATH, 1) 0) { log_it(CRON, getpid(), DEATH, can't malloc); exit(1); }
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu Jul 15 22:18:20 UTC 2010 Modified Files: src/external/bsd/cron/dist: crontab.5 Log Message: Document the format of the system crontab file, since cron(8) says that we do. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/crontab.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.5 diff -u src/external/bsd/cron/dist/crontab.5:1.2 src/external/bsd/cron/dist/crontab.5:1.3 --- src/external/bsd/cron/dist/crontab.5:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/crontab.5 Thu Jul 15 18:18:20 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: crontab.5,v 1.2 2010/05/06 18:53:17 christos Exp $ +.\ $NetBSD: crontab.5,v 1.3 2010/07/15 22:18:20 christos Exp $ .\ .\/* Copyright 1988,1990,1993,1994 by Paul Vixie .\ * All rights reserved @@ -19,7 +19,7 @@ .\ .\ Id: crontab.5,v 2.4 1994/01/15 20:43:43 vixie Exp .\ -.Dd April 4, 2009 +.Dd July 15, 2010 .Dt CRONTAB 5 .Os .Sh NAME @@ -244,9 +244,21 @@ doesn't matter). Ranges or lists of names are not allowed. .Pp +If the +.Nm +file is the system crontab +.Pa /etc/crontab , +then the next ( +.Dq sixth ) +field contains the username to run the command as. +.Pp The .Dq sixth -field (the rest of the line) specifies the command to be run. +field (or the +.Dq seventh +one for +.Pa /etc/crontab ) +(the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or percent signs .Pq Sq % ,
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Sat Jul 10 21:42:30 UTC 2010 Modified Files: src/external/bsd/cron/dist: entry.c Log Message: PR bin/43591: Jeremy Reed: make sure that the default path is always set. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/entry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/entry.c diff -u src/external/bsd/cron/dist/entry.c:1.2 src/external/bsd/cron/dist/entry.c:1.3 --- src/external/bsd/cron/dist/entry.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/entry.c Sat Jul 10 17:42:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: entry.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: entry.c,v 1.3 2010/07/10 21:42:29 christos Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -26,7 +26,7 @@ #if 0 static char rcsid[] = Id: entry.c,v 1.17 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: entry.c,v 1.2 2010/05/06 18:53:17 christos Exp $); +__RCSID($NetBSD: entry.c,v 1.3 2010/07/10 21:42:29 christos Exp $); #endif #endif @@ -305,7 +305,6 @@ } else log_it(CRON, getpid(), error, can't set HOME); } -#ifndef LOGIN_CAP /* If login.conf is in used we will get the default PATH later. */ if (!env_get(PATH, e-envp)) { if (glue_strings(envstr, sizeof envstr, PATH, @@ -318,7 +317,6 @@ } else log_it(CRON, getpid(), error, can't set PATH); } -#endif /* LOGIN_CAP */ if (glue_strings(envstr, sizeof envstr, LOGNAME, pw-pw_name, '=')) { if ((tenvp = env_set(e-envp, envstr)) == NULL) {
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Wed May 19 12:50:49 UTC 2010 Modified Files: src/external/bsd/cron/dist: pathnames.h Log Message: rename the allow and deny files to match the documentation. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/pathnames.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/pathnames.h diff -u src/external/bsd/cron/dist/pathnames.h:1.2 src/external/bsd/cron/dist/pathnames.h:1.3 --- src/external/bsd/cron/dist/pathnames.h:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/pathnames.h Wed May 19 08:50:49 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: pathnames.h,v 1.3 2010/05/19 12:50:49 christos Exp $ */ /* Copyright 1993,1994 by Paul Vixie * All rights reserved @@ -56,8 +56,8 @@ /* cron allow/deny file. At least cron.deny must * exist for ordinary users to run crontab. */ -#define CRON_ALLOW cron.allow -#define CRON_DENY cron.deny +#define CRON_ALLOW allow +#define CRON_DENY deny /* undefining this turns off logging to a file. If * neither LOG_FILE or SYSLOG is defined, we don't log.
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Tue May 18 21:47:43 UTC 2010 Modified Files: src/external/bsd/cron/dist: crontab.c Log Message: Forgot to commit this: Bring back the default to allow any user to install crontabs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/crontab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.c diff -u src/external/bsd/cron/dist/crontab.c:1.2 src/external/bsd/cron/dist/crontab.c:1.3 --- src/external/bsd/cron/dist/crontab.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/crontab.c Tue May 18 17:47:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: crontab.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: crontab.c,v 1.2 2010/05/06 18:53:17 christos Exp $); +__RCSID($NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $); #endif #endif @@ -587,7 +587,7 @@ */ (void)fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n); (void)fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now)); - (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.2 2010/05/06 18:53:17 christos Exp $); + (void)fprintf(tmp, # (Cron version %s -- %s)\n, CRON_VERSION, $NetBSD: crontab.c,v 1.3 2010/05/18 21:47:43 christos Exp $); /* copy the crontab to the tmp */ @@ -729,7 +729,11 @@ if (strcmp(username, ROOT_USER) == 0) return (TRUE); +#ifdef ALLOW_ONLY_ROOT isallowed = FALSE; +#else + isallowed = TRUE; +#endif if ((fp = fopen(allow_file, r)) != NULL) { isallowed = in_file(username, fp, FALSE); (void)fclose(fp);
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Tue May 18 21:49:52 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.c Log Message: - The new cron keeps time internally as localtime. Revert to previous behavior of keeping UTC, and handle timezones the way we handled them before (CRON_TZ). The old behavior can be selected with defining CRON_LOCALTIME. - Provide functions to pretty-print crontab entries. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/bsd/cron/dist/cron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.5 src/external/bsd/cron/dist/cron.c:1.6 --- src/external/bsd/cron/dist/cron.c:1.5 Fri May 7 13:12:00 2010 +++ src/external/bsd/cron/dist/cron.c Tue May 18 17:49:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.5 2010/05/07 17:12:00 christos Exp $ */ +/* $NetBSD: cron.c,v 1.6 2010/05/18 21:49:51 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.5 2010/05/07 17:12:00 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.6 2010/05/18 21:49:51 christos Exp $); #endif #endif @@ -264,14 +264,97 @@ (void) job_runqueue(); } +static const char * +bitprint(const bitstr_t *b, size_t l) +{ + size_t i, set, clear; + static char result[1024]; + char tmp[1024]; + + result[0] = '\0'; + for (i = 0;;) { + for (; i l; i++) + if (bit_test(b, i)) +break; + if (i == l) + return result; + set = i; + for (; i l; i++) + if (!bit_test(b, i)) +break; + clear = i; + if (set == 0 clear == l) { + snprintf(result, sizeof(result), *); + return result; + } + if (clear == l || set == clear - 1) + snprintf(tmp, sizeof(tmp), ,%zu, set); + else + snprintf(tmp, sizeof(tmp), ,%zu-%zu, set, clear - 1); + if (result[0] == '\0') + strlcpy(result, tmp + 1, sizeof(result)); + else + strlcat(result, tmp, sizeof(result)); + } +} + +static const char * +flagsprint(int flags) +{ + static char result[1024]; + + result[0] = '\0'; + if (flags MIN_STAR) + strlcat(result, ,min, sizeof(result)); + if (flags HR_STAR) + strlcat(result, ,hr, sizeof(result)); + if (flags DOM_STAR) + strlcat(result, ,dom, sizeof(result)); + if (flags DOW_STAR) + strlcat(result, ,dow, sizeof(result)); + if (flags WHEN_REBOOT) + strlcat(result, ,reboot, sizeof(result)); + if (flags DONT_LOG) + strlcat(result, ,nolog, sizeof(result)); + + return result + (result[0] == ','); +} + +static void +printone(char *res, size_t len, const char *b) +{ + int comma = strchr(b, ',') != NULL; + if (comma) + strlcat(res, [, len); + strlcat(res, b, len); + strlcat(res, ], + (comma ? 0 : 1), len); +} + +static const char * +tick(const entry *e) +{ + static char result[1024]; + + result[0] = '\0'; + printone(result, sizeof(result), bitprint(e-minute, MINUTE_COUNT)); + printone(result, sizeof(result), bitprint(e-hour, HOUR_COUNT)); + printone(result, sizeof(result), bitprint(e-dom, DOM_COUNT)); + printone(result, sizeof(result), bitprint(e-month, MONTH_COUNT)); + printone(result, sizeof(result), bitprint(e-dow, DOW_COUNT)); + strlcat(result, flags=, sizeof(result)); + strlcat(result, flagsprint(e-flags), sizeof(result)); + return result; +} + static void find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { - time_t virtualSecond = vtime * SECONDS_PER_MINUTE; - struct tm *tm = gmtime(virtualSecond); + time_t virtualSecond = vtime * SECONDS_PER_MINUTE; + struct tm *tm; int minute, hour, dom, month, dow; user *u; entry *e; - char *orig_tz, *job_tz; +#ifndef CRON_LOCALTIME + char *orig_tz, *job_tz; #define maketime(tz1, tz2) do { \ char *t = tz1; \ @@ -281,6 +364,7 @@ setenv(TZ, (tz2), 1); \ else \ unsetenv(TZ); \ + tzset(); \ tm = localtime(virtualSecond); \ minute = tm-tm_min -FIRST_MINUTE; \ hour = tm-tm_hour -FIRST_HOUR; \ @@ -291,6 +375,9 @@ orig_tz = getenv(TZ); maketime(NULL, orig_tz); +#else + tm = gmtime(virtualSecond); +#endif Debug(DSCH, ([%ld] tick(%d,%d,%d,%d,%d) %s %s\n, (long)getpid(), minute, hour, dom, month, dow, @@ -304,11 +391,19 @@ */ for (u = db-head; u != NULL; u = u-next) { for (e = u-crontab; e != NULL; e = e-next) { - Debug(DSCH|DEXT, (user [%s:%ld:%ld:...] cmd=\%s\\n, - e-pwd-pw_name, (long)e-pwd-pw_uid, - (long)e-pwd-pw_gid, e-cmd)); +#ifndef CRON_LOCALTIME job_tz = env_get(CRON_TZ, e-envp); maketime(job_tz, orig_tz); +#else +#define job_tz N/A +#define orig_tz N/A +#endif + Debug(DSCH|DEXT, (user [%s:%ld:%ld:...] + [jobtz=%s, origtz=%s] + tick(%s), cmd=\%s\\n, + e-pwd-pw_name, (long)e-pwd-pw_uid, + (long)e-pwd-pw_gid, job_tz, orig_tz, + tick(e), e-cmd)); if (bit_test(e-minute, minute)
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: joerg Date: Thu May 13 22:35:57 UTC 2010 Modified Files: src/external/bsd/cron/dist: crontab.1 Log Message: Fix .At argument. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/crontab.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.1 diff -u src/external/bsd/cron/dist/crontab.1:1.4 src/external/bsd/cron/dist/crontab.1:1.5 --- src/external/bsd/cron/dist/crontab.1:1.4 Sat May 8 11:55:01 2010 +++ src/external/bsd/cron/dist/crontab.1 Thu May 13 22:35:57 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: crontab.1,v 1.4 2010/05/08 11:55:01 wiz Exp $ +.\ $NetBSD: crontab.1,v 1.5 2010/05/13 22:35:57 joerg Exp $ .\ .\/* Copyright 1988,1990,1993 by Paul Vixie .\ * All rights reserved @@ -140,7 +140,7 @@ .St -p1003.2 . This new command syntax differs from previous versions of Vixie Cron, as well as from the classic -.At V3 +.At v3 syntax. .Sh AUTHORS .An Paul Vixie
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: wiz Date: Sat May 8 11:55:01 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.8 crontab.1 Log Message: Remove trailing whitespace; new sentence, new line; sort sections; standardize SYNOPSIS; use serial comma. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/cron.8 cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/crontab.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.8 diff -u src/external/bsd/cron/dist/cron.8:1.2 src/external/bsd/cron/dist/cron.8:1.3 --- src/external/bsd/cron/dist/cron.8:1.2 Thu May 6 18:53:17 2010 +++ src/external/bsd/cron/dist/cron.8 Sat May 8 11:55:01 2010 @@ -1,5 +1,5 @@ -.\ $NetBSD: cron.8,v 1.2 2010/05/06 18:53:17 christos Exp $ -.\ +.\ $NetBSD: cron.8,v 1.3 2010/05/08 11:55:01 wiz Exp $ +.\ .\ Id: cron.8,v 1.8 2004/01/23 19:03:32 vixie Exp .\ .Dd May 5, 2010 @@ -19,7 +19,8 @@ framework, if cron is switched on in .Xr rc.conf 5 . .Pp -It will return immediately so you don't have to starti it with ''. +It will return immediately so you don't have to start it with +.Sq \*[Am] . .Pp .Nm searches @@ -112,18 +113,18 @@ If time has moved forward, those jobs that would have run in the interval that has been skipped will be run immediately. Conversely, if time has moved backward, care is taken to avoid running -jobs twice. +jobs twice. .Pp Time changes of more than 3 hours are considered to be corrections to the clock or timezone, and the new time is used immediately. .Sh SIGNALS -On receipt of a +On receipt of a .Dv SIGHUP , the cron daemon will close and reopen its log file. -This is useful in scripts which rotate and age log files. +This is useful in scripts which rotate and age log files. Naturally this is not relevant if cron was built to use -.Xr syslog 3. +.Xr syslog 3 . .Sh FILES .Bl -tag -width /var/cron/tabs -compact .It Pa /var/cron/tabs Index: src/external/bsd/cron/dist/crontab.1 diff -u src/external/bsd/cron/dist/crontab.1:1.3 src/external/bsd/cron/dist/crontab.1:1.4 --- src/external/bsd/cron/dist/crontab.1:1.3 Fri May 7 20:43:40 2010 +++ src/external/bsd/cron/dist/crontab.1 Sat May 8 11:55:01 2010 @@ -1,9 +1,9 @@ -.\ $NetBSD: crontab.1,v 1.3 2010/05/07 20:43:40 christos Exp $ +.\ $NetBSD: crontab.1,v 1.4 2010/05/08 11:55:01 wiz Exp $ .\ .\/* Copyright 1988,1990,1993 by Paul Vixie .\ * All rights reserved .\ */ -.\ +.\ .\ Copyright (c) 2004 by Internet Systems Consortium, Inc. (ISC) .\ Copyright (c) 1997,2000 by Internet Software Consortium, Inc. .\ @@ -19,7 +19,7 @@ .\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT .\ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\ -.\ Id: crontab.1,v 1.7 2004/01/23 19:03:32 vixie Exp +.\ Id: crontab.1,v 1.7 2004/01/23 19:03:32 vixie Exp .\ .Dd May 6, 2010 .Dt CRONTAB 1 @@ -31,12 +31,10 @@ .Nm .Op Fl u Ar user .Nm -.Op Fl l -.Op Fl r -.Op Fl e +.Op Fl elr .Sh DESCRIPTION .Nm -is the program used to install, deinstall or list the tables +is the program used to install, deinstall, or list the tables used to drive the .Xr cron 8 daemon in ISC Cron. @@ -72,7 +70,8 @@ If the .Fl u option is given, it specifies the name of the user whose crontab is to be -tweaked. If this option is not given, +tweaked. +If this option is not given, .Nm examines .Dq your @@ -88,7 +87,7 @@ option for safety's sake. .Pp The first form of this command is used to install a new crontab from some -named file or standard input if the pseudo-filename +named file or standard input if the pseudo-filename .Dq - is given. .Pp @@ -103,18 +102,15 @@ The .Fl e option is used to edit the current crontab using the editor specified by -the +the .Dv VISUAL or .Dv EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. -.Sh SEE ALSO -.Xr crontab 5 , -.Xr cron 8 .Sh FILES -.Bl -tag -width /var/cron/maxtabsize -compact +.Bl -tag -width /var/cron/maxtabsize -compact .It Pa /var/cron/allow Optional list of users that are allowed to use .Nm . @@ -124,13 +120,19 @@ .It Pa /var/cron/maxtabsize Maximum size of .Nm -.It Pa /var/cron/tabs/ -Directory containing the individual user crontab files, named after the user. files. Defaults to .Dv 256 kilobytes. +.It Pa /var/cron/tabs/ +Directory containing the individual user crontab files, named after the user. .El +.Sh DIAGNOSTICS +A fairly informative usage message appears if you run it with a bad command +line. +.Sh SEE ALSO +.Xr crontab 5 , +.Xr cron 8 .Sh STANDARDS The .Nm @@ -140,9 +142,6 @@ differs from previous versions of Vixie Cron, as well as from the classic .At V3 syntax. -.Sh DIAGNOSTICS -A fairly informative usage message appears if you run it with a bad command -line. .Sh AUTHORS .An Paul Vixie .Aq
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri May 7 17:12:00 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.c Log Message: remove the +1 second. Otherwise jobs that are supposed to run at 10:00:00, run at 10:00:01 which is tolerable because cron has a 1 minute granularity, but confusing. This restores the old behavior with the new timing logic. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/bsd/cron/dist/cron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.4 src/external/bsd/cron/dist/cron.c:1.5 --- src/external/bsd/cron/dist/cron.c:1.4 Thu May 6 18:38:14 2010 +++ src/external/bsd/cron/dist/cron.c Fri May 7 13:12:00 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.4 2010/05/06 22:38:14 christos Exp $ */ +/* $NetBSD: cron.c,v 1.5 2010/05/07 17:12:00 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.4 2010/05/06 22:38:14 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.5 2010/05/07 17:12:00 christos Exp $); #endif #endif @@ -362,7 +362,7 @@ int seconds_to_wait; t1 = time(NULL) + GMToff; - seconds_to_wait = (int)(target * SECONDS_PER_MINUTE - t1) + 1; + seconds_to_wait = (int)(target * SECONDS_PER_MINUTE - t1); Debug(DSCH, ([%ld] Target time=%lld, sec-to-wait=%d\n, (long)getpid(), (long long)target*SECONDS_PER_MINUTE, seconds_to_wait));
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri May 7 20:43:27 UTC 2010 Modified Files: src/external/bsd/cron/dist: config.h Log Message: bump crontab limit to 256K per the old manual page. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/config.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/config.h diff -u src/external/bsd/cron/dist/config.h:1.2 src/external/bsd/cron/dist/config.h:1.3 --- src/external/bsd/cron/dist/config.h:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/config.h Fri May 7 16:43:27 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: config.h,v 1.3 2010/05/07 20:43:27 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -108,4 +108,4 @@ */ /*#define CRON_GROUP crontab */ -#define MAXTABSIZE_DEFAULT (1024*32) +#define MAXTABSIZE_DEFAULT (1024*256)
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Fri May 7 20:43:40 UTC 2010 Modified Files: src/external/bsd/cron/dist: crontab.1 Log Message: change to mandoc To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/crontab.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/crontab.1 diff -u src/external/bsd/cron/dist/crontab.1:1.2 src/external/bsd/cron/dist/crontab.1:1.3 --- src/external/bsd/cron/dist/crontab.1:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/crontab.1 Fri May 7 16:43:40 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: crontab.1,v 1.2 2010/05/06 18:53:17 christos Exp $ +.\ $NetBSD: crontab.1,v 1.3 2010/05/07 20:43:40 christos Exp $ .\ .\/* Copyright 1988,1990,1993 by Paul Vixie .\ * All rights reserved @@ -21,94 +21,128 @@ .\ .\ Id: crontab.1,v 1.7 2004/01/23 19:03:32 vixie Exp .\ -.TH CRONTAB 1 29 December 1993 -.UC 4 -.SH NAME -crontab \- maintain crontab files for individual users (ISC Cron V4.1) -.SH SYNOPSIS -.B crontab -.RB [ -u -.IR user ] file -.br -.B crontab -.RB [ -u -.IR user ] -.RB [ -l | -r | -e ] -.SH DESCRIPTION -.I Crontab +.Dd May 6, 2010 +.Dt CRONTAB 1 +.Os +.Sh NAME +.Nm crontab +.Nd maintain crontab files for individual users (ISC Cron V4.1) +.Sh SYNOPSIS +.Nm +.Op Fl u Ar user +.Nm +.Op Fl l +.Op Fl r +.Op Fl e +.Sh DESCRIPTION +.Nm is the program used to install, deinstall or list the tables used to drive the -.IR cron (8) -daemon in ISC Cron. Each user can have their own crontab, and though -these are files in /var, they are not intended to be edited directly. -.PP +.Xr cron 8 +daemon in ISC Cron. +Each user can have their own crontab, and though +these are files in +.Pa /var/cron , +they are not intended to be edited directly. +.Pp If the -.I cron.allow +.Pa /var/cron/allow file exists, then you must be listed therein in order to be allowed to use -this command. If the -.I cron.allow +this command. +If the +.Pa /var/cron/allow file does not exist but the -.I cron.deny -file does exist, then you must \fBnot\fR be listed in the -.I cron.deny -file in order to use this command. If neither of these files exists, -only the super user will be allowed to use this command. -.PP +.Pa /var/cron/deny +file does exist, then you must not be listed in the +.Pa /var/cron/deny +file in order to use this command. +If neither of these files exists, depending on the compiled in settings, +only the super user will be allowed to use this command, +or everyone will be allowed to use this command. +On +.Nx +everyone is allowed to use this command. +.Pp The default maximum size for a crontab is 256 kilobytes, but this may be changed for all users on the system by putting the desired maximum size (in bytes) in the -.I maxtabsize +.Pa /var/cron/maxtabsize file. -.PP +.Pp If the -.I -u +.Fl u option is given, it specifies the name of the user whose crontab is to be tweaked. If this option is not given, -.I crontab -examines your crontab, i.e., the crontab of the person executing the -command. Note that -.IR su (1) +.Nm +examines +.Dq your +crontab, i.e., the crontab of the person executing the command. +Note that +.Xr su 1 can confuse -.I crontab +.Nm and that if you are running inside of -.IR su (1) +.Xr su 1 you should always use the -.I -u +.Fl u option for safety's sake. -.PP +.Pp The first form of this command is used to install a new crontab from some -named file or standard input if the pseudo-filename ``-'' is given. -.PP +named file or standard input if the pseudo-filename +.Dq - +is given. +.Pp The -.I -l +.Fl l option causes the current crontab to be displayed on standard output. -.PP +.Pp The -.I -r +.Fl r option causes the current crontab to be removed. -.PP +.Pp The -.I -e +.Fl e option is used to edit the current crontab using the editor specified by -the \s-1VISUAL\s+1 or \s-1EDITOR\s+1 environment variables. After you exit -from the editor, the modified crontab will be installed automatically. -.SH SEE ALSO -crontab(5), cron(8) -.SH FILES -.nf -/var/cron/allow -/var/cron/deny -/var/cron/maxtabsize -.fi -.SH STANDARDS +the +.Dv VISUAL +or +.Dv EDITOR +environment variables. +After you exit from the editor, the modified crontab will be installed +automatically. +.Sh SEE ALSO +.Xr crontab 5 , +.Xr cron 8 +.Sh FILES +.Bl -tag -width /var/cron/maxtabsize -compact +.It Pa /var/cron/allow +Optional list of users that are allowed to use +.Nm . +.It Pa /var/cron/deny +Optional list of users that are disallowed to use +.Nm . +.It Pa /var/cron/maxtabsize +Maximum size of +.Nm +.It Pa /var/cron/tabs/ +Directory containing the individual user crontab files, named after the user. +files. +Defaults to +.Dv 256 +kilobytes. +.El +.Sh STANDARDS The -.I crontab -command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command syntax +.Nm +command conforms to +.St -p1003.2 .
CVS commit: src/external/bsd/cron/bin/crontab
Module Name:src Committed By: christos Date: Fri May 7 21:54:07 UTC 2010 Modified Files: src/external/bsd/cron/bin/crontab: Makefile Log Message: specify bindir To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/bsd/cron/bin/crontab/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/bin/crontab/Makefile diff -u src/external/bsd/cron/bin/crontab/Makefile:1.1 src/external/bsd/cron/bin/crontab/Makefile:1.2 --- src/external/bsd/cron/bin/crontab/Makefile:1.1 Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/bin/crontab/Makefile Fri May 7 17:54:07 2010 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2010/05/06 18:58:45 christos Exp $ +# $NetBSD: Makefile,v 1.2 2010/05/07 21:54:07 christos Exp $ .include bsd.own.mk @@ -8,6 +8,7 @@ CPPFLAGS+=-I${.CURDIR} -DDEBUGGING=1 BINOWN =root BINMODE=4555 +BINDIR=/usr/bin MAN= crontab.1 crontab.5 .include bsd.prog.mk
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu May 6 18:50:29 UTC 2010 Update of /cvsroot/src/external/bsd/cron/dist In directory ivanova.netbsd.org:/tmp/cvs-serv4779 Log Message: import cron 4.1 Status: Vendor Tag: ISC Release Tags: cron-4_1 N src/external/bsd/cron/dist/CONVERSION N src/external/bsd/cron/dist/CHANGES N src/external/bsd/cron/dist/FEATURES N src/external/bsd/cron/dist/INSTALL N src/external/bsd/cron/dist/MAIL N src/external/bsd/cron/dist/Makefile N src/external/bsd/cron/dist/README N src/external/bsd/cron/dist/THANKS N src/external/bsd/cron/dist/config.h N src/external/bsd/cron/dist/cron.8 N src/external/bsd/cron/dist/cron.c N src/external/bsd/cron/dist/cron.h N src/external/bsd/cron/dist/pathnames.h N src/external/bsd/cron/dist/crontab.1 N src/external/bsd/cron/dist/crontab.5 N src/external/bsd/cron/dist/crontab.c N src/external/bsd/cron/dist/database.c N src/external/bsd/cron/dist/do_command.c N src/external/bsd/cron/dist/entry.c N src/external/bsd/cron/dist/env.c N src/external/bsd/cron/dist/externs.h N src/external/bsd/cron/dist/funcs.h N src/external/bsd/cron/dist/globals.h N src/external/bsd/cron/dist/job.c N src/external/bsd/cron/dist/macros.h N src/external/bsd/cron/dist/misc.c N src/external/bsd/cron/dist/structs.h N src/external/bsd/cron/dist/popen.c N src/external/bsd/cron/dist/pw_dup.c N src/external/bsd/cron/dist/user.c No conflicts created by this import
CVS commit: src/external/bsd/cron
Module Name:src Committed By: christos Date: Thu May 6 18:58:45 UTC 2010 Added Files: src/external/bsd/cron: Makefile src/external/bsd/cron/bin: Makefile Makefile.inc src/external/bsd/cron/bin/cron: Makefile src/external/bsd/cron/bin/crontab: Makefile Log Message: Add build glue. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/Makefile cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/bin/Makefile \ src/external/bsd/cron/bin/Makefile.inc cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/bin/cron/Makefile cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/bin/crontab/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/external/bsd/cron/Makefile diff -u /dev/null src/external/bsd/cron/Makefile:1.1 --- /dev/null Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/Makefile Thu May 6 14:58:45 2010 @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1 2010/05/06 18:58:45 christos Exp $ + +SUBDIR= bin + +.include bsd.subdir.mk Index: src/external/bsd/cron/bin/Makefile diff -u /dev/null src/external/bsd/cron/bin/Makefile:1.1 --- /dev/null Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/bin/Makefile Thu May 6 14:58:45 2010 @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1 2010/05/06 18:58:45 christos Exp $ + +SUBDIR= cron crontab + +.include bsd.subdir.mk Index: src/external/bsd/cron/bin/Makefile.inc diff -u /dev/null src/external/bsd/cron/bin/Makefile.inc:1.1 --- /dev/null Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/bin/Makefile.inc Thu May 6 14:58:45 2010 @@ -0,0 +1,4 @@ +# $NetBSD: Makefile.inc,v 1.1 2010/05/06 18:58:45 christos Exp $ + +.PATH: ${.PARSEDIR}/../dist +WARNS?= 4 Index: src/external/bsd/cron/bin/cron/Makefile diff -u /dev/null src/external/bsd/cron/bin/cron/Makefile:1.1 --- /dev/null Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/bin/cron/Makefile Thu May 6 14:58:45 2010 @@ -0,0 +1,11 @@ +# $NetBSD: Makefile,v 1.1 2010/05/06 18:58:45 christos Exp $ + +BINDIR= /usr/sbin +PROG= cron +SRCS= cron.c database.c do_command.c entry.c env.c job.c \ + misc.c popen.c pw_dup.c user.c +CPPFLAGS+=-I${.CURDIR} -DLOGIN_CAP +LDADD+=-lutil +MAN= cron.8 + +.include bsd.prog.mk Index: src/external/bsd/cron/bin/crontab/Makefile diff -u /dev/null src/external/bsd/cron/bin/crontab/Makefile:1.1 --- /dev/null Thu May 6 14:58:45 2010 +++ src/external/bsd/cron/bin/crontab/Makefile Thu May 6 14:58:45 2010 @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.1 2010/05/06 18:58:45 christos Exp $ + +.include bsd.own.mk + +USE_FORT?= yes # setuid +PROG= crontab +SRCS= crontab.c misc.c entry.c env.c pw_dup.c +CPPFLAGS+=-I${.CURDIR} -DDEBUGGING=1 +BINOWN =root +BINMODE=4555 +MAN= crontab.1 crontab.5 + +.include bsd.prog.mk
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu May 6 21:50:16 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.c Log Message: - change times to time_t - use the correct time in job_add - bring back CRON_TZ To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/cron/dist/cron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.2 src/external/bsd/cron/dist/cron.c:1.3 --- src/external/bsd/cron/dist/cron.c:1.2 Thu May 6 14:53:17 2010 +++ src/external/bsd/cron/dist/cron.c Thu May 6 17:50:16 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */ +/* $NetBSD: cron.c,v 1.3 2010/05/06 21:50:16 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.2 2010/05/06 18:53:17 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.3 2010/05/06 21:50:16 christos Exp $); #endif #endif @@ -37,7 +37,7 @@ static void usage(void), run_reboot_jobs(cron_db *), - find_jobs(int, cron_db *, int, int), + find_jobs(time_t, cron_db *, int, int), set_time(int), cron_sleep(int), sigchld_handler(int), @@ -47,7 +47,7 @@ parse_args(int c, char *v[]); static volatile sig_atomic_t got_sighup, got_sigchld; -static int timeRunning, virtualTime, clockTime; +static time_t timeRunning, virtualTime, clockTime; static long GMToff; static void @@ -205,7 +205,7 @@ find_jobs(virtualTime, database, FALSE, TRUE); set_time(FALSE); -} while (virtualTime timeRunning +} while (virtualTime timeRunning clockTime == timeRunning); break; @@ -265,20 +265,32 @@ } static void -find_jobs(int vtime, cron_db *db, int doWild, int doNonWild) { +find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { time_t virtualSecond = vtime * SECONDS_PER_MINUTE; struct tm *tm = gmtime(virtualSecond); int minute, hour, dom, month, dow; user *u; entry *e; + char *orig_tz, *job_tz; - /* make 0-based values out of these so we can use them as indicies - */ - minute = tm-tm_min -FIRST_MINUTE; - hour = tm-tm_hour -FIRST_HOUR; - dom = tm-tm_mday -FIRST_DOM; - month = tm-tm_mon +1 /* 0..11 - 1..12 */ -FIRST_MONTH; - dow = tm-tm_wday -FIRST_DOW; +#define maketime(tz1, tz2) do { \ + char *t = tz1; \ + if (t != NULL *t != '\0') \ + setenv(TZ, t, 1); \ + else if ((tz2) != NULL) \ + setenv(TZ, (tz2), 1); \ + else \ + unsetenv(TZ); \ + tm = localtime(virtualSecond); \ + minute = tm-tm_min -FIRST_MINUTE; \ + hour = tm-tm_hour -FIRST_HOUR; \ + dom = tm-tm_mday -FIRST_DOM; \ + month = tm-tm_mon + 1 /* 0..11 - 1..12 */ -FIRST_MONTH; \ + dow = tm-tm_wday -FIRST_DOW; \ + } while (/*CONSTCOND*/0) + + orig_tz = getenv(TZ); + maketime(NULL, orig_tz); Debug(DSCH, ([%ld] tick(%d,%d,%d,%d,%d) %s %s\n, (long)getpid(), minute, hour, dom, month, dow, @@ -295,6 +307,8 @@ Debug(DSCH|DEXT, (user [%s:%ld:%ld:...] cmd=\%s\\n, e-pwd-pw_name, (long)e-pwd-pw_uid, (long)e-pwd-pw_gid, e-cmd)); + job_tz = env_get(CRON_TZ, e-envp); + maketime(job_tz, orig_tz); if (bit_test(e-minute, minute) bit_test(e-hour, hour) bit_test(e-month, month) @@ -306,7 +320,7 @@ if ((doNonWild !(e-flags (MIN_STAR|HR_STAR))) || (doWild (e-flags (MIN_STAR|HR_STAR - job_add(e, u, virtualSecond); + job_add(e, u, StartTime); } } } @@ -332,7 +346,7 @@ Debug(DSCH, ([%ld] GMToff=%ld\n, (long)getpid(), (long)GMToff)); } - clockTime = (int)((StartTime + GMToff) / (time_t)SECONDS_PER_MINUTE); + clockTime = (StartTime + GMToff) / (time_t)SECONDS_PER_MINUTE; } /*
CVS commit: src/external/bsd/cron/dist
Module Name:src Committed By: christos Date: Thu May 6 22:38:14 UTC 2010 Modified Files: src/external/bsd/cron/dist: cron.c Log Message: remember to restore the original timezone. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/bsd/cron/dist/cron.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/cron/dist/cron.c diff -u src/external/bsd/cron/dist/cron.c:1.3 src/external/bsd/cron/dist/cron.c:1.4 --- src/external/bsd/cron/dist/cron.c:1.3 Thu May 6 17:50:16 2010 +++ src/external/bsd/cron/dist/cron.c Thu May 6 18:38:14 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cron.c,v 1.3 2010/05/06 21:50:16 christos Exp $ */ +/* $NetBSD: cron.c,v 1.4 2010/05/06 22:38:14 christos Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -25,7 +25,7 @@ #if 0 static char rcsid[] = Id: cron.c,v 1.12 2004/01/23 18:56:42 vixie Exp; #else -__RCSID($NetBSD: cron.c,v 1.3 2010/05/06 21:50:16 christos Exp $); +__RCSID($NetBSD: cron.c,v 1.4 2010/05/06 22:38:14 christos Exp $); #endif #endif @@ -324,6 +324,10 @@ } } } + if (orig_tz != NULL) + setenv(TZ, orig_tz, 1); + else + unsetenv(TZ); } /*
CVS commit: src/external/bsd/cron
Module Name:src Committed By: christos Date: Thu May 6 23:19:56 UTC 2010 Added Files: src/external/bsd/cron: cron2netbsd Log Message: for posterity. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/external/bsd/cron/cron2netbsd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/external/bsd/cron/cron2netbsd diff -u /dev/null src/external/bsd/cron/cron2netbsd:1.1 --- /dev/null Thu May 6 19:19:56 2010 +++ src/external/bsd/cron/cron2netbsd Thu May 6 19:19:56 2010 @@ -0,0 +1,105 @@ +#! /bin/sh +# +# $NetBSD: cron2netbsd,v 1.1 2010/05/06 23:19:56 christos Exp $ +# +# Copyright (c) 2000 The NetBSD Foundation, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +#notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +#notice, this list of conditions and the following disclaimer in the +#documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# cron2netbsd: convert an cron source tree into a +# netbsd cron source tree, under src/external/bsd/cron, +# based on bind2netbsd by Bernd Ernesti and changes by Simon Burge +# +# Rough instructions for importing new cron release: +# +# $ cd /some/where/temporary +# $ tar xpfz /new/cron/release/tar/file +# $ sh /usr/src/external/bsd/cron/dist/cron2netbsd crondir `pwd` +# $ cd src/external/bsd/cron/dist +# $ cvs -d cvs.netbsd.org:/cvsroot import -m Import cron 4.1 src/external/bsd/cron/dist ISC cron-4_1 +# +# - check makefiles to see if any extra sources have been added. +# - update distrib/sets if necessary. + +if [ $# -ne 2 ]; then echo cron2netbsd src dest; exit 1; fi + +r=$1 +d=$2/src/external/bsd/cron/dist + +case $d in + /*) + ;; + *) + d=`/bin/pwd`/$d + ;; +esac + +case $r in + /*) + ;; + *) + r=`/bin/pwd`/$r + ;; +esac + +echo preparing directory $d +rm -rf $d +mkdir -p $d + +### Copy the files and directories +echo copying $r to $d +cd $r +pax -rw * $d + +echo removing unneeded directories and files + +### Remove unneeded files +cd $d +rm -f bitstring.h bitstring.3 putman.sh + +### Remove the $'s around RCS tags +find $d -type f -print | xargs egrep -l '\$(Id|Created|Header)' | while read f; do + sed -e 's/\$\(Id.*\) \$/\1/' \ + -e 's/\$\(Created.*\) \$/\1/' \ + -e 's/\$\(Header.*\) \$/\1/' \ + $f /tmp/cron1f$$ mv /tmp/cron1f$$ $f \ + echo removed \$RCS tag from $f +done + +echo cleaning up CVS residue. +( + cd $d + find . -type d -name CVS -print | xargs rm -r +) +echo done + +### Fixing file and directory permissions. +echo Fixing file/directory permissions. +( + cd $d + find . -type f -print | xargs chmod u+rw,go+r + find . -type d -print | xargs chmod u+rwx,go+rx +) +echo done + +exit 0