-/* $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")
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* config.h - configurables for ISC Cron
- */
-
/*
* these are site-dependent
*/
/* #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 /*-*/
-/* $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")
* 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"
-/* $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")
* 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 <err.h>
#define MAIN_PROGRAM
-/* $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")
* 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))
-/* $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
* 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 {
-/* $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")
#include <unistd.h>
#include <utime.h>
-#if defined(SYSLOG)
# include <syslog.h>
-#endif
-#if defined(LOGIN_CAP)
# include <login_cap.h>
-#endif /*LOGIN_CAP*/
-#if defined(BSD_AUTH)
# include <bsd_auth.h>
-#endif /*BSD_AUTH*/
#ifndef TZNAME_ALREADY_DEFINED
extern char *tzname[2];
-/* $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")
FILE *cron_popen(char *, char *, struct passwd *, pid_t *);
-#ifndef HAVE_TM_GMTOFF
-long get_gmtoff(time_t *, struct tm *);
-#endif
-/* $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")
# 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
= {
-/* $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")
#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
-/* $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")
* 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 <limits.h>
-#if defined(SYSLOG) && defined(LOG_FILE)
-# undef LOG_FILE
-#endif
-
#if defined(LOG_DAEMON) && !defined(LOG_CRON)
# define LOG_CRON LOG_DAEMON
#endif
static int LogFD = -1;
-#if defined(SYSLOG)
static int syslog_open = FALSE;
-#endif
int
strcmp_until(const char *left, const char *right, char until)
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 */
syslog(*info ? LOG_INFO : LOG_WARNING, "(%s) %s (%s)", username, event,
detail);
-#endif /*SYSLOG*/
}
close(LogFD);
LogFD = -1;
}
-#if defined(SYSLOG)
closelog();
syslog_open = FALSE;
-#endif /*SYSLOG*/
}
/* char *first_word(char *s, char *t)
* 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.
-/* $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")
#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 <syslog.h>, LOG_FILE will not
- * be used.
- */
-#define LOG_FILE "log"
-
/* where should the daemon stick its PID?
* PIDDIR must end in '/'.
*/
-/* $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")
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* vix 26jan87 [log is in RCS file]
- */
-
#include "cron.h"
void