Blame SOURCES/at-3.1.14-mailwithhostname.patch

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