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.
This commit is contained in:
Ian Barwick
2019-04-09 10:51:36 +09:00
parent 68470a9167
commit 7aaac343f8
3 changed files with 28 additions and 0 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -46,6 +46,14 @@
</para>
</listitem>
<listitem>
<para>
&repmgr;: when executing <link linkend="repmgr-standby-clone"><command>repmgr standby clone</command></link>
in <option>--dry-run</option> mode, ensure provision of the <option>--force</option> option
does not result in an existing data directory being modified in any way.
</para>
</listitem>
</itemizedlist>
</para>
</sect2>