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