mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 00:46:29 +00:00
repmgr: Explicitly set permissions on recovery.conf to 0600
Per GitHub #236 (dmarck)
This commit is contained in:
5
repmgr.c
5
repmgr.c
@@ -5379,10 +5379,15 @@ create_recovery_file(const char *data_dir, t_conninfo_param_list *upstream_conni
|
|||||||
FILE *recovery_file;
|
FILE *recovery_file;
|
||||||
char recovery_file_path[MAXLEN];
|
char recovery_file_path[MAXLEN];
|
||||||
char line[MAXLEN];
|
char line[MAXLEN];
|
||||||
|
mode_t um;
|
||||||
|
|
||||||
maxlen_snprintf(recovery_file_path, "%s/%s", data_dir, RECOVERY_COMMAND_FILE);
|
maxlen_snprintf(recovery_file_path, "%s/%s", data_dir, RECOVERY_COMMAND_FILE);
|
||||||
|
|
||||||
|
/* Set umask to 0600 */
|
||||||
|
um = umask((~(S_IRUSR | S_IWUSR)) & (S_IRWXG | S_IRWXO));
|
||||||
recovery_file = fopen(recovery_file_path, "w");
|
recovery_file = fopen(recovery_file_path, "w");
|
||||||
|
umask(um);
|
||||||
|
|
||||||
if (recovery_file == NULL)
|
if (recovery_file == NULL)
|
||||||
{
|
{
|
||||||
log_err(_("unable to create recovery.conf file at '%s'\n"), recovery_file_path);
|
log_err(_("unable to create recovery.conf file at '%s'\n"), recovery_file_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user