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