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