CVS commit: src/external/bsd/cron/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 17:02:47 UTC 2022

Modified Files:
src/external/bsd/cron/dist: crontab.5

Log Message:
explain CRON_WITHIN better.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/external/bsd/cron/dist/crontab.5:1.11
--- src/external/bsd/cron/dist/crontab.5:1.10	Sat Apr 18 15:32:19 2020
+++ src/external/bsd/cron/dist/crontab.5	Sat Feb 26 12:02:47 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: crontab.5,v 1.10 2020/04/18 19:32:19 christos Exp $
+.\" $NetBSD: crontab.5,v 1.11 2022/02/26 17:02:47 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 April 17, 2020
+.Dd February 26, 2022
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -298,6 +298,12 @@ The
 .Ev CRON_WITHIN
 variable should indicate the number of seconds within a job's
 scheduled time that it should still be run.
+For example if a job is scheduled for 12:30pm and
+.Ev CRON_WITHIN
+is
+.Dv 120
+(2 minutes), then the job will not be run if the system attempts
+to start it past 12:32pm.
 On a heavily loaded system, or on a system that has just been
 .Dq woken up ,
 jobs will sometimes start later than originally intended, and by
@@ -308,7 +314,9 @@ If
 is defined but empty
 .Pq Ev CRON_WITHIN Ns = Ns \&"" ,
 or set to some non-positive value (0, a negative number, or a
-non-numeric string), it is treated as if it was unset.
+non-numeric string), it is treated as if it was unset, that is
+the job will always run, even if it is going to start at a time
+long past its scheduled time.
 .It Ev HOME
 Set from the user's
 .Pa /etc/passwd



CVS commit: src/external/bsd/cron/dist

2022-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 26 17:02:47 UTC 2022

Modified Files:
src/external/bsd/cron/dist: crontab.5

Log Message:
explain CRON_WITHIN better.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.



CVS commit: src/external/bsd/cron/dist

2020-04-18 Thread Christos Zoulas
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

2020-04-18 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2020-04-17 Thread Paul Goyette
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

2020-04-17 Thread Paul Goyette
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.



CVS commit: src/external/bsd/cron/dist

2020-04-17 Thread Christos Zoulas
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

2020-04-17 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2019-08-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug  3 07:06:48 UTC 2019

Modified Files:
src/external/bsd/cron/dist: do_command.c

Log Message:
PR/54433: Hisashi Todd Fujinaka: Empty $MAILTO causes cron to crash


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/external/bsd/cron/dist/do_command.c:1.14
--- src/external/bsd/cron/dist/do_command.c:1.13	Thu Jun 14 18:04:28 2018
+++ src/external/bsd/cron/dist/do_command.c	Sat Aug  3 03:06:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: do_command.c,v 1.13 2018/06/14 22:04:28 christos Exp $	*/
+/*	$NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 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.13 2018/06/14 22:04:28 christos Exp $");
+__RCSID("$NetBSD: do_command.c,v 1.14 2019/08/03 07:06:47 christos Exp $");
 #endif
 #endif
 
@@ -182,7 +182,7 @@ read_data(entry *e, const char *mailto, 
 	/*
 	 * Unsafe, disable mailing.
 	 */
-	if (!safe_p(usernm, mailto))
+	if (mailto && !safe_p(usernm, mailto))
 		mailto = NULL;
 
 	/* if we are supposed to be mailing, MAILTO will



CVS commit: src/external/bsd/cron/dist

2019-08-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug  3 07:06:48 UTC 2019

Modified Files:
src/external/bsd/cron/dist: do_command.c

Log Message:
PR/54433: Hisashi Todd Fujinaka: Empty $MAILTO causes cron to crash


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.



CVS commit: src/external/bsd/cron/dist

2018-07-28 Thread Robert Elz
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

2018-07-28 Thread Robert Elz
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.



CVS commit: src/external/bsd/cron/dist

2018-07-28 Thread Robert Elz
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

2018-07-28 Thread Robert Elz
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.



CVS commit: src/external/bsd/cron/dist

2018-06-15 Thread Thomas Klausner
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

2018-06-15 Thread Thomas Klausner
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.



CVS commit: src/external/bsd/cron/dist

2018-06-14 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2018-06-14 Thread Christos Zoulas
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

2018-06-14 Thread Christos Zoulas
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

2018-06-14 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2018-03-06 Thread Hisashi T Fujinaka
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/dist

2018-03-06 Thread Hisashi T Fujinaka
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.



CVS commit: src/external/bsd/cron/dist

2018-02-03 Thread Christos Zoulas
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

2018-02-03 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2017-09-27 Thread Christos Zoulas
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

2017-09-27 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2017-09-25 Thread Christos Zoulas
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

2017-09-25 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2017-08-17 Thread Christos Zoulas
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/dist

2017-08-17 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2017-06-11 Thread Joerg Sonnenberger
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/dist

2017-06-11 Thread Joerg Sonnenberger
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.



CVS commit: src/external/bsd/cron/dist

2015-12-17 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2015-12-17 Thread Christos Zoulas
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

2015-11-20 Thread Christos Zoulas
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

2015-11-20 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2015-01-04 Thread Joerg Sonnenberger
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.



CVS commit: src/external/bsd/cron/dist

2015-01-04 Thread Joerg Sonnenberger
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

2014-12-15 Thread Christos Zoulas
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

2014-12-15 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2014-09-07 Thread Joerg Sonnenberger
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

2014-09-07 Thread Matthias Scheler
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

2014-09-07 Thread Joerg Sonnenberger
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.



CVS commit: src/external/bsd/cron/dist

2014-09-07 Thread Matthias Scheler
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.



CVS commit: src/external/bsd/cron/dist

2014-09-06 Thread Christos Zoulas
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

2014-09-06 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2014-09-05 Thread Christos Zoulas
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/dist

2014-09-05 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2014-06-24 Thread Nick Hudson
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

2014-06-24 Thread Nick Hudson
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.



Re: CVS commit: src/external/bsd/cron/dist

2014-06-22 Thread David Holland
On Sat, Jun 21, 2014 at 02:20:59PM +, Christos Zoulas wrote:
  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.
  
  ??? This code is not used. We are using the LOGIN_CAP code. What are you
  trying to fix?

Isn't it? (All of it?) I had a problem at one point (a few months
back, I think, it took me a while to remember to fetch the patch out
and commit it) that was printing a useless message, and I added some
extra information to diagnose it, and in the course of found a lot of
similar diagnostics and patched them all for completeness.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/external/bsd/cron/dist

2014-06-22 Thread Christos Zoulas
On Jun 22,  4:50pm, dholland-sourcechan...@netbsd.org (David Holland) wrote:
-- Subject: Re: CVS commit: src/external/bsd/cron/dist

| On Sat, Jun 21, 2014 at 02:20:59PM +, Christos Zoulas wrote:
|   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.
|   
|   ??? This code is not used. We are using the LOGIN_CAP code. What are you
|   trying to fix?
| 
| Isn't it? (All of it?) I had a problem at one point (a few months
| back, I think, it took me a while to remember to fetch the patch out
| and commit it) that was printing a useless message, and I added some
| extra information to diagnose it, and in the course of found a lot of
| similar diagnostics and patched them all for completeness.

All of it :-)

christos


Re: CVS commit: src/external/bsd/cron/dist

2014-06-22 Thread David Holland
On Sun, Jun 22, 2014 at 04:53:50PM -0400, Christos Zoulas wrote:
  |   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.
  |   
  |   ??? This code is not used. We are using the LOGIN_CAP code. What are you
  |   trying to fix?
  | 
  | Isn't it? (All of it?) I had a problem at one point (a few months
  | back, I think, it took me a while to remember to fetch the patch out
  | and commit it) that was printing a useless message, and I added some
  | extra information to diagnose it, and in the course of found a lot of
  | similar diagnostics and patched them all for completeness.
  
  All of it :-)

The chdir one is outside of LOGIN_CAP. That's the one I hit, I think
because of nfs/nis issues, and I fixed the rest because they're all
the same.

I think I was contemplating sending the patch upstream. (is that
worthwhile?)

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/external/bsd/cron/dist

2014-06-22 Thread Christos Zoulas
On Jun 22,  8:58pm, dholland-sourcechan...@netbsd.org (David Holland) wrote:
-- Subject: Re: CVS commit: src/external/bsd/cron/dist

| On Sun, Jun 22, 2014 at 04:53:50PM -0400, Christos Zoulas wrote:
|   |   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.
|   |   
|   |   ??? This code is not used. We are using the LOGIN_CAP code. What are 
you
|   |   trying to fix?
|   | 
|   | Isn't it? (All of it?) I had a problem at one point (a few months
|   | back, I think, it took me a while to remember to fetch the patch out
|   | and commit it) that was printing a useless message, and I added some
|   | extra information to diagnose it, and in the course of found a lot of
|   | similar diagnostics and patched them all for completeness.
|   
|   All of it :-)
| 
| The chdir one is outside of LOGIN_CAP. That's the one I hit, I think
| because of nfs/nis issues, and I fixed the rest because they're all
| the same.

That's the only one. I would have fixed them by also printing the string
that failed not just the user info. But that's better than before.

| I think I was contemplating sending the patch upstream. (is that
| worthwhile?)

Go for it. We have a *lot* of other patches that should be sent upstream
too.

christos


CVS commit: src/external/bsd/cron/dist

2014-06-22 Thread Christos Zoulas
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

2014-06-22 Thread Christos Zoulas
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.



Re: CVS commit: src/external/bsd/cron/dist

2014-06-21 Thread Christos Zoulas
In article 20140621043353.5eb4...@cvs.netbsd.org,
David A. Holland source-changes-d@NetBSD.org wrote:
-=-=-=-=-=-

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.

??? This code is not used. We are using the LOGIN_CAP code. What are you
trying to fix?

christos



CVS commit: src/external/bsd/cron/dist

2014-06-20 Thread David A. Holland
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

2014-06-20 Thread David A. Holland
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.



Re: CVS commit: src/external/bsd/cron/dist

2012-12-25 Thread Christos Zoulas
In article 15993.1356420...@splode.eterna.com.au,
matthew green  m...@eterna.com.au wrote:

 On Mon, Dec 24, 2012 at 02:30:46PM -0500, Christos Zoulas wrote:
   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.

wasn't the problem that mode 0400 files were rejected?  ie, read-only
not writable files.

Yes, it was allowing 0600 and not allowing 0400. Now it allows both.

christos



Re: CVS commit: src/external/bsd/cron/dist

2012-12-25 Thread Bernd Ernesti
On Tue, Dec 25, 2012 at 02:13:57PM +, Christos Zoulas wrote:
 In article 15993.1356420...@splode.eterna.com.au,
 matthew green  m...@eterna.com.au wrote:
 
  On Mon, Dec 24, 2012 at 02:30:46PM -0500, Christos Zoulas wrote:
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.
 
 wasn't the problem that mode 0400 files were rejected?  ie, read-only
 not writable files.
 
 Yes, it was allowing 0600 and not allowing 0400. Now it allows both.

The commit message suggested something differently: Allow file being writable 
by owner.

I haven't checked the source but when does this happen and what is the
result of this change now?
Can you now change a read only file in /var/cron/tabs with crontab -e?

Bernd



Re: CVS commit: src/external/bsd/cron/dist

2012-12-25 Thread Christos Zoulas
In article 20121225142253.ge2...@arresum.veego.de,
Bernd Ernesti  net...@lists.veego.de wrote:

The commit message suggested something differently: Allow file being
writable by owner.

It should say not writable. I've fixed it.

I haven't checked the source but when does this happen and what is the
result of this change now?
Can you now change a read only file in /var/cron/tabs with crontab -e?

Writing should behave exactly like before.

christos



re: CVS commit: src/external/bsd/cron/dist

2012-12-25 Thread matthew green

  On Mon, Dec 24, 2012 at 02:30:46PM -0500, Christos Zoulas wrote:
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.
 
 wasn't the problem that mode 0400 files were rejected?  ie, read-only
 not writable files.

could you please fix the commit log?  it says the opposite.


.mrg.


Re: CVS commit: src/external/bsd/cron/dist

2012-12-24 Thread David Holland
On Mon, Dec 24, 2012 at 02:30:46PM -0500, Christos Zoulas wrote:
  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.

On reflection, I suspect that restriction was intentional -- e.g. for
a restricted user whose homedir is owned by root and so forth, you
might want to give them a crontab but not let them modify it.

-- 
David A. Holland
dholl...@netbsd.org


re: CVS commit: src/external/bsd/cron/dist

2012-12-24 Thread matthew green

 On Mon, Dec 24, 2012 at 02:30:46PM -0500, Christos Zoulas wrote:
   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.

wasn't the problem that mode 0400 files were rejected?  ie, read-only
not writable files.

 On reflection, I suspect that restriction was intentional -- e.g. for
 a restricted user whose homedir is owned by root and so forth, you
 might want to give them a crontab but not let them modify it.


.mrg.


CVS commit: src/external/bsd/cron/dist

2012-12-24 Thread Christos Zoulas
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

2012-12-24 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2012-11-03 Thread Christos Zoulas
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

2012-11-03 Thread Christos Zoulas
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

2012-11-03 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2012-11-03 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2012-03-04 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sun Mar  4 18:38:31 UTC 2012

Modified Files:
src/external/bsd/cron/dist: crontab.c

Log Message:
Fix multiple problems in previous commit:
1.) Correct set-uid check to allow root to run crontab -l again.
2.) Don't the the last error reported in errno in case crontab is not
installed set-uid root. As no system-call failed errno is set
to zero.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.



CVS commit: src/external/bsd/cron/dist

2012-03-02 Thread Christos Zoulas
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

2012-03-02 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2011-10-14 Thread Christos Zoulas
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

2011-10-14 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2011-10-13 Thread Joerg Sonnenberger
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

2011-10-13 Thread Joerg Sonnenberger
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.



Re: CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Jukka Ruohonen
On Wed, Oct 12, 2011 at 12:39:48PM -0400, Christos Zoulas wrote:
 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/

Not that I see much point in the whole commit, but what are these rpms and
how they are related to NetBSD?

- Jukka.

+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



Re: CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Christos Zoulas
In article 20111012181619.GA24188@marx.bitnet,
Jukka Ruohonen  jruoho...@iki.fi wrote:
On Wed, Oct 12, 2011 at 12:39:48PM -0400, Christos Zoulas wrote:
 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/

Not that I see much point in the whole commit, but what are these rpms and
how they are related to NetBSD?

They are not, they were present in the original patch which came from
redhat, and I thought why not leave them in? The way they are done we
can use the code to exclude other names if we need to (.old, .orig, .save,
etc.) if we need to.

christos



Re: CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Thomas Klausner
On Wed, Oct 12, 2011 at 12:39:48PM -0400, Christos Zoulas wrote:
 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/

If we're magically skipping files, shouldn't we rather skip .orig instead of 
.rpmorig etc?
 Thomas


Re: CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread David Holland
On Wed, Oct 12, 2011 at 12:39:48PM -0400, Christos Zoulas wrote:
  Modified Files:
   src/external/bsd/cron/dist: cron.8 database.c pathnames.h
  
  Log Message:
  process files in /etc/cron.d/

For the record, I object to this change. I think keeping /etc small
and simple, and having one right way to do any given thing, is more
important (much more important in the long run) than making it
slightly easier to install canned cron scripts from packages.

This is predicated on the assumption that it's easier for a human to
handle one moderately large structured file than a lot of little tiny
files, but I believe this to be reasonable.


(...also, if I wanted redhat I know where to get it.)
-- 
David A. Holland
dholl...@netbsd.org


CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Christos Zoulas
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

2011-10-12 Thread Christos Zoulas
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

2011-10-12 Thread Thomas Klausner
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

2011-10-12 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2011-10-12 Thread Thomas Klausner
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.



CVS commit: src/external/bsd/cron/dist

2011-07-16 Thread Christos Zoulas
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

2011-07-16 Thread Christos Zoulas
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

2011-07-16 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2011-07-16 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2010-10-02 Thread Matthias Scheler
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

2010-07-15 Thread Christos Zoulas
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

2010-07-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul 15 20:04:14 UTC 2010

Modified Files:
src/external/bsd/cron/dist: database.c

Log Message:
PR/43623: Takahiro Kambe: Allow /etc/crontab processing if it is not writable,
don't insist that it is mode 0600.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.



CVS commit: src/external/bsd/cron/dist

2010-07-10 Thread Christos Zoulas
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

2010-07-10 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2010-05-19 Thread Christos Zoulas
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

2010-05-19 Thread Christos Zoulas
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.



CVS commit: src/external/bsd/cron/dist

2010-05-18 Thread Christos Zoulas
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);



  1   2   >