Blob Blame History Raw
diff -up at-3.1.13/at.1.in.nit at-3.1.13/at.1.in
--- at-3.1.13/at.1.in.nit	2011-06-25 14:43:14.000000000 +0200
+++ at-3.1.13/at.1.in	2011-07-28 13:04:41.398174737 +0200
@@ -126,7 +126,7 @@ and to run a job at 1am tomorrow, you wo
 .B at 1am tomorrow.
 .PP
 The definition of the time specification can be found in
-.IR @prefix@/share/doc/at/timespec .
+.IR @prefix@/share/doc/at-@VERSION@/timespec .
 .PP
 For both
 .BR at " and " batch ,
@@ -204,7 +204,7 @@ queue for
 .BR batch .
 Queues with higher letters run with increased niceness.  The special
 queue "=" is reserved for jobs which are currently running.
-.P
+
 If a job is submitted to a queue designated with an uppercase letter, the
 job is treated as if it were submitted to batch at the time of the job.
 Once the time is reached, the batch processing rules with respect to load
@@ -248,7 +248,7 @@ is an alias for
 .TP
 .B \-v
 Shows the time the job will be executed before reading the job.
-.P
+
 Times displayed will be in the format "Thu Feb 20 14:50:00 1997".
 .TP
 .B
diff -up at-3.1.13/atd.c.nit at-3.1.13/atd.c
--- at-3.1.13/atd.c.nit	2011-06-25 14:43:14.000000000 +0200
+++ at-3.1.13/atd.c	2011-07-28 13:01:31.577967025 +0200
@@ -83,6 +83,9 @@
 #include "getloadavg.h"
 #endif
 
+#ifndef LOG_ATD
+#define LOG_ATD        LOG_DAEMON
+#endif
 /* Macros */
 
 #define BATCH_INTERVAL_DEFAULT 60
@@ -194,6 +197,18 @@ myfork()
 
 #define fork myfork
 #endif
+#undef ATD_MAIL_PROGRAM
+#undef ATD_MAIL_NAME
+#if defined(SENDMAIL)
+#define ATD_MAIL_PROGRAM SENDMAIL
+#define ATD_MAIL_NAME    "sendmail"
+#elif  defined(MAILC)
+#define ATD_MAIL_PROGRAM MAILC
+#define ATD_MAIL_NAME    "mail"
+#elif  defined(MAILX)
+#define ATD_MAIL_PROGRAM MAILX
+#define ATD_MAIL_NAME    "mailx"
+#endif
 
 static void
 run_file(const char *filename, uid_t uid, gid_t gid)
@@ -271,6 +286,9 @@ run_file(const char *filename, uid_t uid
 	free(newname);
 	return;
     }
+
+    (void) setsid(); //own session for process
+
     /* Let's see who we mail to.  Hopefully, we can read it from
      * the command file; if not, send it to the owner, or, failing that,
      * to root.
@@ -433,6 +451,9 @@ run_file(const char *filename, uid_t uid
 	    if (setuid(uid) < 0)
 		perr("Cannot set user id");
 
+	    if (SIG_ERR == signal(SIGCHLD, SIG_DFL))
+		perr("Cannot reset signal handler to default");
+
 	    chdir("/");
 
 	    if (execle("/bin/sh", "sh", (char *) NULL, nenvp) != 0)
@@ -501,6 +522,9 @@ run_file(const char *filename, uid_t uid
 	    if (setuid(uid) < 0)
 		perr("Cannot set user id");
 
+	    if (SIG_ERR == signal(SIGCHLD, SIG_DFL))
+		perr("Cannot reset signal handler to default");
+
 	    chdir ("/");
 
 #if defined(SENDMAIL)
@@ -615,6 +639,7 @@ run_loop()
 		 * Let's remove the lockfile and reschedule.
 		 */
 		strncpy(lock_name, dirent->d_name, sizeof(lock_name));
+		lock_name[sizeof(lock_name)-1] = '\0';
 		lock_name[0] = '=';
 		unlink(lock_name);
 		next_job = now;
@@ -649,6 +674,7 @@ run_loop()
 	    run_batch++;
 	    if (strcmp(batch_name, dirent->d_name) > 0) {
 		strncpy(batch_name, dirent->d_name, sizeof(batch_name));
+		batch_name[sizeof(batch_name)-1] = '\0';
 		batch_uid = buf.st_uid;
 		batch_gid = buf.st_gid;
 		batch_queue = queue;
@@ -723,11 +749,7 @@ main(int argc, char *argv[])
 
     RELINQUISH_PRIVS_ROOT(daemon_uid, daemon_gid)
 
-#ifndef LOG_CRON
-#define LOG_CRON	LOG_DAEMON
-#endif
-
-    openlog("atd", LOG_PID, LOG_CRON);
+    openlog("atd", LOG_PID, LOG_ATD);
 
     opterr = 0;
     errno = 0;