Blame SOURCES/at-3.1.13-mailwithhostname.patch

9ccead
diff -up at-3.1.13/atd.c.hostname at-3.1.13/atd.c
9ccead
--- at-3.1.13/atd.c.hostname	2012-01-12 18:19:36.000000000 +0100
9ccead
+++ at-3.1.13/atd.c	2012-01-12 18:52:34.000000000 +0100
9ccead
@@ -99,6 +99,10 @@ int selinux_enabled=0;
9ccead
 #define BATCH_INTERVAL_DEFAULT 60
9ccead
 #define CHECK_INTERVAL 3600
9ccead
 
9ccead
+#ifndef MAXHOSTNAMELEN
9ccead
+#define MAXHOSTNAMELEN 64
9ccead
+#endif
9ccead
+
9ccead
 /* Global variables */
9ccead
 
9ccead
 uid_t real_uid, effective_uid;
9ccead
@@ -116,6 +120,7 @@ static time_t last_chg;
9ccead
 static int nothing_to_do;
9ccead
 unsigned int batch_interval;
9ccead
 static int run_as_daemon = 0;
9ccead
+static int mail_with_hostname = 0;
9ccead
 
9ccead
 static volatile sig_atomic_t term_signal = 0;
9ccead
 
9ccead
@@ -297,6 +302,7 @@ run_file(const char *filename, uid_t uid
9ccead
     char fmt[64];
9ccead
     unsigned long jobno;
9ccead
     int rc;
9ccead
+    char hostbuf[MAXHOSTNAMELEN];
9ccead
 #ifdef WITH_PAM
9ccead
     int retcode;
9ccead
 #endif
9ccead
@@ -451,6 +457,11 @@ run_file(const char *filename, uid_t uid
9ccead
 
9ccead
     write_string(fd_out, "Subject: Output from your job ");
9ccead
     write_string(fd_out, jobbuf);
9ccead
+    if (mail_with_hostname > 0) {
9ccead
+		gethostname(hostbuf, MAXHOSTNAMELEN-1);
9ccead
+        write_string(fd_out, " ");
9ccead
+        write_string(fd_out, hostbuf);
9ccead
+    }
9ccead
     write_string(fd_out, "\nTo: ");
9ccead
     write_string(fd_out, mailname);    
9ccead
     write_string(fd_out, "\n\n");
9ccead
@@ -910,7 +921,7 @@ main(int argc, char *argv[])
9ccead
     run_as_daemon = 1;
9ccead
     batch_interval = BATCH_INTERVAL_DEFAULT;
9ccead
 
9ccead
-    while ((c = getopt(argc, argv, "sdl:b:f")) != EOF) {
9ccead
+    while ((c = getopt(argc, argv, "sdnl:b:f")) != EOF) {
9ccead
 	switch (c) {
9ccead
 	case 'l':
9ccead
 	    if (sscanf(optarg, "%lf", &load_avg) != 1)
9ccead
@@ -932,6 +943,10 @@ main(int argc, char *argv[])
9ccead
 	    daemon_foreground++;
9ccead
 	    break;
9ccead
 
9ccead
+	case 'n':
9ccead
+	    mail_with_hostname=1;
9ccead
+	    break;
9ccead
+
9ccead
 	case 's':
9ccead
 	    run_as_daemon = 0;
9ccead
 	    break;