On Thu, Mar 21, 2019 at 12:52:14PM +1100, Haribabu Kommi wrote: > Earlier attached patch is wrong.
- oumask = umask(pg_file_create_mode); + oumask = umask(pg_mode_mask); Indeed that was wrong. > Correct patch attached. Sorry for the inconvenience. This looks better for the umask setting, still it could be more simple. #include <sys/time.h> - +#include "common/file_perm.h" #include "lib/stringinfo.h" Nit: it is better for readability to keep an empty line between the system includes and the Postgres ones. A second thing, more important, is that you can reset umask just after opening the file, as attached. This way there is no need to reset the umask in all the code paths leaving update_metainfo_datafile(). Does that look fine to you? -- Michael
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index d1ea46deb8..d1f71c0f7e 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -31,6 +31,7 @@ #include <sys/stat.h> #include <sys/time.h> +#include "common/file_perm.h" #include "lib/stringinfo.h" #include "libpq/pqsignal.h" #include "miscadmin.h" @@ -1453,6 +1454,7 @@ static void update_metainfo_datafile(void) { FILE *fh; + mode_t oumask; if (!(Log_destination & LOG_DESTINATION_STDERR) && !(Log_destination & LOG_DESTINATION_CSVLOG)) @@ -1465,7 +1467,12 @@ update_metainfo_datafile(void) return; } - if ((fh = logfile_open(LOG_METAINFO_DATAFILE_TMP, "w", true)) == NULL) + /* use the same permissions as the data directory for the new file */ + oumask = umask(pg_mode_mask); + fh = fopen(LOG_METAINFO_DATAFILE_TMP, "w"); + umask(oumask); + + if (fh == NULL) { ereport(LOG, (errcode_for_file_access(),
signature.asc
Description: PGP signature