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