]> granicus.if.org Git - postgresql/commit
Refactor dir/file permissions
authorStephen Frost <sfrost@snowman.net>
Sat, 7 Apr 2018 21:45:39 +0000 (17:45 -0400)
committerStephen Frost <sfrost@snowman.net>
Sat, 7 Apr 2018 21:45:39 +0000 (17:45 -0400)
commitda9b580d89903fee871cf54845ffa2b26bda2e11
treec2538c675c15e973c662e58a94fdecd77aa06b2a
parent499be013de65242235ebdde06adb08db887f0ea5
Refactor dir/file permissions

Consolidate directory and file create permissions for tools which work
with the PG data directory by adding a new module (common/file_perm.c)
that contains variables (pg_file_create_mode, pg_dir_create_mode) and
constants to initialize them (0600 for files and 0700 for directories).

Convert mkdir() calls in the backend to MakePGDirectory() if the
original call used default permissions (always the case for regular PG
directories).

Add tests to make sure permissions in PGDATA are set correctly by the
tools which modify the PG data directory.

Authors: David Steele <david@pgmasters.net>,
         Adam Brightwell <adam.brightwell@crunchydata.com>
Reviewed-By: Michael Paquier, with discussion amongst many others.
Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net
34 files changed:
src/backend/access/transam/xlog.c
src/backend/commands/tablespace.c
src/backend/postmaster/postmaster.c
src/backend/postmaster/syslogger.c
src/backend/replication/basebackup.c
src/backend/replication/slot.c
src/backend/storage/file/copydir.c
src/backend/storage/file/fd.c
src/backend/storage/ipc/dsm_impl.c
src/backend/storage/ipc/ipc.c
src/backend/utils/init/miscinit.c
src/bin/initdb/initdb.c
src/bin/initdb/t/001_initdb.pl
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/bin/pg_basebackup/t/020_pg_receivewal.pl
src/bin/pg_basebackup/walmethods.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_ctl/t/001_start_stop.pl
src/bin/pg_resetwal/pg_resetwal.c
src/bin/pg_resetwal/t/001_basic.pl
src/bin/pg_rewind/RewindTest.pm
src/bin/pg_rewind/file_ops.c
src/bin/pg_rewind/t/001_basic.pl
src/bin/pg_upgrade/file.c
src/bin/pg_upgrade/pg_upgrade.c
src/bin/pg_upgrade/test.sh
src/common/Makefile
src/common/file_perm.c [new file with mode: 0644]
src/include/common/file_perm.h [new file with mode: 0644]
src/include/storage/fd.h
src/test/perl/PostgresNode.pm
src/test/perl/TestLib.pm
src/tools/msvc/Mkvcbuild.pm