From 27802abd9ba240d10bceaa25074a7c3ea9ad2422 Mon Sep 17 00:00:00 2001 From: millert Date: Wed, 14 Jan 2015 17:27:51 +0000 Subject: [PATCH] Use HAVE_FOO for BSD-specific features instead of relying on the BSD macro from sys/param.h. --- usr.sbin/cron/atrun.c | 6 +++--- usr.sbin/cron/config.h | 11 ++++++++++- usr.sbin/cron/do_command.c | 6 +++--- usr.sbin/cron/entry.c | 4 +--- usr.sbin/cron/pathnames.h | 6 +++--- usr.sbin/cron/popen.c | 6 +++--- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 52f9070e5f4..26c17da6c00 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.21 2015/01/14 17:27:29 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.22 2015/01/14 17:27:51 millert Exp $ */ /* * Copyright (c) 2002-2003 Todd C. Miller @@ -284,7 +284,7 @@ run_job(atjob *job, char *atfile) log_it("CRON", getpid(), "ORPHANED JOB", atfile); _exit(EXIT_FAILURE); } -#if (defined(BSD)) && (BSD >= 199103) +#ifdef HAVE_PW_EXPIRE if (pw->pw_expire && time(NULL) >= pw->pw_expire) { log_it(pw->pw_name, getpid(), "ACCOUNT EXPIRED, JOB ABORTED", atfile); @@ -459,7 +459,7 @@ run_job(atjob *job, char *atfile) "unable to set groups for %s\n", pw->pw_name); _exit(EXIT_FAILURE); } -#if (defined(BSD)) && (BSD >= 199103) +#ifdef HAVE_SETLOGIN setlogin(pw->pw_name); #endif if (setuid(pw->pw_uid)) { diff --git a/usr.sbin/cron/config.h b/usr.sbin/cron/config.h index d6d6be2c14b..2d0d69e2f14 100644 --- a/usr.sbin/cron/config.h +++ b/usr.sbin/cron/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.17 2004/06/17 22:11:55 millert Exp $ */ +/* $OpenBSD: config.h,v 1.18 2015/01/14 17:27:51 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -85,6 +85,9 @@ */ #define HAVE_TM_GMTOFF /*-*/ + /* if your OS has the paths.h header */ +#define HAVE_PATHS_H /*-*/ + /* if your OS supports a BSD-style login.conf file */ #define LOGIN_CAP /*-*/ @@ -94,6 +97,12 @@ /* if your OS has a getloadavg() function */ #define HAVE_GETLOADAVG /*-*/ + /* if your OS has a setlogin() function */ +#define HAVE_SETLOGIN /*-*/ + + /* if your OS has a pw_expire field in struct passwd */ +#define HAVE_PW_EXPIRE /*-*/ + /* maximum load at which batch jobs will still run */ #define BATCH_MAXLOAD 1.5 /*-*/ diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index d647656ae3c..3f650b19a65 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.39 2015/01/14 17:27:30 millert Exp $ */ +/* $OpenBSD: do_command.c,v 1.40 2015/01/14 17:27:51 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -234,9 +234,9 @@ child_process(entry *e, user *u) { "unable to set groups for %s\n", e->pwd->pw_name); _exit(EXIT_FAILURE); } -#if (defined(BSD)) && (BSD >= 199103) +#ifdef HAVE_SETLOGIN setlogin(usernm); -#endif /* BSD */ +#endif if (setuid(e->pwd->pw_uid)) { fprintf(stderr, "unable to set uid to %lu\n", diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 8d200ece024..2a4fffdd971 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.34 2014/08/25 07:50:26 doug Exp $ */ +/* $OpenBSD: entry.c,v 1.35 2015/01/14 17:27:51 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -329,7 +329,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, } e->envp = tenvp; } -#if defined(BSD) || defined(__linux) if (snprintf(envstr, sizeof envstr, "USER=%s", pw->pw_name) >= sizeof(envstr)) log_it("CRON", getpid(), "error", "can't set USER"); @@ -340,7 +339,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, } e->envp = tenvp; } -#endif Debug(DPARS, ("load_entry()...about to parse command\n")) diff --git a/usr.sbin/cron/pathnames.h b/usr.sbin/cron/pathnames.h index da98c4e306f..9beb706b705 100644 --- a/usr.sbin/cron/pathnames.h +++ b/usr.sbin/cron/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.12 2007/02/13 18:39:34 mglocker Exp $ */ +/* $OpenBSD: pathnames.h,v 1.13 2015/01/14 17:27:51 millert Exp $ */ /* Copyright 1993,1994 by Paul Vixie * All rights reserved @@ -24,9 +24,9 @@ #ifndef _PATHNAMES_H_ #define _PATHNAMES_H_ -#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX) +#ifdef HAVE_PATHS_H # include -#endif /*BSD*/ +#endif /*HAVE_PATHS_H*/ #ifndef CRONDIR /* CRONDIR is where cron(8) and crontab(1) both chdir diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c index 1598f0d969d..5b9da7ebce9 100644 --- a/usr.sbin/cron/popen.c +++ b/usr.sbin/cron/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.23 2015/01/14 17:27:30 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.24 2015/01/14 17:27:51 millert Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -99,9 +99,9 @@ cron_popen(char *program, char *type, struct passwd *pw) { pw->pw_name); _exit(1); } -#if (defined(BSD)) && (BSD >= 199103) +#ifdef HAVE_SETLOGIN setlogin(pw->pw_name); -#endif /* BSD */ +#endif if (setuid(pw->pw_uid)) { fprintf(stderr, "unable to set uid for %s\n", -- 2.20.1