Blob Blame History Raw
diff -up at-3.1.18/atd.c.nit at-3.1.18/atd.c
--- at-3.1.18/atd.c.nit	2016-03-23 12:46:49.222277787 +0100
+++ at-3.1.18/atd.c	2016-03-23 12:47:50.521639804 +0100
@@ -196,6 +196,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
 
 #ifdef WITH_SELINUX
 static int
@@ -339,6 +351,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.
@@ -507,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("/");
 
 	    execle("/bin/sh", "sh", (char *) NULL, nenvp);
@@ -572,6 +590,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)
@@ -699,6 +720,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;
@@ -733,6 +755,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;
diff -up at-3.1.18/at.1.in.nit at-3.1.18/at.1.in
--- at-3.1.18/at.1.in.nit	2015-12-06 16:45:10.000000000 +0100
+++ at-3.1.18/at.1.in	2016-03-23 12:46:49.226277876 +0100
@@ -210,7 +210,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