[Pkg-cron-devel] [pkg-cron] 18/19: Add an option -n to include FQDN in mail subject

Christian Kastner chrisk-guest at moszumanska.debian.org
Fri Oct 10 15:18:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

chrisk-guest pushed a commit to branch ckk/cron-125
in repository pkg-cron.

commit faaeed16d9639112f2a18072300619281abb2e95
Author: Christian Kastner <debian at kvr.at>
Date:   Thu Oct 9 23:31:18 2014 +0200

    Add an option -n to include FQDN in mail subject
    
    Closes: #570423
---
 cron.8       |  4 ++++
 cron.c       | 16 ++++++++++------
 cron.h       |  2 ++
 do_command.c |  3 ++-
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/cron.8 b/cron.8
index e6b1279..c09b717 100644
--- a/cron.8
+++ b/cron.8
@@ -41,6 +41,10 @@ Enable LSB compliant names for /etc/cron.d files. This setting, however, does
 not affect the parsing of files under /etc/cron.hourly, /etc/cron.daily,
 /etc/cron.weekly or /etc/cron.monthly.
 .TP
+.B -n
+Include the FQDN in the subject when sending mails. By default, cron will
+abbreviate the hostname.
+.TP
 .B -L loglevel 
 Tell cron what to log about \fBjobs\fR (errors are logged regardless of this
 value) as the sum of the following values:
diff --git a/cron.c b/cron.c
index 977d2f8..bb36cff 100644
--- a/cron.c
+++ b/cron.c
@@ -470,8 +470,9 @@ parse_args(argc, argv)
 	log_level = 1;
 	stay_foreground = 0;
         lsbsysinit_mode = 0;
+        fqdn_in_subject = 0;
 
-	while (EOF != (argch = getopt(argc, argv, "lfx:L:"))) {
+	while (EOF != (argch = getopt(argc, argv, "lfnx:L:"))) {
 		switch (argch) {
 		default:
 			usage();
@@ -482,12 +483,15 @@ parse_args(argc, argv)
 			if (!set_debug_flags(optarg))
 				usage();
 			break;
-                case 'l':
-                    lsbsysinit_mode = 1;
-                    break;
+		case 'l':
+			lsbsysinit_mode = 1;
+			break;
+		case 'n':
+			fqdn_in_subject = 1;
+			break;
 		case 'L':
-		    log_level = atoi(optarg);
-		    break;
+			log_level = atoi(optarg);
+			break;
 		}
 	}
 }
diff --git a/cron.h b/cron.h
index d1b2bcf..ba037aa 100644
--- a/cron.h
+++ b/cron.h
@@ -305,6 +305,7 @@ static long GMToff;
 
 int	stay_foreground;
 int     lsbsysinit_mode;
+int     fqdn_in_subject;
 int     log_level = 1;
 char    cron_default_mail_charset[MAX_ENVSTR] = "";
 
@@ -321,6 +322,7 @@ extern	char	*copyright[],
 		*DowNames[],
 		*ProgramName;
 extern  int     lsbsysinit_mode;
+extern  int     fqdn_in_subject;
 extern  int     log_level;
 extern	int	LineNumber;
 extern	time_t	StartTime;
diff --git a/do_command.c b/do_command.c
index c22d9d6..d52ec33 100644
--- a/do_command.c
+++ b/do_command.c
@@ -561,7 +561,8 @@ child_process(e, u)
 	fprintf(mail, "From: root (Cron Daemon)\n");
 	fprintf(mail, "To: %s\n", mailto);
 	fprintf(mail, "Subject: Cron <%s@%s> %s%s\n",
-			usernm, first_word(hostname, "."),
+			usernm,
+			fqdn_in_subject ? hostname : first_word(hostname, "."),
 			e->cmd, status?" (failed)":"");
 # if defined(MAIL_DATE)
 	fprintf(mail, "Date: %s\n",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-cron/pkg-cron.git



More information about the Pkg-cron-devel mailing list