Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37859847
en ru br
ALT Linux repos
S:2.3-alt7
5.0: 2.3-alt2
4.1: 2.3-alt1
4.0: 2.3-ipl9mdk
3.0: 2.3-ipl9mdk

Group :: System/Servers
RPM: anacron

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: anacron-2.3-re.patch
Download


--- anacron-2.3~/Makefile	Fri Jun 23 04:00:14 2000
+++ anacron-2.3/Makefile	Fri Feb 23 00:48:30 2001
@@ -22,8 +22,7 @@
 PREFIX = 
 BINDIR = $(PREFIX)/usr/sbin
 MANDIR = $(PREFIX)/usr/man
-CFLAGS = -Wall -pedantic -O2
-#CFLAGS = -Wall -O2 -g -DDEBUG
+CFLAGS = $(RPM_OPT_FLAGS)
 
 # If you change these, please update the man-pages too
 # Only absolute paths here, please
--- anacron-2.3~/global.h	Fri Jun 23 04:00:14 2000
+++ anacron-2.3/global.h	Fri Feb 23 00:48:30 2001
@@ -41,6 +41,7 @@
 #define MAX_MSG 150
 
 #include <signal.h>
+#include <time.h>
 
 /* Some declarations */
 
@@ -73,13 +74,11 @@
 /* Global variables */
 
 extern pid_t primary_pid;
-extern char *program_name;
+extern const char *__progname;
 extern char *anacrontab;
 extern int old_umask;
 extern sigset_t old_sigmask;
 extern int serialize,force,update_only,now,no_daemon,quiet;
-extern int day_now;
-extern int year,month,day_of_month;
 extern int in_background;
 
 extern job_rec *first_job_rec;
@@ -93,6 +92,8 @@
 
 extern int running_jobs,running_mailers;
 
+extern time_t start_sec;		/* time anacron started */
+extern char start_stamp[128];	/* timestamp anacron started */
 
 /* Function prototypes */
 
--- anacron-2.3~/lock.c	Fri Jun 23 01:13:32 2000
+++ anacron-2.3/lock.c	Fri Feb 23 01:01:16 2001
@@ -29,11 +29,10 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <string.h>
 #include <unistd.h>
 #include <errno.h>
-#include <signal.h>
 #include "global.h"
-#include "gregor.h"
 
 static void
 open_tsfile(job_rec *jr)
@@ -78,27 +77,26 @@
  * and return 1, if it's too early, or we can't get the lock, return 0.
  */
 {
-    char timestamp[9];
-    int ts_year, ts_month, ts_day, dn;
+    char timestamp[128];
     ssize_t b;
 
     open_tsfile(jr);
 
     /* read timestamp */
-    b = read(jr->timestamp_fd, timestamp, 8);
+    b = read(jr->timestamp_fd, timestamp, sizeof timestamp - 1);
     if (b == -1) die_e("Error reading timestamp file %s", jr->ident);
-    timestamp[8] = 0;
+    timestamp[b] = 0;
 
     /* is it too early? */
-    if (!force && b == 8)
+    if ( !force && b > 0 )
     {
+	time_t parsed_sec;
+	struct tm parsed_tm;
 	int day_delta;
-	if (sscanf(timestamp, "%4d%2d%2d", &ts_year, &ts_month, &ts_day) == 3)
-	    dn = day_num(ts_year, ts_month, ts_day);
-	else
-	    dn = 0;
-
-	day_delta = day_now - dn;
+	memset( &parsed_tm, 0, sizeof parsed_tm );
+	strptime( timestamp, "%F %T", &parsed_tm );
+	parsed_sec = mktime( &parsed_tm );
+	day_delta = (start_sec - parsed_sec) / (60 * 60 * 24);
 
 	/*
 	 * if day_delta is negative, we assume there was a clock skew 
@@ -137,14 +135,12 @@
  * Note that this is not the way it was with anacron 1.0.3 to 1.0.7.  
  */
 {
-    char stamp[10];
-
-    snprintf(stamp, 10, "%04d%02d%02d\n", year, month, day_of_month);
+    unsigned len = strlen( start_stamp );
     if (lseek(jr->timestamp_fd, 0, SEEK_SET))
 	die_e("Can't lseek timestamp file for job %s", jr->ident);
-    if (write(jr->timestamp_fd, stamp, 9) != 9)
+    if (write(jr->timestamp_fd, start_stamp, len) != len)
 	die_e("Can't write timestamp file for job %s", jr->ident);
-    if (ftruncate(jr->timestamp_fd, 9))
+    if (ftruncate(jr->timestamp_fd, len))
 	die_e("ftruncate error");
 }
 
--- anacron-2.3~/log.c	Fri Jun 23 04:00:14 2000
+++ anacron-2.3/log.c	Fri Feb 23 00:48:30 2001
@@ -34,6 +34,7 @@
  * and "explain" messages when we're in the foreground, and not "quiet".
  */
 
+#include <stdlib.h>
 #include <unistd.h>
 #include <syslog.h>
 #include <stdio.h>
@@ -53,7 +54,7 @@
 {
     if (!log_open)
     {
-	openlog(program_name, LOG_PID, SYSLOG_FACILITY);
+	openlog(__progname, LOG_PID, SYSLOG_FACILITY);
 	log_open = 1;
     }
 }
@@ -91,7 +92,7 @@
 	if (priority == EXPLAIN_LEVEL && !quiet)
 	    fprintf(stderr, "%s\n", msg);
 	else if (priority == COMPLAIN_LEVEL)
-	    fprintf(stderr, "%s: %s\n", program_name, msg);
+	    fprintf(stderr, "%s: %s\n", __progname, msg);
     }
 }
 
@@ -112,7 +113,7 @@
 	    fprintf(stderr, "%s: %s\n", msg, strerror(saved_errno));
 	else if (priority == COMPLAIN_LEVEL)
 	    fprintf(stderr, "%s: %s: %s\n",
-		    program_name, msg, strerror(saved_errno));
+		    __progname, msg, strerror(saved_errno));
     }
 }
 
--- anacron-2.3~/main.c	Fri Jun 23 04:00:14 2000
+++ anacron-2.3/main.c	Fri Feb 23 00:58:56 2001
@@ -22,8 +22,11 @@
 */
 
 
-#include <time.h>
 #include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>
@@ -31,13 +34,9 @@
 #include <sys/stat.h>
 #include <string.h>
 #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 */
@@ -51,7 +50,8 @@
 job_rec *first_job_rec;
 env_rec *first_env_rec;
 
-static time_t start_sec;                       /* time anacron started */
+time_t start_sec;                       /* time anacron started */
+char start_stamp[128];                  /* timestamp anacron started */
 static volatile int got_sigalrm, got_sigchld, got_sigusr1;
 int running_jobs, running_mailers;              /* , number of */
 
@@ -128,9 +128,9 @@
 	    exit(0);
 	case '?':
 	    fprintf(stderr, "%s: invalid option: %c\n",
-		    program_name, optopt);
+		    __progname, optopt);
 	    fprintf(stderr, "type: `%s -h' for more information\n",
-		    program_name);
+		    __progname);
 	    exit(FAILURE_EXIT);
 	}
     }
@@ -342,18 +342,11 @@
 static void
 record_start_time()
 {
-    struct tm *tm_now;
-
-    start_sec = time(NULL);
-    tm_now = localtime(&start_sec);
-    year = tm_now->tm_year + 1900;
-    month = tm_now->tm_mon + 1;
-    day_of_month = tm_now->tm_mday;
-    day_now = day_num(year, month, day_of_month);
-    if (day_now == -1) die("Invalid date (this is really embarrassing)");
-    if (!update_only)
-	explain("Anacron " RELEASE " started on %04d-%02d-%02d",
-		year, month, day_of_month);
+	start_sec = time(0);
+	if ( strftime( start_stamp, sizeof(start_stamp), "%F %T", localtime( &start_sec ) ) <= 0 )
+		error( 1, errno, "strftime" );
+	if ( !update_only)
+		explain( "Anacron " RELEASE " started on `%s'", start_stamp );
 }
 
 static int
@@ -380,8 +373,7 @@
     while (j < njobs)
     {
 	fake_job(job_array[j]);
-	explain("Updated timestamp for job `%s' to %04d-%02d-%02d",
-		job_array[j]->ident, year, month, day_of_month);
+	explain( "Updated timestamp for job `%s' to `%s'", job_array[j]->ident, start_stamp );
 	j++;
     }
 }
@@ -415,11 +407,6 @@
     int j;
 
     anacrontab = NULL;
-
-    if((program_name = strrchr(argv[0], '/')) == NULL)
-	program_name = argv[0];
-    else
-	++program_name; /* move pointer to char after '/' */
 
     parse_opts(argc, argv);
 
--- anacron-2.3~/matchrx.c	Wed Jun 21 03:12:18 2000
+++ anacron-2.3/matchrx.c	Fri Feb 23 00:48:30 2001
@@ -26,6 +26,7 @@
 #include <regex.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <string.h>
 #include "matchrx.h"
 
 int
--- anacron-2.3~/runjob.c	Wed Jun 21 03:12:18 2000
+++ anacron-2.3/runjob.c	Fri Feb 23 00:48:30 2001
@@ -39,28 +39,15 @@
 temp_file()
 /* Open a temporary file and return its file descriptor */
 {
-    const int max_retries = 50;
-    char *name;
-    int fd, i;
-
-    i = 0;
-    name = NULL;
-    do
-    {
-	i++;
-	free(name);
-	name = tempnam(NULL, NULL);
-	if (name == NULL) die("Can't find a unique temporary filename");
-	fd = open(name, O_RDWR | O_CREAT | O_EXCL | O_APPEND,
-		  S_IRUSR | S_IWUSR);
-	/* I'm not sure we actually need to be so persistent here */
-    } while (fd == -1 && errno == EEXIST && i < max_retries);
-    
-    if (fd == -1) die_e("Can't open temporary file");
-    if (unlink(name)) die_e("Can't unlink temporary file");
-    free(name);
-    fcntl(fd, F_SETFD, 1);    /* set close-on-exec flag */
-    return fd;
+	mkdir("/var/run/anacron", 0700);
+	char	name[] = "/var/run/anacron/XXXXXX";
+	int	fd = mkstemp( name );
+	if ( fd < 0 )
+		die_e( "Can't create temporary file" );
+	if ( unlink(name) )
+		die_e( "Can't unlink temporary file" );
+	fcntl( fd, F_SETFD, 1 );	/* set close-on-exec flag */
+	return fd;
 }
 
 static off_t
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin