Skip to content

Commit c33d575

Browse files
committed
More cleanup on roles patch. Allow admin option to be inherited through
role memberships; make superuser/createrole distinction do something useful; fix some locking and CommandCounterIncrement issues; prevent creation of loops in the membership graph.
1 parent 4523e0b commit c33d575

File tree

7 files changed

+534
-311
lines changed

7 files changed

+534
-311
lines changed

src/backend/commands/dbcommands.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.162 2005/06/28 05:08:53 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.163 2005/06/29 20:34:13 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -194,8 +194,8 @@ createdb(const CreatedbStmt *stmt)
194194

195195
if (is_member_of_role(GetUserId(), datdba))
196196
{
197-
/* creating database for self: can be superuser or createdb */
198-
if (!superuser() && !have_createdb_privilege())
197+
/* creating database for self: createdb is required */
198+
if (!have_createdb_privilege())
199199
ereport(ERROR,
200200
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
201201
errmsg("permission denied to create database")));
@@ -759,7 +759,7 @@ RenameDatabase(const char *oldname, const char *newname)
759759
oldname);
760760

761761
/* must have createdb rights */
762-
if (!superuser() && !have_createdb_privilege())
762+
if (!have_createdb_privilege())
763763
ereport(ERROR,
764764
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
765765
errmsg("permission denied to rename database")));
@@ -1044,6 +1044,10 @@ have_createdb_privilege(void)
10441044
bool result = false;
10451045
HeapTuple utup;
10461046

1047+
/* Superusers can always do everything */
1048+
if (superuser())
1049+
return true;
1050+
10471051
utup = SearchSysCache(AUTHOID,
10481052
ObjectIdGetDatum(GetUserId()),
10491053
0, 0, 0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy