Blob Blame History Raw
diff -up at-3.1.12/at.1.in.nit at-3.1.12/at.1.in
--- at-3.1.12/at.1.in.nit	2009-11-23 16:11:52.000000000 +0100
+++ at-3.1.12/at.1.in	2009-12-03 10:32:19.018261655 +0100
@@ -121,7 +121,7 @@ and to run a job at 1am tomorrow, you wo
 .B at 1am tomorrow.
 .PP
 The exact 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 ,
diff -up at-3.1.12/atd.c.nit at-3.1.12/atd.c
--- at-3.1.12/atd.c.nit	2009-11-23 16:11:52.000000000 +0100
+++ at-3.1.12/atd.c	2009-12-03 10:33:12.494259601 +0100
@@ -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)
@@ -276,6 +291,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.
@@ -435,6 +453,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)
@@ -503,6 +524,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)
@@ -617,6 +641,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;
@@ -651,6 +676,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;
@@ -725,11 +751,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;