From ef47589c6b0213b7272fa9baa40c4c85878c501b Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 9 Apr 2019 10:51:36 +0900 Subject: [PATCH] standby clone: always ensure directory is created with correct permissions In Barman mode, if there is an existing, populated data directory, and the "--force" option is provided, the entire directory was being deleted, and later recreated as part of the rsync process, but with the default permissions. Fix this by recreating the data directory with the correct permissions after deleting it. --- HISTORY | 2 ++ dirutil.c | 18 ++++++++++++++++++ doc/appendix-release-notes.sgml | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/HISTORY b/HISTORY index 72f97337..725b848a 100644 --- a/HISTORY +++ b/HISTORY @@ -2,6 +2,8 @@ repmgr: ensure BDR2-specific functionality cannot be used on BDR3 and later (Ian) repmgr: improve --dry-run behaviour in barman mode (Ian) + repmgr: fix data directory permissions issue in barman mode where + an existing directory is being overwritten (Ian) 4.3 2019-04-02 repmgr: add "daemon (start|stop)" command; GitHub #528 (Ian) diff --git a/dirutil.c b/dirutil.c index 356c1a55..be199288 100644 --- a/dirutil.c +++ b/dirutil.c @@ -336,6 +336,15 @@ create_pg_dir(const char *path, bool force) { log_notice(_("-F/--force provided - deleting existing data directory \"%s\""), path); nftw(path, unlink_dir_callback, 64, FTW_DEPTH | FTW_PHYS); + + /* recreate the directory ourselves to ensure permissions are correct */ + if (!create_dir(path)) + { + log_error(_("unable to create directory \"%s\"..."), + path); + return false; + } + return true; } @@ -347,6 +356,15 @@ create_pg_dir(const char *path, bool force) { log_notice(_("deleting existing directory \"%s\""), path); nftw(path, unlink_dir_callback, 64, FTW_DEPTH | FTW_PHYS); + + /* recreate the directory ourselves to ensure permissions are correct */ + if (!create_dir(path)) + { + log_error(_("unable to create directory \"%s\"..."), + path); + return false; + } + return true; } return false; diff --git a/doc/appendix-release-notes.sgml b/doc/appendix-release-notes.sgml index 95d118e6..f12b5862 100644 --- a/doc/appendix-release-notes.sgml +++ b/doc/appendix-release-notes.sgml @@ -46,6 +46,14 @@ + + + &repmgr;: when executing repmgr standby clone + in mode, ensure provision of the option + does not result in an existing data directory being modified in any way. + + +