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