973edf
diff -up at-3.1.13/atd.c.hostname at-3.1.13/atd.c
973edf
--- at-3.1.13/atd.c.hostname	2012-01-12 18:19:36.000000000 +0100
973edf
+++ at-3.1.13/atd.c	2012-01-12 18:52:34.000000000 +0100
973edf
@@ -99,6 +99,10 @@ int selinux_enabled=0;
973edf
 #define BATCH_INTERVAL_DEFAULT 60
973edf
 #define CHECK_INTERVAL 3600
973edf
 
973edf
+#ifndef MAXHOSTNAMELEN
973edf
+#define MAXHOSTNAMELEN 64
973edf
+#endif
973edf
+
973edf
 /* Global variables */
973edf
 
973edf
 uid_t real_uid, effective_uid;
973edf
@@ -116,6 +120,7 @@ static time_t last_chg;
973edf
 static int nothing_to_do;
973edf
 unsigned int batch_interval;
973edf
 static int run_as_daemon = 0;
973edf
+static int mail_with_hostname = 0;
973edf
 
973edf
 static volatile sig_atomic_t term_signal = 0;
973edf
 
973edf
@@ -297,6 +302,7 @@ run_file(const char *filename, uid_t uid
973edf
     char fmt[64];
973edf
     unsigned long jobno;
973edf
     int rc;
973edf
+    char hostbuf[MAXHOSTNAMELEN];
973edf
 #ifdef WITH_PAM
973edf
     int retcode;
973edf
 #endif
973edf
@@ -451,6 +457,11 @@ run_file(const char *filename, uid_t uid
973edf
 
973edf
     write_string(fd_out, "Subject: Output from your job ");
973edf
     write_string(fd_out, jobbuf);
973edf
+    if (mail_with_hostname > 0) {
973edf
+		gethostname(hostbuf, MAXHOSTNAMELEN-1);
973edf
+        write_string(fd_out, " ");
973edf
+        write_string(fd_out, hostbuf);
973edf
+    }
973edf
     write_string(fd_out, "\nTo: ");
973edf
     write_string(fd_out, mailname);    
973edf
     write_string(fd_out, "\n\n");
973edf
@@ -910,7 +921,7 @@ main(int argc, char *argv[])
973edf
     run_as_daemon = 1;
973edf
     batch_interval = BATCH_INTERVAL_DEFAULT;
973edf
 
973edf
-    while ((c = getopt(argc, argv, "sdl:b:f")) != EOF) {
973edf
+    while ((c = getopt(argc, argv, "sdnl:b:f")) != EOF) {
973edf
 	switch (c) {
973edf
 	case 'l':
973edf
 	    if (sscanf(optarg, "%lf", &load_avg) != 1)
973edf
@@ -932,6 +943,10 @@ main(int argc, char *argv[])
973edf
 	    daemon_foreground++;
973edf
 	    break;
973edf
 
973edf
+	case 'n':
973edf
+	    mail_with_hostname=1;
973edf
+	    break;
973edf
+
973edf
 	case 's':
973edf
 	    run_as_daemon = 0;
973edf
 	    break;