svn commit: r232568 - in stable/7/usr.sbin/cron: cron crontab doc
lib
Xin LI
delphij at FreeBSD.org
Mon Mar 5 19:32:45 UTC 2012
Author: delphij
Date: Mon Mar 5 19:32:44 2012
New Revision: 232568
URL: http://svn.freebsd.org/changeset/base/232568
Log:
Merge all revisions except r199804 back to stable/7.
Modified:
stable/7/usr.sbin/cron/cron/Makefile
stable/7/usr.sbin/cron/cron/cron.c
stable/7/usr.sbin/cron/cron/cron.h
stable/7/usr.sbin/cron/cron/database.c
stable/7/usr.sbin/cron/cron/do_command.c
stable/7/usr.sbin/cron/cron/externs.h
stable/7/usr.sbin/cron/crontab/Makefile
stable/7/usr.sbin/cron/crontab/crontab.5
stable/7/usr.sbin/cron/crontab/crontab.c
stable/7/usr.sbin/cron/doc/CHANGES
stable/7/usr.sbin/cron/doc/MAIL
stable/7/usr.sbin/cron/lib/Makefile
stable/7/usr.sbin/cron/lib/entry.c
stable/7/usr.sbin/cron/lib/misc.c
Directory Properties:
stable/7/usr.sbin/cron/ (props changed)
stable/7/usr.sbin/cron/cron/ (props changed)
stable/7/usr.sbin/cron/crontab/ (props changed)
Modified: stable/7/usr.sbin/cron/cron/Makefile
==============================================================================
--- stable/7/usr.sbin/cron/cron/Makefile Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/Makefile Mon Mar 5 19:32:44 2012 (r232568)
@@ -9,4 +9,6 @@ CFLAGS+= -DLOGIN_CAP -DPAM
DPADD= ${LIBCRON} ${LIBPAM} ${LIBUTIL}
LDADD= ${LIBCRON} ${MINUSLPAM} -lutil
+WARNS?= 2
+
.include <bsd.prog.mk>
Modified: stable/7/usr.sbin/cron/cron/cron.c
==============================================================================
--- stable/7/usr.sbin/cron/cron/cron.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/cron.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -32,17 +32,17 @@ static const char rcsid[] =
#endif
-static void usage __P((void)),
- run_reboot_jobs __P((cron_db *)),
- cron_tick __P((cron_db *)),
- cron_sync __P((void)),
- cron_sleep __P((cron_db *)),
- cron_clean __P((cron_db *)),
+static void usage(void),
+ run_reboot_jobs(cron_db *),
+ cron_tick(cron_db *),
+ cron_sync(void),
+ cron_sleep(cron_db *),
+ cron_clean(cron_db *),
#ifdef USE_SIGCHLD
- sigchld_handler __P((int)),
+ sigchld_handler(int),
#endif
- sighup_handler __P((int)),
- parse_args __P((int c, char *v[]));
+ sighup_handler(int),
+ parse_args(int c, char *v[]);
static time_t last_time = 0;
static int dst_enabled = 0;
Modified: stable/7/usr.sbin/cron/cron/cron.h
==============================================================================
--- stable/7/usr.sbin/cron/cron/cron.h Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/cron.h Mon Mar 5 19:32:44 2012 (r232568)
@@ -199,49 +199,50 @@ typedef struct _cron_db {
} cron_db;
-void set_cron_uid __P((void)),
- set_cron_cwd __P((void)),
- load_database __P((cron_db *)),
- open_logfile __P((void)),
- sigpipe_func __P((void)),
- job_add __P((entry *, user *)),
- do_command __P((entry *, user *)),
- link_user __P((cron_db *, user *)),
- unlink_user __P((cron_db *, user *)),
- free_user __P((user *)),
- env_free __P((char **)),
- unget_char __P((int, FILE *)),
- free_entry __P((entry *)),
- skip_comments __P((FILE *)),
- log_it __P((char *, int, char *, char *)),
- log_close __P((void));
-
-int job_runqueue __P((void)),
- set_debug_flags __P((char *)),
- get_char __P((FILE *)),
- get_string __P((char *, int, FILE *, char *)),
- swap_uids __P((void)),
- load_env __P((char *, FILE *)),
- cron_pclose __P((FILE *)),
- strcmp_until __P((char *, char *, int)),
- allowed __P((char *)),
- strdtb __P((char *));
-
-char *env_get __P((char *, char **)),
- *arpadate __P((time_t *)),
- *mkprints __P((unsigned char *, unsigned int)),
- *first_word __P((char *, char *)),
- **env_init __P((void)),
- **env_copy __P((char **)),
- **env_set __P((char **, char *));
+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 *, 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 __P((int, struct passwd *, char *)),
- *find_user __P((cron_db *, char *));
+user *load_user(int, struct passwd *, char *),
+ *find_user(cron_db *, char *);
-entry *load_entry __P((FILE *, void (*)(),
- struct passwd *, char **));
+entry *load_entry(FILE *, void (*)(char *),
+ struct passwd *, char **);
-FILE *cron_popen __P((char *, char *, entry *));
+FILE *cron_popen(char *, char *, entry *);
/* in the C tradition, we only create
Modified: stable/7/usr.sbin/cron/cron/database.c
==============================================================================
--- stable/7/usr.sbin/cron/cron/database.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/database.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -33,9 +33,9 @@ static const char rcsid[] =
#define TMAX(a,b) ((a)>(b)?(a):(b))
-static void process_crontab __P((char *, char *, char *,
+static void process_crontab(char *, char *, char *,
struct stat *,
- cron_db *, cron_db *));
+ cron_db *, cron_db *);
void
Modified: stable/7/usr.sbin/cron/cron/do_command.c
==============================================================================
--- stable/7/usr.sbin/cron/cron/do_command.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/do_command.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -38,8 +38,8 @@ static const char rcsid[] =
#endif
-static void child_process __P((entry *, user *)),
- do_univ __P((user *));
+static void child_process(entry *, user *),
+ do_univ(user *);
void
@@ -147,7 +147,7 @@ child_process(e, u)
#ifdef USE_SIGCHLD
/* our parent is watching for our death by catching SIGCHLD. we
* do not care to watch for our children's deaths this way -- we
- * use wait() explictly. so we have to disable the signal (which
+ * use wait() explicitly. so we have to disable the signal (which
* was inherited from the parent).
*/
(void) signal(SIGCHLD, SIG_DFL);
Modified: stable/7/usr.sbin/cron/cron/externs.h
==============================================================================
--- stable/7/usr.sbin/cron/cron/externs.h Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/cron/externs.h Mon Mar 5 19:32:44 2012 (r232568)
@@ -1,3 +1,5 @@
+/* $FreeBSD$ */
+
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
*
@@ -71,7 +73,7 @@ extern void *malloc(), *realloc();
* external variables needed for the interface.
*/
#if (!defined(BSD) || (BSD < 198911)) && !defined(ATT) && !defined(UNICOS)
-int getopt __P((int, char * const *, const char *));
+int getopt(int, char * const *, const char *);
#endif
#if (!defined(BSD) || (BSD < 199103))
@@ -109,19 +111,19 @@ extern int optind, opterr, optopt;
#endif
#ifdef NEED_STRCASECMP
-extern int strcasecmp __P((char *, char *));
+extern int strcasecmp(char *, char *);
#endif
#ifdef NEED_STRDUP
-extern char *strdup __P((char *));
+extern char *strdup(char *);
#endif
#ifdef NEED_STRERROR
-extern char *strerror __P((int));
+extern char *strerror(int);
#endif
#ifdef NEED_FLOCK
-extern int flock __P((int, int));
+extern int flock(int, int);
# define LOCK_SH 1
# define LOCK_EX 2
# define LOCK_NB 4
@@ -129,17 +131,17 @@ extern int flock __P((int, int));
#endif
#ifdef NEED_SETSID
-extern int setsid __P((void));
+extern int setsid(void);
#endif
#ifdef NEED_GETDTABLESIZE
-extern int getdtablesize __P((void));
+extern int getdtablesize(void);
#endif
#ifdef NEED_SETENV
-extern int setenv __P((char *, char *, int));
+extern int setenv(char *, char *, int);
#endif
#ifdef NEED_VFORK
-extern PID_T vfork __P((void));
+extern PID_T vfork(void);
#endif
Modified: stable/7/usr.sbin/cron/crontab/Makefile
==============================================================================
--- stable/7/usr.sbin/cron/crontab/Makefile Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/crontab/Makefile Mon Mar 5 19:32:44 2012 (r232568)
@@ -8,6 +8,8 @@ BINOWN= root
BINMODE=4555
PRECIOUSPROG=
+WARNS?= 3
+
CFLAGS+= -I${.CURDIR}/../cron
DPADD= ${LIBCRON} ${LIBMD} ${LIBUTIL}
Modified: stable/7/usr.sbin/cron/crontab/crontab.5
==============================================================================
--- stable/7/usr.sbin/cron/crontab/crontab.5 Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/crontab/crontab.5 Mon Mar 5 19:32:44 2012 (r232568)
@@ -118,7 +118,7 @@ is defined (and non-empty), mail is
sent to the user so named.
.Ev MAILTO
may also be used to direct mail to multiple recipients
-by seperating recipient users with a comma.
+by separating recipient users with a comma.
If
.Ev MAILTO
is defined but empty (MAILTO=""), no
Modified: stable/7/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- stable/7/usr.sbin/cron/crontab/crontab.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/crontab/crontab.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -63,18 +63,17 @@ static FILE *NewCrontab;
static int CheckErrorCount;
static enum opt_t Option;
static struct passwd *pw;
-static void list_cmd __P((void)),
- delete_cmd __P((void)),
- edit_cmd __P((void)),
- poke_daemon __P((void)),
- check_error __P((char *)),
- parse_args __P((int c, char *v[]));
-static int replace_cmd __P((void));
+static void list_cmd(void),
+ delete_cmd(void),
+ edit_cmd(void),
+ poke_daemon(void),
+ check_error(char *),
+ parse_args(int c, char *v[]);
+static int replace_cmd(void);
static void
-usage(msg)
- char *msg;
+usage(char *msg)
{
fprintf(stderr, "crontab: usage error: %s\n", msg);
fprintf(stderr, "%s\n%s\n",
@@ -85,9 +84,7 @@ usage(msg)
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int exitstatus;
@@ -138,6 +135,7 @@ parse_args(argc, argv)
if (!(pw = getpwuid(getuid())))
errx(ERROR_EXIT, "your UID isn't in the passwd file, bailing out");
+ bzero(pw->pw_passwd, strlen(pw->pw_passwd));
(void) strncpy(User, pw->pw_name, (sizeof User)-1);
User[(sizeof User)-1] = '\0';
strcpy(RealUser, User);
@@ -154,6 +152,7 @@ parse_args(argc, argv)
errx(ERROR_EXIT, "must be privileged to use -u");
if (!(pw = getpwnam(optarg)))
errx(ERROR_EXIT, "user `%s' unknown", optarg);
+ bzero(pw->pw_passwd, strlen(pw->pw_passwd));
(void) strncpy(User, pw->pw_name, (sizeof User)-1);
User[(sizeof User)-1] = '\0';
break;
@@ -195,6 +194,17 @@ parse_args(argc, argv)
}
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 +215,11 @@ parse_args(argc, argv)
!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() < 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",
@@ -261,7 +261,7 @@ list_cmd() {
FILE *f;
log_it(RealUser, Pid, "LIST", User);
- (void) sprintf(n, CRON_TAB(User));
+ (void) snprintf(n, sizeof(n), CRON_TAB(User));
if (!(f = fopen(n, "r"))) {
if (errno == ENOENT)
errx(ERROR_EXIT, "no crontab for %s", User);
@@ -291,7 +291,7 @@ delete_cmd() {
}
log_it(RealUser, Pid, "DELETE", User);
- (void) sprintf(n, CRON_TAB(User));
+ (void) snprintf(n, sizeof(n), CRON_TAB(User));
if (unlink(n)) {
if (errno == ENOENT)
errx(ERROR_EXIT, "no crontab for %s", User);
@@ -325,7 +325,7 @@ edit_cmd() {
char new_md5[MD5_SIZE];
log_it(RealUser, Pid, "BEGIN EDIT", User);
- (void) sprintf(n, CRON_TAB(User));
+ (void) snprintf(n, sizeof(n), CRON_TAB(User));
if (!(f = fopen(n, "r"))) {
if (errno != ENOENT)
err(ERROR_EXIT, "%s", n);
@@ -335,7 +335,7 @@ edit_cmd() {
}
um = umask(077);
- (void) sprintf(Filename, "/tmp/crontab.XXXXXXXXXX");
+ (void) snprintf(Filename, sizeof(Filename), "/tmp/crontab.XXXXXXXXXX");
if ((t = mkstemp(Filename)) == -1) {
warn("%s", Filename);
(void) umask(um);
@@ -364,11 +364,15 @@ edit_cmd() {
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) {
@@ -412,14 +416,14 @@ edit_cmd() {
/* parent */
{
- void (*f[4])();
- f[0] = signal(SIGHUP, SIG_IGN);
- f[1] = signal(SIGINT, SIG_IGN);
- f[2] = signal(SIGTERM, SIG_IGN);
+ void (*sig[3])(int signal);
+ sig[0] = signal(SIGHUP, SIG_IGN);
+ sig[1] = signal(SIGINT, SIG_IGN);
+ sig[2] = signal(SIGTERM, SIG_IGN);
xpid = wait(&waiter);
- signal(SIGHUP, f[0]);
- signal(SIGINT, f[1]);
- signal(SIGTERM, f[2]);
+ signal(SIGHUP, sig[0]);
+ signal(SIGINT, sig[1]);
+ signal(SIGTERM, sig[2]);
}
if (xpid != pid) {
warnx("wrong PID (%d != %d) from \"%s\"", xpid, pid, editor);
@@ -434,6 +438,8 @@ edit_cmd() {
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 +450,8 @@ edit_cmd() {
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;
@@ -502,8 +510,9 @@ replace_cmd() {
return (-2);
}
- (void) sprintf(n, "tmp.%d", Pid);
- (void) sprintf(tn, CRON_TAB(n));
+ (void) snprintf(n, sizeof(n), "tmp.%d", Pid);
+ (void) snprintf(tn, sizeof(tn), CRON_TAB(n));
+
if (!(tmp = fopen(tn, "w+"))) {
warn("%s", tn);
return (-2);
@@ -590,12 +599,13 @@ replace_cmd() {
return (-2);
}
- (void) sprintf(n, CRON_TAB(User));
+ (void) snprintf(n, sizeof(n), CRON_TAB(User));
if (rename(tn, n)) {
warn("error renaming %s to %s", tn, n);
unlink(tn);
return (-2);
}
+
log_it(RealUser, Pid, "REPLACE", User);
poke_daemon();
Modified: stable/7/usr.sbin/cron/doc/CHANGES
==============================================================================
--- stable/7/usr.sbin/cron/doc/CHANGES Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/doc/CHANGES Mon Mar 5 19:32:44 2012 (r232568)
@@ -1,3 +1,6 @@
+$FreeBSD$
+--------
+
Vixie Cron Changes from V2 to V3
Paul Vixie
29-Dec-1993
@@ -20,7 +23,7 @@ be reread whenever it changes.
I also added a "-e" option to crontab(1). Nine people also sent me diffs
to add this option, but I had already implemented it on my own. I actually
-released an interrim version (V2.2, I think) for limited testing, and got a
+released an interim version (V2.2, I think) for limited testing, and got a
chance to fix a bad security bug in the "-e" option thanks to XXX.
The daemon used to be extraordinarily sloppy in its use of file descriptors.
@@ -57,7 +60,7 @@ which explains why a lot of other people
syslog even when they configured it that way :-). Steve Simmons told me
first, though, so he gets the point.
-An interrim version of the daemon tried to "stat" every file before
+An interim version of the daemon tried to "stat" every file before
executing it; this turned out to be a horribly bad idea since finding the
name of a file from a shell command is a hard job (that's why we have
shells, right?) I removed this bogus code. Dave Burgess gets the point.
Modified: stable/7/usr.sbin/cron/doc/MAIL
==============================================================================
--- stable/7/usr.sbin/cron/doc/MAIL Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/doc/MAIL Mon Mar 5 19:32:44 2012 (r232568)
@@ -186,7 +186,7 @@ five fields. Examples:
(run command if day-of-month AND day-of-week are true)
-Get the picture? This would be compatable with existing versions of
+Get the picture? This would be compatible with existing versions of
cron (which wouldn't currently be using any special characters, so
that old crontabs would be handled correctly).
Modified: stable/7/usr.sbin/cron/lib/Makefile
==============================================================================
--- stable/7/usr.sbin/cron/lib/Makefile Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/lib/Makefile Mon Mar 5 19:32:44 2012 (r232568)
@@ -4,6 +4,8 @@ LIB= cron
INTERNALLIB=
SRCS= entry.c env.c misc.c
+WARNS?= 3
+
CFLAGS+= -I${.CURDIR}/../cron
CFLAGS+= -DLOGIN_CAP -DPAM
Modified: stable/7/usr.sbin/cron/lib/entry.c
==============================================================================
--- stable/7/usr.sbin/cron/lib/entry.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/lib/entry.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -41,10 +41,10 @@ typedef enum ecode {
#endif
} ecode_e;
-static char get_list __P((bitstr_t *, int, int, char *[], int, FILE *)),
- get_range __P((bitstr_t *, int, int, char *[], int, FILE *)),
- get_number __P((int *, int, char *[], int, FILE *));
-static int set_element __P((bitstr_t *, int, int, int));
+static char get_list(bitstr_t *, int, int, char *[], int, FILE *),
+ get_range(bitstr_t *, int, int, char *[], int, FILE *),
+ get_number(int *, int, char *[], int, FILE *);
+static int set_element(bitstr_t *, int, int, int);
static char *ecodes[] =
{
@@ -87,7 +87,7 @@ free_entry(e)
entry *
load_entry(file, error_func, pw, envp)
FILE *file;
- void (*error_func)();
+ void (*error_func)(char *);
struct passwd *pw;
char **envp;
{
@@ -254,7 +254,7 @@ load_entry(file, error_func, pw, envp)
}
}
- /* make sundays equivilent */
+ /* make sundays equivalent */
if (bit_test(e->dow, 0) || bit_test(e->dow, 7)) {
bit_set(e->dow, 0);
bit_set(e->dow, 7);
Modified: stable/7/usr.sbin/cron/lib/misc.c
==============================================================================
--- stable/7/usr.sbin/cron/lib/misc.c Mon Mar 5 19:13:19 2012 (r232567)
+++ stable/7/usr.sbin/cron/lib/misc.c Mon Mar 5 19:32:44 2012 (r232568)
@@ -324,9 +324,7 @@ skip_comments(file)
* FALSE otherwise.
*/
static int
-in_file(string, file)
- char *string;
- FILE *file;
+in_file(char *string, FILE *file)
{
char line[MAX_TEMPSTR];
@@ -520,11 +518,8 @@ first_word(s, t)
/* warning:
* heavily ascii-dependent.
*/
-void
-mkprint(dst, src, len)
- register char *dst;
- register unsigned char *src;
- register int len;
+static void
+mkprint(register char *dst, register unsigned char *src, register int len)
{
while (len-- > 0)
{
More information about the svn-src-stable-7
mailing list