diff --git a/anacron-2.3-hostname.patch b/anacron-2.3-hostname.patch deleted file mode 100644 index 984e0e6..0000000 --- a/anacron-2.3-hostname.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- anacron-2.3/runjob.c.hostname 2006-10-04 11:58:55.000000000 +0200 -+++ anacron-2.3/runjob.c 2006-10-09 09:43:23.000000000 +0200 -@@ -94,6 +94,17 @@ - } - - static char * -+hostname() -+{ -+ char hostname[MAXHOSTNAME]; -+ -+ if (gethostname(hostname, MAXHOSTNAME) == 0) -+ return hostname; -+ else -+ die_e("Can't resolve hostname"); -+} -+ -+static char * - mailto() - { - char *alias; -@@ -255,9 +266,11 @@ - xwrite(fd, "Content-Type: text/plain; charset=\""); - xwrite(fd, nl_langinfo(CODESET)); - xwrite(fd, "\"\n"); -- xwrite(fd, "Subject: Anacron job '"); -+ xwrite(fd, "Subject: Anacron job for '"); -+ xwrite(fd, hostname()); -+ xwrite(fd, "' "); - xwrite(fd, jr->ident); -- xwrite(fd, "'\n\n"); -+ xwrite(fd, "\n"); - jr->mail_header_size = file_size(fd); - - pid = xfork(); ---- anacron-2.3/global.h.hostname 2006-10-04 11:58:55.000000000 +0200 -+++ anacron-2.3/global.h 2006-10-04 11:58:55.000000000 +0200 -@@ -33,6 +33,7 @@ - - /* Mail interface. (All MTAs should supply this command) */ - #define SENDMAIL "/usr/sbin/sendmail" -+#define MAXHOSTNAME 64 - - #ifndef PID_FILE - #define PID_FILE "/var/run/anacron.pid" diff --git a/anacron-2.3-lock-files.patch b/anacron-2.3-lock-files.patch deleted file mode 100644 index 63927c9..0000000 --- a/anacron-2.3-lock-files.patch +++ /dev/null @@ -1,248 +0,0 @@ ---- anacron-2.3/main.c.lock-files 2000-06-22 20:00:14.000000000 -0400 -+++ anacron-2.3/main.c 2006-04-13 20:38:13.000000000 -0400 -@@ -21,39 +21,42 @@ - `COPYING' that comes with the Anacron source distribution. - */ - -- --#include --#include -+#include - #include -+#include - #include - #include --#include -+#include - #include - #include -+#include -+#include -+#include -+#include - #include "global.h" - #include "gregor.h" - --pid_t primary_pid; --int day_now; --int year, month, day_of_month; /* date anacron started */ -- --char *program_name; --char *anacrontab; --int serialize, force, update_only, now, -- no_daemon, quiet; /* command-line options */ --char **args; /* vector of "job" command-line arguments */ --int nargs; /* number of these */ -+pid_t primary_pid=-1; -+int day_now=0; -+int year=0, month=0, day_of_month=0; /* date anacron started */ -+ -+char *program_name=0; -+char *anacrontab=0; -+int serialize=0, force=0, update_only=0, now=0, -+ no_daemon=0, quiet=0; /* command-line options */ -+char **args=0; /* vector of "job" command-line arguments */ -+int nargs=0; /* number of these */ - char *defarg = "*"; --int in_background; /* are we in the background? */ --int old_umask; /* umask when started */ --sigset_t old_sigmask; /* signal mask when started */ -- --job_rec *first_job_rec; --env_rec *first_env_rec; -- --static time_t start_sec; /* time anacron started */ --static volatile int got_sigalrm, got_sigchld, got_sigusr1; --int running_jobs, running_mailers; /* , number of */ -+int in_background=0; /* are we in the background? */ -+int old_umask=0; /* umask when started */ -+sigset_t old_sigmask={0}; /* signal mask when started */ -+ -+job_rec *first_job_rec=0; -+env_rec *first_env_rec=0; -+ -+static time_t start_sec=0; /* time anacron started */ -+static volatile int got_sigalrm=0, got_sigchld=0, got_sigusr1=0; -+int running_jobs=0, running_mailers=0; /* , number of */ - - static void - print_version() -@@ -183,6 +186,8 @@ - if (close(fd)) die_e("Can't close file descriptor %d", fd); - } - -+static int anacron_already_running(); -+ - static void - go_background() - /* Become a daemon. The foreground process exits successfully. */ -@@ -206,9 +211,16 @@ - else - { - /* child */ -+ xcloselog(); - primary_pid = getpid(); - if (setsid() == -1) die_e("setsid() error"); - in_background = 1; -+ chdir(SPOOLDIR); -+ if( anacron_already_running() ) -+ { -+ errno=EDEADLK; -+ die_e("Cannot run in daemon mode - anacron already running."); -+ } - } - } - -@@ -265,6 +277,16 @@ - sa.sa_mask = ss; - sa.sa_flags = 0; - if (sigaction(SIGUSR1, &sa, NULL)) die_e("sigaction error"); -+ /* setup SIGQUIT handler */ -+ sa.sa_handler = handle_sigusr1; -+ sa.sa_mask = ss; -+ sa.sa_flags = 0; -+ if (sigaction(SIGQUIT, &sa, NULL)) die_e("sigaction error"); -+ /* setup SIGTERM handler */ -+ sa.sa_handler = handle_sigusr1; -+ sa.sa_mask = ss; -+ sa.sa_flags = 0; -+ if (sigaction(SIGTERM, &sa, NULL)) die_e("sigaction error"); - } - - static void -@@ -409,6 +431,94 @@ - explain("Jobs will be executed sequentially"); - } - -+static void remove_lock_and_pid_files(void) -+{ -+ unlink(PID_FILE); -+ unlink(LOCK_FILE); -+} -+ -+static int anacron_already_running() -+{ -+ char buf[PATH_MAX], buf2[PATH_MAX], buf3[32]; -+ FILE *fp=0; -+ pid_t pid=-1; -+ mode_t mode; -+ int len, fd; -+ -+ if ( access( PID_FILE, F_OK ) == 0 ) -+ { -+ if ( ( fp = fopen( PID_FILE, "r" ) ) == 0L ) -+ { -+ complain("%s exists but is not readable",PID_FILE); -+ return 1; -+ } -+ -+ if ( fscanf(fp,"%u",&pid) != 1 ) -+ { -+ explain("%s does not contain a valid pid",PID_FILE); -+ return 1; -+ } -+ -+ fclose(fp); -+ -+ snprintf(buf, PATH_MAX, "/proc/%u", pid); -+ -+ if( access(buf, F_OK) == 0 ) -+ { -+ -+ snprintf(buf3, 32, "/proc/%u/exe", pid); -+ if( (len = readlink(buf3, buf2, PATH_MAX)) <= 0 ) -+ len = 0; -+ -+ buf2[len] = '\0'; -+ -+ snprintf(buf3, 32, "/proc/%u/exe", getpid()); -+ if( (len = readlink(buf3, buf, PATH_MAX)) <= 0 ) -+ len = 0; -+ buf[len] = '\0'; -+ -+ if( strcmp( buf, buf2 ) == 0 ) -+ return 1; -+ } -+ } -+ /* main process removes lock files once it -+ * has determined no other anacron is running: -+ */ -+ remove_lock_and_pid_files(); -+ -+ if( no_daemon || in_background ) -+ { -+ /* daemon process, or main process in no_daemon mode, -+ * creates the lock and pid files: -+ */ -+ if( ( fd = open(LOCK_FILE, O_CREAT | O_WRONLY | O_EXCL, 0600) ) == -1 ) -+ { -+ complain("Cannot exclusively create %s: %s",PID_FILE,strerror(errno)); -+ return 1; -+ } -+ close(fd); -+ -+ mode = umask(0077); -+ if( ( fp = fopen(PID_FILE, "w") ) == 0L ) -+ { -+ complain("Cannot create %s",PID_FILE); -+ umask(mode); -+ return 1; -+ } -+ umask(mode); -+ -+ /* lock and pid files removed automatically at normal exit -+ * by creator process: -+ */ -+ atexit( remove_lock_and_pid_files ); -+ -+ fprintf(fp,"%u",getpid()); -+ fflush(fp); -+ fclose(fp); -+ } -+ return 0; -+} -+ - int - main(int argc, char *argv[]) - { -@@ -423,6 +533,12 @@ - - parse_opts(argc, argv); - -+ if ( anacron_already_running() ) -+ { -+ errno=EDEADLK; -+ die_e("Cannot run - another anacron process is already running."); -+ } -+ - if (anacrontab == NULL) - anacrontab = strdup(ANACRONTAB); - -@@ -433,7 +549,9 @@ - old_umask = umask(0); - - if (sigprocmask(0, NULL, &old_sigmask)) die_e("sigset error"); -- -+ -+ if( !no_daemon ) -+ ioctl(0,TIOCNOTTY,0); - if (fclose(stdin)) die_e("Can't close stdin"); - xopen(0, "/dev/null", O_RDONLY); - ---- anacron-2.3/global.h.lock-files 2000-06-22 20:00:14.000000000 -0400 -+++ anacron-2.3/global.h 2006-04-13 20:25:42.000000000 -0400 -@@ -34,6 +34,14 @@ - /* Mail interface. (All MTAs should supply this command) */ - #define SENDMAIL "/usr/sbin/sendmail" - -+#ifndef PID_FILE -+#define PID_FILE "/var/run/anacron.pid" -+#endif -+ -+#ifndef LOCK_FILE -+#define LOCK_FILE "/var/lock/subsys/anacron" -+#endif -+ - /* End of user-configurable section */ - - diff --git a/anacron-2.3-mailto.patch b/anacron-2.3-mailto.patch deleted file mode 100644 index 79629d8..0000000 --- a/anacron-2.3-mailto.patch +++ /dev/null @@ -1,58 +0,0 @@ -diff -U 3 anacron-2.3.oud/runjob.c anacron-2.3/runjob.c ---- anacron-2.3.oud/runjob.c 2000-06-21 01:12:18.000000000 +0200 -+++ anacron-2.3/runjob.c 2004-07-09 19:05:22.314056376 +0200 -@@ -83,6 +83,18 @@ - return ps->pw_name; - } - -+static char * -+mailto() -+{ -+ char *alias; -+ -+ alias = getenv("MAILTO"); -+ if (alias == NULL || strlen(alias) == 0) -+ return username(); -+ else -+ return alias; -+} -+ - static void - xputenv(const char *s) - { -@@ -109,7 +121,6 @@ - run_job(const job_rec *jr) - /* This is called to start the job, after the fork */ - { -- setup_env(jr); - /* setup stdout and stderr */ - xclose(1); - xclose(2); -@@ -173,7 +184,7 @@ - * options, which don't seem to be appropriate here. - * Hopefully, this will keep all the MTAs happy. */ - execl(SENDMAIL, SENDMAIL, "-FAnacron", "-odi", -- username(), (char *)NULL); -+ mailto(), (char *)NULL); - die_e("Can't exec " SENDMAIL); - } - /* parent */ -@@ -208,6 +219,9 @@ - pid_t pid; - int fd; - -+ /* import environment for mailto() to work properly */ -+ setup_env(jr); -+ - /* create temporary file for stdout and stderr of the job */ - fd = jr->output_fd = temp_file(); - /* write mail header */ -@@ -215,7 +229,7 @@ - xwrite(fd, username()); - xwrite(fd, " (Anacron)\n"); - xwrite(fd, "To: "); -- xwrite(fd, username()); -+ xwrite(fd, mailto()); - xwrite(fd, "\n"); - xwrite(fd, "Subject: Anacron job '"); - xwrite(fd, jr->ident); diff --git a/anacron-2.3-memleaking.patch b/anacron-2.3-memleaking.patch index 66641a2..a4d3b9a 100644 --- a/anacron-2.3-memleaking.patch +++ b/anacron-2.3-memleaking.patch @@ -1,7 +1,73 @@ -diff -ur anacron-2.3.orig/global.h anacron-2.3/global.h ---- anacron-2.3.orig/global.h 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/global.h 2006-10-08 10:08:18.000000000 -0400 -@@ -108,18 +108,25 @@ +--- anacron-2.3/gregor.c.mem 2007-08-08 10:02:58.000000000 +0200 ++++ anacron-2.3/gregor.c 2007-08-08 10:10:55.000000000 +0200 +@@ -27,7 +27,7 @@ + #include + #include "gregor.h" + +-const static int ++static const int + days_in_month[] = { + 31, /* Jan */ + 28, /* Feb (non-leap) */ +--- anacron-2.3/log.c.mem 2007-08-08 10:02:58.000000000 +0200 ++++ anacron-2.3/log.c 2007-08-08 10:13:03.000000000 +0200 +@@ -83,7 +83,7 @@ + } + + static void +-log(int priority, const char *fmt, va_list args) ++slog(int priority, const char *fmt, va_list args) + /* Log a message, described by "fmt" and "args", with the specified + * "priority". */ + { +@@ -101,7 +101,7 @@ + + static void + log_e(int priority, const char *fmt, va_list args) +-/* Same as log(), but also appends an error description corresponding ++/* Same as slog(), but also appends an error description corresponding + * to "errno". */ + { + int saved_errno; +@@ -127,7 +127,7 @@ + va_list args; + + va_start(args, fmt); +- log(EXPLAIN_LEVEL, fmt, args); ++ slog(EXPLAIN_LEVEL, fmt, args); + va_end(args); + } + +@@ -149,7 +149,7 @@ + va_list args; + + va_start(args, fmt); +- log(COMPLAIN_LEVEL, fmt, args); ++ slog(COMPLAIN_LEVEL, fmt, args); + va_end(args); + + complaints += 1; +@@ -175,7 +175,7 @@ + va_list args; + + va_start(args, fmt); +- log(COMPLAIN_LEVEL, fmt, args); ++ slog(COMPLAIN_LEVEL, fmt, args); + va_end(args); + if (getpid() == primary_pid) complain("Aborted"); + +@@ -207,7 +207,7 @@ + va_list args; + + va_start(args, fmt); +- log(DEBUG_LEVEL, fmt, args); ++ slog(DEBUG_LEVEL, fmt, args); + va_end(args); + } + +--- anacron-2.3/global.h.mem 2007-08-08 10:02:58.000000000 +0200 ++++ anacron-2.3/global.h 2007-08-08 10:10:21.000000000 +0200 +@@ -105,18 +105,25 @@ /* main.c */ int xopen(int fd, const char *file_name, int flags); void xclose(int fd); @@ -37,160 +103,17 @@ diff -ur anacron-2.3.orig/global.h anacron-2.3/global.h #ifdef DEBUG #define Debug(args) xdebug args -@@ -130,8 +137,8 @@ - #endif /* not DEBUG */ +@@ -128,7 +135,7 @@ /* readtab.c */ --void read_tab(); + void read_tab(int cwd); -void arrange_jobs(); -+void read_tab(void); +void arrange_jobs(void); /* lock.c */ int consider_job(job_rec *jr); -diff -ur anacron-2.3.orig/gregor.c anacron-2.3/gregor.c ---- anacron-2.3.orig/gregor.c 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/gregor.c 2006-10-08 10:24:05.000000000 -0400 -@@ -25,7 +25,7 @@ - #include - #include "gregor.h" - --const static int -+static const int - days_in_month[] = { - 31, /* Jan */ - 28, /* Feb (non-leap) */ -diff -ur anacron-2.3.orig/lock.c anacron-2.3/lock.c ---- anacron-2.3.orig/lock.c 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/lock.c 2006-10-08 16:14:14.000000000 -0400 -@@ -42,7 +42,7 @@ - jr->timestamp_fd = open(jr->ident, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); - if (jr->timestamp_fd == -1) - die_e("Can't open timestamp file for job %s", jr->ident); -- fcntl(jr->timestamp_fd, F_SETFD, 1); /* set close-on-exec flag */ -+ fcntl(jr->timestamp_fd, F_SETFD, FD_CLOEXEC); /* set close-on-exec flag */ - /* We want to own this file, and set its mode to 0600. This is necessary - * in order to prevent other users from putting locks on it. */ - if (fchown(jr->timestamp_fd, getuid(), getgid())) -diff -ur anacron-2.3.orig/log.c anacron-2.3/log.c ---- anacron-2.3.orig/log.c 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/log.c 2006-10-08 10:27:29.000000000 -0400 -@@ -35,6 +35,7 @@ - */ - - #include -+#include - #include - #include - #include -@@ -79,7 +80,7 @@ - } - - static void --log(int priority, const char *fmt, va_list args) -+slog(int priority, const char *fmt, va_list args) - /* Log a message, described by "fmt" and "args", with the specified - * "priority". */ - { -@@ -97,7 +98,7 @@ - - static void - log_e(int priority, const char *fmt, va_list args) --/* Same as log(), but also appends an error description corresponding -+/* Same as slog(), but also appends an error description corresponding - * to "errno". */ - { - int saved_errno; -@@ -123,7 +124,7 @@ - va_list args; - - va_start(args, fmt); -- log(EXPLAIN_LEVEL, fmt, args); -+ slog(EXPLAIN_LEVEL, fmt, args); - va_end(args); - } - -@@ -145,7 +146,7 @@ - va_list args; - - va_start(args, fmt); -- log(COMPLAIN_LEVEL, fmt, args); -+ slog(COMPLAIN_LEVEL, fmt, args); - va_end(args); - } - -@@ -167,7 +168,7 @@ - va_list args; - - va_start(args, fmt); -- log(COMPLAIN_LEVEL, fmt, args); -+ slog(COMPLAIN_LEVEL, fmt, args); - va_end(args); - if (getpid() == primary_pid) complain("Aborted"); - -@@ -199,7 +200,7 @@ - va_list args; - - va_start(args, fmt); -- log(DEBUG_LEVEL, fmt, args); -+ slog(DEBUG_LEVEL, fmt, args); - va_end(args); - } - -diff -ur anacron-2.3.orig/matchrx.c anacron-2.3/matchrx.c ---- anacron-2.3.orig/matchrx.c 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/matchrx.c 2006-10-08 10:29:24.000000000 -0400 -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #include "matchrx.h" - - int -@@ -49,11 +50,23 @@ - sub_offsets = malloc(sizeof(regmatch_t) * (n_sub + 1)); - memset(sub_offsets, 0, sizeof(regmatch_t) * (n_sub + 1)); - -- if (regcomp(&crx, rx, REG_EXTENDED)) return - 1; -+ if (regcomp(&crx, rx, REG_EXTENDED)) -+ { -+ free(sub_offsets); -+ return - 1; -+ } - r = regexec(&crx, string, n_sub + 1, sub_offsets, 0); -- if (r != 0 && r != REG_NOMATCH) return - 1; -+ if (r != 0 && r != REG_NOMATCH) -+ { -+ free(sub_offsets); -+ return - 1; -+ } - regfree(&crx); -- if (r == REG_NOMATCH) return 0; -+ if (r == REG_NOMATCH) -+ { -+ free(sub_offsets); -+ return 0; -+ } - - va_start(va, n_sub); - n = 1; -@@ -62,7 +75,11 @@ - substring = va_arg(va, char**); - if (substring != NULL) - { -- if (sub_offsets[n].rm_so == -1) return - 1; -+ if (sub_offsets[n].rm_so == -1) -+ { -+ free(sub_offsets); -+ return - 1; -+ } - *substring = string + sub_offsets[n].rm_so; - *(string + sub_offsets[n].rm_eo) = 0; - } -diff -ur anacron-2.3.orig/runjob.c anacron-2.3/runjob.c ---- anacron-2.3.orig/runjob.c 2006-10-08 09:58:47.000000000 -0400 -+++ anacron-2.3/runjob.c 2006-10-08 16:09:37.000000000 -0400 +--- anacron-2.3/runjob.c.mem 2007-08-08 10:02:58.000000000 +0200 ++++ anacron-2.3/runjob.c 2007-08-08 10:17:44.000000000 +0200 @@ -64,8 +64,8 @@ if (fdin == -1) die_e("Can't open temporary file for reading"); if (unlink(name)) die_e("Can't unlink temporary file"); @@ -202,12 +125,58 @@ diff -ur anacron-2.3.orig/runjob.c anacron-2.3/runjob.c jr->input_fd = fdin; jr->output_fd = fdout; -@@ -178,7 +178,7 @@ +@@ -175,8 +175,6 @@ pid = xfork(); if (pid == 0) { - long fdflags; -+ /* long fdflags; */ - +- /* child */ in_background = 1; + /* set stdin to the job's output */ +--- anacron-2.3/matchrx.c.mem 2000-06-21 01:12:18.000000000 +0200 ++++ anacron-2.3/matchrx.c 2007-08-08 10:16:54.000000000 +0200 +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include "matchrx.h" + + int +@@ -49,11 +50,20 @@ + sub_offsets = malloc(sizeof(regmatch_t) * (n_sub + 1)); + memset(sub_offsets, 0, sizeof(regmatch_t) * (n_sub + 1)); + +- if (regcomp(&crx, rx, REG_EXTENDED)) return - 1; ++ if (regcomp(&crx, rx, REG_EXTENDED)) { ++ free(sub_offsets); ++ return - 1; ++ } + r = regexec(&crx, string, n_sub + 1, sub_offsets, 0); +- if (r != 0 && r != REG_NOMATCH) return - 1; ++ if (r != 0 && r != REG_NOMATCH) { ++ free(sub_offsets); ++ return - 1; ++ } + regfree(&crx); +- if (r == REG_NOMATCH) return 0; ++ if (r == REG_NOMATCH) { ++ free(sub_offsets); ++ return 0; ++ } + + va_start(va, n_sub); + n = 1; +@@ -62,7 +72,10 @@ + substring = va_arg(va, char**); + if (substring != NULL) + { +- if (sub_offsets[n].rm_so == -1) return - 1; ++ if (sub_offsets[n].rm_so == -1) { ++ free(sub_offsets); ++ return - 1; ++ } + *substring = string + sub_offsets[n].rm_so; + *(string + sub_offsets[n].rm_eo) = 0; + } diff --git a/anacron-2.3-mk-incl.patch b/anacron-2.3-mk-incl.patch deleted file mode 100644 index 8dff5fb..0000000 --- a/anacron-2.3-mk-incl.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -u anacron-2.3/Makefile~ anacron-2.3/Makefile ---- anacron-2.3/Makefile~ 2002-08-28 19:18:49.000000000 +0900 -+++ anacron-2.3/Makefile 2002-08-28 19:18:49.000000000 +0900 -@@ -54,7 +54,7 @@ - $(SHELL) -ec "$(CC) -MM $(ALL_CPPFLAGS) $< \ - | sed '1s/^\(.*\)\.o[ :]*/\1.d &/1' > $@" - --include $(csources:.c=.d) -+-include $(csources:.c=.d) - - anacron: $(objects) - $(CC) $(LDFLAGS) $^ $(LOADLIBES) -o $@ diff --git a/anacron-2.3-noconst.patch b/anacron-2.3-noconst.patch deleted file mode 100644 index f72b796..0000000 --- a/anacron-2.3-noconst.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- anacron-2.3/gregor.c.sopwith 2004-07-02 10:51:24.000000000 -0400 -+++ anacron-2.3/gregor.c 2004-07-02 10:51:33.000000000 -0400 -@@ -65,7 +65,7 @@ - { - int dn; - int i; -- const int isleap; /* save three calls to leap() */ -+ int isleap; /* save three calls to leap() */ - - /* Some validity checks */ - diff --git a/anacron-2.3-path.patch b/anacron-2.3-path.patch deleted file mode 100644 index 1442bd8..0000000 --- a/anacron-2.3-path.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ./anacrontab.path 2006-08-30 14:57:23.000000000 +0200 -+++ ./anacrontab 2006-08-30 14:58:09.000000000 +0200 -@@ -3,7 +3,7 @@ - # See anacron(8) and anacrontab(5) for details. - - SHELL=/bin/sh --PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -+PATH=/sbin:/bin:/usr/sbin:/usr/bin - MAILTO=root - - 1 65 cron.daily run-parts /etc/cron.daily diff --git a/anacron-script.patch b/anacron-script.patch new file mode 100644 index 0000000..715660b --- /dev/null +++ b/anacron-script.patch @@ -0,0 +1,12 @@ +--- anacron-2.3/debian/0anacron.daily.script 2007-08-09 14:08:36.000000000 +0200 ++++ anacron-2.3/debian/0anacron.daily 2007-08-09 14:27:22.000000000 +0200 +@@ -9,4 +9,8 @@ + # _before_ all other scripts. + + test -x /usr/sbin/anacron || exit 0 +-anacron -u cron.daily ++AUX1=`cat /var/spool/anacron/cron.daily` ++AUX2=`date +%Y%m%d` ++if [ $AUX1 != $AUX2 ]; then ++ anacron -u cron.daily ++fi diff --git a/anacron.init b/anacron.init index 1117ca7..1ccc1ab 100755 --- a/anacron.init +++ b/anacron.init @@ -11,20 +11,29 @@ [ -f /usr/sbin/anacron ] || exit 0 prog="anacron" -PIDFILE=/var/run/${prog}.pid +PIDFILE=/var/spool/anacron/cron.daily LOCKFILE=/var/lock/subsys/$prog # # NOTE: anacron exits after it has determined it has no more work to do. # Hence, its initscript cannot do normal lock file management. -# The anacron binary now creates its own /var/run/anacron.pid pid file -# and /var/lock/subsys lock files, and removes them automatically at exit, -# so at least there will be no more "anacron is dead but subsys locked" -# messages. The pid and lock is existing only, when anacron is running -# (only when cron wake anacron up). +# The anacron binary now creates its own timestamps in files +# /var/spool/anacron/cron.{daily,monthly,weekly} +# and /var/lock/subsys lock files. # start() { echo -n $"Starting $prog: " +# on_ac_power doesn't exist, on_ac_power returns 0 (ac power being used) + if test -x /usr/bin/on_ac_power + then + /usr/bin/on_ac_power > /dev/null + if test $? -eq 1 + then + echo "deferred while on battery power." + RETVAL=0 + exit 0 + fi + fi daemon +19 anacron -s RETVAL=$? if [ $RETVAL -ne 0 ]; then @@ -59,8 +68,8 @@ case "$1" in status) ## anacron's status is always stopped, because anacron sleep, until ## cron wake him - status anacron - RETVAL=1 + status $PIDFILE + RETVAL=$? ;; restart) @@ -68,15 +77,8 @@ case "$1" in start ;; - condrestart) - if [ -f $LOCKFILE ]; then - stop - start - fi - ;; - *) - echo $"Usage: $0 {start|stop|restart|condrestart|status}" + echo $"Usage: $0 {start|stop|restart|status}" RETVAL=3 esac diff --git a/anacron.spec b/anacron.spec index dabdad1..52fb0d8 100644 --- a/anacron.spec +++ b/anacron.spec @@ -1,24 +1,20 @@ Summary: A cron-like program that can run jobs lost during downtime Name: anacron Version: 2.3 -Release: 47%{?dist} +Release: 49%{?dist} License: GPL Group: System Environment/Base URL: http://packages.debian.org/stable/source/anacron Source: http://ftp.debian.org/debian/pool/main/a/anacron/%{name}_%{version}.orig.tar.gz Source1: anacrontab Source2: anacron.init -Patch0: anacron-2.3-mk-incl.patch +Patch0: anacron_2.3-13.patch Patch1: anacron-2.3-mail-content-type-77108.patch -Patch2: anacron-2.3-noconst.patch -Patch3: anacron-2.3-mailto.patch -Patch4: anacron-2.3-lock-files.patch -Patch5: anacron-2.3-fdclose.patch -Patch6: anacron-2.3-hostname.patch -Patch7: anacron-2.3-pic.patch -Patch8: anacron-2.3-memleaking.patch +Patch2: anacron-2.3-fdclose.patch +Patch3: anacron-2.3-pic.patch +Patch4: anacron-2.3-memleaking.patch +Patch5: anacron-script.patch -Requires: /bin/sh Requires: crontabs Requires: initscripts Requires(post): /sbin/chkconfig @@ -44,15 +40,12 @@ jobs of other Red Hat Linux (or Fedora) packages are executed each day. %prep %setup -q -%patch0 -p1 -b .incl +%patch0 -p1 -b .try %patch1 -p1 -b .charset -%patch2 -p1 -b .noconst -%patch3 -p1 -b .mailto -%patch4 -p1 -b .lock-files -%patch5 -p1 -b .fdclose -%patch6 -p1 -b .hostname -%patch7 -p1 -b .pic -%patch8 -p1 -b .memleaking +%patch2 -p1 -b .fdclose +%patch3 -p1 -b .pic +%patch4 -p1 -b .memleaking +%patch5 -p1 -b .script %build make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} @@ -70,30 +63,11 @@ cp %SOURCE1 $RPM_BUILD_ROOT/etc for i in cron.daily cron.weekly cron.monthly;do mkdir -p $RPM_BUILD_ROOT/etc/$i/ -cat << EOF > $RPM_BUILD_ROOT/etc/$i/0anacron -#!/bin/sh -# -# anacron's cron script -# -# This script updates anacron time stamps. It is called through run-parts -# either by anacron itself or by cron. -# -# The script is called "0anacron" to assure that it will be executed -# _before_ all other scripts. - -# Don't run anacron if this script is called by anacron. -if [ ! -e /var/run/anacron.pid ]; then - anacron -u $i -fi - -EOF -chmod +x $RPM_BUILD_ROOT/etc/$i/0anacron done -# -#for i in `find $RPM_BUILD_ROOT/ -type 'f' -perm '+a=x'`;do -# file $i|grep -q "not stripped" && strip $i -#done +cp debian/0anacron.daily $RPM_BUILD_ROOT/etc/cron.daily/0anacron +cp debian/0anacron.monthly $RPM_BUILD_ROOT/etc/cron.monthly/0anacron +cp debian/0anacron.weekly $RPM_BUILD_ROOT/etc/cron.weekly/0anacron mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d/ install -c -m755 %SOURCE2 $RPM_BUILD_ROOT/etc/rc.d/init.d/anacron @@ -125,12 +99,17 @@ fi /%{_mandir}/man5/* /%{_mandir}/man8/* /usr/sbin/anacron -##%config(noreplace) /etc/cron.daily/0anacron %attr(755,root,root) %dir /etc/cron.daily/0anacron %attr(755,root,root) %dir /etc/cron.monthly/0anacron %attr(755,root,root) %dir /etc/cron.weekly/0anacron %changelog +* Wed Aug 08 2007 Marcela Maslanova 2.3-49 +- adopt some patches from upstream for better locking +- add own changes, which resolve problem with two or more run of + cron.daily. +- Resolves: #157448 + * Wed Jul 11 2007 Marcela Maslanova 2.3-48 - changes in init script (not build) diff --git a/anacrontab b/anacrontab index ab071e7..8108dbc 100644 --- a/anacrontab +++ b/anacrontab @@ -6,6 +6,6 @@ SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root -1 65 cron.daily run-parts /etc/cron.daily -7 70 cron.weekly run-parts /etc/cron.weekly -30 75 cron.monthly run-parts /etc/cron.monthly +1 65 cron.daily nice run-parts /etc/cron.daily +7 70 cron.weekly nice run-parts /etc/cron.weekly +@monthly 75 cron.monthly nice run-parts /etc/cron.monthly