git: fe590ffe40f4 - main - Import vixie cron 4.0

From: Eric van Gyzen <vangyzen_at_FreeBSD.org>
Date: Thu, 01 Jun 2023 19:14:25 UTC
The branch main has been updated by vangyzen:

URL: https://cgit.FreeBSD.org/src/commit/?id=fe590ffe40f49fe09d8275fbf29f0d46c5b99dc7

commit fe590ffe40f49fe09d8275fbf29f0d46c5b99dc7
Author:     Eric van Gyzen <vangyzen@FreeBSD.org>
AuthorDate: 2023-06-01 19:14:07 +0000
Commit:     Eric van Gyzen <vangyzen@FreeBSD.org>
CommitDate: 2023-06-01 19:14:07 +0000

    Import vixie cron 4.0
    
    Specifically, import the diff from commit e745bd4c10ab to
    commit 83563783cc2 in https://github.com/vixie/cron.git
    
    My sole motivation is changing to the common MIT license.
    The old license, especially the "buildable source" clause,
    is unfriendly for commercial users of this code.  Simply
    changing the license without importing [most of] the code
    accompanying that license seemed legally dubious.
    
    The most regrettable change is losing Paul's uucp path.
    I partially atone for this loss by restoring the upstream
    $Id$ tags, since $FreeBSD$ is no longer useful.
    
    This is [intended to be] a complete list of the functional
    changes in this commit.  Some changes were made so that we
    could consider vixie cron to be our upstream and reduce our
    diffs against it, while others were simply a good idea.
    
    - main() - use putenv instead of setenv for PATH
    - open_pidfile no longer needs snprintf to build pidfile
    - crontab main() - abort() on impossible errors
    - check for truncation when building strings with snprintf
    - getdtablesize() -> sysconf(_SC_OPEN_MAX)
    
    These changes were not taken from upstream's 4.0 diff because
    they [could] actually change behavior.  Some of them might be
    beneficial, but should be taken separately.
    
    - config.h - sendmail args: remove -oi and add -or0s
    - call setlocale(LC_ALL, "") at the top of main()
    - acquire_daemonlock - we already use pidfile
    - cast getpid(), uid_t, and gid_t to long for printf
    - remove unnecessary braces - I consider them beneficial
    - BSDi support
    - glue_strings() - use snprintf(), as we often already did
    
    MFC after:      on demand
    Sponsored by:   Dell EMC Isilon
    Differential Revision:  https://reviews.freebsd.org/D40260
---
 usr.sbin/cron/cron/compat.h      | 136 -----------------
 usr.sbin/cron/cron/config.h      |  56 +++----
 usr.sbin/cron/cron/cron.8        |  32 ++--
 usr.sbin/cron/cron/cron.c        | 139 +++++++----------
 usr.sbin/cron/cron/cron.h        | 323 +++------------------------------------
 usr.sbin/cron/cron/database.c    |  92 ++++++-----
 usr.sbin/cron/cron/do_command.c  | 124 +++++++--------
 usr.sbin/cron/cron/externs.h     | 199 +++++++++++-------------
 usr.sbin/cron/cron/funcs.h       |  70 +++++++++
 usr.sbin/cron/cron/globals.h     |  78 ++++++++++
 usr.sbin/cron/cron/job.c         |  50 +++---
 usr.sbin/cron/cron/macros.h      | 134 ++++++++++++++++
 usr.sbin/cron/cron/pathnames.h   |  44 +++---
 usr.sbin/cron/cron/popen.c       |  33 ++--
 usr.sbin/cron/cron/structs.h     |  81 ++++++++++
 usr.sbin/cron/cron/user.c        |  58 +++----
 usr.sbin/cron/crontab/crontab.1  |  30 ++--
 usr.sbin/cron/crontab/crontab.5  |  30 ++--
 usr.sbin/cron/crontab/crontab.c  | 174 ++++++++++-----------
 usr.sbin/cron/doc/INSTALL        |  28 ++--
 usr.sbin/cron/doc/Makefile.vixie |  68 ++++-----
 usr.sbin/cron/doc/README         |  46 +++---
 usr.sbin/cron/lib/compat.c       | 225 ---------------------------
 usr.sbin/cron/lib/entry.c        | 106 ++++++++-----
 usr.sbin/cron/lib/env.c          |  50 +++---
 usr.sbin/cron/lib/misc.c         |  83 +++++-----
 26 files changed, 1091 insertions(+), 1398 deletions(-)

diff --git a/usr.sbin/cron/cron/compat.h b/usr.sbin/cron/cron/compat.h
deleted file mode 100644
index ba32a31b417e..000000000000
--- a/usr.sbin/cron/cron/compat.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 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 Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
- */
-
-/*
- * $FreeBSD$
- */
-
-#ifndef __P
-# ifdef __STDC__
-#  define __P(x) x
-# else
-#  define __P(x) ()
-#  define const
-# endif
-#endif
-
-#if defined(UNIXPC) || defined(unixpc)
-# define UNIXPC 1
-# define ATT 1
-#endif
-
-#if defined(hpux) || defined(_hpux) || defined(__hpux)
-# define HPUX 1
-# define seteuid(e) setresuid(-1,e,-1)
-# define setreuid(r,e)	setresuid(r,e,-1)
-#endif
-
-#if defined(_IBMR2)
-# define AIX 1
-#endif
-
-#if defined(__convex__)
-# define CONVEX 1
-#endif
-
-#if defined(sgi) || defined(_sgi) || defined(__sgi)
-# define IRIX 1
-/* IRIX 4 hdrs are broken: one cannot #include both <stdio.h>
- * and <stdlib.h> because they disagree on system(), perror().
- * Therefore we must zap the "const" keyword BEFORE including
- * either of them.
- */
-# define const
-#endif
-
-#if defined(_UNICOS)
-# define UNICOS 1
-#endif
-
-#ifndef POSIX
-# if (BSD >= 199103) || defined(__linux) || defined(ultrix) || defined(AIX) ||\
-	defined(HPUX) || defined(CONVEX) || defined(IRIX)
-#  define POSIX
-# endif
-#endif
-
-#ifndef BSD
-# if defined(ultrix)
-#  define BSD 198902
-# endif
-#endif
-
-/*****************************************************************/
-
-#if (!defined(BSD) || (BSD < 198902)) && !defined(__linux) && \
-	!defined(IRIX) && !defined(NeXT) && !defined(HPUX)
-# define NEED_STRCASECMP
-#endif
-
-#if (!defined(BSD) || (BSD < 198911)) && !defined(__linux) &&\
-	!defined(IRIX) && !defined(UNICOS) && !defined(HPUX)
-# define NEED_STRDUP
-#endif
-
-#if (!defined(BSD) || (BSD < 198911)) && !defined(POSIX) && !defined(NeXT)
-# define NEED_STRERROR
-#endif
-
-#if defined(HPUX) || defined(AIX) || defined(UNIXPC)
-# define NEED_FLOCK
-#endif
-
-#ifndef POSIX
-# define NEED_SETSID
-#endif
-
-#if (defined(POSIX) && !defined(BSD)) && !defined(__linux)
-# define NEED_GETDTABLESIZE
-#endif
-
-#ifdef POSIX
-#include <unistd.h>
-#ifdef _POSIX_SAVED_IDS
-# define HAVE_SAVED_UIDS
-#endif
-#endif
-
-#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && !defined(UNICOS)
-# define USE_SIGCHLD
-#endif
-
-#if !defined(AIX) && !defined(UNICOS)
-# define SYS_TIME_H 1
-#else
-# define SYS_TIME_H 0
-#endif
-
-#if defined(BSD) && !defined(POSIX)
-# define USE_UTIMES
-#endif
-
-#if defined(AIX) || defined(HPUX) || defined(IRIX)
-# define NEED_SETENV
-#endif
-
-#if !defined(UNICOS) && !defined(UNIXPC)
-# define HAS_FCHOWN
-#endif
-
-#if !defined(UNICOS) && !defined(UNIXPC)
-# define HAS_FCHMOD
-#endif
diff --git a/usr.sbin/cron/cron/config.h b/usr.sbin/cron/cron/config.h
index 6d77da27580d..ea30c8def194 100644
--- a/usr.sbin/cron/cron/config.h
+++ b/usr.sbin/cron/cron/config.h
@@ -1,29 +1,29 @@
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
  *
- * 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.
+ * 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.
  *
- * 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 Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM 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.
  */
 
 /* config.h - configurables for Vixie Cron
  *
- * $FreeBSD$
+ * $Id: config.h,v 1.2 1998/08/14 00:32:36 vixie Exp $
  */
 
-#if !defined(_PATH_SENDMAIL)
-# define _PATH_SENDMAIL "/usr/lib/sendmail"
-#endif /*SENDMAIL*/
-
 /*
  * these are site-dependent
  */
@@ -33,35 +33,35 @@
 #endif
 
 			/*
-			 * choose one of these MAILCMD commands.  I use
+			 * choose one of these mailer commands.  some use
 			 * /bin/mail for speed; it makes biff bark but doesn't
-			 * do aliasing.  /usr/lib/sendmail does aliasing but is
+			 * do aliasing.  sendmail does do aliasing but is
 			 * a hog for short messages.  aliasing is not needed
 			 * if you make use of the MAILTO= feature in crontabs.
 			 * (hint: MAILTO= was added for this reason).
 			 */
 
-#define MAILCMD _PATH_SENDMAIL					/*-*/
-#define MAILARGS "%s -FCronDaemon -odi -oem -oi -t"             /*-*/
+#define MAILFMT "%s -FCronDaemon -odi -oem -oi -t"	/*-*/
 			/* -Fx	 = set full-name of sender
 			 * -odi	 = Option Deliverymode Interactive
 			 * -oem	 = Option Errors Mailedtosender
-			 * -oi   = Option dot message terminator
-			 * -t    = read recipients from header of message
+			 * -or0s = Option Readtimeout -- don't time out
+			 * -t    = Get recipient from headers
 			 */
+#define MAILARG _PATH_SENDMAIL				/*-*/
 
-/* #define MAILCMD "/bin/mail" */		/*-*/
-/* #define MAILARGS "%s -d  %s" */		/*-*/
+/* #define MAILFMT "%s -d %s" */			/*-*/
 			/* -d = undocumented but common flag: deliver locally?
 			 */
+/* #define MAILARG "/bin/mail",mailto */
 
-/* #define MAILCMD "/usr/mmdf/bin/submit" */	/*-*/
-/* #define MAILARGS "%s -mlrxto %s" */		/*-*/
+/* #define MAILFMT "%s -mlrxto %s" */			/*-*/
+/* #define MAILARG "/usr/mmdf/bin/submit",mailto */	/*-*/
 
 /* #define MAIL_DATE */				/*-*/
 			/* should we include an ersatz Date: header in
 			 * generated mail?  if you are using sendmail
-			 * for MAILCMD, it is better to let sendmail
+			 * as the mailer, it is better to let sendmail
 			 * generate the Date: header.
 			 */
 
@@ -69,7 +69,7 @@
 			 * defined but neither exists, should crontab(1) be
 			 * usable only by root?
 			 */
-/* #define ALLOW_ONLY_ROOT */			/*-*/
+/*#define ALLOW_ONLY_ROOT */			/*-*/
 
 			/* if you want to use syslog(3) instead of appending
 			 * to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define
diff --git a/usr.sbin/cron/cron/cron.8 b/usr.sbin/cron/cron/cron.8
index 15e930439564..782bbce2fb6e 100644
--- a/usr.sbin/cron/cron/cron.8
+++ b/usr.sbin/cron/cron/cron.8
@@ -1,21 +1,23 @@
-.\"/* Copyright 1988,1990,1993 by Paul Vixie
+.\"/* Copyright 1988,1990,1993,1996 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 Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
 .\" */
 .\"
-.\" $FreeBSD$
+.\"Copyright (c) 1997 by Internet Software Consortium
+.\"
+.\"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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+.\"ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+.\"OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+.\"CONSORTIUM 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.
+.\"
+.\" $Id: cron.8,v 1.2 1998/08/14 00:32:36 vixie Exp $
 .\"
 .Dd February 9, 2022
 .Dt CRON 8
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index 90bae65fd1ee..46ed984711a5 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -1,37 +1,33 @@
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
  *
- * 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.
+ * 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.
  *
- * 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 Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM 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.
  */
 
 #if !defined(lint) && !defined(LINT)
 static const char rcsid[] =
-  "$FreeBSD$";
+    "$Id: cron.c,v 1.3 1998/08/14 00:32:36 vixie Exp $";
 #endif
 
 #define	MAIN_PROGRAM
 
-
 #include "cron.h"
 #include <sys/mman.h>
-#include <sys/signal.h>
-#if SYS_TIME_H
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
-
 
 static	void	usage(void),
 		run_reboot_jobs(cron_db *),
@@ -39,9 +35,7 @@ static	void	usage(void),
 		cron_sync(int),
 		cron_sleep(cron_db *, int),
 		cron_clean(cron_db *),
-#ifdef USE_SIGCHLD
 		sigchld_handler(int),
-#endif
 		sighup_handler(int),
 		parse_args(int c, char *v[]);
 
@@ -58,7 +52,7 @@ static void
 usage(void)
 {
 #if DEBUGGING
-    char **dflags;
+	const char **dflags;
 #endif
 
 	fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] "
@@ -66,7 +60,7 @@ usage(void)
 #if DEBUGGING
 	fprintf(stderr, "\ndebugflags: ");
 
-        for(dflags = DebugFlagNames; *dflags; dflags++) {
+        for (dflags = DebugFlagNames; *dflags; dflags++) {
 		fprintf(stderr, "%s ", *dflags);
 	}
         fprintf(stderr, "\n");
@@ -78,11 +72,10 @@ usage(void)
 static void
 open_pidfile(void)
 {
-	char	pidfile[MAX_FNAME];
+	const char *pidfile = PIDDIR PIDFILE;
 	char	buf[MAX_TEMPSTR];
 	int	otherpid;
 
-	(void) snprintf(pidfile, sizeof(pidfile), PIDFILE, PIDDIR);
 	pfh = pidfile_open(pidfile, 0600, &otherpid);
 	if (pfh == NULL) {
 		if (errno == EEXIST) {
@@ -114,20 +107,14 @@ main(int argc, char *argv[])
 
 	parse_args(argc, argv);
 
-#ifdef USE_SIGCHLD
 	(void) signal(SIGCHLD, sigchld_handler);
-#else
-	(void) signal(SIGCLD, SIG_IGN);
-#endif
 	(void) signal(SIGHUP, sighup_handler);
 
 	open_pidfile();
 	set_cron_uid();
 	set_cron_cwd();
 
-#if defined(POSIX)
-	setenv("PATH", _PATH_DEFPATH, 1);
-#endif
+	putenv("PATH="_PATH_DEFPATH);
 
 	/* if there are no debug flags turned on, fork as a daemon should.
 	 */
@@ -197,15 +184,14 @@ main(int argc, char *argv[])
 	}
 }
 
-
 static void
 run_reboot_jobs(cron_db *db)
 {
-	register user		*u;
-	register entry		*e;
+	user *u;
+	entry *e;
 
-	for (u = db->head;  u != NULL;  u = u->next) {
-		for (e = u->crontab;  e != NULL;  e = e->next) {
+	for (u = db->head; u != NULL; u = u->next) {
+		for (e = u->crontab; e != NULL; e = e->next) {
 			if (e->flags & WHEN_REBOOT) {
 				job_add(e, u);
 			}
@@ -217,19 +203,21 @@ run_reboot_jobs(cron_db *db)
 	(void) job_runqueue();
 }
 
-
 static void
 cron_tick(cron_db *db, int secres)
 {
-	static struct tm	lasttm;
-	static time_t	diff = 0, /* time difference in seconds from the last offset change */
-		difflimit = 0; /* end point for the time zone correction */
-	struct tm	otztm; /* time in the old time zone */
-	int		otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow;
- 	register struct tm	*tm = localtime(&TargetTime);
-	register int		second, minute, hour, dom, month, dow;
-	register user		*u;
-	register entry		*e;
+	static struct tm lasttm;
+	/* time difference in seconds from the last offset change */
+	static time_t diff = 0;
+	/* end point for the time zone correction */
+	static time_t difflimit = 0;
+	/* time in the old time zone */
+	struct tm otztm;
+	int otzsecond, otzminute, otzhour, otzdom, otzmonth, otzdow;
+	struct tm *tm = localtime(&TargetTime);
+	int second, minute, hour, dom, month, dow;
+	user *u;
+	entry *e;
 
 	/* make 0-based values out of these so we can use them as indices
 	 */
@@ -252,8 +240,8 @@ cron_tick(cron_db *db, int secres)
 		if ( diff > 0 ) { /* ST->DST */
 			/* mark jobs for an earlier run */
 			difflimit = TargetTime + diff;
-			for (u = db->head;  u != NULL;  u = u->next) {
-				for (e = u->crontab;  e != NULL;  e = e->next) {
+			for (u = db->head; u != NULL; u = u->next) {
+				for (e = u->crontab; e != NULL; e = e->next) {
 					e->flags &= ~NOT_UNTIL;
 					if ( e->lastrun >= TargetTime )
 						e->lastrun = 0;
@@ -267,8 +255,8 @@ cron_tick(cron_db *db, int secres)
 		} else { /* diff < 0 : DST->ST */
 			/* mark jobs for skipping */
 			difflimit = TargetTime - diff;
-			for (u = db->head;  u != NULL;  u = u->next) {
-				for (e = u->crontab;  e != NULL;  e = e->next) {
+			for (u = db->head; u != NULL; u = u->next) {
+				for (e = u->crontab; e != NULL; e = e->next) {
 					e->flags |= NOT_UNTIL;
 					e->flags &= ~RUN_AT;
 				}
@@ -282,8 +270,8 @@ cron_tick(cron_db *db, int secres)
 			/* disable the TZ switch checks */
 			diff = 0;
 			difflimit = 0;
-			for (u = db->head;  u != NULL;  u = u->next) {
-				for (e = u->crontab;  e != NULL;  e = e->next) {
+			for (u = db->head; u != NULL; u = u->next) {
+				for (e = u->crontab; e != NULL; e = e->next) {
 					e->flags &= ~(RUN_AT|NOT_UNTIL);
 				}
 			}
@@ -309,8 +297,8 @@ cron_tick(cron_db *db, int secres)
 	 * is why we keep 'e->dow_star' and 'e->dom_star'.  yes, it's bizarre.
 	 * like many bizarre things, it's the standard.
 	 */
-	for (u = db->head;  u != NULL;  u = u->next) {
-		for (e = u->crontab;  e != NULL;  e = e->next) {
+	for (u = db->head; u != NULL; u = u->next) {
+		for (e = u->crontab; e != NULL; e = e->next) {
 			Debug(DSCH|DEXT, ("user [%s:%d:%d:...] cmd=\"%s\"\n",
 					  env_get("LOGNAME", e->envp),
 					  e->uid, e->gid, e->cmd))
@@ -323,11 +311,11 @@ cron_tick(cron_db *db, int secres)
 			}
 
 			if ( diff != 0 && (e->flags & (RUN_AT|NOT_UNTIL)) ) {
-				if (bit_test(e->second, otzsecond)
-				 && bit_test(e->minute, otzminute)
-				 && bit_test(e->hour, otzhour)
-				 && bit_test(e->month, otzmonth)
-				 && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
+				if (bit_test(e->second, otzsecond) &&
+				    bit_test(e->minute, otzminute) &&
+				    bit_test(e->hour, otzhour) &&
+				    bit_test(e->month, otzmonth) &&
+				    ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
 					  ? (bit_test(e->dow,otzdow) && bit_test(e->dom,otzdom))
 					  : (bit_test(e->dow,otzdow) || bit_test(e->dom,otzdom))
 					)
@@ -343,11 +331,11 @@ cron_tick(cron_db *db, int secres)
 					continue;
 			}
 
-			if (bit_test(e->second, second)
-			 && bit_test(e->minute, minute)
-			 && bit_test(e->hour, hour)
-			 && bit_test(e->month, month)
-			 && ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
+			if (bit_test(e->second, second) &&
+			    bit_test(e->minute, minute) &&
+			    bit_test(e->hour, hour) &&
+			    bit_test(e->month, month) &&
+			    ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
 			      ? (bit_test(e->dow,dow) && bit_test(e->dom,dom))
 			      : (bit_test(e->dow,dow) || bit_test(e->dom,dom))
 			    )
@@ -363,7 +351,6 @@ cron_tick(cron_db *db, int secres)
 	lasttm = *tm;
 }
 
-
 /* the task here is to figure out how long it's going to be until :00 of the
  * following minute and initialize TargetTime to this value.  TargetTime
  * will subsequently slide 60 seconds at a time, with correction applied
@@ -375,7 +362,7 @@ cron_tick(cron_db *db, int secres)
  */
 static void
 cron_sync(int secres) {
- 	struct tm *tm;
+	struct tm *tm;
 
 	TargetTime = time((time_t*)0);
 	if (secres != 0) {
@@ -474,19 +461,14 @@ cron_clean(cron_db *db)
 	}
 }
 
-#ifdef USE_SIGCHLD
 static void
 sigchld_handler(int x)
 {
-	WAIT_T		waiter;
-	PID_T		pid;
+	WAIT_T waiter;
+	PID_T pid;
 
 	for (;;) {
-#ifdef POSIX
 		pid = waitpid(-1, &waiter, WNOHANG);
-#else
-		pid = wait3(&waiter, WNOHANG, (struct rusage *)0);
-#endif
 		switch (pid) {
 		case -1:
 			Debug(DPROC,
@@ -504,8 +486,6 @@ sigchld_handler(int x)
 		}
 	}
 }
-#endif /*USE_SIGCHLD*/
-
 
 static void
 sighup_handler(int x)
@@ -513,12 +493,11 @@ sighup_handler(int x)
 	log_close();
 }
 
-
 static void
 parse_args(int argc, char *argv[])
 {
-	int	argch;
-	char	*endp;
+	int argch;
+	char *endp;
 
 	while ((argch = getopt(argc, argv, "j:J:m:nosx:")) != -1) {
 		switch (argch) {
diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h
index f0f9e88d6b59..67d91b57750e 100644
--- a/usr.sbin/cron/cron/cron.h
+++ b/usr.sbin/cron/cron/cron.h
@@ -1,318 +1,37 @@
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
+ */
+
+/*
+ * Copyright (c) 1997 by Internet Software Consortium
  *
- * 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.
+ * 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.
  *
- * 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 Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM 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.
  */
 
 /* cron.h - header for vixie's cron
  *
- * $FreeBSD$
+ * $Id: cron.h,v 1.3 1998/08/14 00:32:37 vixie Exp $
  *
  * vix 14nov88 [rest of log is in RCS]
  * vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley]
  * vix 30dec86 [written]
  */
 
-/* reorder these #include's at your peril */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include "compat.h"
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <libutil.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <time.h>
-#include <sys/wait.h>
-
-#include "pathnames.h"
 #include "config.h"
 #include "externs.h"
-
-	/* these are really immutable, and are
-	 *   defined for symbolic convenience only
-	 * TRUE, FALSE, and ERR must be distinct
-	 * ERR must be < OK.
-	 */
-#define TRUE		1
-#define FALSE		0
-	/* system calls return this on success */
-#define OK		0
-	/*   or this on error */
-#define ERR		(-1)
-
-	/* turn this on to get '-x' code */
-#ifndef DEBUGGING
-#define DEBUGGING	FALSE
-#endif
-
-#define READ_PIPE	0	/* which end of a pipe pair do you read? */
-#define WRITE_PIPE	1	/*   or write to? */
-#define STDIN		0	/* what is stdin's file descriptor? */
-#define STDOUT		1	/*   stdout's? */
-#define STDERR		2	/*   stderr's? */
-#define ERROR_EXIT	1	/* exit() with this will scare the shell */
-#define	OK_EXIT		0	/* exit() with this is considered 'normal' */
-#define	MAX_FNAME	100	/* max length of internally generated fn */
-#define	MAX_COMMAND	1000	/* max length of internally generated cmd */
-#define	MAX_ENVSTR	1000	/* max length of envvar=value\0 strings */
-#define	MAX_TEMPSTR	100	/* obvious */
-#define	ROOT_UID	0	/* don't change this, it really must be root */
-#define	ROOT_USER	"root"	/* ditto */
-#define	SYS_NAME	"*system*" /* magic owner name for system crontab */
-
-				/* NOTE: these correspond to DebugFlagNames,
-				 *	defined below.
-				 */
-#define	DEXT		0x0001	/* extend flag for other debug masks */
-#define	DSCH		0x0002	/* scheduling debug mask */
-#define	DPROC		0x0004	/* process control debug mask */
-#define	DPARS		0x0008	/* parsing debug mask */
-#define	DLOAD		0x0010	/* database loading debug mask */
-#define	DMISC		0x0020	/* misc debug mask */
-#define	DTEST		0x0040	/* test mode: don't execute any commands */
-#define	DBIT		0x0080	/* bit twiddling shown (long) */
-
-#define	CRON_TAB(u)	"%s/%s", SPOOL_DIR, u
-#define	REG		register
-#define	PPC_NULL	((char **)NULL)
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-#define	Skip_Blanks(c, f) \
-			while (c == '\t' || c == ' ') \
-				c = get_char(f);
-
-#define	Skip_Nonblanks(c, f) \
-			while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
-				c = get_char(f);
-
-#define	Skip_Line(c, f) \
-			do {c = get_char(f);} while (c != '\n' && c != EOF);
-
-#if DEBUGGING
-# define Debug(mask, message) \
-			if ( (DebugFlags & (mask) ) == (mask) ) \
-				printf message;
-#else /* !DEBUGGING */
-# define Debug(mask, message) \
-			;
-#endif /* DEBUGGING */
-
-#define	MkLower(ch)	(isupper(ch) ? tolower(ch) : ch)
-#define	MkUpper(ch)	(islower(ch) ? toupper(ch) : ch)
-#define	Set_LineNum(ln)	{Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
-			 LineNumber = ln; \
-			}
-
-#define	FIRST_SECOND	0
-#define	LAST_SECOND	59
-#define	SECOND_COUNT	(LAST_SECOND - FIRST_SECOND + 1)
-
-#define	FIRST_MINUTE	0
-#define	LAST_MINUTE	59
-#define	MINUTE_COUNT	(LAST_MINUTE - FIRST_MINUTE + 1)
-
-#define	FIRST_HOUR	0
-#define	LAST_HOUR	23
-#define	HOUR_COUNT	(LAST_HOUR - FIRST_HOUR + 1)
-
-#define	FIRST_DOM	1
-#define	LAST_DOM	31
-#define	DOM_COUNT	(LAST_DOM - FIRST_DOM + 1)
-
-#define	FIRST_MONTH	1
-#define	LAST_MONTH	12
-#define	MONTH_COUNT	(LAST_MONTH - FIRST_MONTH + 1)
-
-/* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
-#define	FIRST_DOW	0
-#define	LAST_DOW	7
-#define	DOW_COUNT	(LAST_DOW - FIRST_DOW + 1)
-
-#ifdef LOGIN_CAP
-/* see init.c */
-#define RESOURCE_RC "daemon"
-#endif
-
-			/* each user's crontab will be held as a list of
-			 * the following structure.
-			 *
-			 * These are the cron commands.
-			 */
-
-typedef	struct _entry {
-	struct _entry	*next;
-	uid_t		uid;
-	gid_t		gid;
-#ifdef LOGIN_CAP
-	char            *class;
-#endif
-	char		**envp;
-	char		*cmd;
-	union {
-		struct {
-			bitstr_t	bit_decl(second, SECOND_COUNT);
-			bitstr_t	bit_decl(minute, MINUTE_COUNT);
-			bitstr_t	bit_decl(hour,   HOUR_COUNT);
-			bitstr_t	bit_decl(dom,    DOM_COUNT);
-			bitstr_t	bit_decl(month,  MONTH_COUNT);
-			bitstr_t	bit_decl(dow,    DOW_COUNT);
-		};
-		struct {
-			time_t	lastexit;
-			time_t	interval;
-			pid_t	child;
-		};
-	};
-	int		flags;
-#define	DOM_STAR	0x01
-#define	DOW_STAR	0x02
-#define	WHEN_REBOOT	0x04
-#define	RUN_AT		0x08
-#define	NOT_UNTIL	0x10
-#define	SEC_RES		0x20
-#define	INTERVAL	0x40
-#define	DONT_LOG	0x80
-#define	MAIL_WHEN_ERR	0x100
-	time_t	lastrun;
-} entry;
-
-			/* the crontab database will be a list of the
-			 * following structure, one element per user
-			 * plus one for the system.
-			 *
-			 * These are the crontabs.
-			 */
-
-typedef	struct _user {
-	struct _user	*next, *prev;	/* links */
-	char		*name;
-	time_t		mtime;		/* last modtime of crontab */
-	entry		*crontab;	/* this person's crontab */
-} user;
-
-typedef	struct _cron_db {
-	user		*head, *tail;	/* links */
-	time_t		mtime;		/* last modtime on spooldir */
-} cron_db;
-
-
-void		set_cron_uid(void),
-		set_cron_cwd(void),
-		load_database(cron_db *),
-		open_logfile(void),
-		sigpipe_func(void),
-		job_add(entry *, user *),
-		do_command(entry *, user *),
-		link_user(cron_db *, user *),
-		unlink_user(cron_db *, user *),
-		free_user(user *),
-		env_free(char **),
-		unget_char(int, FILE *),
-		free_entry(entry *),
-		skip_comments(FILE *),
-		log_it(char *, int, char *, const char *),
-		log_close(void);
-
-int		job_runqueue(void),
-		set_debug_flags(char *),
-		get_char(FILE *),
-		get_string(char *, int, FILE *, char *),
-		swap_uids(void),
-		swap_uids_back(void),
-		load_env(char *, FILE *),
-		cron_pclose(FILE *),
-		strcmp_until(char *, char *, int),
-		allowed(char *),
-		strdtb(char *);
-
-char		*env_get(char *, char **),
-		*arpadate(time_t *),
-		*mkprints(unsigned char *, unsigned int),
-		*first_word(char *, char *),
-		**env_init(void),
-		**env_copy(char **),
-		**env_set(char **, char *);
-
-user		*load_user(int, struct passwd *, char *),
-		*find_user(cron_db *, char *);
-
-entry		*load_entry(FILE *, void (*)(char *),
-				 struct passwd *, char **);
-
-FILE		*cron_popen(char *, char *, entry *, PID_T *);
-
-
-				/* in the C tradition, we only create
-				 * variables for the main program, just
-				 * extern them elsewhere.
-				 */
-
-#ifdef MAIN_PROGRAM
-# if !defined(LINT) && !defined(lint)
-char	*copyright[] = {
-		"@(#) Copyright 1988,1989,1990,1993,1994 by Paul Vixie",
-		"@(#) All rights reserved"
-	};
-# endif
-
-char	*MonthNames[] = {
-		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
-		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
-		NULL
*** 2902 LINES SKIPPED ***