aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/user.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-11-03 15:41:32 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-11-03 15:41:32 -0500
commit136f87ea57b3a7a6bf64c832a5e1b69e18091775 (patch)
treea829959f5cf65ea45618d4ab61718fb7e783a202 /src/backend/commands/user.c
parentd3befe9b98d523d7ae04d93c295001385550e4a3 (diff)
downloadpostgresql-136f87ea57b3a7a6bf64c832a5e1b69e18091775.tar.gz
postgresql-136f87ea57b3a7a6bf64c832a5e1b69e18091775.zip
Allow users with BYPASSRLS to alter their own passwords.
The intention in commit 491c029db was to require superuserness to change the BYPASSRLS property, but the actual effect of the coding in AlterRole() was to require superuserness to change anything at all about a BYPASSRLS role. Other properties of a BYPASSRLS role should be changeable under the same rules as for a normal role, though. Fix that, and also take care of some documentation omissions related to BYPASSRLS and REPLICATION role properties. Tom Lane and Stephen Frost, per bug report from Wolfgang Walther. Back-patch to all supported branches. Discussion: https://postgr.es/m/a5548a9f-89ee-3167-129d-162b5985fcf8@technowledgy.de
Diffstat (limited to 'src/backend/commands/user.c')
-rw-r--r--src/backend/commands/user.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 770633aec23..85fb57f4b1d 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -709,8 +709,10 @@ AlterRole(AlterRoleStmt *stmt)
roleid = authform->oid;
/*
- * To mess with a superuser you gotta be superuser; else you need
- * createrole, or just want to change your own password
+ * To mess with a superuser or replication role in any way you gotta be
+ * superuser. We also insist on superuser to change the BYPASSRLS
+ * property. Otherwise, if you don't have createrole, you're only allowed
+ * to change your own password.
*/
if (authform->rolsuper || issuper >= 0)
{
@@ -726,7 +728,7 @@ AlterRole(AlterRoleStmt *stmt)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to alter replication users")));
}
- else if (authform->rolbypassrls || bypassrls >= 0)
+ else if (bypassrls >= 0)
{
if (!superuser())
ereport(ERROR,
@@ -735,11 +737,11 @@ AlterRole(AlterRoleStmt *stmt)
}
else if (!have_createrole_privilege())
{
+ /* We already checked issuper, isreplication, and bypassrls */
if (!(inherit < 0 &&
createrole < 0 &&
createdb < 0 &&
canlogin < 0 &&
- isreplication < 0 &&
!dconnlimit &&
!rolemembers &&
!validUntil &&