[Midnightbsd-cvs] src [10828] sync with freebsd.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jun 10 16:31:34 EDT 2018


Revision: 10828
          http://svnweb.midnightbsd.org/src/?rev=10828
Author:   laffer1
Date:     2018-06-10 16:31:34 -0400 (Sun, 10 Jun 2018)
Log Message:
-----------
sync with freebsd.

Modified Paths:
--------------
    trunk/usr.sbin/cron/crontab/Makefile
    trunk/usr.sbin/cron/crontab/crontab.1
    trunk/usr.sbin/cron/crontab/crontab.5
    trunk/usr.sbin/cron/crontab/crontab.c

Property Changed:
----------------
    trunk/usr.sbin/cron/crontab/crontab.1
    trunk/usr.sbin/cron/crontab/crontab.5

Modified: trunk/usr.sbin/cron/crontab/Makefile
===================================================================
--- trunk/usr.sbin/cron/crontab/Makefile	2018-06-10 20:31:17 UTC (rev 10827)
+++ trunk/usr.sbin/cron/crontab/Makefile	2018-06-10 20:31:34 UTC (rev 10828)
@@ -1,5 +1,5 @@
-# $MidnightBSD: src/usr.sbin/cron/crontab/Makefile,v 1.2 2007/08/18 06:53:01 laffer1 Exp $
-# $FreeBSD: src/usr.sbin/cron/crontab/Makefile,v 1.14 2004/11/03 18:01:21 ru Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/cron/crontab/Makefile 185040 2008-11-18 00:12:15Z matteo $
 
 BINDIR=	/usr/bin
 

Modified: trunk/usr.sbin/cron/crontab/crontab.1
===================================================================
--- trunk/usr.sbin/cron/crontab/crontab.1	2018-06-10 20:31:17 UTC (rev 10827)
+++ trunk/usr.sbin/cron/crontab/crontab.1	2018-06-10 20:31:34 UTC (rev 10828)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"/* Copyright 1988,1990,1993 by Paul Vixie
 .\" * All rights reserved
 .\" *
@@ -15,10 +16,9 @@
 .\" * Paul Vixie          <paul at vix.com>          uunet!decwrl!vixie!paul
 .\" */
 .\"
-.\" $MidnightBSD$
-.\" $FreeBSD: src/usr.sbin/cron/crontab/crontab.1,v 1.15 2005/01/18 20:02:33 ru Exp $
+.\" $FreeBSD: stable/10/usr.sbin/cron/crontab/crontab.1 321243 2017-07-19 20:26:35Z ngie $
 .\"
-.Dd December 29, 1993
+.Dd December 20, 2016
 .Dt CRONTAB 1
 .Os
 .Sh NAME
@@ -32,7 +32,8 @@
 .Op Fl u Ar user
 {
 .Fl l |
-.Fl r |
+.Fl r Op Fl f
+|
 .Fl e
 }
 .Sh DESCRIPTION
@@ -98,6 +99,11 @@
 Display the current crontab on standard output.
 .It Fl r
 Remove the current crontab.
+By default the
+.Fl r
+option prompts for confirmation, adding the
+.Fl f
+option will attempt to remove the current crontab without confirmation.
 .It Fl e
 Edit the current crontab using the editor specified by
 the
@@ -115,7 +121,11 @@
 .Sh FILES
 .Bl -tag -width /var/cron/allow -compact
 .It Pa /var/cron/allow
+List of users allowed to use crontab
 .It Pa /var/cron/deny
+List of users prohibited from using crontab
+.It Pa /var/cron/tabs
+Directory for personal crontab files
 .El
 .Sh DIAGNOSTICS
 A fairly informative usage message appears if you run it with a bad command


Property changes on: trunk/usr.sbin/cron/crontab/crontab.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/cron/crontab/crontab.5
===================================================================
--- trunk/usr.sbin/cron/crontab/crontab.5	2018-06-10 20:31:17 UTC (rev 10827)
+++ trunk/usr.sbin/cron/crontab/crontab.5	2018-06-10 20:31:34 UTC (rev 10828)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\"/* Copyright 1988,1990,1993,1994 by Paul Vixie
 .\" * All rights reserved
 .\" *
@@ -15,10 +16,9 @@
 .\" * Paul Vixie          <paul at vix.com>          uunet!decwrl!vixie!paul
 .\" */
 .\"
-.\" $MidnightBSD: src/usr.sbin/cron/crontab/crontab.5,v 1.2 2007/08/18 06:53:01 laffer1 Exp $
-.\" $FreeBSD: src/usr.sbin/cron/crontab/crontab.5,v 1.27.2.1 2005/08/04 19:58:48 brueffer Exp $
+.\" $FreeBSD: stable/10/usr.sbin/cron/crontab/crontab.5 242101 2012-10-25 22:54:29Z sobomax $
 .\"
-.Dd July 31, 2005
+.Dd April 28, 2012
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -225,7 +225,7 @@
 .Bd -literal -offset indent
 string		meaning
 ------		-------
- at reboot		Run once, at startup.
+ at reboot		Run once, at startup of cron.
 @yearly		Run once a year, "0 0 1 1 *".
 @annually	(same as @yearly)
 @monthly	Run once a month, "0 0 1 * *".
@@ -233,6 +233,8 @@
 @daily		Run once a day, "0 0 * * *".
 @midnight	(same as @daily)
 @hourly		Run once an hour, "0 * * * *".
+ at every_minute	Run once a minute, "*/1 * * * *".
+ at every_second	Run once a second.
 .Ed
 .Sh EXAMPLE CRON FILE
 .Bd -literal
@@ -297,12 +299,23 @@
 .An Paul Vixie Aq paul at vix.com
 .Sh BUGS
 If you are in one of the 70-odd countries that observe Daylight
-Savings Time, jobs scheduled during the rollback or advance will be
-affected.
+Savings Time, jobs scheduled during the rollback or advance may be
+affected if
+.Xr cron 8
+is not started with the
+.Fl s
+flag.
 In general, it is not a good idea to schedule jobs during
-this period.
+this period if
+.Xr cron 8
+is not started with the
+.Fl s
+flag, which is enabled by default.
+See
+.Xr cron 8
+for more details.
 .Pp
-For US timezones (except parts of IN, AZ, and HI) the time shift occurs at
+For US timezones (except parts of AZ and HI) the time shift occurs at
 2AM local time.
 For others, the output of the
 .Xr zdump 8


Property changes on: trunk/usr.sbin/cron/crontab/crontab.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/cron/crontab/crontab.c
===================================================================
--- trunk/usr.sbin/cron/crontab/crontab.c	2018-06-10 20:31:17 UTC (rev 10827)
+++ trunk/usr.sbin/cron/crontab/crontab.c	2018-06-10 20:31:34 UTC (rev 10828)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
  *
@@ -14,12 +15,11 @@
  * I'll try to keep a version up to date.  I can be reached as follows:
  * Paul Vixie          <paul at vix.com>          uunet!decwrl!vixie!paul
  * From Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp
- * $FreeBSD: src/usr.sbin/cron/crontab/crontab.c,v 1.22 2004/09/14 19:01:19 dds Exp $
  */
 
 #if !defined(lint) && !defined(LINT)
 static const char rcsid[] =
-  "$MidnightBSD: src/usr.sbin/cron/crontab/crontab.c,v 1.3 2007/08/18 06:53:01 laffer1 Exp $";
+  "$FreeBSD: stable/10/usr.sbin/cron/crontab/crontab.c 321243 2017-07-19 20:26:35Z ngie $";
 #endif
 
 /* crontab - install and manage per-user crontab files
@@ -29,6 +29,7 @@
 
 #define	MAIN_PROGRAM
 
+#include <sys/param.h>
 #include "cron.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -58,11 +59,12 @@
 
 
 static	PID_T		Pid;
-static	char		User[MAX_UNAME], RealUser[MAX_UNAME];
+static	char		User[MAXLOGNAME], RealUser[MAXLOGNAME];
 static	char		Filename[MAX_FNAME];
 static	FILE		*NewCrontab;
 static	int		CheckErrorCount;
 static	enum opt_t	Option;
+static	int		fflag;
 static	struct passwd	*pw;
 static	void		list_cmd(void),
 			delete_cmd(void),
@@ -79,7 +81,7 @@
 	fprintf(stderr, "crontab: usage error: %s\n", msg);
 	fprintf(stderr, "%s\n%s\n",
 		"usage: crontab [-u user] file",
-		"       crontab [-u user] { -e | -l | -r }");
+		"       crontab [-u user] { -l | -r [-f] | -e }");
 	exit(ERROR_EXIT);
 }
 
@@ -142,7 +144,7 @@
 	strcpy(RealUser, User);
 	Filename[0] = '\0';
 	Option = opt_unknown;
-	while ((argch = getopt(argc, argv, "u:lerx:")) != -1) {
+	while ((argch = getopt(argc, argv, "u:lerx:f")) != -1) {
 		switch (argch) {
 		case 'x':
 			if (!set_debug_flags(optarg))
@@ -172,6 +174,9 @@
 				usage("only one operation permitted");
 			Option = opt_edit;
 			break;
+		case 'f':
+			fflag = 1;
+			break;
 		default:
 			usage("unrecognized option");
 		}
@@ -195,6 +200,17 @@
 	}
 
 	if (Option == opt_replace) {
+		/* relinquish the setuid status of the binary during
+		 * the open, lest nonroot users read files they should
+		 * not be able to read.  we can't use access() here
+		 * since there's a race condition.  thanks go out to
+		 * Arnt Gulbrandsen <agulbra at pvv.unit.no> for spotting
+		 * the race.
+		 */
+
+		if (swap_uids() < OK)
+			err(ERROR_EXIT, "swapping uids");
+
 		/* we have to open the file here because we're going to
 		 * chdir(2) into /var/cron before we get around to
 		 * reading the file.
@@ -205,21 +221,11 @@
 		    !strcmp(resolved_path, SYSCRONTAB)) {
 			err(ERROR_EXIT, SYSCRONTAB " must be edited manually");
 		} else {
-			/* relinquish the setuid status of the binary during
-			 * the open, lest nonroot users read files they should
-			 * not be able to read.  we can't use access() here
-			 * since there's a race condition.  thanks go out to
-			 * Arnt Gulbrandsen <agulbra at pvv.unit.no> for spotting
-			 * the race.
-			 */
-
-			if (swap_uids() < OK)
-				err(ERROR_EXIT, "swapping uids");
 			if (!(NewCrontab = fopen(Filename, "r")))
 				err(ERROR_EXIT, "%s", Filename);
-			if (swap_uids_back() < OK)
-				err(ERROR_EXIT, "swapping uids back");
 		}
+		if (swap_uids_back() < OK)
+			err(ERROR_EXIT, "swapping uids back");
 	}
 
 	Debug(DMISC, ("user=%s, file=%s, option=%s\n",
@@ -281,7 +287,7 @@
 	char	n[MAX_FNAME];
 	int ch, first;
 
-	if (isatty(STDIN_FILENO)) {
+	if (!fflag && isatty(STDIN_FILENO)) {
 		(void)fprintf(stderr, "remove crontab for %s? ", User);
 		first = ch = getchar();
 		while (ch != '\n' && ch != EOF)
@@ -364,11 +370,15 @@
 		goto fatal;
 	}
  again:
+	if (swap_uids() < OK)
+		err(ERROR_EXIT, "swapping uids");
 	if (stat(Filename, &statbuf) < 0) {
 		warn("stat");
  fatal:		unlink(Filename);
 		exit(ERROR_EXIT);
 	}
+	if (swap_uids_back() < OK)
+		err(ERROR_EXIT, "swapping uids back");
 	if (statbuf.st_dev != fsbuf.st_dev || statbuf.st_ino != fsbuf.st_ino)
 		errx(ERROR_EXIT, "temp file must be edited in place");
 	if (MD5File(Filename, orig_md5) == NULL) {
@@ -434,6 +444,8 @@
 			editor, WTERMSIG(waiter), WCOREDUMP(waiter) ?"" :"no ");
 		goto fatal;
 	}
+	if (swap_uids() < OK)
+		err(ERROR_EXIT, "swapping uids");
 	if (stat(Filename, &statbuf) < 0) {
 		warn("stat");
 		goto fatal;
@@ -444,6 +456,8 @@
 		warn("MD5");
 		goto fatal;
 	}
+	if (swap_uids_back() < OK)
+		err(ERROR_EXIT, "swapping uids back");
 	if (strcmp(orig_md5, new_md5) == 0 && !syntax_error) {
 		warnx("no changes made to crontab");
 		goto remove;
@@ -524,7 +538,7 @@
 	Set_LineNum(1)
 	while (EOF != (ch = get_char(NewCrontab)))
 		putc(ch, tmp);
-	ftruncate(fileno(tmp), ftell(tmp));
+	ftruncate(fileno(tmp), ftello(tmp));
 	fflush(tmp);  rewind(tmp);
 
 	if (ferror(tmp)) {
@@ -550,7 +564,7 @@
 		case FALSE:
 			e = load_entry(tmp, check_error, pw, envp);
 			if (e)
-				free(e);
+				free_entry(e);
 			break;
 		case TRUE:
 			break;
@@ -600,6 +614,15 @@
 
 	log_it(RealUser, Pid, "REPLACE", User);
 
+	/*
+	 * Creating the 'tn' temp file has already updated the
+	 * modification time of the spool directory.  Sleep for a
+	 * second to ensure that poke_daemon() sets a later
+	 * modification time.  Otherwise, this can race with the cron
+	 * daemon scanning for updated crontabs.
+	 */
+	sleep(1);
+
 	poke_daemon();
 
 	return (0);
@@ -610,9 +633,8 @@
 poke_daemon() {
 #ifdef USE_UTIMES
 	struct timeval tvs[2];
-	struct timezone tz;
 
-	(void) gettimeofday(&tvs[0], &tz);
+	(void)gettimeofday(&tvs[0], NULL);
 	tvs[1] = tvs[0];
 	if (utimes(SPOOL_DIR, tvs) < OK) {
 		warn("can't update mtime on spooldir %s", SPOOL_DIR);



More information about the Midnightbsd-cvs mailing list