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