summaryrefslogtreecommitdiff
path: root/src/backend/commands/user.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:44:51 +0000
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2010-03-25 14:44:51 +0000
commit08729b4e8aa3a27bf9b43a2dae6b962405f63222 (patch)
tree674bf428fa1036b3195877756528719fc1cd9b9e /src/backend/commands/user.c
parent505efe9917043eca815e07cccdbb95366700992f (diff)
Prevent ALTER USER f RESET ALL from removing the settings that were put there
by a superuser -- "ALTER USER f RESET setting" already disallows removing such a setting. Apply the same treatment to ALTER DATABASE d RESET ALL when run by a database owner that's not superuser.
Diffstat (limited to 'src/backend/commands/user.c')
-rw-r--r--src/backend/commands/user.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 6796a1f5e29..cabbb232a6f 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.187 2009/06/11 14:48:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.187.2.1 2010/03/25 14:44:51 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -772,9 +772,30 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
if (stmt->setstmt->kind == VAR_RESET_ALL)
{
- /* RESET ALL, so just set rolconfig to null */
- repl_null[Anum_pg_authid_rolconfig - 1] = true;
- repl_val[Anum_pg_authid_rolconfig - 1] = (Datum) 0;
+ ArrayType *new = NULL;
+ Datum datum;
+ bool isnull;
+
+ /*
+ * in RESET ALL, request GUC to reset the settings array; if none
+ * left, we can set rolconfig to null; otherwise use the returned
+ * array
+ */
+ datum = SysCacheGetAttr(AUTHNAME, oldtuple,
+ Anum_pg_authid_rolconfig, &isnull);
+ if (!isnull)
+ new = GUCArrayReset(DatumGetArrayTypeP(datum));
+ if (new)
+ {
+ repl_val[Anum_pg_authid_rolconfig - 1] = PointerGetDatum(new);
+ repl_repl[Anum_pg_authid_rolconfig - 1] = true;
+ repl_null[Anum_pg_authid_rolconfig - 1] = false;
+ }
+ else
+ {
+ repl_null[Anum_pg_authid_rolconfig - 1] = true;
+ repl_val[Anum_pg_authid_rolconfig - 1] = (Datum) 0;
+ }
}
else
{