Clean up deleted files.

This commit is contained in:
mycroft 1994-01-12 19:26:40 +00:00
parent 954ef13a90
commit 3ce42c6893
7 changed files with 0 additions and 1104 deletions

View File

@ -1,9 +0,0 @@
# $Id: Makefile,v 1.3 1994/01/05 21:10:29 jtc Exp $
PROG= cron
SRCS= cron.c database.c user.c entry.c job.c do_command.c \
misc.c env.c popen.c compat.c
CFLAGS+=-I${.CURDIR}
MAN8= cron.0
.include <bsd.prog.mk>

View File

@ -1,233 +0,0 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
#if !defined(lint) && !defined(LINT)
static char rcsid[] = "$Id: compat.c,v 1.1.1.2 1994/01/12 18:35:27 jtc Exp $";
#endif
/* vix 30dec93 [broke this out of misc.c - see RCS log for history]
* vix 15jan87 [added TIOCNOTTY, thanks csg@pyramid]
*/
#include "cron.h"
#ifdef NEED_GETDTABLESIZE
# include <limits.h>
#endif
#if defined(NEED_SETSID) && defined(BSD)
# include <sys/ioctl.h>
#endif
#include <errno.h>
/* the code does not depend on any of vfork's
* side-effects; it just uses it as a quick
* fork-and-exec.
*/
#ifdef NEED_VFORK
PID_T
vfork() {
return (fork());
}
#endif
#ifdef NEED_STRDUP
char *
strdup(str)
char *str;
{
char *temp;
temp = malloc(strlen(str) + 1);
(void) strcpy(temp, str);
return temp;
}
#endif
#ifdef NEED_STRERROR
char *
strerror(error)
int error;
{
extern char *sys_errlist[];
extern int sys_nerr;
static char buf[32];
if ((error <= sys_nerr) && (error > 0)) {
return sys_errlist[error];
}
sprintf(buf, "Unknown error: %d", error);
return buf;
}
#endif
#ifdef NEED_STRCASECMP
int
strcasecmp(left, right)
char *left;
char *right;
{
while (*left && (MkLower(*left) == MkLower(*right))) {
left++;
right++;
}
return MkLower(*left) - MkLower(*right);
}
#endif
#ifdef NEED_SETSID
int
setsid()
{
int newpgrp;
# if defined(BSD)
int fd;
# if defined(POSIX)
newpgrp = setpgid((pid_t)0, getpid());
# else
newpgrp = setpgrp(0, getpid());
# endif
if ((fd = open("/dev/tty", 2)) >= 0)
{
(void) ioctl(fd, TIOCNOTTY, (char*)0);
(void) close(fd);
}
# else /*BSD*/
newpgrp = setpgrp();
(void) close(STDIN); (void) open("/dev/null", 0);
(void) close(STDOUT); (void) open("/dev/null", 1);
(void) close(STDERR); (void) open("/dev/null", 2);
# endif /*BSD*/
return newpgrp;
}
#endif /*NEED_SETSID*/
#ifdef NEED_GETDTABLESIZE
int
getdtablesize() {
#ifdef _SC_OPEN_MAX
return sysconf(_SC_OPEN_MAX);
#else
return _POSIX_OPEN_MAX;
#endif
}
#endif
#ifdef NEED_FLOCK
/* The following flock() emulation snarfed intact *) from the HP-UX
* "BSD to HP-UX porting tricks" maintained by
* system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
* from the version "last updated: 11-Jan-1993"
* Snarfage done by Jarkko Hietaniemi <Jarkko.Hietaniemi@hut.fi>
* *) well, almost, had to K&R the function entry, HPUX "cc"
* does not grok ANSI function prototypes */
/*
* flock (fd, operation)
*
* This routine performs some file locking like the BSD 'flock'
* on the object described by the int file descriptor 'fd',
* which must already be open.
*
* The operations that are available are:
*
* LOCK_SH - get a shared lock.
* LOCK_EX - get an exclusive lock.
* LOCK_NB - don't block (must be ORed with LOCK_SH or LOCK_EX).
* LOCK_UN - release a lock.
*
* Return value: 0 if lock successful, -1 if failed.
*
* Note that whether the locks are enforced or advisory is
* controlled by the presence or absence of the SETGID bit on
* the executable.
*
* Note that there is no difference between shared and exclusive
* locks, since the 'lockf' system call in SYSV doesn't make any
* distinction.
*
* The file "<sys/file.h>" should be modified to contain the definitions
* of the available operations, which must be added manually (see below
* for the values).
*/
/* this code has been reformatted by vixie */
int
flock(fd, operation)
int fd;
int operation;
{
int i;
switch (operation) {
case LOCK_SH: /* get a shared lock */
case LOCK_EX: /* get an exclusive lock */
i = lockf (fd, F_LOCK, 0);
break;
case LOCK_SH|LOCK_NB: /* get a non-blocking shared lock */
case LOCK_EX|LOCK_NB: /* get a non-blocking exclusive lock */
i = lockf (fd, F_TLOCK, 0);
if (i == -1)
if ((errno == EAGAIN) || (errno == EACCES))
errno = EWOULDBLOCK;
break;
case LOCK_UN: /* unlock */
i = lockf (fd, F_ULOCK, 0);
break;
default: /* can't decipher operation */
i = -1;
errno = EINVAL;
break;
}
return (i);
}
#endif /*NEED_FLOCK*/
#ifdef NEED_SETENV
int
setenv(name, value, overwrite)
char *name, *value;
int overwrite;
{
char *tmp;
if (overwrite && getenv(name))
return -1;
if (!(tmp = malloc(strlen(name) + strlen(value) + 2))) {
errno = ENOMEM;
return -1;
}
sprintf("%s=%s", name, value);
return putenv(tmp); /* intentionally orphan 'tmp' storage */
}
#endif

View File

@ -1,137 +0,0 @@
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
/*
* $Id: compat.h,v 1.1.1.2 1994/01/12 18:35:45 jtc Exp $
*/
#ifndef __P
# ifdef __STDC__
# define __P(x) x
# else
# define __P(x) ()
# define const
# endif
#endif
#if defined(UNIXPC) || defined(unixpc)
# define UNIXPC 1
# define ATT 1
#endif
#if defined(hpux) || defined(_hpux) || defined(__hpux)
# define HPUX 1
# define seteuid(e) setresuid(-1,e,-1)
# define setreuid(r,e) setresuid(r,e,-1)
#endif
#if defined(_IBMR2)
# define AIX 1
#endif
#if defined(__convex__)
# define CONVEX 1
#endif
#if defined(sgi) || defined(_sgi) || defined(__sgi)
# define IRIX 1
/* IRIX 4 hdrs are broken: one cannot #include both <stdio.h>
* and <stdlib.h> because they disagree on system(), perror().
* Therefore we must zap the "const" keyword BEFORE including
* either of them.
*/
# define const
#endif
#if defined(_UNICOS)
# define UNICOS 1
#endif
#ifndef POSIX
# if (BSD >= 199103) || defined(__linux) || defined(ultrix) || defined(AIX) ||\
defined(HPUX) || defined(CONVEX) || defined(IRIX)
# define POSIX
# endif
#endif
#ifndef BSD
# if defined(ultrix)
# define BSD 198902
# endif
#endif
/*****************************************************************/
#if !defined(BSD) && !defined(HPUX) && !defined(CONVEX) && !defined(__linux)
# define NEED_VFORK
#endif
#if (!defined(BSD) || (BSD < 198902)) && !defined(__linux) && \
!defined(IRIX) && !defined(NeXT) && !defined(HPUX)
# define NEED_STRCASECMP
#endif
#if (!defined(BSD) || (BSD < 198911)) && !defined(__linux) &&\
!defined(IRIX) && !defined(UNICOS) && !defined(HPUX)
# define NEED_STRDUP
#endif
#if (!defined(BSD) || (BSD < 198911)) && !defined(POSIX) && !defined(NeXT)
# define NEED_STRERROR
#endif
#if defined(HPUX) || defined(AIX) || defined(UNIXPC)
# define NEED_FLOCK
#endif
#ifndef POSIX
# define NEED_SETSID
#endif
#if (defined(POSIX) && !defined(BSD)) && !defined(__linux)
# define NEED_GETDTABLESIZE
#endif
#if (BSD >= 199103)
# define HAVE_SAVED_UIDS
#endif
#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && !defined(UNICOS)
# define USE_SIGCHLD
#endif
#if !defined(AIX) && !defined(UNICOS)
# define SYS_TIME_H 1
#else
# define SYS_TIME_H 0
#endif
#if defined(BSD) && !defined(POSIX)
# define USE_UTIMES
#endif
#if defined(AIX) || defined(HPUX) || defined(IRIX)
# define NEED_SETENV
#endif
#if !defined(UNICOS) && !defined(UNIXPC)
# define HAS_FCHOWN
#endif
#if !defined(UNICOS) && !defined(UNIXPC)
# define HAS_FCHMOD
#endif

View File

@ -1,86 +0,0 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
/* config.h - configurables for Vixie Cron
*
* $Id: config.h,v 1.1.1.2 1994/01/12 18:35:59 jtc Exp $
*/
#if !defined(_PATH_SENDMAIL)
# define _PATH_SENDMAIL "/usr/lib/sendmail"
#endif /*SENDMAIL*/
/*
* these are site-dependent
*/
#ifndef DEBUGGING
#define DEBUGGING 1 /* 1 or 0 -- do you want debugging code built in? */
#endif
/*
* choose one of these MAILCMD commands. I use
* /bin/mail for speed; it makes biff bark but doesn't
* do aliasing. /usr/lib/sendmail does aliasing but is
* a hog for short messages. aliasing is not needed
* if you make use of the MAILTO= feature in crontabs.
* (hint: MAILTO= was added for this reason).
*/
#define MAILCMD _PATH_SENDMAIL /*-*/
#define MAILARGS "%s -FCronDaemon -odi -oem -or0s %s" /*-*/
/* -Fx = set full-name of sender
* -odi = Option Deliverymode Interactive
* -oem = Option Errors Mailedtosender
* -or0s = Option Readtimeout -- don't time out
*/
/* #define MAILCMD "/bin/mail" /*-*/
/* #define MAILARGS "%s -d %s" /*-*/
/* -d = undocumented but common flag: deliver locally?
*/
/* #define MAILCMD "/usr/mmdf/bin/submit" /*-*/
/* #define MAILARGS "%s -mlrxto %s" /*-*/
/* #define MAIL_DATE /*-*/
/* should we include an ersatz Date: header in
* generated mail? if you are using sendmail
* for MAILCMD, it is better to let sendmail
* generate the Date: header.
*/
/* if ALLOW_FILE and DENY_FILE are not defined or are
* defined but neither exists, should crontab(1) be
* usable only by root?
*/
/*#define ALLOW_ONLY_ROOT /*-*/
/* 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 /*-*/

View File

@ -1,61 +0,0 @@
.\"/* Copyright 1988,1990,1993 by Paul Vixie
.\" * All rights reserved
.\" *
.\" * Distribute freely, except: don't remove my name from the source or
.\" * documentation (don't take credit for my work), mark your changes (don't
.\" * get me blamed for your possible bugs), don't alter or remove this
.\" * notice. May be sold if buildable source is provided to buyer. No
.\" * warrantee of any kind, express or implied, is included with this
.\" * software; use at your own risk, responsibility for damages (if any) to
.\" * anyone resulting from the use of this software rests entirely with the
.\" * user.
.\" *
.\" * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
.\" * I'll try to keep a version up to date. I can be reached as follows:
.\" * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
.\" */
.\"
.\" $Id: cron.8,v 1.1.1.1 1994/01/05 20:40:13 jtc Exp $
.\"
.TH CRON 8 "20 December 1993"
.UC 4
.SH NAME
cron \- daemon to execute scheduled commands (Vixie Cron)
.SH SYNOPSIS
cron
.SH DESCRIPTION
.I Cron
should be started from /etc/rc or /etc/rc.local. It will return immediately,
so you don't need to start it with '&'.
.PP
.I Cron
searches /var/cron/tabs for crontab files which are named after accounts in
/etc/passwd; crontabs found are loaded into memory.
.I Cron
also searches for /etc/crontab which is in a different format (see
.IR crontab(5)).
.I Cron
then wakes up every minute, examining all stored crontabs, checking each
command to see if it should be run in the current minute. When executing
commands, any output is mailed to the owner of the crontab (or to the user
named in the MAILTO environment variable in the crontab, if such exists).
.PP
Additionally,
.I cron
checks each minute to see if its spool directory's modtime (or the modtime
on
.IR /etc/crontab)
has changed, and if it has,
.I cron
will then examine the modtime on all crontabs and reload those which have
changed. Thus
.I cron
need not be restarted whenever a crontab file is modified. Note that the
.IR Crontab (1)
command updates the modtime of the spool directory whenever it changes a
crontab.
.SH "SEE ALSO"
crontab(1), crontab(5)
.SH AUTHOR
.nf
Paul Vixie <paul@vix.com>

View File

@ -1,301 +0,0 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
#if !defined(lint) && !defined(LINT)
static char rcsid[] = "$Id: cron.c,v 1.1.1.3 1994/01/12 18:36:09 jtc Exp $";
#endif
#define MAIN_PROGRAM
#include "cron.h"
#include <sys/signal.h>
#if SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
#endif
static void usage __P((void)),
run_reboot_jobs __P((cron_db *)),
cron_tick __P((cron_db *)),
cron_sync __P((void)),
cron_sleep __P((void)),
#ifdef USE_SIGCHLD
sigchld_handler __P((int)),
#endif
sighup_handler __P((int)),
parse_args __P((int c, char *v[]));
static void
usage() {
fprintf(stderr, "usage: %s [-x debugflag[,...]]\n", ProgramName);
exit(ERROR_EXIT);
}
int
main(argc, argv)
int argc;
char *argv[];
{
cron_db database;
ProgramName = argv[0];
#if defined(BSD)
setlinebuf(stdout);
setlinebuf(stderr);
#endif
parse_args(argc, argv);
#ifdef USE_SIGCHLD
(void) signal(SIGCHLD, sigchld_handler);
#else
(void) signal(SIGCLD, SIG_IGN);
#endif
(void) signal(SIGHUP, sighup_handler);
acquire_daemonlock(0);
set_cron_uid();
set_cron_cwd();
#if defined(POSIX)
setenv("PATH", _PATH_DEFPATH, 1);
#endif
/* if there are no debug flags turned on, fork as a daemon should.
*/
# if DEBUGGING
if (DebugFlags) {
# else
if (0) {
# endif
(void) fprintf(stderr, "[%d] cron started\n", getpid());
} else {
switch (fork()) {
case -1:
log_it("CRON",getpid(),"DEATH","can't fork");
exit(0);
break;
case 0:
/* child process */
log_it("CRON",getpid(),"STARTUP","fork ok");
(void) setsid();
break;
default:
/* parent process should just die */
_exit(0);
}
}
acquire_daemonlock(0);
database.head = NULL;
database.tail = NULL;
database.mtime = (time_t) 0;
load_database(&database);
run_reboot_jobs(&database);
cron_sync();
while (TRUE) {
# if DEBUGGING
if (!(DebugFlags & DTEST))
# endif /*DEBUGGING*/
cron_sleep();
load_database(&database);
/* do this iteration
*/
cron_tick(&database);
/* sleep 1 minute
*/
TargetTime += 60;
}
}
static void
run_reboot_jobs(db)
cron_db *db;
{
register user *u;
register entry *e;
for (u = db->head; u != NULL; u = u->next) {
for (e = u->crontab; e != NULL; e = e->next) {
if (e->flags & WHEN_REBOOT) {
job_add(e, u);
}
}
}
(void) job_runqueue();
}
static void
cron_tick(db)
cron_db *db;
{
register struct tm *tm = localtime(&TargetTime);
register int minute, hour, dom, month, dow;
register user *u;
register entry *e;
/* make 0-based values out of these so we can use them as indicies
*/
minute = tm->tm_min -FIRST_MINUTE;
hour = tm->tm_hour -FIRST_HOUR;
dom = tm->tm_mday -FIRST_DOM;
month = tm->tm_mon +1 /* 0..11 -> 1..12 */ -FIRST_MONTH;
dow = tm->tm_wday -FIRST_DOW;
Debug(DSCH, ("[%d] tick(%d,%d,%d,%d,%d)\n",
getpid(), minute, hour, dom, month, dow))
/* the dom/dow situation is odd. '* * 1,15 * Sun' will run on the
* first and fifteenth AND every Sunday; '* * * * Sun' will run *only*
* on Sundays; '* * 1,15 * *' will run *only* the 1st and 15th. this
* is why we keep 'e->dow_star' and 'e->dom_star'. yes, it's bizarre.
* like many bizarre things, it's the standard.
*/
for (u = db->head; u != NULL; u = u->next) {
for (e = u->crontab; e != NULL; e = e->next) {
Debug(DSCH|DEXT, ("user [%s:%d:%d:...] cmd=\"%s\"\n",
env_get("LOGNAME", e->envp),
e->uid, e->gid, e->cmd))
if (bit_test(e->minute, minute)
&& bit_test(e->hour, hour)
&& bit_test(e->month, month)
&& ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
? (bit_test(e->dow,dow) && bit_test(e->dom,dom))
: (bit_test(e->dow,dow) || bit_test(e->dom,dom))
)
) {
job_add(e, u);
}
}
}
}
/* the task here is to figure out how long it's going to be until :00 of the
* following minute and initialize TargetTime to this value. TargetTime
* will subsequently slide 60 seconds at a time, with correction applied
* implicitly in cron_sleep(). it would be nice to let cron execute in
* the "current minute" before going to sleep, but by restarting cron you
* could then get it to execute a given minute's jobs more than once.
* instead we have the chance of missing a minute's jobs completely, but
* that's something sysadmin's know to expect what with crashing computers..
*/
static void
cron_sync() {
register struct tm *tm;
TargetTime = time((time_t*)0);
tm = localtime(&TargetTime);
TargetTime += (60 - tm->tm_sec);
}
static void
cron_sleep() {
register int seconds_to_wait;
do {
seconds_to_wait = (int) (TargetTime - time((time_t*)0));
Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n",
getpid(), TargetTime, seconds_to_wait))
/* if we intend to sleep, this means that it's finally
* time to empty the job queue (execute it).
*
* if we run any jobs, we'll probably screw up our timing,
* so go recompute.
*
* note that we depend here on the left-to-right nature
* of &&, and the short-circuiting.
*/
} while (seconds_to_wait > 0 && job_runqueue());
while (seconds_to_wait > 0) {
Debug(DSCH, ("[%d] sleeping for %d seconds\n",
getpid(), seconds_to_wait))
seconds_to_wait = (int) sleep((unsigned int) seconds_to_wait);
}
}
#ifdef USE_SIGCHLD
static void
sigchld_handler(x) {
WAIT_T waiter;
PID_T pid;
for (;;) {
#ifdef POSIX
pid = waitpid(-1, &waiter, WNOHANG);
#else
pid = wait3(&waiter, WNOHANG, (struct rusage *)0);
#endif
switch (pid) {
case -1:
Debug(DPROC,
("[%d] sigchld...no children\n", getpid()))
return;
case 0:
Debug(DPROC,
("[%d] sigchld...no dead kids\n", getpid()))
return;
default:
Debug(DPROC,
("[%d] sigchld...pid #%d died, stat=%d\n",
getpid(), pid, WEXITSTATUS(waiter)))
}
}
}
#endif /*USE_SIGCHLD*/
static void
sighup_handler(x) {
log_close();
}
static void
parse_args(argc, argv)
int argc;
char *argv[];
{
int argch;
while (EOF != (argch = getopt(argc, argv, "x:"))) {
switch (argch) {
default:
usage();
case 'x':
if (!set_debug_flags(optarg))
usage();
break;
}
}
}

View File

@ -1,277 +0,0 @@
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
/* cron.h - header for vixie's cron
*
* $Id: cron.h,v 1.1.1.3 1994/01/12 18:36:21 jtc Exp $
*
* vix 14nov88 [rest of log is in RCS]
* vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley]
* vix 30dec86 [written]
*/
/* reorder these #include's at your peril */
#include <sys/types.h>
#include <sys/param.h>
#include "compat.h"
#include <stdio.h>
#include <ctype.h>
#include <bitstring.h>
#include <pwd.h>
#include <sys/wait.h>
#include "pathnames.h"
#include "config.h"
#include "externs.h"
/* these are really immutable, and are
* defined for symbolic convenience only
* TRUE, FALSE, and ERR must be distinct
* ERR must be < OK.
*/
#define TRUE 1
#define FALSE 0
/* system calls return this on success */
#define OK 0
/* or this on error */
#define ERR (-1)
/* turn this on to get '-x' code */
#ifndef DEBUGGING
#define DEBUGGING FALSE
#endif
#define READ_PIPE 0 /* which end of a pipe pair do you read? */
#define WRITE_PIPE 1 /* or write to? */
#define STDIN 0 /* what is stdin's file descriptor? */
#define STDOUT 1 /* stdout's? */
#define STDERR 2 /* stderr's? */
#define ERROR_EXIT 1 /* exit() with this will scare the shell */
#define OK_EXIT 0 /* exit() with this is considered 'normal' */
#define MAX_FNAME 100 /* max length of internally generated fn */
#define MAX_COMMAND 1000 /* max length of internally generated cmd */
#define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */
#define MAX_TEMPSTR 100 /* obvious */
#define MAX_UNAME 20 /* 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 */
/* NOTE: these correspond to DebugFlagNames,
* defined below.
*/
#define DEXT 0x0001 /* extend flag for other debug masks */
#define DSCH 0x0002 /* scheduling debug mask */
#define DPROC 0x0004 /* process control debug mask */
#define DPARS 0x0008 /* parsing debug mask */
#define DLOAD 0x0010 /* database loading debug mask */
#define DMISC 0x0020 /* misc debug mask */
#define DTEST 0x0040 /* test mode: don't execute any commands */
#define DBIT 0x0080 /* bit twiddling shown (long) */
#define CRON_TAB(u) "%s/%s", SPOOL_DIR, u
#define REG register
#define PPC_NULL ((char **)NULL)
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
#define Skip_Blanks(c, f) \
while (c == '\t' || c == ' ') \
c = get_char(f);
#define Skip_Nonblanks(c, f) \
while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
c = get_char(f);
#define Skip_Line(c, f) \
do {c = get_char(f);} while (c != '\n' && c != EOF);
#if DEBUGGING
# define Debug(mask, message) \
if ( (DebugFlags & (mask) ) == (mask) ) \
printf message;
#else /* !DEBUGGING */
# define Debug(mask, message) \
;
#endif /* DEBUGGING */
#define MkLower(ch) (isupper(ch) ? tolower(ch) : ch)
#define MkUpper(ch) (islower(ch) ? toupper(ch) : ch)
#define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
LineNumber = ln; \
}
#define FIRST_MINUTE 0
#define LAST_MINUTE 59
#define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1)
#define FIRST_HOUR 0
#define LAST_HOUR 23
#define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1)
#define FIRST_DOM 1
#define LAST_DOM 31
#define DOM_COUNT (LAST_DOM - FIRST_DOM + 1)
#define FIRST_MONTH 1
#define LAST_MONTH 12
#define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1)
/* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
#define FIRST_DOW 0
#define LAST_DOW 7
#define DOW_COUNT (LAST_DOW - FIRST_DOW + 1)
/* each user's crontab will be held as a list of
* the following structure.
*
* These are the cron commands.
*/
typedef struct _entry {
struct _entry *next;
uid_t uid;
gid_t gid;
char **envp;
char *cmd;
bitstr_t bit_decl(minute, MINUTE_COUNT);
bitstr_t bit_decl(hour, HOUR_COUNT);
bitstr_t bit_decl(dom, DOM_COUNT);
bitstr_t bit_decl(month, MONTH_COUNT);
bitstr_t bit_decl(dow, DOW_COUNT);
int flags;
#define DOM_STAR 0x01
#define DOW_STAR 0x02
#define WHEN_REBOOT 0x04
} entry;
/* the crontab database will be a list of the
* following structure, one element per user
* plus one for the system.
*
* These are the crontabs.
*/
typedef struct _user {
struct _user *next, *prev; /* links */
char *name;
time_t mtime; /* last modtime of crontab */
entry *crontab; /* this person's crontab */
} user;
typedef struct _cron_db {
user *head, *tail; /* links */
time_t mtime; /* last modtime on spooldir */
} cron_db;
void set_cron_uid __P((void)),
set_cron_cwd __P((void)),
load_database __P((cron_db *)),
open_logfile __P((void)),
sigpipe_func __P((void)),
job_add __P((entry *, user *)),
do_command __P((entry *, user *)),
link_user __P((cron_db *, user *)),
unlink_user __P((cron_db *, user *)),
free_user __P((user *)),
env_free __P((char **)),
unget_char __P((int, FILE *)),
free_entry __P((entry *)),
acquire_daemonlock __P((int)),
skip_comments __P((FILE *)),
log_it __P((char *, int, char *, char *)),
log_close __P((void));
int job_runqueue __P((void)),
set_debug_flags __P((char *)),
get_char __P((FILE *)),
get_string __P((char *, int, FILE *, char *)),
swap_uids __P((void)),
load_env __P((char *, FILE *)),
cron_pclose __P((FILE *)),
strcmp_until __P((char *, char *, int)),
allowed __P((char *)),
strdtb __P((char *));
char *env_get __P((char *, char **)),
*arpadate __P((time_t *)),
*mkprints __P((unsigned char *, unsigned int)),
*first_word __P((char *, char *)),
**env_init __P((void)),
**env_copy __P((char **)),
**env_set __P((char **, char *));
user *load_user __P((int, struct passwd *, char *)),
*find_user __P((cron_db *, char *));
entry *load_entry __P((FILE *, void (*)(),
struct passwd *, char **));
FILE *cron_popen __P((char *, char *));
/* in the C tradition, we only create
* variables for the main program, just
* extern them elsewhere.
*/
#ifdef MAIN_PROGRAM
# if !defined(LINT) && !defined(lint)
char *copyright[] = {
"@(#) Copyright 1988,1989,1990,1993,1994 by Paul Vixie",
"@(#) All rights reserved"
};
# endif
char *MonthNames[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
NULL
};
char *DowNames[] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
NULL
};
char *ProgramName;
int LineNumber;
time_t TargetTime;
# if DEBUGGING
int DebugFlags;
char *DebugFlagNames[] = { /* sync with #defines */
"ext", "sch", "proc", "pars", "load", "misc", "test", "bit",
NULL /* NULL must be last element */
};
# endif /* DEBUGGING */
#else /*MAIN_PROGRAM*/
extern char *copyright[],
*MonthNames[],
*DowNames[],
*ProgramName;
extern int LineNumber;
extern time_t TargetTime;
# if DEBUGGING
extern int DebugFlags;
extern char *DebugFlagNames[];
# endif /* DEBUGGING */
#endif /*MAIN_PROGRAM*/