Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d4e2a84

Browse files
committed
Switch TAP tests of pg_rewind to use a role with minimal permissions
Up to now the tests of pg_rewind have been using a superuser for all the tests (which is the default of many tests actually, and something that ought to be reviewed) when involving an online source server, still it is possible to use a non-superuser role to do that as long as this role is granted permissions to execute all the source-side functions used for the rewind. This is possible since v11, and was already documented as of bfc8068. This will allow to catch up easily any change in pg_rewind if the tool begins to use more backend-side functions, so as the properties introduced by v11 are kept. Per suggestion from Peter Eisentraut. Author: Michael Paquier Reviewed-by: Magnus Hagander Discussion: https://postgr.es/m/20190411041336.GM2728@paquier.xyz
1 parent d527fda commit d4e2a84

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bin/pg_rewind/t/RewindTest.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ sub start_master
144144
{
145145
$node_master->start;
146146

147+
# Create a custom role which will be used to run pg_rewind. This
148+
# role is used for all the tests, and has minimal permissions enough
149+
# to rewind from an online source.
150+
$node_master->psql('postgres', "
151+
CREATE ROLE rewind_user LOGIN;
152+
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean)
153+
TO rewind_user;
154+
GRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean)
155+
TO rewind_user;
156+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text)
157+
TO rewind_user;
158+
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean)
159+
TO rewind_user;");
160+
147161
#### Now run the test-specific parts to initialize the master before setting
148162
# up standby
149163

@@ -207,6 +221,9 @@ sub run_pg_rewind
207221
my $standby_connstr = $node_standby->connstr('postgres');
208222
my $tmp_folder = TestLib::tempdir;
209223

224+
# Append the rewind-specific role to the connection string.
225+
$standby_connstr = "$standby_connstr user=rewind_user";
226+
210227
# Stop the master and be ready to perform the rewind
211228
$node_master->stop;
212229

0 commit comments

Comments
 (0)