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.
Modified files:
Index: src/external/bsd/cron/dist/database.c
diff -u src/external/bsd/cron/dist/database.c:1.2 src/external/bsd/cron/dist/database.c:1.3
--- src/external/bsd/cron/dist/database.c:1.2 Thu May 6 14:53:17 2010
+++ src/external/bsd/cron/dist/database.c Thu Jul 15 16:04:14 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: database.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */
+/* $NetBSD: database.c,v 1.3 2010/07/15 20:04:14 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.2 2010/05/06 18:53:17 christos Exp $");
+__RCSID("$NetBSD: database.c,v 1.3 2010/07/15 20:04:14 christos Exp $");
#endif
#endif
@@ -184,12 +184,19 @@
{
struct passwd *pw = NULL;
int crontab_fd = OK - 1;
+ mode_t eqmode = 0600, badmode = 0;
user *u;
if (fname == NULL) {
- /* must be set to something for logging purposes.
+ /*
+ * SYSCRONTAB:
+ * set fname to something for logging purposes.
+ * Allow it to become readable by group and others, but
+ * not writable.
*/
fname = "*system*";
+ eqmode = 0;
+ badmode = 022;
} else if ((pw = getpwnam(uname)) == NULL) {
/* file doesn't have a user in passwd file.
*/
@@ -212,7 +219,8 @@
log_it(fname, getpid(), "NOT REGULAR", tabname);
goto next_crontab;
}
- if ((statbuf->st_mode & 07777) != 0600) {
+ if ((eqmode && (statbuf->st_mode & 07777) != eqmode) ||
+ (badmode && (statbuf->st_mode & badmode) != 0)) {
log_it(fname, getpid(), "BAD FILE MODE", tabname);
goto next_crontab;
}