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