304494
diff -up cronie-1.4.11/src/crontab.c.temp-name cronie-1.4.11/src/crontab.c
304494
--- cronie-1.4.11/src/crontab.c.temp-name	2016-02-23 15:32:33.754463457 +0100
304494
+++ cronie-1.4.11/src/crontab.c	2016-02-23 15:33:17.401466818 +0100
304494
@@ -104,7 +104,7 @@ edit_cmd(void),
304494
 poke_daemon(void),
304494
 check_error(const char *), parse_args(int c, char *v[]), die(int) ATTRIBUTE_NORETURN;
304494
 static int replace_cmd(void), hostset_cmd(void), hostget_cmd(void);
304494
-static char *host_specific_filename(const char *filename, int prefix);
304494
+static char *host_specific_filename(const char *prefix, const char *suffix);
304494
 static const char *tmp_path(void);
304494
 
304494
 static void usage(const char *msg) ATTRIBUTE_NORETURN;
304494
@@ -445,26 +445,27 @@ static const char *tmp_path(void) {
304494
 	return tmpdir ? tmpdir : "/tmp";
304494
 }
304494
 
304494
-static char *host_specific_filename(const char *filename, int prefix)
304494
+static char *host_specific_filename(const char *prefix, const char *suffix)
304494
 {
304494
 	/*
304494
 	 * For cluster-wide use, where there is otherwise risk of the same
304494
-	 * name being generated on more than one host at once, prefix with
304494
-	 * "hostname." or suffix with ".hostname" as requested, and return
304494
-	 * static buffer or NULL on failure.
304494
+	 * name being generated on more than one host at once, insert hostname
304494
+	 * separated with dots, and return static buffer or NULL on failure.
304494
 	 */
304494
 
304494
 	static char safename[MAX_FNAME];
304494
-	char hostname[MAXHOSTNAMELEN];
304494
+	char hostname[MAX_FNAME];
304494
 
304494
 	if (gethostname(hostname, sizeof hostname) != 0)
304494
 		return NULL;
304494
 
304494
 	if (prefix) {
304494
-		if (!glue_strings(safename, sizeof safename, hostname, filename, '.'))
304494
+		if (!glue_strings(safename, sizeof safename, prefix, hostname, '.'))
304494
 			return NULL;
304494
-	} else {
304494
-		if (!glue_strings(safename, sizeof safename, filename, hostname, '.'))
304494
+		strcpy(hostname, safename);
304494
+	}
304494
+	if (suffix) {
304494
+		if (!glue_strings(safename, sizeof safename, hostname, suffix, '.'))
304494
 			return NULL;
304494
 	}
304494
 
304494
@@ -745,7 +746,7 @@ static int replace_cmd(void) {
304494
 	char *safename;
304494
 
304494
 
304494
-	safename = host_specific_filename("tmp.XXXXXXXXXX", 1);
304494
+	safename = host_specific_filename("#tmp", "XXXXXXXXXX");
304494
 	if (!safename || !glue_strings(TempFilename, sizeof TempFilename, SPOOL_DIR,
304494
 			safename, '/')) {
304494
 		TempFilename[0] = '\0';
304494
@@ -911,7 +912,7 @@ static int hostset_cmd(void) {
304494
 	if (!HostSpecified)
304494
 		gethostname(Host, sizeof Host);
304494
 	
304494
-	safename = host_specific_filename("tmp.XXXXXXXXXX", 1);
304494
+	safename = host_specific_filename("#tmp", "XXXXXXXXXX");
304494
 	if (!safename || !glue_strings(TempFilename, sizeof TempFilename, SPOOL_DIR,
304494
 		safename, '/')) {
304494
 		TempFilename[0] = '\0';