From 13986b6e47df953685032d2305df1aa393e8a3f5 Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Tue, 15 Jan 2019 14:58:21 +1100
Subject: [PATCH] current_logfiles file following group access mode

Earlier current_logfiles file used to follow the
log_file_mode permissions, but this file contains
only the meta data of the log file and following
log_file_mode can leads to backup failure.
---
 src/backend/postmaster/syslogger.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index d1ea46deb8..d31d8f03fc 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -30,7 +30,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/time.h>
-
+#include "common/file_perm.h"
 #include "lib/stringinfo.h"
 #include "libpq/pqsignal.h"
 #include "miscadmin.h"
@@ -1465,7 +1465,7 @@ update_metainfo_datafile(void)
 		return;
 	}
 
-	if ((fh = logfile_open(LOG_METAINFO_DATAFILE_TMP, "w", true)) == NULL)
+	if ((fh = fopen(LOG_METAINFO_DATAFILE_TMP, "w")) == NULL)
 	{
 		ereport(LOG,
 				(errcode_for_file_access(),
@@ -1501,6 +1501,12 @@ update_metainfo_datafile(void)
 	}
 	fclose(fh);
 
+	if (chmod(LOG_METAINFO_DATAFILE_TMP, pg_file_create_mode) != 0)
+		ereport(LOG,
+				(errcode_for_file_access(),
+				 errmsg("could not set permissions of file \"%s\": %m",
+						 LOG_METAINFO_DATAFILE_TMP)));
+
 	if (rename(LOG_METAINFO_DATAFILE_TMP, LOG_METAINFO_DATAFILE) != 0)
 		ereport(LOG,
 				(errcode_for_file_access(),
-- 
2.18.0.windows.1

