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