Blame SOURCES/at-3.1.13-mailwithhostname.patch

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