aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorItagaki Takahiro <itagaki.takahiro@gmail.com>2009-12-11 03:34:57 +0000
committerItagaki Takahiro <itagaki.takahiro@gmail.com>2009-12-11 03:34:57 +0000
commitf1325ce213ae1843d2ee636ff6780c3f8ac9ada6 (patch)
tree2fab9db3d075fcca27a87e92a9be02263865b93a /src/backend/commands
parent64579962bbe522bf9ced8e4ed712b9072fb89142 (diff)
downloadpostgresql-f1325ce213ae1843d2ee636ff6780c3f8ac9ada6.tar.gz
postgresql-f1325ce213ae1843d2ee636ff6780c3f8ac9ada6.zip
Add large object access control.
A new system catalog pg_largeobject_metadata manages ownership and access privileges of large objects. KaiGai Kohei, reviewed by Jaime Casanova.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/alter.c7
-rw-r--r--src/backend/commands/comment.c19
-rw-r--r--src/backend/commands/tablecmds.c3
3 files changed, 25 insertions, 4 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index b91f2205d1c..8ba630a83db 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -8,13 +8,14 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.31 2009/01/01 17:23:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.32 2009/12/11 03:34:55 itagaki Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/namespace.h"
+#include "catalog/pg_largeobject.h"
#include "commands/alter.h"
#include "commands/conversioncmds.h"
#include "commands/dbcommands.h"
@@ -233,6 +234,10 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
AlterLanguageOwner(strVal(linitial(stmt->object)), newowner);
break;
+ case OBJECT_LARGEOBJECT:
+ LargeObjectAlterOwner(intVal(linitial(stmt->object)), newowner);
+ break;
+
case OBJECT_OPERATOR:
Assert(list_length(stmt->objarg) == 2);
AlterOperatorOwner(stmt->object,
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 610816db6d0..d57ea25d9ca 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -7,7 +7,7 @@
* Copyright (c) 1996-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.108 2009/10/12 19:49:24 adunstan Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.109 2009/12/11 03:34:55 itagaki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,6 +25,7 @@
#include "catalog/pg_description.h"
#include "catalog/pg_language.h"
#include "catalog/pg_largeobject.h"
+#include "catalog/pg_largeobject_metadata.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
@@ -42,6 +43,7 @@
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "commands/tablespace.h"
+#include "libpq/be-fsstubs.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "parser/parse_func.h"
@@ -1435,7 +1437,20 @@ CommentLargeObject(List *qualname, char *comment)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("large object %u does not exist", loid)));
- /* Call CreateComments() to create/drop the comments */
+ /* Permission checks */
+ if (!lo_compat_privileges &&
+ !pg_largeobject_ownercheck(loid, GetUserId()))
+ ereport(ERROR,
+ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ errmsg("must be owner of large object %u", loid)));
+
+ /*
+ * Call CreateComments() to create/drop the comments
+ *
+ * See the comment in the inv_create() which describes
+ * the reason why LargeObjectRelationId is used instead
+ * of the LargeObjectMetadataRelationId.
+ */
CreateComments(loid, LargeObjectRelationId, 0, comment);
}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index c9188b2d7c6..2344b79547b 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.308 2009/12/09 21:57:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.309 2009/12/11 03:34:55 itagaki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -6186,6 +6186,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
case OCLASS_CAST:
case OCLASS_CONVERSION:
case OCLASS_LANGUAGE:
+ case OCLASS_LARGEOBJECT:
case OCLASS_OPERATOR:
case OCLASS_OPCLASS:
case OCLASS_OPFAMILY: