Skip to content

Commit 9752436

Browse files
committed
Use has_privs_for_roles for predefined role checks: round 2
Similar to commit 6198420, replace is_member_of_role with has_privs_for_role for predefined role access checks in recently committed basebackup code. In passing fix a double-word error in a nearby comment. Discussion: https://postgr.es/m/flat/CAGB+Vh4Zv_TvKt2tv3QNS6tUM_F_9icmuj0zjywwcgVi4PAhFA@mail.gmail.com
1 parent cfdd03f commit 9752436

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

contrib/basebackup_to_shell/basebackup_to_shell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ _PG_init(void)
9090
}
9191

9292
/*
93-
* We choose to defer sanity sanity checking until shell_get_sink(), and so
93+
* We choose to defer sanity checking until shell_get_sink(), and so
9494
* just pass the target detail through without doing anything. However, we do
9595
* permissions checks here, before any real work has been done.
9696
*/
@@ -103,7 +103,7 @@ shell_check_detail(char *target, char *target_detail)
103103

104104
StartTransactionCommand();
105105
roleid = get_role_oid(shell_required_role, true);
106-
if (!is_member_of_role(GetUserId(), roleid))
106+
if (!has_privs_of_role(GetUserId(), roleid))
107107
ereport(ERROR,
108108
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
109109
errmsg("permission denied to use basebackup_to_shell")));

doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ PostgreSQL documentation
237237
<literal>server:/some/path</literal>, the backup will be stored on
238238
the machine where the server is running in the
239239
<literal>/some/path</literal> directory. Storing a backup on the
240-
server requires superuser privileges or being granted the
240+
server requires superuser privileges or having privileges of the
241241
<literal>pg_write_server_files</literal> role. If the target is set to
242242
<literal>blackhole</literal>, the contents are discarded and not
243243
stored anywhere. This should only be used for testing purposes, as you

src/backend/replication/basebackup_server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ bbsink_server_new(bbsink *next, char *pathname)
6969

7070
/* Replication permission is not sufficient in this case. */
7171
StartTransactionCommand();
72-
if (!is_member_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
72+
if (!has_privs_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
7373
ereport(ERROR,
7474
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
75-
errmsg("must be superuser or a member of the pg_write_server_files role to create server backup")));
75+
errmsg("must be superuser or a role with privileges of the pg_write_server_files role to create server backup")));
7676
CommitTransactionCommand();
7777

7878
/*

0 commit comments

Comments
 (0)