--- crontab.5.orig Tue Sep 5 17:32:17 2006 +++ crontab.5 Tue Sep 5 17:54:15 2006 @@ -148,6 +148,32 @@ ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday. +.PP +Instead of the first five fields, one of eight special strings may +appear: +.IP +.ta 1.5i +string meaning +.br +------ ------- +.br +@reboot Run once, at startup. +.br +@yearly Run once a year, "0 0 1 1 *". +.br +@annually (same as @yearly) +.br +@monthly Run once a month, "0 0 1 * *". +.br +@weekly Run once a week, "0 0 * * 0". +.br +@daily Run once a day, "0 0 * * *". +.br +@midnight (same as @daily) +.br +@hourly Run once an hour, "0 * * * *". +.br +.fi .SH EXAMPLE CRON FILE .nf # use /bin/sh to run commands, no matter what /etc/passwd says @@ -164,6 +190,9 @@ 23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" 5 4 * * sun echo "run at 5 after 4 every sunday" .fi +.SH FILES +/etc/crontab System crontab file + .SH SEE ALSO cron(8), crontab(1) .SH EXTENSIONS --- cron.c.orig Tue Sep 5 17:32:17 2006 +++ cron.c Tue Sep 5 17:38:16 2006 @@ -25,6 +25,7 @@ #define MAIN_PROGRAM +#include #include "cron.h" enum timejump { negative, small, medium, large }; @@ -61,7 +62,7 @@ cron_db database; int fd; - ProgramName = argv[0]; + ProgramName = basename(argv[0]); setlocale(LC_ALL, ""); --- entry.c.orig Tue Sep 5 17:32:17 2006 +++ entry.c Tue Sep 5 17:41:12 2006 @@ -336,7 +336,9 @@ /* If the first character of the command is '-' it is a cron option. */ - while ((ch = get_char(file)) == '-') { + ch = get_char(file); + Skip_Blanks(ch, file) + while (ch == '-') { switch (ch = get_char(file)) { case 'q': e->flags |= DONT_LOG; --- Makefile.orig Tue Sep 5 17:32:17 2006 +++ Makefile Tue Sep 5 18:08:41 2006 @@ -59,7 +59,7 @@ INCLUDE = -I. #INCLUDE = #<> -LIBS = +LIBS = -lpam #<> #CDEBUG = -O CDEBUG = -g @@ -110,8 +110,8 @@ $(CC) $(LDFLAGS) -o crontab $(CRONTAB_OBJ) $(LIBS) install : all - $(INSTALL) -c -m 111 -o root -s cron $(DESTSBIN)/ - $(INSTALL) -c -m 4111 -o root -s crontab $(DESTBIN)/ + $(INSTALL) -c -m 755 cron $(DESTSBIN)/ + $(INSTALL) -c -m 4755 crontab $(DESTBIN)/ # $(INSTALL) -c -m 111 -o root -g crontab -s cron $(DESTSBIN)/ # $(INSTALL) -c -m 2111 -o root -g crontab -s crontab $(DESTBIN)/ sh putman.sh crontab.1 $(DESTMAN) --- do_command.c.orig Tue Sep 5 17:42:14 2006 +++ do_command.c Tue Sep 5 17:42:43 2006 @@ -263,12 +263,23 @@ } } #else - setgid(e->pwd->pw_gid); + initgroups(usernm, e->pwd->pw_gid); #if (defined(BSD)) && (BSD >= 199103) setlogin(usernm); #endif /* BSD */ - setuid(e->pwd->pw_uid); /* we aren't root after this... */ + // setuid(e->pwd->pw_uid); /* we aren't root after this... */ + + if ( setgid(e->pwd->pw_gid) == -1 ) { + fprintf(stderr,"can't set gid for %s\n", e->pwd->pw_name); + _exit(1); + } + + if ( setuid(e->pwd->pw_uid) == -1 ) { + fprintf(stderr,"can't set uid for %s\n", e->pwd->pw_name); + _exit(1); + } + #endif /* LOGIN_CAP */ chdir(env_get("HOME", e->envp)); --- misc.c.orig Tue Sep 5 18:10:31 2006 +++ misc.c Tue Sep 5 18:12:03 2006 @@ -676,7 +676,7 @@ } int swap_uids_back(void) { - return ((setegid(getgid()) || seteuid(getuid())) ? -1 : 0); + return ((setegid(save_egid) || seteuid(save_euid)) ? -1 : 0); } #else /*HAVE_SAVED_UIDS*/