Skip site navigation (1) Skip section navigation (2)

pgsql: Allow non-superusers to create (some) extensions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow non-superusers to create (some) extensions.
Date: 2011-03-04 21:09:07
Message-ID: E1PvcFH-0004GZ-PO@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Allow non-superusers to create (some) extensions.

Remove the unconditional superuser permissions check in CREATE EXTENSION,
and instead define a "superuser" extension property, which when false
(not the default) skips the superuser permissions check.  In this case
the calling user only needs enough permissions to execute the commands
in the extension's installation script.  The superuser property is also
enforced in the same way for ALTER EXTENSION UPDATE cases.

In other ALTER EXTENSION cases and DROP EXTENSION, test ownership of
the extension rather than superuserness.  ALTER EXTENSION ADD/DROP needs
to insist on ownership of the target object as well; to do that without
duplicating code, refactor comment.c's big switch for permissions checks
into a separate function in objectaddress.c.

I also removed the superuserness checks in pg_available_extensions and
related functions; there's no strong reason why everybody shouldn't
be able to see that info.

Also invent an IF NOT EXISTS variant of CREATE EXTENSION, and use that
in pg_dump, so that dumps won't fail for installed-by-default extensions.
We don't have any of those yet, but we will soon.

This is all per discussion of wrapping the standard procedural languages
into extensions.  I'll make those changes in a separate commit; this is
just putting the core infrastructure in place.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/8d3b421f5f7b955e7ac7d156aa74ee6a6fe4e9f6

Modified Files
--------------
doc/src/sgml/catalogs.sgml             |   14 ++-
doc/src/sgml/extend.sgml               |   13 ++
doc/src/sgml/ref/alter_extension.sgml  |    4 +-
doc/src/sgml/ref/create_extension.sgml |   21 +++-
doc/src/sgml/ref/drop_extension.sgml   |    2 +-
src/backend/catalog/aclchk.c           |   47 +++++++
src/backend/catalog/objectaddress.c    |  151 ++++++++++++++++++++++
src/backend/catalog/system_views.sql   |    2 +-
src/backend/commands/comment.c         |  222 ++++----------------------------
src/backend/commands/extension.c       |  185 +++++++++++++++------------
src/backend/nodes/copyfuncs.c          |    1 +
src/backend/nodes/equalfuncs.c         |    1 +
src/backend/parser/gram.y              |    9 ++
src/bin/pg_dump/pg_dump.c              |   16 ++-
src/include/catalog/catversion.h       |    2 +-
src/include/catalog/objectaddress.h    |    6 +-
src/include/catalog/pg_proc.h          |    2 +-
src/include/nodes/parsenodes.h         |    1 +
src/include/utils/acl.h                |    2 +
src/test/regress/expected/rules.out    |    2 +-
20 files changed, 410 insertions(+), 293 deletions(-)

pgsql-committers by date

Next:From: Peter EisentrautDate: 2011-03-04 21:43:03
Subject: pgsql: Don't allow CREATE TABLE AS to create a column with invalidcoll
Previous:From: Peter EisentrautDate: 2011-03-04 20:16:08
Subject: pgsql: When creating a collation, check that the locales can be loaded

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group