-/* $OpenBSD: atrun.c,v 1.25 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: atrun.c,v 1.26 2015/01/23 01:01:06 tedu Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
struct dirent *file;
struct stat statbuf;
- Debug(DLOAD, ("[%ld] scan_atjobs()\n", (long)getpid()))
-
if (stat(AT_DIR, &statbuf) != 0) {
log_it("CRON", getpid(), "CAN'T STAT", AT_DIR);
return (0);
}
if (old_db->mtime == statbuf.st_mtime) {
- Debug(DLOAD, ("[%ld] at jobs dir mtime unch, no load needed.\n",
- (long)getpid()))
return (0);
}
closedir(atdir);
/* Free up old at db */
- Debug(DLOAD, ("unlinking old at database:\n"))
for (job = old_db->head; job != NULL; ) {
- Debug(DLOAD, ("\t%lld.%c\n", (long long)job->run_time, job->queue))
tjob = job;
job = job->next;
free(tjob);
/* Install the new database */
*old_db = new_db;
- Debug(DLOAD, ("scan_atjobs is done\n"))
return (pending);
}
double la;
atjob *job, *batch;
- Debug(DPROC, ("[%ld] atrun()\n", (long)getpid()))
-
for (batch = NULL, job = db->head; job; job = job->next) {
/* Skip jobs in the future */
if (job->run_time > now)
int output_pipe[2];
char *nargv[2], *nenvp[1];
- Debug(DPROC, ("[%ld] run_job('%s')\n", (long)getpid(), atfile))
-
/* Open the file and unlink it so we don't try running it again. */
if ((fd = open(atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < OK) {
log_it("CRON", getpid(), "CAN'T OPEN", atfile);
_exit(EXIT_FAILURE);
/*NOTREACHED*/
case 0:
- Debug(DPROC, ("[%ld] grandchild process fork()'ed\n",
- (long)getpid()))
-
/* Write log message now that we have our real pid. */
log_it(pw->pw_name, getpid(), "ATJOB", atfile);
if (job->queue > 'b')
(void)setpriority(PRIO_PROCESS, 0, job->queue - 'b');
-#if DEBUGGING
- if (DebugFlags & DTEST) {
- fprintf(stderr,
- "debug DTEST is on, not exec'ing at job %s\n",
- atfile);
- _exit(EXIT_SUCCESS);
- }
-#endif /*DEBUGGING*/
(void) signal(SIGPIPE, SIG_DFL);
break;
}
- Debug(DPROC, ("[%ld] child continues, closing output pipe\n",
- (long)getpid()))
-
/* Close the atfile's fd and the end of the pipe we don't use. */
close(fd);
close(output_pipe[WRITE_PIPE]);
/* Read piped output (if any) from the at job. */
- Debug(DPROC, ("[%ld] child reading output from grandchild\n",
- (long)getpid()))
-
if ((fp = fdopen(output_pipe[READ_PIPE], "r")) == NULL) {
perror("fdopen");
(void) _exit(EXIT_FAILURE);
char mailcmd[MAX_COMMAND];
char hostname[HOST_NAME_MAX + 1];
- Debug(DPROC|DEXT, ("[%ld] got data from grandchild\n",
- (long)getpid()))
-
if (gethostname(hostname, sizeof(hostname)) != 0)
strlcpy(hostname, "unknown", sizeof(hostname));
if (snprintf(mailcmd, sizeof mailcmd, MAILFMT,
* If the mailer exits with non-zero exit status, log
* this fact so the problem can (hopefully) be debugged.
*/
- Debug(DPROC, ("[%ld] closing pipe to mail\n",
- (long)getpid()))
if ((status = cron_pclose(mail)) != 0) {
snprintf(buf, sizeof(buf), "mailed %lu byte%s of output"
" but got status 0x%04x\n", (unsigned long)bytes,
log_it(pw->pw_name, getpid(), "MAIL", buf);
}
}
- Debug(DPROC, ("[%ld] got EOF from grandchild\n", (long)getpid()))
fclose(fp); /* also closes output_pipe[READ_PIPE] */
/* Wait for grandchild to die. */
- Debug(DPROC, ("[%ld] waiting for grandchild (%ld) to finish\n",
- (long)getpid(), (long)pid))
for (;;) {
if (waitpid(pid, &waiter, 0) == -1) {
if (errno == EINTR)
continue;
- Debug(DPROC,
- ("[%ld] no grandchild process--mail written?\n",
- (long)getpid()))
break;
} else {
- Debug(DPROC, ("[%ld] grandchild (%ld) finished, status=%04x",
- (long)getpid(), (long)pid, WEXITSTATUS(waiter)))
+ /*
if (WIFSIGNALED(waiter) && WCOREDUMP(waiter))
Debug(DPROC, (", dumped core"))
- Debug(DPROC, ("\n"))
+ */
break;
}
}
-/* $OpenBSD: config.h,v 1.18 2015/01/14 17:27:51 millert Exp $ */
+/* $OpenBSD: config.h,v 1.19 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
* these are site-dependent
*/
-#ifndef DEBUGGING
-#define DEBUGGING 1 /* 1 or 0 -- do you want debugging code built in? */
-#endif
-
/*
* choose one of these mailer commands. some use
* /bin/mail for speed; it makes biff bark but doesn't
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.\" $OpenBSD: cron.8,v 1.31 2013/07/16 11:13:33 schwarze Exp $
+.\" $OpenBSD: cron.8,v 1.32 2015/01/23 01:01:06 tedu Exp $
.\"
-.Dd $Mdocdate: July 16 2013 $
+.Dd $Mdocdate: January 23 2015 $
.Dt CRON 8
.Os
.Sh NAME
.Nm cron
.Op Fl n
.Op Fl l Ar load_avg
-.Oo
-.Fl x
-.Sm off
-.Oo Ar ext , sch , proc ,
-.Ar pars , load , misc , test
-.Oc
-.Sm on
-.Oc
.Sh DESCRIPTION
The
.Nm
The
.Fl n
option disables this behavior and causes it to run in the foreground.
-.It Fl x Ar debug_flags
-If
-.Nm
-was compiled with debugging support, a number of debugging flags
-are available to show what
-.Nm
-is doing.
-The following flags may be specified:
-.Bl -tag -width Ds
-.It ext
-show extended information; used in conjunction with other debug flags
-to provide even more information
-.It sch
-print information related to scheduling jobs
-.It proc
-print information related to running processes
-.It pars
-print information related to parsing
-.Xr crontab 5
-files
-.It load
-print when loading the databases
-.It misc
-show misc other debugging information
-.It test
-test mode; don't actually execute commands
-.El
-.Pp
-Multiple flags may be specified, separated by a comma
-.Pq So , Sc .
-Regardless of which flags were specified, the
-.Fl x
-flag will cause
-.Nm
-to stay in the foreground and not become a daemon.
.El
.Sh SIGNALS
.Bl -tag -width Ds
-/* $OpenBSD: cron.c,v 1.48 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: cron.c,v 1.49 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
static void
usage(void) {
-#if DEBUGGING
- const char **dflags;
-#endif
fprintf(stderr, "usage: %s [-n] [-l load_avg] [-x [", ProgramName);
-#if DEBUGGING
- for (dflags = DebugFlagNames; *dflags; dflags++)
- fprintf(stderr, "%s%s", *dflags, dflags[1] ? "," : "]");
-#else
fprintf(stderr, "debugging flags (none supported in this build)]");
-#endif
fprintf(stderr, "]\n");
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
- /* if there are no debug flags turned on, fork as a daemon should.
- */
- if (DebugFlags) {
-#if DEBUGGING
- (void) fprintf(stderr, "[%ld] cron started\n", (long)getpid());
-#endif
- } else if (NoFork == 0) {
+ if (NoFork == 0) {
switch (fork()) {
case -1:
log_it("CRON",getpid(),"DEATH","can't fork");
* (wokeup late) run jobs for each virtual
* minute until caught up.
*/
- Debug(DSCH, ("[%ld], normal case %d minutes to go\n",
- (long)getpid(), timeDiff))
do {
if (job_runqueue())
sleep(10);
* have a chance to run, and we do our
* housekeeping.
*/
- Debug(DSCH, ("[%ld], DST begins %d minutes to go\n",
- (long)getpid(), timeDiff))
/* run wildcard jobs for current minute */
find_jobs(timeRunning, &database, TRUE, FALSE);
* not be repeated. Virtual time does not
* change until we are caught up.
*/
- Debug(DSCH, ("[%ld], DST ends %d minutes to go\n",
- (long)getpid(), timeDiff))
find_jobs(timeRunning, &database, TRUE, FALSE);
break;
default:
* other: time has changed a *lot*,
* jump virtual time, and run everything
*/
- Debug(DSCH, ("[%ld], clock jumped\n",
- (long)getpid()))
virtualTime = timeRunning;
find_jobs(timeRunning, &database, TRUE, TRUE);
}
month = tm->tm_mon +1 /* 0..11 -> 1..12 */ -FIRST_MONTH;
dow = tm->tm_wday -FIRST_DOW;
- Debug(DSCH, ("[%ld] tick(%d,%d,%d,%d,%d) %s %s\n",
- (long)getpid(), minute, hour, dom, month, dow,
- doWild?" ":"No wildcard",doNonWild?" ":"Wildcard only"))
-
/* 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
*/
for (u = db->head; u != NULL; u = u->next) {
for (e = u->crontab; e != NULL; e = e->next) {
- Debug(DSCH|DEXT, ("user [%s:%lu:%lu:...] cmd=\"%s\"\n",
- e->pwd->pw_name, (unsigned long)e->pwd->pw_uid,
- (unsigned long)e->pwd->pw_gid, e->cmd))
if (bit_test(e->minute, minute) &&
bit_test(e->hour, hour) &&
bit_test(e->month, month) &&
if (initialize || tm.tm_isdst != isdst) {
isdst = tm.tm_isdst;
GMToff = get_gmtoff(&StartTime, &tm);
- Debug(DSCH, ("[%ld] GMToff=%ld\n",
- (long)getpid(), (long)GMToff))
}
clockTime = (StartTime + GMToff) / (time_t)SECONDS_PER_MINUTE;
}
pfd[0].events = POLLIN;
while (timerisset(&tv) && tv.tv_sec < 65) {
- Debug(DSCH, ("[%ld] Target time=%lld, sec-to-wait=%lld\n",
- (long)getpid(), (long long)target*SECONDS_PER_MINUTE,
- (long long)tv.tv_sec))
-
poke = RELOAD_CRON | RELOAD_AT;
/* Sleep until we time out, get a poke, or get a signal. */
if (nfds == -1 && errno != EINTR)
break; /* an error occurred */
if (nfds > 0) {
- Debug(DSCH, ("[%ld] Got a poke on the socket\n",
- (long)getpid()))
sunlen = sizeof(s_un);
fd = accept(cronSock, (struct sockaddr *)&s_un, &sunlen);
if (fd >= 0 && fcntl(fd, F_SETFL, O_NONBLOCK) == 0) {
case -1:
if (errno == EINTR)
continue;
- Debug(DPROC,
- ("[%ld] sigchld...no children\n",
- (long)getpid()))
break;
case 0:
- Debug(DPROC,
- ("[%ld] sigchld...no dead kids\n",
- (long)getpid()))
break;
default:
- Debug(DPROC,
- ("[%ld] sigchld...pid #%ld died, stat=%d\n",
- (long)getpid(), (long)pid, WEXITSTATUS(waiter)))
break;
}
} while (pid > 0);
int argch;
char *ep;
- while (-1 != (argch = getopt(argc, argv, "l:nx:"))) {
+ while (-1 != (argch = getopt(argc, argv, "l:n"))) {
switch (argch) {
case 'l':
errno = 0;
case 'n':
NoFork = 1;
break;
- case 'x':
- if (!set_debug_flags(optarg))
- usage();
- break;
default:
usage();
}
-/* $OpenBSD: crontab.c,v 1.67 2015/01/14 17:27:29 millert Exp $ */
+/* $OpenBSD: crontab.c,v 1.68 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace };
-#if DEBUGGING
-static char *Options[] = { "???", "list", "delete", "edit", "replace" };
-static char *getoptargs = "u:lerx:";
-#else
static char *getoptargs = "u:ler";
-#endif
static pid_t Pid;
static char User[MAX_UNAME], RealUser[MAX_UNAME];
Option = opt_unknown;
while (-1 != (argch = getopt(argc, argv, getoptargs))) {
switch (argch) {
-#if DEBUGGING
- case 'x':
- if (!set_debug_flags(optarg))
- usage("bad debug option");
- break;
-#endif
case 'u':
if (getuid() != ROOT_UID) {
fprintf(stderr,
}
}
}
-
- Debug(DMISC, ("user=%s, file=%s, option=%s\n",
- User, Filename, Options[(int)Option]))
}
static void
-/* $OpenBSD: database.c,v 1.21 2015/01/14 17:30:53 millert Exp $ */
+/* $OpenBSD: database.c,v 1.22 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
DIR *dir;
user *u, *nu;
- Debug(DLOAD, ("[%ld] load_database()\n", (long)getpid()))
-
/* before we start loading any data, do a stat on SPOOL_DIR
* so that if anything changes as of this moment (i.e., before we've
* cached any of the database), we'll see the changes next time.
* time this function is called.
*/
if (old_db->mtime == HASH(statbuf.st_mtime, syscron_stat.st_mtime)) {
- Debug(DLOAD, ("[%ld] spool dir mtime unch, no load needed.\n",
- (long)getpid()))
return;
}
/* whatever's left in the old database is now junk.
*/
- Debug(DLOAD, ("unlinking old database:\n"))
for (u = old_db->head; u != NULL; u = nu) {
- Debug(DLOAD, ("\t%s\n", u->name))
nu = u->next;
unlink_user(old_db, u);
free_user(u);
/* overwrite the database control block with the new one.
*/
*old_db = new_db;
- Debug(DLOAD, ("load_database is done\n"))
}
void
goto next_crontab;
}
- Debug(DLOAD, ("\t%s:", fname))
u = find_user(old_db, fname);
if (u != NULL) {
/* if crontab has not changed since we last read it
* in, then we can just use our existing entry.
*/
if (u->mtime == statbuf->st_mtime) {
- Debug(DLOAD, (" [no change, using old data]"))
unlink_user(old_db, u);
link_user(new_db, u);
goto next_crontab;
* users will be deleted from the old database when
* we finish with the crontab...
*/
- Debug(DLOAD, (" [delete old data]"))
unlink_user(old_db, u);
free_user(u);
log_it(fname, getpid(), "RELOAD", tabname);
next_crontab:
if (crontab_fd >= OK) {
- Debug(DLOAD, (" [done]\n"))
close(crontab_fd);
}
}
-/* $OpenBSD: do_command.c,v 1.41 2015/01/14 17:30:53 millert Exp $ */
+/* $OpenBSD: do_command.c,v 1.42 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
void
do_command(entry *e, user *u) {
- Debug(DPROC, ("[%ld] do_command(%s, (%s,%lu,%lu))\n",
- (long)getpid(), e->cmd, u->name,
- (u_long)e->pwd->pw_uid, (u_long)e->pwd->pw_gid))
/* fork to become asynchronous -- parent process is done immediately,
* and continues to run the normal cron code, which means return to
/* child process */
acquire_daemonlock(1);
child_process(e, u);
- Debug(DPROC, ("[%ld] child process done, exiting\n",
- (long)getpid()))
_exit(EXIT_SUCCESS);
break;
default:
/* parent process */
break;
}
- Debug(DPROC, ("[%ld] main process returning to work\n",(long)getpid()))
}
static void
char *input_data, *usernm;
int children = 0;
- Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd))
-
/* mark ourselves as different to PS command watchers */
setproctitle("running job");
_exit(EXIT_FAILURE);
/*NOTREACHED*/
case 0:
- Debug(DPROC, ("[%ld] grandchild process fork()'ed\n",
- (long)getpid()))
-
/* write a log message. we've waited this long to do it
* because it was not until now that we knew the PID that
* the actual user command shell was going to get and the
{
char *shell = env_get("SHELL", e->envp);
-# if DEBUGGING
- if (DebugFlags & DTEST) {
- fprintf(stderr,
- "debug DTEST is on, not exec'ing command.\n");
- fprintf(stderr,
- "\tcmd='%s' shell='%s'\n", e->cmd, shell);
- _exit(EXIT_SUCCESS);
- }
-# endif /*DEBUGGING*/
execle(shell, shell, "-c", e->cmd, (char *)NULL, e->envp);
fprintf(stderr, "execle: couldn't exec `%s'\n", shell);
perror("execle");
* the user's command.
*/
- Debug(DPROC, ("[%ld] child continues, closing pipes\n",(long)getpid()))
-
/* close the ends of the pipe that will only be referenced in the
* grandchild process...
*/
int escaped = FALSE;
int ch;
- Debug(DPROC, ("[%ld] child2 sending data to grandchild\n",
- (long)getpid()))
-
/* close the pipe we don't use, since we inherited it and
* are part of its reference count now.
*/
*/
fclose(out);
- Debug(DPROC, ("[%ld] child2 done sending to grandchild\n",
- (long)getpid()))
_exit(EXIT_SUCCESS);
}
* when the grandchild exits, we'll get EOF.
*/
- Debug(DPROC, ("[%ld] child reading output from grandchild\n",
- (long)getpid()))
-
(void) signal(SIGPIPE, SIG_IGN);
in = fdopen(stdout_pipe[READ_PIPE], "r");
if (in != NULL) {
int bytes = 1;
int status = 0;
- Debug(DPROC|DEXT,
- ("[%ld] got data (%x:%c) from grandchild\n",
- (long)getpid(), ch, ch))
-
/* get name of recipient. this is MAILTO if set to a
* valid local username; USER otherwise.
*/
*/
if (mail) {
- Debug(DPROC, ("[%ld] closing pipe to mail\n",
- (long)getpid()))
/* Note: the pclose will probably see
* the termination of the grandchild
* in addition to the mail process, since
} /*if data from grandchild*/
- Debug(DPROC, ("[%ld] got EOF from grandchild\n",
- (long)getpid()))
-
fclose(in); /* also closes stdout_pipe[READ_PIPE] */
}
int waiter;
pid_t pid;
- Debug(DPROC, ("[%ld] waiting for grandchild #%d to finish\n",
- (long)getpid(), children))
while ((pid = wait(&waiter)) < OK && errno == EINTR)
;
if (pid < OK) {
- Debug(DPROC,
- ("[%ld] no more grandchildren--mail written?\n",
- (long)getpid()))
break;
}
- Debug(DPROC, ("[%ld] grandchild #%ld finished, status=%04x",
- (long)getpid(), (long)pid, WEXITSTATUS(waiter)))
- if (WIFSIGNALED(waiter) && WCOREDUMP(waiter))
+ /*
+ * if (WIFSIGNALED(waiter) && WCOREDUMP(waiter))
Debug(DPROC, (", dumped core"))
- Debug(DPROC, ("\n"))
+ */
}
}
-/* $OpenBSD: entry.c,v 1.36 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: entry.c,v 1.37 2015/01/23 01:01:06 tedu Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
char envstr[MAX_ENVSTR];
char **tenvp;
- Debug(DPARS, ("load_entry()...about to eat comments\n"))
-
skip_comments(file);
ch = get_char(file);
goto eof;
}
} else {
- Debug(DPARS, ("load_entry()...about to parse numerics\n"))
-
if (ch == '*')
e->flags |= MIN_STAR;
ch = get_list(e->minute, FIRST_MINUTE, LAST_MINUTE,
if (!pw) {
char *username = cmd; /* temp buffer */
- Debug(DPARS, ("load_entry()...about to parse username\n"))
ch = get_string(username, MAX_COMMAND, file, " \t\n");
- Debug(DPARS, ("load_entry()...got %s\n",username))
if (ch == EOF || ch == '\n' || ch == '*') {
ecode = e_cmd;
goto eof;
ecode = e_username;
goto eof;
}
- Debug(DPARS, ("load_entry()...uid %lu, gid %lu\n",
- (unsigned long)pw->pw_uid,
- (unsigned long)pw->pw_gid))
}
if ((e->pwd = pw_dup(pw)) == NULL) {
e->envp = tenvp;
}
- Debug(DPARS, ("load_entry()...about to parse command\n"))
-
/* If the first character of the command is '-' it is a cron option.
*/
ch = get_char(file);
goto eof;
}
- Debug(DPARS, ("load_entry()...returning successfully\n"))
-
/* success, fini, return pointer to the entry we just created...
*/
return (e);
* assume the same thing.
*/
- Debug(DPARS|DEXT, ("get_list()...entered\n"))
-
/* list = range {"," range}
*/
Skip_Nonblanks(ch, file)
Skip_Blanks(ch, file)
- Debug(DPARS|DEXT, ("get_list()...exiting w/ %02x\n", ch))
-
return (ch);
}
int i, num1, num2, num3;
- Debug(DPARS|DEXT, ("get_range()...entering, exit won't show\n"))
-
if (ch == '*') {
/* '*' means "first-last" but can still be modified by /step
*/
*pc = '\0';
if (len != 0 && strchr(terms, ch)) {
for (i = 0; names[i] != NULL; i++) {
- Debug(DPARS|DEXT,
- ("get_num, compare(%s,%s)\n", names[i],
- temp))
if (!strcasecmp(names[i], temp)) {
*numptr = i+low;
return (ch);
static int
set_element(bitstr_t *bits, int low, int high, int number) {
- Debug(DPARS|DEXT, ("set_element(?,%d,%d,%d)\n", low, high, number))
if (number < low || number > high)
return (EOF);
-/* $OpenBSD: env.c,v 1.25 2015/01/14 18:28:15 millert Exp $ */
+/* $OpenBSD: env.c,v 1.26 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
if (EOF == get_string(envstr, MAX_ENVSTR, f, "\n"))
return (ERR);
- Debug(DPARS, ("load_env, read <%s>\n", envstr))
-
bzero(name, sizeof name);
bzero(val, sizeof val);
str = name;
}
}
if (state != FINI && !(state == VALUE && !quotechar)) {
- Debug(DPARS, ("load_env, not an env var, state = %d\n", state))
fseek(f, filepos, SEEK_SET);
Set_LineNum(fileline);
return (FALSE);
*/
if (snprintf(envstr, MAX_ENVSTR, "%s=%s", name, val) >= MAX_ENVSTR)
return (FALSE);
- Debug(DPARS, ("load_env, <%s> <%s> -> <%s>\n", name, val, envstr))
return (TRUE);
}
-/* $OpenBSD: funcs.h,v 1.15 2013/04/17 15:58:45 deraadt Exp $ */
+/* $OpenBSD: funcs.h,v 1.16 2015/01/23 01:01:06 tedu Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
atrun(at_db *, double, time_t);
int job_runqueue(void),
- set_debug_flags(const char *),
get_char(FILE *),
get_string(char *, int, FILE *, char *),
swap_gids(void),
-/* $OpenBSD: globals.h,v 1.8 2013/08/15 20:19:26 millert Exp $ */
+/* $OpenBSD: globals.h,v 1.9 2015/01/23 01:01:06 tedu Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
XTRN time_t StartTime INIT(0);
XTRN int NoFork INIT(0);
-#if DEBUGGING
-XTRN int DebugFlags INIT(0);
-XTRN const char *DebugFlagNames[]
-#ifdef MAIN_PROGRAM
- = {
- "ext", "sch", "proc", "pars", "load", "misc", "test", NULL
- }
-#endif
- ;
-#else
#define DebugFlags 0
-#endif /* DEBUGGING */
-/* $OpenBSD: macros.h,v 1.9 2015/01/14 17:30:53 millert Exp $ */
+/* $OpenBSD: macros.h,v 1.10 2015/01/23 01:01:06 tedu Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
/* or this on error */
#define ERR (-1)
- /* turn this on to get '-x' code */
-#ifndef DEBUGGING
-#define DEBUGGING FALSE
-#endif
-
#define INIT_PID 1 /* parent of orphans */
#define READ_PIPE 0 /* which end of a pipe pair do you read? */
#define WRITE_PIPE 1 /* or write to? */
#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 PPC_NULL ((const char **)NULL)
#define Skip_Blanks(c, f) \
while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
c = get_char(f);
-#if DEBUGGING
-# define Debug(mask, message) \
- if (DebugFlags & (mask)) \
- printf message;
-#else /* !DEBUGGING */
-# define Debug(mask, message) \
- ;
-#endif /* DEBUGGING */
-
-#define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
- LineNumber = ln; \
- }
+#define Set_LineNum(ln) { LineNumber = ln; }
/* Data values used on cron socket */
#define RELOAD_CRON 0x2
-/* $OpenBSD: misc.c,v 1.51 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: misc.c,v 1.52 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
return (*left - *right);
}
-int
-set_debug_flags(const char *flags) {
- /* debug flags are of the form flag[,flag ...]
- *
- * if an error occurs, print a message to stdout and return FALSE.
- * otherwise return TRUE after setting ERROR_FLAGS.
- */
-
-#if !DEBUGGING
-
- printf("this program was compiled without debugging enabled\n");
- return (FALSE);
-
-#else /* DEBUGGING */
-
- const char *pc = flags;
-
- DebugFlags = 0;
-
- while (*pc) {
- const char **test;
- int mask;
-
- /* try to find debug flag name in our list.
- */
- for (test = DebugFlagNames, mask = 1;
- *test != NULL && strcmp_until(*test, pc, ',');
- test++, mask <<= 1)
- continue;
-
- if (!*test) {
- fprintf(stderr,
- "unrecognized debug flag <%s> <%s>\n",
- flags, pc);
- return (FALSE);
- }
-
- DebugFlags |= mask;
-
- /* skip to the next flag
- */
- while (*pc && *pc != ',')
- pc++;
- if (*pc == ',')
- pc++;
- }
-
- if (DebugFlags) {
- int flag;
-
- fprintf(stderr, "debug flags enabled:");
-
- for (flag = 0; DebugFlagNames[flag]; flag++)
- if (DebugFlags & (1 << flag))
- fprintf(stderr, " %s", DebugFlagNames[flag]);
- fprintf(stderr, "\n");
- }
-
- return (TRUE);
-
-#endif /* DEBUGGING */
-}
-
void
set_cron_uid(void) {
if (seteuid(ROOT_UID) < OK) {
#endif /*SYSLOG*/
-#if DEBUGGING
- if (DebugFlags) {
- fprintf(stderr, "log_it: (%s %ld) %s (%s)\n",
- username, (long)pid, event, detail);
- }
-#endif
}
void
-/* $OpenBSD: user.c,v 1.9 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: user.c,v 1.10 2015/01/23 01:01:06 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
return (NULL);
}
- Debug(DPARS, ("load_user()\n"))
-
/* file is open. build user entry, then read the crontab file.
*/
if ((u = malloc(sizeof(user))) == NULL)
done:
env_free(envp);
fclose(file);
- Debug(DPARS, ("...load_user() done\n"))
return (u);
}