CVS commit: src/usr.sbin/cron

2011-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 30 10:08:12 UTC 2011

Removed Files:
src/usr.sbin/cron: Makefile compat.c compat.h config.h cron.8 cron.c
cron.h crontab.1 crontab.5 crontab.c database.c do_command.c
entry.c env.c externs.h job.c misc.c pathnames.h popen.c user.c

Log Message:
in external now


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r0 src/usr.sbin/cron/Makefile src/usr.sbin/cron/env.c
cvs rdiff -u -r1.5 -r0 src/usr.sbin/cron/compat.c src/usr.sbin/cron/cron.h \
src/usr.sbin/cron/pathnames.h
cvs rdiff -u -r1.4 -r0 src/usr.sbin/cron/compat.h src/usr.sbin/cron/externs.h \
src/usr.sbin/cron/user.c
cvs rdiff -u -r1.7 -r0 src/usr.sbin/cron/config.h src/usr.sbin/cron/crontab.1 \
src/usr.sbin/cron/database.c
cvs rdiff -u -r1.8 -r0 src/usr.sbin/cron/cron.8
cvs rdiff -u -r1.13 -r0 src/usr.sbin/cron/cron.c
cvs rdiff -u -r1.14 -r0 src/usr.sbin/cron/crontab.5 src/usr.sbin/cron/misc.c
cvs rdiff -u -r1.33 -r0 src/usr.sbin/cron/crontab.c
cvs rdiff -u -r1.25 -r0 src/usr.sbin/cron/do_command.c
cvs rdiff -u -r1.10 -r0 src/usr.sbin/cron/entry.c
cvs rdiff -u -r1.6 -r0 src/usr.sbin/cron/job.c
cvs rdiff -u -r1.11 -r0 src/usr.sbin/cron/popen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/cron

2010-03-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Mar 12 09:36:15 UTC 2010

Modified Files:
src/usr.sbin/cron: crontab.5

Log Message:
Quote question mark so it's correctly marked up.
Problem reported by Ryo HAYASAKA in PR 42963.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/cron/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/usr.sbin/cron/crontab.5
diff -u src/usr.sbin/cron/crontab.5:1.13 src/usr.sbin/cron/crontab.5:1.14
--- src/usr.sbin/cron/crontab.5:1.13	Sat Apr  4 17:29:59 2009
+++ src/usr.sbin/cron/crontab.5	Fri Mar 12 09:36:15 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: crontab.5,v 1.13 2009/04/04 17:29:59 wiz Exp $
+.\	$NetBSD: crontab.5,v 1.14 2010/03/12 09:36:15 wiz Exp $
 .\
 .\/* Copyright 1988,1990,1993,1994 by Paul Vixie
 .\ * All rights reserved
@@ -198,7 +198,7 @@
 entry specifies execution at hours 8, 9, 10, and 11.
 .Pp
 A field may begin with a question mark
-.Pq Sq ? ,
+.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



CVS commit: src/usr.sbin/cron

2009-04-11 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Apr 11 12:44:29 UTC 2009

Modified Files:
src/usr.sbin/cron: crontab.c

Log Message:
fix -Wcast-qual issues


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/cron/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/usr.sbin/cron/crontab.c
diff -u src/usr.sbin/cron/crontab.c:1.30 src/usr.sbin/cron/crontab.c:1.31
--- src/usr.sbin/cron/crontab.c:1.30	Wed May 24 21:43:43 2006
+++ src/usr.sbin/cron/crontab.c	Sat Apr 11 12:44:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: crontab.c,v 1.30 2006/05/24 21:43:43 christos Exp $	*/
+/*	$NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $	*/
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp;
 #else
-__RCSID($NetBSD: crontab.c,v 1.30 2006/05/24 21:43:43 christos Exp $);
+__RCSID($NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $);
 #endif
 #endif
 
@@ -62,7 +62,7 @@
 enum opt_t	{ opt_unknown, opt_list, opt_delete, opt_edit, opt_replace };
 
 #if DEBUGGING
-static char	*Options[] = { ???, list, delete, edit, replace };
+static const char *Options[] = { ???, list, delete, edit, replace };
 #endif
 
 
@@ -80,12 +80,12 @@
 			check_error(const char *),
 			parse_args(int c, char *v[]),
 			skip_header(int *, FILE *),
-			usage(char *);
+			usage(const char *);
 static	int		replace_cmd(void);
 
 
 static void
-usage(char *msg)
+usage(const char *msg)
 {
 	fprintf(stderr, %s: usage error: %s\n, getprogname(), msg);
 	fprintf(stderr, usage:\t%s [-u user] file\n, getprogname());
@@ -568,7 +568,7 @@
 	fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n);
 	fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now));
 	fprintf(tmp, # (Cron version -- %s)\n,
-	$NetBSD: crontab.c,v 1.30 2006/05/24 21:43:43 christos Exp $);
+	$NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $);
 
 	/* copy the crontab to the tmp
 	 */



CVS commit: src/usr.sbin/cron

2009-04-11 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Apr 11 12:55:29 UTC 2009

Modified Files:
src/usr.sbin/cron: crontab.c

Log Message:
fix -Wsign-compare issue on amd64


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/cron/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/usr.sbin/cron/crontab.c
diff -u src/usr.sbin/cron/crontab.c:1.31 src/usr.sbin/cron/crontab.c:1.32
--- src/usr.sbin/cron/crontab.c:1.31	Sat Apr 11 12:44:29 2009
+++ src/usr.sbin/cron/crontab.c	Sat Apr 11 12:55:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $	*/
+/*	$NetBSD: crontab.c,v 1.32 2009/04/11 12:55:29 lukem Exp $	*/
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp;
 #else
-__RCSID($NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $);
+__RCSID($NetBSD: crontab.c,v 1.32 2009/04/11 12:55:29 lukem Exp $);
 #endif
 #endif
 
@@ -554,7 +554,7 @@
 	warn(error stat'ing crontab input);
 	goto out;
 	}
-	if (statbuf.st_size  maxtabsize)  {
+	if (statbuf.st_size  (off_t)maxtabsize)  {
 	warnx(%ld bytes is larger than the maximum size of %ld bytes,
 		(long) statbuf.st_size, (long) maxtabsize);
 	val = -1;
@@ -568,7 +568,7 @@
 	fprintf(tmp, # DO NOT EDIT THIS FILE - edit the master and reinstall.\n);
 	fprintf(tmp, # (%s installed on %-24.24s)\n, Filename, ctime(now));
 	fprintf(tmp, # (Cron version -- %s)\n,
-	$NetBSD: crontab.c,v 1.31 2009/04/11 12:44:29 lukem Exp $);
+	$NetBSD: crontab.c,v 1.32 2009/04/11 12:55:29 lukem Exp $);
 
 	/* copy the crontab to the tmp
 	 */



CVS commit: src/usr.sbin/cron

2009-04-04 Thread Perry E. Metzger
Module Name:src
Committed By:   perry
Date:   Sat Apr  4 16:05:10 UTC 2009

Modified Files:
src/usr.sbin/cron: crontab.5 entry.c

Log Message:
New feature: ? for time specifications, means a single time selected at
random from within the range at file read time. Very useful if you
want to avoid having a fleet of machines melt a server by all trying to
contact it at a precise time every morning. See docs for details.

Reviewed by: christos, apb, vixie, others.

XXX apb suggests, quite reasonably, that ?10-16/2 should mean
something like 10,12,14,16 or 11,13,15. I'm too lazy to do it right
now, but it should be done.

XXX vixie suggests, quite reasonably, that if you're using ? one
should delay randomly by 0-59 seconds. In the modern NTP world, you
could imagine that with a million well synchronized machines the
second just at the minute would be hit quite hard. I'm too lazy to do
it right now, but it should be done.

XXX cron needs to be updated to Vixie's cron 4.1 code.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/cron/crontab.5
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/cron/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/usr.sbin/cron/crontab.5
diff -u src/usr.sbin/cron/crontab.5:1.11 src/usr.sbin/cron/crontab.5:1.12
--- src/usr.sbin/cron/crontab.5:1.11	Thu Sep  2 11:41:27 2004
+++ src/usr.sbin/cron/crontab.5	Sat Apr  4 16:05:10 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: crontab.5,v 1.11 2004/09/02 11:41:27 jmmv Exp $
+.\	$NetBSD: crontab.5,v 1.12 2009/04/04 16:05:10 perry Exp $
 .\
 .\/* Copyright 1988,1990,1993,1994 by Paul Vixie
 .\ * All rights reserved
@@ -135,6 +135,20 @@
 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10
 and 11.
 .PP
+A field may begin with a question mark (?), 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, ``? ?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.
+.PP
 Lists are allowed.  A list is a set of numbers (or ranges)
 separated by commas.  Examples: ``1,2,5,9'', ``0-4,8-12''.
 .PP
@@ -211,6 +225,7 @@
 0 22 * * 1-5mail -s It's 10pm joe%Joe,%%Where are your kids?%
 23 0-23/2 * * * echo run 23 minutes after midn, 2am, 4am ..., everyday
 5 4 * * sun echo run at 5 after 4 every sunday
+? ?2-4 1,15 * * echo random between 2am-4:59am on the 1st and 15th
 .fi
 .SH SEE ALSO
 cron(8), crontab(1)

Index: src/usr.sbin/cron/entry.c
diff -u src/usr.sbin/cron/entry.c:1.9 src/usr.sbin/cron/entry.c:1.10
--- src/usr.sbin/cron/entry.c:1.9	Sat Feb 16 07:26:00 2008
+++ src/usr.sbin/cron/entry.c	Sat Apr  4 16:05:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: entry.c,v 1.9 2008/02/16 07:26:00 matt Exp $	*/
+/*	$NetBSD: entry.c,v 1.10 2009/04/04 16:05:10 perry Exp $	*/
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = Id: entry.c,v 2.12 1994/01/17 03:20:37 vixie Exp;
 #else
-__RCSID($NetBSD: entry.c,v 1.9 2008/02/16 07:26:00 matt Exp $);
+__RCSID($NetBSD: entry.c,v 1.10 2009/04/04 16:05:10 perry Exp $);
 #endif
 #endif
 
@@ -358,6 +358,18 @@
 }
 
 
+static int
+random_with_range(int low, int high)
+{
+	/* Kind of crappy error detection, but...
+	 */
+	if (low = high)
+		return low;
+	else
+		return arc4random() % (high - low + 1) + low;
+}
+
+
 static char
 get_range(bitstr_t *bits,   /* one bit per flag, default=FALSE */
   int low,  /* bounds, impl. offset for bitstr */
@@ -371,24 +383,44 @@
 
 	int	i;
 	int	num1, num2, num3;
+	int	qmark, star;
+
+	qmark = star = FALSE;
 
 	Debug(DPARS|DEXT, (get_range()...entering, exit won't show\n))
 
 	if (ch == '*') {
 		/* '*' means first-last but can still be modified by /step
 		 */
+		star = TRUE;
 		num1 = low;
 		num2 = high;
 		ch = get_char(file);
 		if (ch == EOF)
 			return EOF;
-	} else {
+	} else if (ch == '?') {
+		qmark = TRUE;
+		ch = get_char(file);
+		if (ch == EOF)
+			return EOF;
+		if (!isdigit(ch)) {
+			num1 = random_with_range(low, high);
+			if (EOF == set_element(bits, low, high, num1))
+return EOF;
+			return ch;
+		}
+	}
+
+	if (!star) {
 		if (EOF == (ch = get_number(num1, low, names, ch, file)))
 			return EOF;
 
 		if (ch != '-') {
 			/* not a range, it's a single number.
+			 * a single number after '?' is bogus.
 			 */
+			if (qmark)
+return EOF;
 			if (EOF == set_element(bits, low, high, num1))
 return EOF;