summaryrefslogtreecommitdiff
path: root/src/backend/catalog
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-05-26 18:35:51 +0000
committerBruce Momjian <bruce@momjian.us>2004-05-26 18:35:51 +0000
commit97d625dd1cf766e25815e1f6d5e5ee845f7b1030 (patch)
tree080dafb65de8c0537cb59e7ac76e87e91e91ea21 /src/backend/catalog
parent51227f8d9db81237a3da8133fa0dc5e39d9fc905 (diff)
downloadpostgresql-97d625dd1cf766e25815e1f6d5e5ee845f7b1030.tar.gz
*) inet_(client|server)_(addr|port)() and necessary documentation for
the four functions. > Also, please justify the temp-related changes. I was not aware that we > had any breakage there. patch-tmp-schema.txt contains the following bits: *) Changes pg_namespace_aclmask() so that the superuser is always able to create objects in the temp namespace. *) Changes pg_namespace_aclmask() so that if this is a temp namespace, objects are only allowed to be created in the temp namespace if the user has TEMP privs on the database. This encompasses all object creation, not just TEMP tables. *) InitTempTableNamespace() checks to see if the current user, not the session user, has access to create a temp namespace. The first two changes are necessary to support the third change. Now it's possible to revoke all temp table privs from non-super users and limiting all creation of temp tables/schemas via a function that's executed with elevated privs (security definer). Before this change, it was not possible to have a setuid function to create a temp table/schema if the session user had no TEMP privs. patch-area-path.txt contains: *) Can now determine the area of a closed path. patch-dfmgr.txt contains: *) Small tweak to add the library path that's being expanded. I was using $lib/foo.so and couldn't easily figure out what the error message, "invalid macro name in dynamic library path" meant without looking through the source code. With the path in there, at least I know where to start looking in my config file. Sean Chittenden
Diffstat (limited to 'src/backend/catalog')
-rw-r--r--src/backend/catalog/aclchk.c26
-rw-r--r--src/backend/catalog/namespace.c10
2 files changed, 23 insertions, 13 deletions
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cabeb69088..cc64d70930 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.99 2004/05/26 04:41:06 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.100 2004/05/26 18:35:32 momjian Exp $
*
* NOTES
* See acl.h.
@@ -1342,18 +1342,28 @@ pg_namespace_aclmask(Oid nsp_oid, AclId userid,
bool isNull;
Acl *acl;
- /*
- * If we have been assigned this namespace as a temp namespace, assume
- * we have all grantable privileges on it.
- */
- if (isTempNamespace(nsp_oid))
- return mask;
-
/* Superusers bypass all permission checking. */
if (superuser_arg(userid))
return mask;
/*
+ * If we have been assigned this namespace as a temp
+ * namespace, check to make sure we have CREATE permissions on
+ * the database.
+ *
+ * Instead of returning ACLCHECK_NO_PRIV, should we return via
+ * ereport() with a message about trying to create an object
+ * in a TEMP namespace when GetUserId() doesn't have perms?
+ */
+ if (isTempNamespace(nsp_oid)) {
+ if (pg_database_aclcheck(MyDatabaseId, GetUserId(),
+ ACL_CREATE_TEMP) == ACLCHECK_OK)
+ return ACLCHECK_OK;
+ else
+ return ACLCHECK_NO_PRIV;
+ }
+
+ /*
* Get the schema's ACL from pg_namespace
*/
tuple = SearchSysCache(NAMESPACEOID,
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index e9b5a35ba7..1b59e81a4c 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.64 2004/05/26 04:41:07 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.65 2004/05/26 18:35:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1640,11 +1640,11 @@ InitTempTableNamespace(void)
* tables. We use a nonstandard error message here since
* "databasename: permission denied" might be a tad cryptic.
*
- * Note we apply the check to the session user, not the currently active
- * userid, since we are not going to change our minds about temp table
- * availability during the session.
+ * ACL_CREATE_TEMP perms are also checked in
+ * pg_namespace_aclcheck() that way only users who have TEMP
+ * perms can create objects.
*/
- if (pg_database_aclcheck(MyDatabaseId, GetSessionUserId(),
+ if (pg_database_aclcheck(MyDatabaseId, GetUserId(),
ACL_CREATE_TEMP) != ACLCHECK_OK)
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),