From c0d4d5473a09cb7f6682a84abaee29e087c5886c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 8 Sep 2001 15:24:00 +0000 Subject: Make the world somewhat safe for (not from) DELETE FROM pg_shadow; Assign the fixed user id 1 to the user created by initdb. A stand-alone backend will always set the user id to 1. (Consequently, the name of that user is no longer important.) In stand-alone mode, the user id 1 will have implicit superuser status, to allow repairs even if there are no users defined. Print a warning message when starting in stand-alone mode when no users are defined. Disallow dropping the current user and session user. Granting/revoking superuser status also grants/revokes usecatupd. (Previously, it would never grant it back. This could lead to "deadlocks".) CREATE USER and CREATE GROUP will start allocating user ids at 100 (unless explicitly specified), to prevent accidental creation of a superuser (plus some room for future extensions). --- src/backend/utils/misc/superuser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/misc/superuser.c') diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index 73cfe8cb979..2f092028480 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.18 2001/06/13 21:44:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.19 2001/09/08 15:24:00 petere Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,10 @@ superuser(void) bool result = false; HeapTuple utup; + /* Special escape path in case you deleted all your users. */ + if (!IsUnderPostmaster && GetUserId() == BOOTSTRAP_USESYSID) + return true; + utup = SearchSysCache(SHADOWSYSID, ObjectIdGetDatum(GetUserId()), 0, 0, 0); -- cgit v1.2.3