Blame SOURCES/at-3.1.14-mailwithhostname.patch

76a39a
diff -up at-3.1.14/atd.c.mail at-3.1.14/atd.c
76a39a
--- at-3.1.14/atd.c.mail	2013-12-04 11:39:44.556239282 +0100
76a39a
+++ at-3.1.14/atd.c	2013-12-04 11:40:50.544234246 +0100
76a39a
@@ -100,6 +100,10 @@ int selinux_enabled=0;
76a39a
 #define BATCH_INTERVAL_DEFAULT 60
76a39a
 #define CHECK_INTERVAL 3600
76a39a
 
76a39a
+#ifndef MAXHOSTNAMELEN
76a39a
+#define MAXHOSTNAMELEN 64
76a39a
+#endif
76a39a
+
76a39a
 /* Global variables */
76a39a
 
76a39a
 uid_t real_uid, effective_uid;
76a39a
@@ -117,6 +121,7 @@ static time_t last_chg;
76a39a
 static int nothing_to_do;
76a39a
 unsigned int batch_interval;
76a39a
 static int run_as_daemon = 0;
76a39a
+static int mail_with_hostname = 0;
76a39a
 
76a39a
 static volatile sig_atomic_t term_signal = 0;
76a39a
 
76a39a
@@ -298,6 +303,7 @@ run_file(const char *filename, uid_t uid
76a39a
     char fmt[64];
76a39a
     unsigned long jobno;
76a39a
     int rc;
76a39a
+    char hostbuf[MAXHOSTNAMELEN];
76a39a
 #ifdef WITH_PAM
76a39a
     int retcode;
76a39a
 #endif
76a39a
@@ -452,6 +458,11 @@ run_file(const char *filename, uid_t uid
76a39a
 
76a39a
     write_string(fd_out, "Subject: Output from your job ");
76a39a
     write_string(fd_out, jobbuf);
76a39a
+    if (mail_with_hostname > 0) {
76a39a
+               gethostname(hostbuf, MAXHOSTNAMELEN-1);
76a39a
+        write_string(fd_out, " ");
76a39a
+        write_string(fd_out, hostbuf);
76a39a
+    }
76a39a
     write_string(fd_out, "\nTo: ");
76a39a
     write_string(fd_out, mailname);    
76a39a
     write_string(fd_out, "\n\n");
76a39a
@@ -843,7 +854,7 @@ main(int argc, char *argv[])
76a39a
     run_as_daemon = 1;
76a39a
     batch_interval = BATCH_INTERVAL_DEFAULT;
76a39a
 
76a39a
-    while ((c = getopt(argc, argv, "sdl:b:f")) != EOF) {
76a39a
+    while ((c = getopt(argc, argv, "sdnl:b:f")) != EOF) {
76a39a
 	switch (c) {
76a39a
 	case 'l':
76a39a
 	    if (sscanf(optarg, "%lf", &load_avg) != 1)
76a39a
@@ -865,6 +876,10 @@ main(int argc, char *argv[])
76a39a
 	    daemon_foreground++;
76a39a
 	    break;
76a39a
 
76a39a
+	case 'n':
76a39a
+	    mail_with_hostname=1;
76a39a
+	    break;
76a39a
+
76a39a
 	case 's':
76a39a
 	    run_as_daemon = 0;
76a39a
 	    break;