From 11834cabf71f16f8c49b8708a94f9ee816d69287 Mon Sep 17 00:00:00 2001 From: tedu Date: Tue, 6 Oct 2015 14:58:37 +0000 Subject: [PATCH] clear out some more legacy code and whatnot --- usr.sbin/cron/config.h | 44 +------------------ usr.sbin/cron/cron.h | 9 +--- usr.sbin/cron/crontab.c | 7 +-- usr.sbin/cron/database.c | 5 +-- usr.sbin/cron/entry.c | 8 +--- usr.sbin/cron/externs.h | 8 +--- usr.sbin/cron/funcs.h | 5 +-- usr.sbin/cron/globals.h | 17 +------- usr.sbin/cron/macros.h | 4 +- usr.sbin/cron/misc.c | 91 +-------------------------------------- usr.sbin/cron/pathnames.h | 10 +---- usr.sbin/cron/user.c | 5 +-- 12 files changed, 12 insertions(+), 201 deletions(-) diff --git a/usr.sbin/cron/config.h b/usr.sbin/cron/config.h index e66ad2a02cc..f81f0bd825d 100644 --- a/usr.sbin/cron/config.h +++ b/usr.sbin/cron/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.21 2015/02/09 23:00:14 deraadt Exp $ */ +/* $OpenBSD: config.h,v 1.22 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,9 +17,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* config.h - configurables for ISC Cron - */ - /* * these are site-dependent */ @@ -50,51 +47,12 @@ /* #define MAILFMT "%s -mlrxto %s" -*/ /* #define MAILARG "/usr/mmdf/bin/submit",mailto -*/ -/* #define MAIL_DATE -*/ - /* should we include an ersatz Date: header in - * generated mail? if you are using sendmail - * as the mailer, it is better to let sendmail - * generate the Date: header. - */ - - /* if you want to use syslog(3) instead of appending - * to CRONDIR/LOG_FILE (/var/cron/log, e.g.), define - * SYSLOG here. Note that quite a bit of logging - * info is written, and that you probably don't want - * to use this on 4.2bsd since everything goes in - * /usr/spool/mqueue/syslog. On 4.[34]bsd you can - * tell /etc/syslog.conf to send cron's logging to - * a separate file. - * - * Note that if this and LOG_FILE in "pathnames.h" - * are both defined, then logging will go to both - * places. - */ -#define SYSLOG /*-*/ - - /* if you have a tm_gmtoff member in struct tm. - * If not, we will have to compute the value ourselves. - */ -#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 /*-*/ - - /* if your OS supports BSD authentication */ -#define BSD_AUTH /*-*/ - /* 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/cron.h b/usr.sbin/cron/cron.h index 1b8546ed796..695470ce877 100644 --- a/usr.sbin/cron/cron.h +++ b/usr.sbin/cron/cron.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.h,v 1.10 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: cron.h,v 1.11 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,13 +17,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* cron.h - header for vixie's cron - * - * vix 14nov88 [rest of log is in RCS] - * vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley] - * vix 30dec86 [written] - */ - #define CRON_VERSION "V5.0" #include "config.h" #include "externs.h" diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 79c015e5519..18189d604a2 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.71 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: crontab.c,v 1.72 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,11 +17,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* crontab - install and manage per-user crontab files - * vix 02may87 [RCS has the rest of the log] - * vix 26jan87 [original] - */ - #include #define MAIN_PROGRAM diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index b5820c34690..3ac199f72bc 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.25 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: database.c,v 1.26 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,9 +17,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* vix 26jan87 [RCS has the log] - */ - #include "cron.h" #define HASH(a,b) ((a)+(b)) diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 381fc99d58b..57ae77c0a48 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.41 2015/10/03 12:46:54 tedu Exp $ */ +/* $OpenBSD: entry.c,v 1.42 2015/10/06 14:58:37 tedu Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -18,12 +18,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* vix 26jan87 [RCS'd; rest of log is in RCS file] - * vix 01jan87 [added line-level error recovery] - * vix 31dec86 [added /step to the from-to range, per bob@acornrc] - * vix 30dec86 [written] - */ - #include "cron.h" typedef enum ecode { diff --git a/usr.sbin/cron/externs.h b/usr.sbin/cron/externs.h index 5652780bcac..0566131c526 100644 --- a/usr.sbin/cron/externs.h +++ b/usr.sbin/cron/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.16 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: externs.h,v 1.17 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -46,17 +46,11 @@ #include #include -#if defined(SYSLOG) # include -#endif -#if defined(LOGIN_CAP) # include -#endif /*LOGIN_CAP*/ -#if defined(BSD_AUTH) # include -#endif /*BSD_AUTH*/ #ifndef TZNAME_ALREADY_DEFINED extern char *tzname[2]; diff --git a/usr.sbin/cron/funcs.h b/usr.sbin/cron/funcs.h index 56ecedc7965..6c938d9714f 100644 --- a/usr.sbin/cron/funcs.h +++ b/usr.sbin/cron/funcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: funcs.h,v 1.18 2015/10/03 19:47:21 tedu Exp $ */ +/* $OpenBSD: funcs.h,v 1.19 2015/10/06 14:58:37 tedu Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -76,6 +76,3 @@ entry *load_entry(FILE *, FILE *cron_popen(char *, char *, struct passwd *, pid_t *); -#ifndef HAVE_TM_GMTOFF -long get_gmtoff(time_t *, struct tm *); -#endif diff --git a/usr.sbin/cron/globals.h b/usr.sbin/cron/globals.h index 5a04e88340c..ee400029c5f 100644 --- a/usr.sbin/cron/globals.h +++ b/usr.sbin/cron/globals.h @@ -1,4 +1,4 @@ -/* $OpenBSD: globals.h,v 1.10 2015/01/23 15:56:04 millert Exp $ */ +/* $OpenBSD: globals.h,v 1.11 2015/10/06 14:58:37 tedu Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -25,21 +25,6 @@ # define INIT(x) #endif -#if 0 -XTRN const char *copyright[] -#ifdef MAIN_PROGRAM - = { - "@(#) ISC Cron V4.1", - "@(#) Copyright 1988,1989,1990,1993,1994 by Paul Vixie", - "@(#) Copyright 1997,2000 by Internet Software Consortium, Inc.", - "@(#) Copyright 2004 by Internet Systems Consortium, Inc.", - "@(#) All rights reserved", - NULL - } -#endif - ; -#endif - XTRN const char *MonthNames[] #ifdef MAIN_PROGRAM = { diff --git a/usr.sbin/cron/macros.h b/usr.sbin/cron/macros.h index f8afdf42360..0b0ec9905c7 100644 --- a/usr.sbin/cron/macros.h +++ b/usr.sbin/cron/macros.h @@ -1,4 +1,4 @@ -/* $OpenBSD: macros.h,v 1.11 2015/01/23 02:37:25 tedu Exp $ */ +/* $OpenBSD: macros.h,v 1.12 2015/10/06 14:58:37 tedu Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -47,9 +47,7 @@ #define RELOAD_CRON 0x2 #define RELOAD_AT 0x4 -#ifdef HAVE_TM_GMTOFF #define get_gmtoff(c, t) ((t)->tm_gmtoff) -#endif #define SECONDS_PER_MINUTE 60 diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index 14a94a9b36b..269d7df18e0 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.55 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.56 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,17 +17,9 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* vix 26jan87 [RCS has the rest of the log] - * vix 30dec86 [written] - */ - #include "cron.h" #include -#if defined(SYSLOG) && defined(LOG_FILE) -# undef LOG_FILE -#endif - #if defined(LOG_DAEMON) && !defined(LOG_CRON) # define LOG_CRON LOG_DAEMON #endif @@ -38,9 +30,7 @@ static int LogFD = -1; -#if defined(SYSLOG) static int syslog_open = FALSE; -#endif int strcmp_until(const char *left, const char *right, char until) @@ -376,58 +366,9 @@ allowed(const char *username, const char *allow_file, const char *deny_file) void log_it(const char *username, pid_t xpid, const char *event, const char *detail) { -#if defined(LOG_FILE) || DEBUGGING - pid_t pid = xpid; -#endif -#if defined(LOG_FILE) - char *msg; - size_t msglen; - time_t now = time(NULL); - struct tm *t = localtime(&now); -#endif /*LOG_FILE*/ -#if defined(SYSLOG) char **info, *info_events[] = { "CMD", "ATJOB", "BEGIN EDIT", "DELETE", "END EDIT", "LIST", "MAIL", "RELOAD", "REPLACE", "STARTUP", NULL }; -#endif /*SYSLOG*/ -#if defined(LOG_FILE) - /* we assume that MAX_TEMPSTR will hold the date, time, &punctuation. - */ - msglen = strlen(username) + strlen(event) + strlen(detail) + - MAX_TEMPSTR; - if ((msg = malloc(msglen)) == NULL) - return; - - if (LogFD < 0) { - LogFD = open(LOG_FILE, O_WRONLY|O_APPEND|O_CREAT|O_CLOEXEC, - 0600); - if (LogFD < 0) { - fprintf(stderr, "%s: can't open log file\n", - ProgramName); - perror(LOG_FILE); - } - } - - /* we have to snprintf() it because fprintf() doesn't always write - * everything out in one chunk and this has to be atomically appended - * to the log file. - */ - snprintf(msg, msglen, "%s (%02d/%02d-%02d:%02d:%02d-%ld) %s (%s)\n", - username, - t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, - (long)pid, event, detail); - - if (LogFD < 0 || write(LogFD, msg, strlen(msg)) < 0) { - if (LogFD >= 0) - perror(LOG_FILE); - fprintf(stderr, "%s: can't write to log file\n", ProgramName); - write(STDERR_FILENO, msg, strlen(msg)); - } - - free(msg); -#endif /*LOG_FILE*/ - -#if defined(SYSLOG) if (!syslog_open) { openlog(ProgramName, LOG_PID, FACILITY); syslog_open = TRUE; /* assume openlog success */ @@ -439,7 +380,6 @@ log_it(const char *username, pid_t xpid, const char *event, const char *detail) syslog(*info ? LOG_INFO : LOG_WARNING, "(%s) %s (%s)", username, event, detail); -#endif /*SYSLOG*/ } @@ -450,10 +390,8 @@ log_close(void) close(LogFD); LogFD = -1; } -#if defined(SYSLOG) closelog(); syslog_open = FALSE; -#endif /*SYSLOG*/ } /* char *first_word(char *s, char *t) @@ -588,33 +526,6 @@ int swap_gids_back() { return (setegid(save_egid)); } * clobbers the static storage space used by localtime() and gmtime(). * If the local pointer is non-NULL it *must* point to a local copy. */ -#ifndef HAVE_TM_GMTOFF -long get_gmtoff(time_t *clock, struct tm *local) -{ - struct tm gmt; - long offset; - - gmt = *gmtime(clock); - if (local == NULL) - local = localtime(clock); - - offset = (local->tm_sec - gmt.tm_sec) + - ((local->tm_min - gmt.tm_min) * 60) + - ((local->tm_hour - gmt.tm_hour) * 3600); - - /* Timezone may cause year rollover to happen on a different day. */ - if (local->tm_year < gmt.tm_year) - offset -= 24 * 3600; - else if (local->tm_year > gmt.tm_year) - offset += 24 * 3600; - else if (local->tm_yday < gmt.tm_yday) - offset -= 24 * 3600; - else if (local->tm_yday > gmt.tm_yday) - offset += 24 * 3600; - - return (offset); -} -#endif /* HAVE_TM_GMTOFF */ /* void open_socket(void) * opens a UNIX domain socket that crontab uses to poke cron. diff --git a/usr.sbin/cron/pathnames.h b/usr.sbin/cron/pathnames.h index bc3f4d932bd..fc41d2f901d 100644 --- a/usr.sbin/cron/pathnames.h +++ b/usr.sbin/cron/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.14 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: pathnames.h,v 1.15 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -69,14 +69,6 @@ #define AT_ALLOW "at.allow" #define AT_DENY "at.deny" - /* undefining this turns off logging to a file. If - * neither LOG_FILE or SYSLOG is defined, we don't log. - * If both are defined, we log both ways. Note that if - * LOG_CRON is defined by , LOG_FILE will not - * be used. - */ -#define LOG_FILE "log" - /* where should the daemon stick its PID? * PIDDIR must end in '/'. */ diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c index 8c87520bf67..2fbc356ae23 100644 --- a/usr.sbin/cron/user.c +++ b/usr.sbin/cron/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.14 2015/02/09 22:35:08 deraadt Exp $ */ +/* $OpenBSD: user.c,v 1.15 2015/10/06 14:58:37 tedu Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -17,9 +17,6 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* vix 26jan87 [log is in RCS file] - */ - #include "cron.h" void -- 2.20.1