From 3325eee250e78c651d60357044eb92acecd5c5a7 Mon Sep 17 00:00:00 2001 From: millert Date: Wed, 14 Jan 2015 17:27:13 +0000 Subject: [PATCH] Remove compatibility defines for ancient systems. We assume a reasonable level of POSIX compliance. --- usr.sbin/cron/crontab.c | 13 ++--------- usr.sbin/cron/externs.h | 52 +---------------------------------------- usr.sbin/cron/misc.c | 18 +------------- 3 files changed, 4 insertions(+), 79 deletions(-) diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 963b9657124..9f069ce135e 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.65 2014/11/26 18:34:52 millert Exp $ */ +/* $OpenBSD: crontab.c,v 1.66 2015/01/14 17:27:13 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -143,7 +143,7 @@ parse_args(int argc, char *argv[]) { break; #endif case 'u': - if (MY_UID(pw) != ROOT_UID) { + if (getuid() != ROOT_UID) { fprintf(stderr, "must be privileged to use -u\n"); exit(EXIT_FAILURE); @@ -553,21 +553,12 @@ replace_cmd(void) { goto done; } -#ifdef HAVE_FCHOWN if (fchown(fileno(tmp), pw->pw_uid, -1) < OK) { perror("fchown"); fclose(tmp); error = -2; goto done; } -#else - if (chown(TempFilename, pw->pw_uid, -1) < OK) { - perror("chown"); - fclose(tmp); - error = -2; - goto done; - } -#endif if (fclose(tmp) == EOF) { perror("fclose"); diff --git a/usr.sbin/cron/externs.h b/usr.sbin/cron/externs.h index c8c3c113743..0cf2f0a27b0 100644 --- a/usr.sbin/cron/externs.h +++ b/usr.sbin/cron/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.12 2014/10/29 04:39:02 deraadt Exp $ */ +/* $OpenBSD: externs.h,v 1.13 2015/01/14 17:27:13 millert Exp $ */ /* Copyright 1993,1994 by Paul Vixie * All rights reserved @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -35,9 +34,6 @@ #include #include -#ifndef isascii -#define isascii(c) ((unsigned)(c)<=0177) -#endif #include #include #include @@ -76,52 +72,6 @@ extern char *tzname[2]; #endif #define TZONE(tm) tzname[(tm).tm_isdst] -#if (defined(BSD)) && (BSD >= 198606) || defined(__linux) -# define HAVE_FCHOWN -# define HAVE_FCHMOD -#endif - -#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) -# define HAVE_SAVED_UIDS -#endif - -#define MY_UID(pw) getuid() -#define MY_GID(pw) getgid() - -/* getopt() isn't part of POSIX. some systems define it in anyway. - * of those that do, some complain that our definition is different and some - * do not. to add to the misery and confusion, some systems define getopt() - * in ways that we cannot predict or comprehend, yet do not define the adjunct - * external variables needed for the interface. - */ -#if (!defined(BSD) || (BSD < 198911)) -int getopt(int, char * const *, const char *); -#endif - -#if (!defined(BSD) || (BSD < 199103)) -extern char *optarg; -extern int optind, opterr, optopt; -#endif - -/* digital unix needs this but does not give us a way to identify it. - */ -extern int flock(int, int); - -/* not all systems who provide flock() provide these definitions. - */ -#ifndef LOCK_SH -# define LOCK_SH 1 -#endif -#ifndef LOCK_EX -# define LOCK_EX 2 -#endif -#ifndef LOCK_NB -# define LOCK_NB 4 -#endif -#ifndef LOCK_UN -# define LOCK_UN 8 -#endif - #ifndef WCOREDUMP # define WCOREDUMP(st) (((st) & 0200) != 0) #endif diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index c2b14431921..ef1da72f82c 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.48 2014/10/26 22:16:16 guenther Exp $ */ +/* $OpenBSD: misc.c,v 1.49 2015/01/14 17:27:13 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -125,17 +125,10 @@ set_debug_flags(const char *flags) { void set_cron_uid(void) { -#if defined(BSD) || defined(POSIX) if (seteuid(ROOT_UID) < OK) { perror("seteuid"); exit(EXIT_FAILURE); } -#else - if (setuid(ROOT_UID) < OK) { - perror("setuid"); - exit(EXIT_FAILURE); - } -#endif } void @@ -493,11 +486,7 @@ log_it(const char *username, PID_T xpid, const char *event, const char *detail) #if defined(SYSLOG) if (!syslog_open) { -# ifdef LOG_DAEMON openlog(ProgramName, LOG_PID, FACILITY); -# else - openlog(ProgramName, LOG_PID); -# endif syslog_open = TRUE; /* assume openlog success */ } @@ -650,14 +639,9 @@ arpadate(clock) } #endif /*MAIL_DATE*/ -#ifdef HAVE_SAVED_UIDS static gid_t save_egid; int swap_gids() { save_egid = getegid(); return (setegid(getgid())); } int swap_gids_back() { return (setegid(save_egid)); } -#else /*HAVE_SAVED_UIDS*/ -int swap_gids() { return (setregid(getegid(), getgid())); } -int swap_gids_back() { return (swap_gids()); } -#endif /*HAVE_SAVED_UIDS*/ /* Return the offset from GMT in seconds (algorithm taken from sendmail). * -- 2.20.1