diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-10-26 14:27:42 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-10-26 14:27:42 +0000 |
commit | 828fce48e56069e661e2e4e44058637a2272164f (patch) | |
tree | 5aab5fc65dfe3afa93bca000eb6c8f7fc5111b39 | |
parent | 65ed3f6879f7329db5c48afd8dfd5ec3fc4b5cea (diff) |
Remove some useless defines and the set_cron_uid() function.
OK jung@
-rw-r--r-- | usr.sbin/cron/cron.c | 3 | ||||
-rw-r--r-- | usr.sbin/cron/crontab.c | 4 | ||||
-rw-r--r-- | usr.sbin/cron/database.c | 6 | ||||
-rw-r--r-- | usr.sbin/cron/entry.c | 10 | ||||
-rw-r--r-- | usr.sbin/cron/macros.h | 7 | ||||
-rw-r--r-- | usr.sbin/cron/misc.c | 13 |
6 files changed, 14 insertions, 29 deletions
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index f38cc5e055a..88deab1eba5 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.55 2015/10/25 21:30:11 millert Exp $ */ +/* $OpenBSD: cron.c,v 1.56 2015/10/26 14:27:41 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -77,7 +77,6 @@ main(int argc, char *argv[]) sact.sa_handler = SIG_IGN; (void) sigaction(SIGPIPE, &sact, NULL); - set_cron_uid(); set_cron_cwd(); cronSock = open_socket(); diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 18189d604a2..05d90d07e87 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.72 2015/10/06 14:58:37 tedu Exp $ */ +/* $OpenBSD: crontab.c,v 1.73 2015/10/26 14:27:41 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -126,7 +126,7 @@ parse_args(int argc, char *argv[]) while (-1 != (argch = getopt(argc, argv, getoptargs))) { switch (argch) { case 'u': - if (getuid() != ROOT_UID) { + if (getuid() != 0) { fprintf(stderr, "must be privileged to use -u\n"); exit(EXIT_FAILURE); diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index 3ac199f72bc..19d2e186da9 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.26 2015/10/06 14:58:37 tedu Exp $ */ +/* $OpenBSD: database.c,v 1.27 2015/10/26 14:27:41 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -68,7 +68,7 @@ load_database(cron_db *old_db) new_db.head = new_db.tail = NULL; if (syscron_stat.st_mtime) { - process_crontab(ROOT_USER, NULL, SYSCRONTAB, &syscron_stat, + process_crontab("root", NULL, SYSCRONTAB, &syscron_stat, &new_db, old_db); } @@ -201,7 +201,7 @@ process_crontab(const char *uname, const char *fname, const char *tabname, goto next_crontab; } } - if (statbuf->st_uid != ROOT_UID && (pw == NULL || + if (statbuf->st_uid != 0 && (pw == NULL || statbuf->st_uid != pw->pw_uid || strcmp(uname, pw->pw_name) != 0)) { log_it(fname, getpid(), "WRONG FILE OWNER", tabname); goto next_crontab; diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 57ae77c0a48..c59dab981aa 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.42 2015/10/06 14:58:37 tedu Exp $ */ +/* $OpenBSD: entry.c,v 1.43 2015/10/26 14:27:41 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -165,7 +165,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= MIN_STAR; ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE, - PPC_NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_minute; goto eof; @@ -177,7 +177,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= HR_STAR; ch = get_list(e->hour, FIRST_HOUR, LAST_HOUR, - PPC_NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_hour; goto eof; @@ -189,7 +189,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (ch == '*') e->flags |= DOM_STAR; ch = get_list(e->dom, FIRST_DOM, LAST_DOM, - PPC_NULL, ch, file); + NULL, ch, file); if (ch == EOF) { ecode = e_dom; goto eof; @@ -462,7 +462,7 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], * element id, it's a step size. 'low' is * sent as a 0 since there is no offset either. */ - ch = get_number(&num3, 0, PPC_NULL, ch, file, ", \t\n"); + ch = get_number(&num3, 0, NULL, ch, file, ", \t\n"); if (ch == EOF || num3 == 0) return (EOF); } else { diff --git a/usr.sbin/cron/macros.h b/usr.sbin/cron/macros.h index 0b0ec9905c7..7b52d1b90a8 100644 --- a/usr.sbin/cron/macros.h +++ b/usr.sbin/cron/macros.h @@ -1,4 +1,4 @@ -/* $OpenBSD: macros.h,v 1.12 2015/10/06 14:58:37 tedu Exp $ */ +/* $OpenBSD: macros.h,v 1.13 2015/10/26 14:27:41 millert Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -20,7 +20,6 @@ #define TRUE 1 #define FALSE 0 -#define INIT_PID 1 /* parent of orphans */ #define READ_PIPE 0 /* which end of a pipe pair do you read? */ #define WRITE_PIPE 1 /* or write to? */ #define MAX_FNAME 100 /* max length of internally generated fn */ @@ -28,10 +27,6 @@ #define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */ #define MAX_TEMPSTR 100 /* obvious */ #define MAX_UNAME (_PW_NAME_LEN+1) /* max length of username, should be overkill */ -#define ROOT_UID 0 /* don't change this, it really must be root */ -#define ROOT_USER "root" /* ditto */ - -#define PPC_NULL ((const char **)NULL) #define Skip_Blanks(c, f) \ while (c == '\t' || c == ' ') \ diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index a2946a405a7..5677cf988a7 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.58 2015/10/25 21:30:11 millert Exp $ */ +/* $OpenBSD: misc.c,v 1.59 2015/10/26 14:27:41 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -48,15 +48,6 @@ strcmp_until(const char *left, const char *right, char until) } void -set_cron_uid(void) -{ - if (seteuid(ROOT_UID) < 0) { - perror("seteuid"); - exit(EXIT_FAILURE); - } -} - -void set_cron_cwd(void) { struct stat sb; @@ -261,7 +252,7 @@ allowed(const char *username, const char *allow_file, const char *deny_file) FILE *fp; int isallowed; - if (strcmp(username, ROOT_USER) == 0) + if (strcmp(username, "root") == 0) return (TRUE); isallowed = FALSE; if ((fp = fopen(allow_file, "r")) != NULL) { |