mirror of
https://github.com/postgres/postgres.git
synced 2025-08-08 06:02:22 +03:00
Allow group access on PGDATA
Allow the cluster to be optionally init'd with read access for the group. This means a relatively non-privileged user can perform a backup of the cluster without requiring write privileges, which enhances security. The mode of PGDATA is used to determine whether group permissions are enabled for directory and file creates. This method was chosen as it's simple and works well for the various utilities that write into PGDATA. Changing the mode of PGDATA manually will not automatically change the mode of all the files contained therein. If the user would like to enable group access on an existing cluster then changing the mode of all the existing files will be required. Note that pg_upgrade will automatically change the mode of all migrated files if the new cluster is init'd with the -g option. Tests are included for the backend and all the utilities which operate on the PG data directory to ensure that the correct mode is set based on the data directory permissions. Author: David Steele <david@pgmasters.net> Reviewed-By: Michael Paquier, with discussion amongst many others. Discussion: https://postgr.es/m/ad346fe6-b23e-59f1-ecb7-0e08390ad629%40pgmasters.net
This commit is contained in:
@@ -2,9 +2,11 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use Config;
|
||||
use Fcntl ':mode';
|
||||
use File::stat qw{lstat};
|
||||
use PostgresNode;
|
||||
use TestLib;
|
||||
use Test::More tests => 21;
|
||||
use Test::More tests => 24;
|
||||
|
||||
my $tempdir = TestLib::tempdir;
|
||||
my $tempdir_short = TestLib::tempdir_short;
|
||||
@@ -74,6 +76,27 @@ SKIP:
|
||||
ok(check_mode_recursive("$tempdir/data", 0700, 0600));
|
||||
}
|
||||
|
||||
# Log file for group access test
|
||||
$logFileName = "$tempdir/data/perm-test-640.log";
|
||||
|
||||
SKIP:
|
||||
{
|
||||
skip "group access not supported on Windows", 3 if ($windows_os);
|
||||
|
||||
system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/data";
|
||||
|
||||
# Change the data dir mode so log file will be created with group read
|
||||
# privileges on the next start
|
||||
chmod_recursive("$tempdir/data", 0750, 0640);
|
||||
|
||||
command_ok(
|
||||
[ 'pg_ctl', 'start', '-D', "$tempdir/data", '-l', $logFileName ],
|
||||
'start server to check group permissions');
|
||||
|
||||
ok(-f $logFileName);
|
||||
ok(check_mode_recursive("$tempdir/data", 0750, 0640));
|
||||
}
|
||||
|
||||
command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ],
|
||||
'pg_ctl restart with server running');
|
||||
|
||||
|
Reference in New Issue
Block a user