mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Create temporary pg.auto.conf file with the same permissions as the original
Commit 0574279 set the file permissions to 0600 rather than the user's
umask, but if initdb was executed with -g/--allow-group-access, the
file is maintained with 0640, so we'll just maintain the existing
permssions.
This commit is contained in:
10
configfile.c
10
configfile.c
@@ -1821,6 +1821,7 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
|
||||
|
||||
FILE *fp;
|
||||
mode_t um;
|
||||
struct stat auto_conf_st;
|
||||
|
||||
KeyValueList config = {NULL, NULL};
|
||||
KeyValueListCell *cell = NULL;
|
||||
@@ -1877,8 +1878,13 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
|
||||
cell->key, cell->value);
|
||||
}
|
||||
|
||||
/* Set umask to 0600 */
|
||||
um = umask((~(S_IRUSR | S_IWUSR)) & (S_IRWXG | S_IRWXO));
|
||||
stat(auto_conf.data, &auto_conf_st);
|
||||
|
||||
/*
|
||||
* Set umask so the temporary file is created in the same mode as the original
|
||||
* postgresql.auto.conf file.
|
||||
*/
|
||||
um = umask(~(auto_conf_st.st_mode));
|
||||
fp = fopen(auto_conf_tmp.data, "w");
|
||||
umask(um);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user