1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-14 06:54:15 +02:00

limit tablespace permissions kludge to only PG11

This commit is contained in:
Grigory Smolkin
2019-05-27 18:22:25 +03:00
parent 64d5d32fff
commit ca02ecade0

View File

@ -939,6 +939,7 @@ opt_externaldir_map(ConfigOption *opt, const char *arg)
* Enforce permissions from backup_content.control. The only * Enforce permissions from backup_content.control. The only
* problem now is with PGDATA itself. * problem now is with PGDATA itself.
* TODO: we must preserve PGDATA permissions somewhere. Is it actually a problem? * TODO: we must preserve PGDATA permissions somewhere. Is it actually a problem?
* Shouldn`t starting postgres force correct permissions on PGDATA?
* *
* TODO: symlink handling. If user located symlink in PG_TBLSPC_DIR, it will * TODO: symlink handling. If user located symlink in PG_TBLSPC_DIR, it will
* be restored as directory. * be restored as directory.
@ -949,11 +950,29 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
{ {
int i; int i;
parray *links = NULL; parray *links = NULL;
mode_t pg_tablespace_mode = 0; mode_t pg_tablespace_mode = DIR_PERMISSION;
char to_path[MAXPGPATH]; char to_path[MAXPGPATH];
/* Ugly: get PG_TBLSPC_DIR pemission mask. /* get tablespace map */
* We will use it to set permissions for tablespace directories. if (extract_tablespaces)
{
links = parray_new();
read_tablespace_map(links, backup_dir);
/* Sort links by a link name */
parray_qsort(links, pgFileCompareName);
}
/*
* We have no idea about tablespace permission
* For PG < 11 we can just force default permissions.
*/
#if PG_VERSION_NUM >= 110000
if (links)
{
/* For PG>=11 we use temp kludge: trust permissions on 'pg_tblspc'
* and force them on every tablespace.
* TODO: remove kludge and ask data_directory_mode
* at the start of backup.
*/ */
for (i = 0; i < parray_num(dest_files); i++) for (i = 0; i < parray_num(dest_files); i++)
{ {
@ -973,19 +992,8 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
break; break;
} }
} }
/* sanity */
if (!pg_tablespace_mode)
pg_tablespace_mode = DIR_PERMISSION;
/* get tablespace map */
if (extract_tablespaces)
{
links = parray_new();
read_tablespace_map(links, backup_dir);
/* Sort links by a link name */
parray_qsort(links, pgFileCompareName);
} }
#endif
/* /*
* We iterate over dest_files and for every directory with parent 'pg_tblspc' * We iterate over dest_files and for every directory with parent 'pg_tblspc'