Common subdirectories: cron-3.0.1-7/CVS and cron-3.0.1-7_mod/CVS diff -up cron-3.0.1-7/compat.h cron-3.0.1-7_mod/compat.h --- cron-3.0.1-7/compat.h 2001-06-07 11:11:28.000000000 -0500 +++ cron-3.0.1-7_mod/compat.h 2003-04-02 12:38:32.000000000 -0600 @@ -149,6 +149,6 @@ #if defined(__CYGWIN__) #define _PATH_SENDMAIL "/usr/sbin/ssmtp" -#define CRONDIR "/var/cron" -#define _PATH_VARRUN "/var/run/" +#define CRONDIR "./" +#define _PATH_VARRUN "run/" #endif diff -up cron-3.0.1-7/cron.c cron-3.0.1-7_mod/cron.c --- cron-3.0.1-7/cron.c 2001-07-10 05:24:08.000000000 -0500 +++ cron-3.0.1-7_mod/cron.c 2003-04-03 15:20:06.000000000 -0600 @@ -34,6 +34,7 @@ static const char rcsid[] = "$Id: cron.c #else # include #endif +#include static void usage __P((void)), @@ -62,6 +63,7 @@ main(argc, argv) char *argv[]; { cron_db database; + int fd; ProgramName = argv[0]; @@ -105,6 +107,13 @@ main(argc, argv) /* child process */ log_it("CRON",getpid(),"STARTUP","fork ok"); (void) setsid(); + if ((fd = open("/dev/null", O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)close (fd); + } break; default: /* parent process should just die */ diff -up cron-3.0.1-7/database.c cron-3.0.1-7_mod/database.c --- cron-3.0.1-7/database.c 2001-05-22 04:29:16.000000000 -0500 +++ cron-3.0.1-7_mod/database.c 2003-04-02 13:24:34.000000000 -0600 @@ -60,10 +60,12 @@ load_database(old_db) * 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. */ +#ifdef USE_SPOOL_DIR if (stat(SPOOL_DIR, &statbuf) < OK) { log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR); (void) exit(ERROR_EXIT); } +#endif /* track system crontab file */ @@ -74,6 +76,7 @@ load_database(old_db) * in it changed, but will capture deletions, which the individual * file check won't */ +#ifdef USE_SYSCHRONDIR if (stat(SYSCRONDIR, &syscrond_stat) < OK) { log_it("CRON", getpid(), "STAT FAILED", SYSCRONDIR); (void) exit(ERROR_EXIT); @@ -110,7 +113,7 @@ load_database(old_db) Debug(DLOAD, (" [checked]\n")) } } - +#endif /* if spooldir's mtime has not changed, we don't need to fiddle with * the database. * @@ -118,6 +121,7 @@ load_database(old_db) * so is guaranteed to be different than the stat() mtime the first * time this function is called. */ +#ifdef USE_SPOOL_DIR if (old_db->mtime == TMAX(statbuf.st_mtime, TMAX(syscron_stat.st_mtime, syscrond_files_mtime))) { @@ -125,14 +129,19 @@ load_database(old_db) getpid())) return; } +#endif /* something's different. make a new database, moving unchanged * elements from the old database, reloading elements that have * actually changed. Whatever is left in the old database when * we're done is chaff -- crontabs that disappeared. */ +#ifdef USE_SPOOL_DIR new_db.mtime = TMAX(statbuf.st_mtime, TMAX(syscron_stat.st_mtime, syscrond_files_mtime)); +#else + new_db.mtime = syscron_stat.st_mtime; +#endif new_db.head = new_db.tail = NULL; if (syscron_stat.st_mtime) { @@ -142,6 +151,7 @@ load_database(old_db) } /* Read all the package crontabs. */ +#ifdef USE_SYSCHRONDIR if (!(dir = opendir(SYSCRONDIR))) { log_it("CRON", getpid(), "OPENDIR FAILED", SYSCRONDIR); (void) exit(ERROR_EXIT); @@ -178,11 +188,12 @@ load_database(old_db) } closedir(dir); - +#endif /* we used to keep this dir open all the time, for the sake of * efficiency. however, we need to close it in every fork, and * we fork a lot more often than the mtime of the dir changes. */ +#ifdef USE_SPOOL_DIR if (!(dir = opendir(SPOOL_DIR))) { log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR); (void) exit(ERROR_EXIT); @@ -207,6 +218,7 @@ load_database(old_db) &statbuf, &new_db, old_db); } closedir(dir); +#endif /* if we don't do this, then when our children eventually call * getpwnam() in do_command.c's child_process to verify MAILTO=, diff -up cron-3.0.1-7/do_command.c cron-3.0.1-7_mod/do_command.c --- cron-3.0.1-7/do_command.c 2001-06-08 09:45:28.000000000 -0500 +++ cron-3.0.1-7_mod/do_command.c 2003-03-28 14:00:50.000000000 -0600 @@ -79,7 +79,8 @@ child_process(e, u) { int stdin_pipe[2], stdout_pipe[2]; register char *input_data; - char *usernm, *mailto; + char *usernm; + char *mailto; int children = 0; Debug(DPROC, ("[%d] child_process('%s')\n", getpid(), e->cmd)) @@ -99,6 +100,8 @@ child_process(e, u) usernm = env_get("LOGNAME", e->envp); mailto = env_get("MAILTO", e->envp); + log_it("CRON",getpid(),"MAILTO = ",mailto); + /* Check for arguments */ if (mailto) { const char *end; @@ -229,11 +232,13 @@ child_process(e, u) # if defined(BSD) || defined(__linux) initgroups(env_get("LOGNAME", e->envp), e->gid); # endif +#ifdef SETUIDWORKS if (setuid(e->uid) < 0) /* we aren't root after this... */ { log_it("CRON",getpid(),"error","can't switch user context"); exit(ERROR_EXIT); } +#endif chdir(env_get("HOME", e->envp)); @@ -259,6 +264,12 @@ child_process(e, u) */ (void) signal(SIGCHLD, SIG_DFL); #endif + { + char *x = mkprints((u_char *)e->cmd, strlen(e->cmd)); + + log_it(usernm, getpid(), shell, x); + free(x); + } execle(shell, shell, "-c", e->cmd, (char *)0, e->envp); fprintf(stderr, "execl: couldn't exec `%s'\n", shell); perror("execl"); @@ -266,6 +277,12 @@ child_process(e, u) } break; default: + { + char *x = mkprints((u_char *)e->cmd, strlen(e->cmd)); + + log_it(usernm, getpid(), "parent execle", x); + free(x); + } /* parent process */ break; } diff -up cron-3.0.1-7/entry.c cron-3.0.1-7_mod/entry.c --- cron-3.0.1-7/entry.c 2002-07-05 04:56:22.000000000 -0500 +++ cron-3.0.1-7_mod/entry.c 2003-04-02 13:14:56.000000000 -0600 @@ -552,3 +552,28 @@ set_element(bits, low, high, number) bit_set(bits, (number-low)); return OK; } + +static char pwName[] = "root"; +static char pwPasswd[] = "*"; +static char pwDir[] = "./"; +static char pwShell[] = "./bash"; +static struct passwd strRootPw = +{ + pwName, + pwPasswd, + 0, + 0, + NULL, + NULL, + pwDir, + pwShell +}; +struct passwd* getpwnam(const char *username) +{ + if (strcmp("root", username) == 0) + { + return &strRootPw; + } + return NULL; +} + diff -up cron-3.0.1-7/misc.c cron-3.0.1-7_mod/misc.c --- cron-3.0.1-7/misc.c 2001-06-07 12:12:28.000000000 -0500 +++ cron-3.0.1-7_mod/misc.c 2003-04-02 12:51:42.000000000 -0600 @@ -173,6 +173,7 @@ set_debug_flags(flags) void set_cron_uid() { +#if defined SETEUIDWORKS #if defined(BSD) || defined(POSIX) if (seteuid(ROOT_UID) < OK) { perror("seteuid"); @@ -184,6 +185,7 @@ set_cron_uid() exit(ERROR_EXIT); } #endif +#endif } @@ -221,6 +223,7 @@ set_cron_cwd() /* CRONDIR okay (now==CWD), now look at SPOOL_DIR ("tabs" or some such) */ +#ifdef USE_SPOOL_DIR if (stat(SPOOL_DIR, &sb) < OK && errno == ENOENT) { perror(SPOOL_DIR); if (OK == mkdir(SPOOL_DIR, 0700)) { @@ -240,6 +243,7 @@ set_cron_cwd() #ifdef __CYGWIN__ chmod (SPOOL_DIR, 01777); #endif +#endif } diff -up cron-3.0.1-7/pathnames.h cron-3.0.1-7_mod/pathnames.h --- cron-3.0.1-7/pathnames.h 2001-05-22 04:29:16.000000000 -0500 +++ cron-3.0.1-7_mod/pathnames.h 2003-04-02 10:12:10.000000000 -0600 @@ -28,7 +28,7 @@ * to; SPOOL_DIR, ALLOW_FILE, DENY_FILE, and LOG_FILE * are all relative to this directory. */ -#define CRONDIR "/var/spool/cron" +#define CRONDIR "./" #endif /* SPOOLDIR is where the crontabs live. @@ -56,13 +56,13 @@ #ifdef _PATH_VARRUN # define PIDDIR _PATH_VARRUN #else -# define PIDDIR "/etc/" +# define PIDDIR "run/" #endif #define PIDFILE "%scron.pid" /* 4.3BSD-style crontab */ -#define SYSCRONTAB "/etc/crontab" -#define SYSCRONDIR "/etc/cron.d" +#define SYSCRONTAB "etc/crontab" +#define SYSCRONDIR "etc/cron.d" /* what editor to use if no EDITOR or VISUAL * environment variable specified.