--- anacron-2.3-orig/gregor.c 2007-09-21 19:24:49.000000000 +0200 +++ anacron-2.3/gregor.c 2007-09-21 17:40:15.000000000 +0200 @@ -65,7 +65,7 @@ { int dn; int i; - const int isleap; /* save three calls to leap() */ + const int isleap = leap(year); /* save three calls to leap() */ /* Some validity checks */ @@ -76,8 +76,6 @@ if (month > 12 || month < 1) return - 1; if (day < 1) return - 1; - isleap = leap(year); - if (month != 2) { if(day > days_in_month[month - 1]) return - 1; } --- anacron-2.3-orig/main.c 2000-06-23 00:58:07.000000000 +0200 +++ anacron-2.3/main.c 2007-09-21 19:27:33.000000000 +0200 @@ -30,6 +30,7 @@ #include #include #include +#include #include "global.h" #include "gregor.h" @@ -39,6 +40,7 @@ char *program_name; char *anacrontab; +char *spooldir; int serialize, force, update_only, now, no_daemon, quiet; /* command-line options */ char **args; /* vector of "job" command-line arguments */ @@ -69,8 +71,8 @@ static void print_usage() { - printf("Usage: anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [job] ...\n" - " anacron -u [job] ...\n" + printf("Usage: anacron [-s] [-f] [-n] [-d] [-q] [-t anacrontab] [-p spooldir] [job] ...\n" + " anacron [-p spooldir] -u [job] ...\n" " anacron [-V|-h]\n" "\n" " -s Serialize execution of jobs\n" @@ -80,6 +82,7 @@ " -q Suppress stderr messages, only applicable with -d\n" " -u Update the timestamps without actually running anything\n" " -t Use this anacrontab\n" + " -p Use this spool directory (option added by ALDI)\n" " -V Print version information\n" " -h Print this message\n" "\n" @@ -95,7 +98,7 @@ quiet = no_daemon = serialize = force = update_only = now = 0; opterr = 0; - while ((opt = getopt(argc, argv, "sfundqt:Vh")) != EOF) + while ((opt = getopt(argc, argv, "sfundqt:p:Vh")) != EOF) { switch (opt) { @@ -120,6 +123,9 @@ case 't': anacrontab = strdup(optarg); break; + case 'p': + spooldir = strdup(optarg); + break; case 'V': print_version(); exit(0); @@ -413,8 +419,10 @@ main(int argc, char *argv[]) { int j; + char* home; anacrontab = NULL; + spooldir = NULL; if((program_name = strrchr(argv[0], '/')) == NULL) program_name = argv[0]; @@ -423,12 +431,23 @@ parse_opts(argc, argv); - if (anacrontab == NULL) - anacrontab = strdup(ANACRONTAB); + home = getenv("HOME"); + + if (anacrontab == NULL) { + anacrontab = (char*) malloc(strlen(home)+strlen("/.anacrontab")+1); + strcat(anacrontab, home); + strcat(anacrontab, "/.anacrontab"); + } + + if (spooldir == NULL) { + spooldir = (char*) malloc(strlen(home)+strlen("/.anacron")+1); + strcat(spooldir, home); + strcat(spooldir, "/.anacron"); + } in_background = 0; - if (chdir(SPOOLDIR)) die_e("Can't chdir to " SPOOLDIR); + if (chdir(spooldir)) die_e("Can't chdir to %s", spooldir); old_umask = umask(0);