Blame SOURCES/cronie-1.4.11-temp-name.patch

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