Skip to content

Commit aee8a60

Browse files
committed
Remove ALTER DEFAULT PRIVILEGES' requirement of schema CREATE permissions.
Per discussion, this restriction isn't needed for any real security reason, and it seems to confuse people more often than it helps them. It could also result in some database states being unrestorable. So just drop it. Back-patch to 9.0, where ALTER DEFAULT PRIVILEGES was introduced.
1 parent 8c3fdbb commit aee8a60

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

doc/src/sgml/ref/alter_default_privileges.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ REVOKE [ GRANT OPTION FOR ]
111111
<term><replaceable>schema_name</replaceable></term>
112112
<listitem>
113113
<para>
114-
The name of an existing schema. Each <replaceable>target_role</>
115-
must have <literal>CREATE</> privileges for each specified schema.
114+
The name of an existing schema. If specified, the default privileges
115+
are altered for objects later created in that schema.
116116
If <literal>IN SCHEMA</> is omitted, the global default privileges
117117
are altered.
118118
</para>

src/backend/catalog/aclchk.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -992,27 +992,26 @@ SetDefaultACLsInSchemas(InternalDefaultACL *iacls, List *nspnames)
992992
}
993993
else
994994
{
995-
/* Look up the schema OIDs and do permissions checks */
995+
/* Look up the schema OIDs and set permissions for each one */
996996
ListCell *nspcell;
997997

998998
foreach(nspcell, nspnames)
999999
{
10001000
char *nspname = strVal(lfirst(nspcell));
1001-
AclResult aclresult;
10021001

1003-
/*
1004-
* Note that we must do the permissions check against the target
1005-
* role not the calling user. We require CREATE privileges, since
1006-
* without CREATE you won't be able to do anything using the
1007-
* default privs anyway.
1008-
*/
10091002
iacls->nspid = get_namespace_oid(nspname, false);
10101003

1011-
aclresult = pg_namespace_aclcheck(iacls->nspid, iacls->roleid,
1012-
ACL_CREATE);
1013-
if (aclresult != ACLCHECK_OK)
1014-
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
1015-
nspname);
1004+
/*
1005+
* We used to insist that the target role have CREATE privileges
1006+
* on the schema, since without that it wouldn't be able to create
1007+
* an object for which these default privileges would apply.
1008+
* However, this check proved to be more confusing than helpful,
1009+
* and it also caused certain database states to not be
1010+
* dumpable/restorable, since revoking CREATE doesn't cause
1011+
* default privileges for the schema to go away. So now, we just
1012+
* allow the ALTER; if the user lacks CREATE he'll find out when
1013+
* he tries to create an object.
1014+
*/
10161015

10171016
SetDefaultACL(iacls);
10181017
}

0 commit comments

Comments
 (0)