From 585d9be6bb6d448e46612ddbbf011e7472b45079 Mon Sep 17 00:00:00 2001 From: tedu Date: Fri, 23 Jan 2015 01:01:06 +0000 Subject: [PATCH] remove debug code. I think the level of debug code in cron is excessive for a program that has reached feature complete. If cron needs to provide more information to the user about its operational status, I think syslog would be more appropriate. (The debug flags also disable forking into the background, so they aren't even that useful for debugging a live system.) ok deraadt millert --- usr.sbin/cron/atrun.c | 46 ++---------------------- usr.sbin/cron/config.h | 6 +--- usr.sbin/cron/cron.8 | 47 ++----------------------- usr.sbin/cron/cron.c | 56 ++---------------------------- usr.sbin/cron/crontab.c | 16 +-------- usr.sbin/cron/database.c | 13 +------ usr.sbin/cron/do_command.c | 53 +++------------------------- usr.sbin/cron/entry.c | 25 +------------- usr.sbin/cron/env.c | 6 +--- usr.sbin/cron/funcs.h | 3 +- usr.sbin/cron/globals.h | 13 +------ usr.sbin/cron/macros.h | 31 ++--------------- usr.sbin/cron/misc.c | 71 +------------------------------------- usr.sbin/cron/user.c | 5 +-- 14 files changed, 23 insertions(+), 368 deletions(-) diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 74b3ff955d0..3bd5bdecb1f 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $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 @@ -42,16 +42,12 @@ scan_atjobs(at_db *old_db, struct timeval *tv) 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); } @@ -120,9 +116,7 @@ scan_atjobs(at_db *old_db, struct timeval *tv) 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); @@ -134,7 +128,6 @@ scan_atjobs(at_db *old_db, struct timeval *tv) /* Install the new database */ *old_db = new_db; - Debug(DLOAD, ("scan_atjobs is done\n")) return (pending); } @@ -150,8 +143,6 @@ atrun(at_db *db, double batch_maxload, time_t now) 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) @@ -233,8 +224,6 @@ run_job(atjob *job, char *atfile) 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); @@ -382,9 +371,6 @@ run_job(atjob *job, char *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); @@ -469,14 +455,6 @@ run_job(atjob *job, char *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); @@ -498,17 +476,11 @@ run_job(atjob *job, char *atfile) 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); @@ -521,9 +493,6 @@ run_job(atjob *job, char *atfile) 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, @@ -556,8 +525,6 @@ run_job(atjob *job, char *atfile) * 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, @@ -565,27 +532,20 @@ run_job(atjob *job, char *atfile) 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; } } diff --git a/usr.sbin/cron/config.h b/usr.sbin/cron/config.h index 2d0d69e2f14..b9981622dac 100644 --- a/usr.sbin/cron/config.h +++ b/usr.sbin/cron/config.h @@ -1,4 +1,4 @@ -/* $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 @@ -28,10 +28,6 @@ * 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 diff --git a/usr.sbin/cron/cron.8 b/usr.sbin/cron/cron.8 index abdefc7bc33..d87b18a5d7f 100644 --- a/usr.sbin/cron/cron.8 +++ b/usr.sbin/cron/cron.8 @@ -17,9 +17,9 @@ .\" 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 @@ -29,14 +29,6 @@ .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 @@ -135,41 +127,6 @@ will detach from the current tty and become a daemon. 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 diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index e827b2419ba..f307f0e76b9 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $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 @@ -48,17 +48,9 @@ static double batch_maxload = BATCH_MAXLOAD; 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); } @@ -103,13 +95,7 @@ main(int argc, char *argv[]) { 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"); @@ -196,8 +182,6 @@ main(int argc, char *argv[]) { * (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); @@ -219,8 +203,6 @@ main(int argc, char *argv[]) { * 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); @@ -245,8 +227,6 @@ main(int argc, char *argv[]) { * 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: @@ -254,8 +234,6 @@ main(int argc, char *argv[]) { * 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); } @@ -312,10 +290,6 @@ find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { 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 @@ -324,9 +298,6 @@ find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) { */ 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) && @@ -361,8 +332,6 @@ set_time(int initialize) { 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; } @@ -388,10 +357,6 @@ cron_sleep(time_t target) { 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. */ @@ -401,8 +366,6 @@ cron_sleep(time_t target) { 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) { @@ -477,19 +440,10 @@ sigchld_reaper(void) { 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); @@ -500,7 +454,7 @@ parse_args(int argc, char *argv[]) { 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; @@ -515,10 +469,6 @@ parse_args(int argc, char *argv[]) { case 'n': NoFork = 1; break; - case 'x': - if (!set_debug_flags(optarg)) - usage(); - break; default: usage(); } diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 7d01f0b2315..17a5632e0f0 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $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 @@ -36,12 +36,7 @@ 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]; @@ -136,12 +131,6 @@ parse_args(int argc, char *argv[]) { 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, @@ -221,9 +210,6 @@ parse_args(int argc, char *argv[]) { } } } - - Debug(DMISC, ("user=%s, file=%s, option=%s\n", - User, Filename, Options[(int)Option])) } static void diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index ff1c5806533..363f51b6241 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $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 @@ -40,8 +40,6 @@ load_database(cron_db *old_db) { 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. @@ -64,8 +62,6 @@ load_database(cron_db *old_db) { * 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; } @@ -122,9 +118,7 @@ load_database(cron_db *old_db) { /* 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); @@ -133,7 +127,6 @@ load_database(cron_db *old_db) { /* overwrite the database control block with the new one. */ *old_db = new_db; - Debug(DLOAD, ("load_database is done\n")) } void @@ -221,14 +214,12 @@ process_crontab(const char *uname, const char *fname, const char *tabname, 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; @@ -241,7 +232,6 @@ process_crontab(const char *uname, const char *fname, const char *tabname, * 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); @@ -254,7 +244,6 @@ process_crontab(const char *uname, const char *fname, const char *tabname, next_crontab: if (crontab_fd >= OK) { - Debug(DLOAD, (" [done]\n")) close(crontab_fd); } } diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 970276e8915..6e774f2e66f 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.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 @@ -27,9 +27,6 @@ static void child_process(entry *, user *); 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 @@ -46,15 +43,12 @@ do_command(entry *e, user *u) { /* 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 @@ -64,8 +58,6 @@ child_process(entry *e, user *u) { 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"); @@ -130,9 +122,6 @@ child_process(entry *e, user *u) { _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 @@ -255,15 +244,6 @@ child_process(entry *e, user *u) { { 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"); @@ -281,8 +261,6 @@ child_process(entry *e, user *u) { * 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... */ @@ -306,9 +284,6 @@ child_process(entry *e, user *u) { 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. */ @@ -343,8 +318,6 @@ child_process(entry *e, user *u) { */ fclose(out); - Debug(DPROC, ("[%ld] child2 done sending to grandchild\n", - (long)getpid())) _exit(EXIT_SUCCESS); } @@ -362,9 +335,6 @@ child_process(entry *e, user *u) { * 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) { @@ -376,10 +346,6 @@ child_process(entry *e, user *u) { 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. */ @@ -448,8 +414,6 @@ child_process(entry *e, user *u) { */ 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 @@ -475,9 +439,6 @@ child_process(entry *e, user *u) { } /*if data from grandchild*/ - Debug(DPROC, ("[%ld] got EOF from grandchild\n", - (long)getpid())) - fclose(in); /* also closes stdout_pipe[READ_PIPE] */ } @@ -487,21 +448,15 @@ child_process(entry *e, user *u) { 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")) + */ } } diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 547be2fa536..0b399590c02 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $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 @@ -90,8 +90,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, char envstr[MAX_ENVSTR]; char **tenvp; - Debug(DPARS, ("load_entry()...about to eat comments\n")) - skip_comments(file); ch = get_char(file); @@ -172,8 +170,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, 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, @@ -248,10 +244,8 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, 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; @@ -262,9 +256,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, 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) { @@ -340,8 +331,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, 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); @@ -383,8 +372,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, goto eof; } - Debug(DPARS, ("load_entry()...returning successfully\n")) - /* success, fini, return pointer to the entry we just created... */ return (e); @@ -411,8 +398,6 @@ get_list(bitstr_t *bits, int low, int high, const char *names[], * assume the same thing. */ - Debug(DPARS|DEXT, ("get_list()...entered\n")) - /* list = range {"," range} */ @@ -437,8 +422,6 @@ get_list(bitstr_t *bits, int low, int high, const char *names[], Skip_Nonblanks(ch, file) Skip_Blanks(ch, file) - Debug(DPARS|DEXT, ("get_list()...exiting w/ %02x\n", ch)) - return (ch); } @@ -452,8 +435,6 @@ get_range(bitstr_t *bits, int low, int high, const char *names[], 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 */ @@ -563,9 +544,6 @@ get_number(int *numptr, int low, const char *names[], int ch, FILE *file, *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); @@ -581,7 +559,6 @@ bad: 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); diff --git a/usr.sbin/cron/env.c b/usr.sbin/cron/env.c index ff9f1c9251d..51a97eeb075 100644 --- a/usr.sbin/cron/env.c +++ b/usr.sbin/cron/env.c @@ -1,4 +1,4 @@ -/* $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 @@ -139,8 +139,6 @@ load_env(char *envstr, FILE *f) { 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; @@ -206,7 +204,6 @@ load_env(char *envstr, FILE *f) { } } 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); @@ -226,7 +223,6 @@ load_env(char *envstr, FILE *f) { */ 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); } diff --git a/usr.sbin/cron/funcs.h b/usr.sbin/cron/funcs.h index 19550df7e4a..bd8adc42ae2 100644 --- a/usr.sbin/cron/funcs.h +++ b/usr.sbin/cron/funcs.h @@ -1,4 +1,4 @@ -/* $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") @@ -43,7 +43,6 @@ void set_cron_uid(void), 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), diff --git a/usr.sbin/cron/globals.h b/usr.sbin/cron/globals.h index 318b348390b..767505aa07c 100644 --- a/usr.sbin/cron/globals.h +++ b/usr.sbin/cron/globals.h @@ -1,4 +1,4 @@ -/* $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") @@ -64,15 +64,4 @@ XTRN int LineNumber INIT(0); 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 */ diff --git a/usr.sbin/cron/macros.h b/usr.sbin/cron/macros.h index c9b5d4adb2e..7f6b8626d47 100644 --- a/usr.sbin/cron/macros.h +++ b/usr.sbin/cron/macros.h @@ -1,4 +1,4 @@ -/* $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") @@ -29,11 +29,6 @@ /* 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? */ @@ -45,17 +40,6 @@ #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) \ @@ -66,18 +50,7 @@ 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 diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index 158b4c17c90..98aca4f4a83 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $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 @@ -60,69 +60,6 @@ strcmp_until(const char *left, const char *right, char until) { 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) { @@ -498,12 +435,6 @@ log_it(const char *username, pid_t xpid, const char *event, const char *detail) #endif /*SYSLOG*/ -#if DEBUGGING - if (DebugFlags) { - fprintf(stderr, "log_it: (%s %ld) %s (%s)\n", - username, (long)pid, event, detail); - } -#endif } void diff --git a/usr.sbin/cron/user.c b/usr.sbin/cron/user.c index bca609d071e..e73093414dd 100644 --- a/usr.sbin/cron/user.c +++ b/usr.sbin/cron/user.c @@ -1,4 +1,4 @@ -/* $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 @@ -52,8 +52,6 @@ load_user(int crontab_fd, struct passwd *pw, const char *name) { return (NULL); } - Debug(DPARS, ("load_user()\n")) - /* file is open. build user entry, then read the crontab file. */ if ((u = malloc(sizeof(user))) == NULL) @@ -107,6 +105,5 @@ load_user(int crontab_fd, struct passwd *pw, const char *name) { done: env_free(envp); fclose(file); - Debug(DPARS, ("...load_user() done\n")) return (u); } -- 2.20.1