aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/user.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-03-09 14:34:56 -0500
committerRobert Haas <rhaas@postgresql.org>2012-03-09 14:34:56 -0500
commit07d1edb954bc8f5d0e2c010dec8482328af38cb8 (patch)
tree64418e4a346496da207c943b460cd692775f971d /src/backend/commands/user.c
parentb14953932dfdda7d915b9e276a09df8458efeec8 (diff)
downloadpostgresql-07d1edb954bc8f5d0e2c010dec8482328af38cb8.tar.gz
postgresql-07d1edb954bc8f5d0e2c010dec8482328af38cb8.zip
Extend object access hook framework to support arguments, and DROP.
This allows loadable modules to get control at drop time, perhaps for the purpose of performing additional security checks or to log the event. The initial purpose of this code is to support sepgsql, but other applications should be possible as well. KaiGai Kohei, reviewed by me.
Diffstat (limited to 'src/backend/commands/user.c')
-rw-r--r--src/backend/commands/user.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 9a88c907894..2edbabe7549 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -425,7 +425,8 @@ CreateRole(CreateRoleStmt *stmt)
GetUserId(), false);
/* Post creation hook for new role */
- InvokeObjectAccessHook(OAT_POST_CREATE, AuthIdRelationId, roleid, 0);
+ InvokeObjectAccessHook(OAT_POST_CREATE,
+ AuthIdRelationId, roleid, 0, NULL);
/*
* Close pg_authid, but keep lock till commit.
@@ -932,6 +933,15 @@ DropRole(DropRoleStmt *stmt)
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to drop superusers")));
+ /* DROP hook for the role being removed */
+ if (object_access_hook)
+ {
+ ObjectAccessDrop drop_arg;
+ memset(&drop_arg, 0, sizeof(ObjectAccessDrop));
+ InvokeObjectAccessHook(OAT_DROP,
+ AuthIdRelationId, roleid, 0, &drop_arg);
+ }
+
/*
* Lock the role, so nobody can add dependencies to her while we drop
* her. We keep the lock until the end of transaction.