rpms/sepostgresql/F-8 sepostgresql-8.2.6-1.patch, 1.2, 1.3 sepostgresql.init, 1.10, 1.11 sepostgresql.spec, 1.10, 1.11 sepostgresql.te, 1.10, 1.11

KaiGai Kohei (kaigai) fedora-extras-commits at redhat.com
Thu Feb 7 01:05:39 UTC 2008


Author: kaigai

Update of /cvs/pkgs/rpms/sepostgresql/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32212

Modified Files:
	sepostgresql-8.2.6-1.patch sepostgresql.init sepostgresql.spec 
	sepostgresql.te 
Log Message:
- bugfix: fopen() used incorrect flag, "rb" should be used.
- bugfix: blob:{read} is not evaluated correctly
- use system generic timezone data
- policy update: allow db_database:{get_param set_param}



sepostgresql-8.2.6-1.patch:

Index: sepostgresql-8.2.6-1.patch
===================================================================
RCS file: /cvs/pkgs/rpms/sepostgresql/F-8/sepostgresql-8.2.6-1.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sepostgresql-8.2.6-1.patch	22 Jan 2008 12:25:40 -0000	1.2
+++ sepostgresql-8.2.6-1.patch	7 Feb 2008 01:05:33 -0000	1.3
@@ -1913,7 +1913,7 @@
 +endif
 diff -rpNU3 base/src/backend/security/pgaceCommon.c sepgsql/src/backend/security/pgaceCommon.c
 --- base/src/backend/security/pgaceCommon.c	1970-01-01 09:00:00.000000000 +0900
-+++ sepgsql/src/backend/security/pgaceCommon.c	2008-01-22 21:11:17.000000000 +0900
++++ sepgsql/src/backend/security/pgaceCommon.c	2008-01-28 20:19:10.000000000 +0900
 @@ -0,0 +1,770 @@
 +/*
 + * src/backend/security/pgaceCommon.c
@@ -2196,7 +2196,7 @@
 +
 +	if (pg_security_state > 0)
 +		return true;
-+	if (IsBootstrapProcessingMode() || pg_security_state == 0)
++	if (IsBootstrapProcessingMode() || pg_security_state==0)
 +		return false;
 +	/*
 +	 * if initial setting up was not done, the cache file is remaining.
@@ -2205,7 +2205,7 @@
 +	 * the existance of 'EARLY_PG_SECURITY'.
 +	 */
 +	snprintf(fname, sizeof(fname), "%s/%s", DataDir, EARLY_PG_SECURITY);
-+	filp = fopen(fname, "a+");
++	filp = fopen(fname, "rb");
 +	if (filp) {
 +		Relation rel;
 +		CatalogIndexState ind;
@@ -2244,12 +2244,12 @@
 +		PG_CATCH();
 +		{
 +			fclose(filp);
-+			pg_security_state = -1;
 +			PG_RE_THROW();
 +		}
 +		PG_END_TRY();
 +		fclose(filp);
-+		unlink(fname);
++		if (unlink(fname) != 0)
++			elog(ERROR, "PGACE: could not unlink '%s'", fname);
 +	}
 +	pg_security_state = 1;
 +
@@ -3710,8 +3710,8 @@
 +}
 diff -rpNU3 base/src/backend/security/sepgsqlHooks.c sepgsql/src/backend/security/sepgsqlHooks.c
 --- base/src/backend/security/sepgsqlHooks.c	1970-01-01 09:00:00.000000000 +0900
-+++ sepgsql/src/backend/security/sepgsqlHooks.c	2008-01-22 21:11:17.000000000 +0900
-@@ -0,0 +1,678 @@
++++ sepgsql/src/backend/security/sepgsqlHooks.c	2008-01-30 17:08:18.000000000 +0900
+@@ -0,0 +1,681 @@
 +/*
 + * src/backend/sepgsqlHooks.c
 + *   SE-PostgreSQL hooks
@@ -3938,9 +3938,9 @@
 +	} else {
 +		selerror("unknown trigger event type (%u)", tgdata->tg_event);
 +	}
-+	if (oldtup && !sepgsqlCheckTuplePerms(rel, oldtup, NULL, DB_TUPLE__SELECT, false))
++	if (oldtup && !sepgsqlCheckTuplePerms(rel, oldtup, NULL, SEPGSQL_PERMS_SELECT, false))
 +		return false;
-+	if (newtup && !sepgsqlCheckTuplePerms(rel, newtup, NULL, DB_TUPLE__SELECT, false))
++	if (newtup && !sepgsqlCheckTuplePerms(rel, newtup, NULL, SEPGSQL_PERMS_SELECT, false))
 +		return false;
 +
 +	sepgsqlCallFunction(finfo, false);
@@ -4031,12 +4031,12 @@
 +
 +void sepgsqlLargeObjectOpen(Relation rel, HeapTuple tuple, bool read_only)
 +{
-+	sepgsqlCheckTuplePerms(rel, tuple, NULL, DB_TUPLE__SELECT, true);
++	sepgsqlCheckTuplePerms(rel, tuple, NULL, SEPGSQL_PERMS_SELECT, true);
 +}
 +
 +void sepgsqlLargeObjectRead(Relation rel, HeapTuple tuple)
 +{
-+	sepgsqlCheckTuplePerms(rel, tuple, NULL, DB_TUPLE__SELECT | DB_BLOB__READ, true);
++	sepgsqlCheckTuplePerms(rel, tuple, NULL, SEPGSQL_PERMS_SELECT | SEPGSQL_PERMS_READ, true);
 +}
 +
 +void sepgsqlLargeObjectWrite(Relation rel, HeapTuple newtup, HeapTuple oldtup)
@@ -4065,7 +4065,7 @@
 +		systable_endscan(sd);
 +	}
 +	HeapTupleSetSecurity(newtup, lo_security);
-+	sepgsqlCheckTuplePerms(rel, newtup, NULL, DB_TUPLE__UPDATE | DB_BLOB__WRITE, true);
++	sepgsqlCheckTuplePerms(rel, newtup, NULL, SEPGSQL_PERMS_UPDATE | SEPGSQL_PERMS_WRITE, true);
 +}
 +
 +void sepgsqlLargeObjectImport()
@@ -4266,14 +4266,14 @@
 +		newcon = sepgsqlComputeImplicitContext(rel, tuple);
 +		HeapTupleSetSecurity(tuple, newcon);
 +	}
-+	sepgsqlCheckTuplePerms(rel, tuple, NULL, DB_TUPLE__INSERT, true);
++	sepgsqlCheckTuplePerms(rel, tuple, NULL, SEPGSQL_PERMS_INSERT, true);
 +}
 +
 +void sepgsqlSimpleHeapUpdate(Relation rel, ItemPointer tid, HeapTuple newtup)
 +{
 +	HeapTuple oldtup;
 +	Oid ncon, ocon;
-+	uint32 perms = DB_TUPLE__UPDATE;
++	uint32 perms = SEPGSQL_PERMS_UPDATE;
 +
 +	if (!__is_simple_system_relation(rel))
 +		return;
@@ -4285,12 +4285,15 @@
 +		HeapTupleSetSecurity(newtup, ocon);
 +		ncon = ocon;
 +	}
-+	if (ncon != ocon)
-+		perms |= DB_TUPLE__RELABELFROM;
-+	sepgsqlCheckTuplePerms(rel, oldtup, NULL, perms, true);
 +
-+	perms = (ncon != ocon ? DB_TUPLE__RELABELTO : 0);
-+	sepgsqlCheckTuplePerms(rel, newtup, oldtup, perms, true);
++	if (ncon == ocon) {
++		sepgsqlCheckTuplePerms(rel, oldtup, NULL, perms, true);
++	} else {
++		perms |= SEPGSQL_PERMS_RELABELFROM;
++		sepgsqlCheckTuplePerms(rel, oldtup, NULL, perms, true);
++
++		sepgsqlCheckTuplePerms(rel, newtup, oldtup, SEPGSQL_PERMS_RELABELTO, true);
++	}
 +
 +	heap_freetuple(oldtup);
 +}
@@ -4303,7 +4306,7 @@
 +		return;
 +
 +	oldtup = __getHeapTupleFromItemPointer(rel, tid);
-+	sepgsqlCheckTuplePerms(rel, oldtup, NULL, DB_TUPLE__DELETE, true);
++	sepgsqlCheckTuplePerms(rel, oldtup, NULL, SEPGSQL_PERMS_DELETE, true);
 +	heap_freetuple(oldtup);
 +}
 +
@@ -4325,9 +4328,9 @@
 +		newcon = sepgsqlComputeImplicitContext(rel, tuple);
 +		HeapTupleSetSecurity(tuple, newcon);
 +	}
-+	perms = DB_TUPLE__INSERT;
++	perms = SEPGSQL_PERMS_INSERT;
 +	if (with_returning)
-+		perms |= DB_TUPLE__SELECT;
++		perms |= SEPGSQL_PERMS_SELECT;
 +
 +	return sepgsqlCheckTuplePerms(rel, tuple, NULL, perms, false);
 +}
@@ -4347,9 +4350,9 @@
 +		oldcon = newcon;
 +	}
 +	if (newcon != oldcon) {
-+		perms |= DB_TUPLE__RELABELTO;
++		perms |= SEPGSQL_PERMS_RELABELTO;
 +		if (with_returning)
-+			perms |= DB_TUPLE__SELECT;
++			perms |= SEPGSQL_PERMS_SELECT;
 +	}
 +	rc = sepgsqlCheckTuplePerms(rel, newtup, oldtup, perms, false);
 +
@@ -4392,8 +4395,8 @@
 +}
 diff -rpNU3 base/src/backend/security/sepgsqlPerms.c sepgsql/src/backend/security/sepgsqlPerms.c
 --- base/src/backend/security/sepgsqlPerms.c	1970-01-01 09:00:00.000000000 +0900
-+++ sepgsql/src/backend/security/sepgsqlPerms.c	2007-10-25 13:12:52.000000000 +0900
-@@ -0,0 +1,489 @@
++++ sepgsql/src/backend/security/sepgsqlPerms.c	2008-01-30 17:08:18.000000000 +0900
+@@ -0,0 +1,514 @@
 +/*
 + * src/backend/security/sepgsqlPerms.c
 + *   SE-PostgreSQL permission checking functions
@@ -4456,14 +4459,35 @@
 +	return t_security;
 +}
 +
-+static uint32 __tuple_perms_to_common_perms(uint32 perms) {
++static uint32 __sepgsql_perms_to_common_perms(uint32 perms) {
 +	uint32 __perms = 0;
-+	__perms |= (perms & DB_TUPLE__RELABELFROM ? COMMON_DATABASE__RELABELFROM : 0);
-+	__perms |= (perms & DB_TUPLE__RELABELTO ? COMMON_DATABASE__RELABELTO : 0);
-+	__perms |= (perms & DB_TUPLE__SELECT ? COMMON_DATABASE__GETATTR : 0);
-+    __perms |= (perms & DB_TUPLE__UPDATE ? COMMON_DATABASE__SETATTR : 0);
-+    __perms |= (perms & DB_TUPLE__INSERT ? COMMON_DATABASE__CREATE : 0);
-+    __perms |= (perms & DB_TUPLE__DELETE ? COMMON_DATABASE__DROP : 0);
++
++	Assert((perms & ~SEPGSQL_PERMS_ALL) == 0);
++	__perms |= (perms & SEPGSQL_PERMS_USE       ? COMMON_DATABASE__GETATTR : 0);
++	__perms |= (perms & SEPGSQL_PERMS_SELECT    ? COMMON_DATABASE__GETATTR : 0);
++	__perms |= (perms & SEPGSQL_PERMS_UPDATE    ? COMMON_DATABASE__SETATTR : 0);
++	__perms |= (perms & SEPGSQL_PERMS_INSERT    ? COMMON_DATABASE__CREATE  : 0);
++	__perms |= (perms & SEPGSQL_PERMS_DELETE    ? COMMON_DATABASE__DROP    : 0);
++	__perms |= (perms & SEPGSQL_PERMS_RELABELFROM ? COMMON_DATABASE__RELABELFROM : 0);
++	__perms |= (perms & SEPGSQL_PERMS_RELABELTO ? COMMON_DATABASE__RELABELTO : 0);
++
++	return __perms;
++}
++
++static uint32 __sepgsql_perms_to_tuple_perms(uint32 perms) {
++	uint32 __perms = 0;
++
++	//Assert((perms & ~SEPGSQL_PERMS_ALL) == 0);
++	if (perms & ~SEPGSQL_PERMS_ALL)
++		selbugon(1);
++	__perms |= (perms & SEPGSQL_PERMS_USE       ? DB_TUPLE__USE : 0);
++	__perms |= (perms & SEPGSQL_PERMS_SELECT    ? DB_TUPLE__SELECT : 0);
++	__perms |= (perms & SEPGSQL_PERMS_UPDATE    ? DB_TUPLE__UPDATE : 0);
++	__perms |= (perms & SEPGSQL_PERMS_INSERT    ? DB_TUPLE__INSERT : 0);
++	__perms |= (perms & SEPGSQL_PERMS_DELETE    ? DB_TUPLE__DELETE : 0);
++	__perms |= (perms & SEPGSQL_PERMS_RELABELFROM ? DB_TUPLE__RELABELFROM : 0);
++	__perms |= (perms & SEPGSQL_PERMS_RELABELTO ? DB_TUPLE__RELABELTO : 0);
++
 +	return __perms;
 +}
 +
@@ -4571,12 +4595,13 @@
 +		__lookupRelationForm(attrForm->attrelid, &classForm);
 +		if (classForm.relkind != RELKIND_RELATION) {
 +			*p_tclass = SECCLASS_DB_TUPLE;
++			*p_perms = __sepgsql_perms_to_tuple_perms(*p_perms);
 +			return;
 +		}
 +		break;
 +	}
 +	*p_tclass = SECCLASS_DB_COLUMN;
-+	*p_perms = __tuple_perms_to_common_perms(*p_perms);
++	*p_perms = __sepgsql_perms_to_common_perms(*p_perms);
 +	if (HeapTupleIsValid(oldtup)) {
 +		Form_pg_attribute oldForm = (Form_pg_attribute) GETSTRUCT(oldtup);
 +
@@ -4595,12 +4620,13 @@
 +	SysScanDesc sd;
 +	uint32 perms = 0;
 +
-+	perms |= (*p_perms & DB_TUPLE__SELECT ? DB_BLOB__GETATTR : 0);
-+	perms |= (*p_perms & DB_TUPLE__UPDATE ? DB_BLOB__SETATTR : 0);
-+	perms |= (*p_perms & DB_BLOB__READ    ? DB_BLOB__READ    : 0);
-+	perms |= (*p_perms & DB_BLOB__WRITE   ? DB_BLOB__WRITE   : 0);
++	perms |= (*p_perms & SEPGSQL_PERMS_USE    ? DB_BLOB__GETATTR : 0);
++	perms |= (*p_perms & SEPGSQL_PERMS_SELECT ? DB_BLOB__GETATTR : 0);
++	perms |= (*p_perms & SEPGSQL_PERMS_UPDATE ? DB_BLOB__SETATTR : 0);
++	perms |= (*p_perms & SEPGSQL_PERMS_READ   ? DB_BLOB__READ    : 0);
++	perms |= (*p_perms & SEPGSQL_PERMS_WRITE  ? DB_BLOB__WRITE   : 0);
 +
-+	if (*p_perms & DB_TUPLE__INSERT) {
++	if (*p_perms & SEPGSQL_PERMS_INSERT) {
 +		bool found = false;
 +
 +		ScanKeyInit(&skey,
@@ -4614,10 +4640,10 @@
 +            found = true;
 +		systable_endscan(sd);
 +		heap_close(rel, AccessShareLock);
-+		perms |= (!found ? DB_BLOB__CREATE : DB_BLOB__SETATTR);
++		perms |= (!found ? DB_BLOB__CREATE : DB_BLOB__SETATTR | DB_BLOB__WRITE);
 +	}
 +
-+	if (*p_perms & DB_TUPLE__DELETE) {
++	if (*p_perms & SEPGSQL_PERMS_DELETE) {
 +		HeapTuple exttup;
 +		bool found = false;
 +
@@ -4647,7 +4673,7 @@
 +static void __check_pg_proc(HeapTuple tuple, HeapTuple oldtup,
 +							uint32 *p_perms, uint16 *p_tclass)
 +{
-+	uint32 perms = __tuple_perms_to_common_perms(*p_perms);
++	uint32 perms = __sepgsql_perms_to_common_perms(*p_perms);
 +	Form_pg_proc procForm = (Form_pg_proc) GETSTRUCT(tuple);
 +
 +	if (procForm->prolang == ClanguageId) {
@@ -4714,9 +4740,10 @@
 +	Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
 +	if (classForm->relkind == RELKIND_RELATION) {
 +		*p_tclass = SECCLASS_DB_TABLE;
-+		*p_perms = __tuple_perms_to_common_perms(*p_perms);
++		*p_perms = __sepgsql_perms_to_common_perms(*p_perms);
 +	} else {
 +		*p_tclass = SECCLASS_DB_TUPLE;
++		*p_perms = __sepgsql_perms_to_tuple_perms(*p_perms);
 +	}
 +}
 +
@@ -4730,7 +4757,7 @@
 +
 +	switch (tableoid) {
 +	case DatabaseRelationId:		/* pg_database */
-+		perms = __tuple_perms_to_common_perms(perms);
++		perms = __sepgsql_perms_to_common_perms(perms);
 +		tclass = SECCLASS_DB_DATABASE;
 +		break;
 +
@@ -4751,6 +4778,7 @@
 +		break;
 +
 +	default:
++		perms = __sepgsql_perms_to_tuple_perms(perms);
 +		tclass = SECCLASS_DB_TUPLE;
 +		break;
 +	}
@@ -4885,8 +4913,8 @@
 +}
 diff -rpNU3 base/src/backend/security/sepgsqlProxy.c sepgsql/src/backend/security/sepgsqlProxy.c
 --- base/src/backend/security/sepgsqlProxy.c	1970-01-01 09:00:00.000000000 +0900
-+++ sepgsql/src/backend/security/sepgsqlProxy.c	2008-01-08 16:53:27.000000000 +0900
-@@ -0,0 +1,1489 @@
++++ sepgsql/src/backend/security/sepgsqlProxy.c	2008-01-30 17:08:18.000000000 +0900
+@@ -0,0 +1,1467 @@
 +/*
 + * src/backend/security/sepgsqlProxy.c
 + *   SE-PostgreSQL Query Proxy function to walk on query node tree
@@ -4916,16 +4944,6 @@
 +#include "utils/fmgroids.h"
 +#include "utils/syscache.h"
 +
-+#define RTEMARK_USE           (1<<(N_ACL_RIGHTS))
-+#define RTEMARK_SELECT        (1<<(N_ACL_RIGHTS + 1))
-+#define RTEMARK_INSERT        (1<<(N_ACL_RIGHTS + 2))
-+#define RTEMARK_UPDATE        (1<<(N_ACL_RIGHTS + 3))
-+#define RTEMARK_DELETE        (1<<(N_ACL_RIGHTS + 4))
-+#define RTEMARK_RELABELFROM   (1<<(N_ACL_RIGHTS + 5))
-+#define RTEMARK_RELABELTO     (1<<(N_ACL_RIGHTS + 6))
-+#define RTEMARK_BLOB_READ     (1<<(N_ACL_RIGHTS + 7))
-+#define RTEMARK_BLOB_WRITE    (1<<(N_ACL_RIGHTS + 8))
-+
 +/* SE-PostgreSQL Evaluation Item */
 +#define T_SEvalItem		(T_TIDBitmap + 1)		/* must be unique identifier */
 +
@@ -5007,11 +5025,11 @@
 +
 +static List *addEvalPgClass(List *selist, RangeTblEntry *rte, uint32 perms)
 +{
-+	rte->requiredPerms |= (perms & DB_TABLE__USE    ? RTEMARK_USE    : 0);
-+	rte->requiredPerms |= (perms & DB_TABLE__SELECT ? RTEMARK_SELECT : 0);
-+	rte->requiredPerms |= (perms & DB_TABLE__INSERT ? RTEMARK_INSERT : 0);
-+	rte->requiredPerms |= (perms & DB_TABLE__UPDATE ? RTEMARK_UPDATE : 0);
-+	rte->requiredPerms |= (perms & DB_TABLE__DELETE ? RTEMARK_DELETE : 0);
++	rte->requiredPerms |= (perms & DB_TABLE__USE    ? SEPGSQL_PERMS_USE    : 0);
++	rte->requiredPerms |= (perms & DB_TABLE__SELECT ? SEPGSQL_PERMS_SELECT : 0);
++	rte->requiredPerms |= (perms & DB_TABLE__INSERT ? SEPGSQL_PERMS_INSERT : 0);
++	rte->requiredPerms |= (perms & DB_TABLE__UPDATE ? SEPGSQL_PERMS_UPDATE : 0);
++	rte->requiredPerms |= (perms & DB_TABLE__DELETE ? SEPGSQL_PERMS_DELETE : 0);
 +
 +	return __addEvalPgClass(selist, rte->relid, rte->inh, perms);
 +}
@@ -5047,15 +5065,15 @@
 +	/* for 'security_context' */
 +	if (attno == SecurityAttributeNumber
 +		&& (perms & (DB_COLUMN__UPDATE | DB_COLUMN__INSERT)))
-+		rte->requiredPerms |= RTEMARK_RELABELFROM;
++		rte->requiredPerms |= SEPGSQL_PERMS_RELABELFROM;
 +
 +	/* for 'pg_largeobject' */
 +	if (rte->relid == LargeObjectRelationId
 +		&& attno == Anum_pg_largeobject_data) {
 +		if (perms & DB_COLUMN__SELECT)
-+			rte->requiredPerms |= RTEMARK_BLOB_READ;
++			rte->requiredPerms |= SEPGSQL_PERMS_READ;
 +		if (perms & (DB_COLUMN__UPDATE | DB_COLUMN__INSERT))
-+			rte->requiredPerms |= RTEMARK_BLOB_WRITE;
++			rte->requiredPerms |= SEPGSQL_PERMS_WRITE;
 +	}
 +
 +	return __addEvalPgAttribute(selist, rte->relid, rte->inh, attno, perms);
@@ -5595,35 +5613,15 @@
 +	RangeTblEntry *rte;
 +	Relation rel;
 +	TupleDesc tdesc;
-+	uint32 perms = 0;
++	uint32 perms;
 +
 +	query = getQueryFromChain(qc);
 +	rte = list_nth(query->rtable, rtindex - 1);
 +	rel = relation_open(rte->relid, AccessShareLock);
 +	tdesc = RelationGetDescr(rel);
 +
-+	/* setup tclass and access vector */
-+	perms = 0;
-+	if (rte->requiredPerms & RTEMARK_USE)
-+		perms |= DB_TUPLE__USE;
-+	if (rte->requiredPerms & RTEMARK_SELECT)
-+		perms |= DB_TUPLE__SELECT;
-+	if (rte->requiredPerms & RTEMARK_INSERT)
-+		perms |= DB_TUPLE__INSERT;
-+	if (rte->requiredPerms & RTEMARK_UPDATE)
-+		perms |= DB_TUPLE__UPDATE;
-+	if (rte->requiredPerms & RTEMARK_DELETE)
-+		perms |= DB_TUPLE__DELETE;
-+	if (rte->requiredPerms & RTEMARK_RELABELFROM)
-+		perms |= DB_TUPLE__RELABELFROM;
-+	if (rte->requiredPerms & RTEMARK_RELABELTO)
-+		perms |= DB_TUPLE__RELABELTO;
-+	if (rte->requiredPerms & RTEMARK_BLOB_READ)
-+		perms |= DB_BLOB__READ;
-+	if (rte->requiredPerms & RTEMARK_BLOB_WRITE)
-+		perms |= DB_BLOB__WRITE;
-+
 +	/* append sepgsql_tuple_perm(relid, record, perms) */
++	perms = rte->requiredPerms & SEPGSQL_PERMS_ALL;
 +	if (perms) {
 +		Var *v1, *v2, *v4;
 +		Const *c3;
@@ -5669,7 +5667,7 @@
 +	/* clean-up polluted RangeTblEntry */
 +	foreach (l, query->rtable) {
 +		RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
-+		rte->requiredPerms &= ((1<<N_ACL_RIGHTS) - 1);
++		rte->requiredPerms &= ~SEPGSQL_PERMS_ALL;
 +	}
 +
 +	return selist;
@@ -5713,20 +5711,29 @@
 +	if (cmdType != CMD_DELETE) {
 +		foreach (l, query->targetList) {
 +			TargetEntry *tle = lfirst(l);
++			bool is_security_attr = false;
 +			Assert(IsA(tle, TargetEntry));
 +
-+			selist = sepgsqlWalkExpr(selist, qc, (Node *) tle->expr,
-+									 tle->resjunk ? WKFLAG_INTERNAL_USE : 0);
++			if (tle->resjunk && !strcmp(tle->resname, SECURITY_SYSATTR_NAME))
++				is_security_attr = true;
++
++			/* pure junk target entries */
++			if (tle->resjunk && !is_security_attr) {
++				selist = sepgsqlWalkExpr(selist, qc, (Node *) tle->expr,
++										 WKFLAG_INTERNAL_USE);
++				continue;
++			}
++
++			selist = sepgsqlWalkExpr(selist, qc, (Node *) tle->expr, 0);
 +			/* mark insert/update target */
 +			if (cmdType==CMD_UPDATE || cmdType==CMD_INSERT) {
 +				uint32 perms = (cmdType == CMD_UPDATE
 +								? DB_COLUMN__UPDATE : DB_COLUMN__INSERT);
-+				if (tle->resjunk) {
-+					if (!strcmp(tle->resname, SECURITY_SYSATTR_NAME))
-+						selist = addEvalPgAttribute(selist,
-+													rte,
-+													SecurityAttributeNumber,
-+													perms);
++				if (is_security_attr) {
++					selist = addEvalPgAttribute(selist,
++												rte,
++												SecurityAttributeNumber,
++												perms);
 +					continue;
 +				}
 +				selist = addEvalPgAttribute(selist, rte, tle->resno, perms);
@@ -5766,7 +5773,7 @@
 +	/* clean-up polluted RangeTblEntry */
 +	foreach (l, query->rtable) {
 +		rte = (RangeTblEntry *) lfirst(l);
-+		rte->requiredPerms &= ((1<<N_ACL_RIGHTS) - 1);
++		rte->requiredPerms &= ~SEPGSQL_PERMS_ALL;
 +	}
 +
 +	return selist;
@@ -5983,11 +5990,10 @@
 +	Form_pg_class pgclass;
 +	HeapTuple tuple;
 +
-+	/* check untouchable tables */
-+	if (perms & (DB_TABLE__UPDATE | DB_TABLE__INSERT | DB_TABLE__DELETE)) {
-+		if (relid == SecurityRelationId)
-+			selerror("user cannot modify pg_security directly, for security reason");
-+	}
++	/* prevent to modify pg_security directly */
++	if (relid == SecurityRelationId
++		&& (perms & (DB_TABLE__UPDATE | DB_TABLE__INSERT | DB_TABLE__DELETE)) != 0)
++		selerror("user cannot modify pg_security directly, for security reason");
 +
 +	/* check table:{required permissions} */
 +	tuple = SearchSysCache(RELOID,
@@ -6018,8 +6024,8 @@
 +	Form_pg_attribute attrForm;
 +
 +	tuple = SearchSysCache(RELOID,
-+							ObjectIdGetDatum(relid),
-+							0, 0, 0);
++						   ObjectIdGetDatum(relid),
++						   0, 0, 0);
 +	if (!HeapTupleIsValid(tuple))
 +		selerror("RELOID cache lookup failed (relid=%u)", relid);
 +	classForm = (Form_pg_class) GETSTRUCT(tuple);
@@ -6287,7 +6293,7 @@
 +
 +bool sepgsqlCopyToTuple(Relation rel, HeapTuple tuple)
 +{
-+	return sepgsqlCheckTuplePerms(rel, tuple, NULL, DB_TUPLE__SELECT, false);
++	return sepgsqlCheckTuplePerms(rel, tuple, NULL, SEPGSQL_PERMS_SELECT, false);
 +}
 +
 +bool sepgsqlCopyFromTuple(Relation rel, HeapTuple tuple)
@@ -6299,7 +6305,7 @@
 +		tcontext = sepgsqlComputeImplicitContext(rel, tuple);
 +		HeapTupleSetSecurity(tuple, tcontext);
 +	}
-+	return sepgsqlCheckTuplePerms(rel, tuple, NULL, DB_TUPLE__INSERT, false);
++	return sepgsqlCheckTuplePerms(rel, tuple, NULL, SEPGSQL_PERMS_INSERT, false);
 +}
 +
 +/* ----------------------------------------------------------
@@ -8482,8 +8488,8 @@
 +#endif /* SEPGSQL_H */
 diff -rpNU3 base/src/include/security/sepgsql_internal.h sepgsql/src/include/security/sepgsql_internal.h
 --- base/src/include/security/sepgsql_internal.h	1970-01-01 09:00:00.000000000 +0900
-+++ sepgsql/src/include/security/sepgsql_internal.h	2008-01-08 21:43:57.000000000 +0900
-@@ -0,0 +1,275 @@
++++ sepgsql/src/include/security/sepgsql_internal.h	2008-01-30 17:08:18.000000000 +0900
+@@ -0,0 +1,290 @@
 +#ifndef SEPGSQL_INTERNAL_H
 +#define SEPGSQL_INTERNAL_H
 +
@@ -8514,6 +8520,7 @@
 +#include "catalog/pg_type.h"
 +#include "lib/stringinfo.h"
 +#include "nodes/nodes.h"
++#include "nodes/parsenodes.h"
 +#include "storage/large_object.h"
 +
 +#include <selinux/selinux.h>
@@ -8559,11 +8566,25 @@
 +			  (att)->attalign, (att)->attnotnull ? 'y' : 'n', (att)->atthasdef ? 'y' : 'n', \
 +			  (att)->attisdropped ? 'y' : 'n', (att)->attislocal ? 'y' : 'n', (att)->attinhcount)
 +
++/*
++ * Permission codes of internal representation
++ */
++#define SEPGSQL_PERMS_USE			(1UL << (N_ACL_RIGHTS + 0))
++#define SEPGSQL_PERMS_SELECT		(1UL << (N_ACL_RIGHTS + 1))
++#define SEPGSQL_PERMS_UPDATE		(1UL << (N_ACL_RIGHTS + 2))
++#define SEPGSQL_PERMS_INSERT		(1UL << (N_ACL_RIGHTS + 3))
++#define SEPGSQL_PERMS_DELETE		(1UL << (N_ACL_RIGHTS + 4))
++#define SEPGSQL_PERMS_RELABELFROM	(1UL << (N_ACL_RIGHTS + 5))
++#define SEPGSQL_PERMS_RELABELTO		(1UL << (N_ACL_RIGHTS + 6))
++#define SEPGSQL_PERMS_READ			(1UL << (N_ACL_RIGHTS + 7))
++#define SEPGSQL_PERMS_WRITE			(1UL << (N_ACL_RIGHTS + 8))
++#define SEPGSQL_PERMS_ALL			(SEPGSQL_PERMS_WRITE - SEPGSQL_PERMS_USE)
++
 +/* The definition of object classes/access vectors are defined at libselinux-devel */
 +#ifndef SECCLASS_DB_DATABASE		/* for legacy selinux/flask.h */
-+#define SECCLASS_DB_DATABASE			(62)		/* next to SECCLASS_MEMPROTECT */
++#define SECCLASS_DB_DATABASE		(62)		/* next to SECCLASS_MEMPROTECT */
 +#define SECCLASS_DB_TABLE			(SECCLASS_DB_DATABASE + 1)
-+#define SECCLASS_DB_PROCEDURE			(SECCLASS_DB_DATABASE + 2)
++#define SECCLASS_DB_PROCEDURE		(SECCLASS_DB_DATABASE + 2)
 +#define SECCLASS_DB_COLUMN			(SECCLASS_DB_DATABASE + 3)
 +#define SECCLASS_DB_TUPLE			(SECCLASS_DB_DATABASE + 4)
 +#define SECCLASS_DB_BLOB			(SECCLASS_DB_DATABASE + 5)


Index: sepostgresql.init
===================================================================
RCS file: /cvs/pkgs/rpms/sepostgresql/F-8/sepostgresql.init,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- sepostgresql.init	22 Jan 2008 12:25:40 -0000	1.10
+++ sepostgresql.init	7 Feb 2008 01:05:33 -0000	1.11
@@ -9,7 +9,7 @@
 
 PGVERSION="8.2.6"
 PGMAJORVERSION=`echo "$PGVERSION" | sed 's/^\([0-9]*\.[0-9]*\).*$/\1/'`
-SEPGVERSION="1.158"
+SEPGVERSION="1.207"
 
 # source function library
 . /etc/rc.d/init.d/functions


Index: sepostgresql.spec
===================================================================
RCS file: /cvs/pkgs/rpms/sepostgresql/F-8/sepostgresql.spec,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- sepostgresql.spec	22 Jan 2008 12:25:40 -0000	1.10
+++ sepostgresql.spec	7 Feb 2008 01:05:33 -0000	1.11
@@ -13,7 +13,7 @@
 Summary: Security Enhanced PostgreSQL
 Name: sepostgresql
 Version: 8.2.6
-Release: 1.158%{?sepgsql_extension}%{?dist}
+Release: 1.207%{?sepgsql_extension}%{?dist}
 License: BSD
 Group: Applications/Databases
 Url: http://code.google.com/p/sepgsql/
@@ -34,6 +34,7 @@
 Requires(postun): policycoreutils
 Requires: postgresql-server = %{version}
 Requires: policycoreutils >= 2.0.16 libselinux >= 2.0.13 selinux-policy >= 3.0.6
+Requires: tzdata
 
 %description
 Security Enhanced PostgreSQL is an extension of PostgreSQL
@@ -72,7 +73,8 @@
                 --enable-cassert                \
 %endif
                 --libdir=%{_libdir}/sepgsql     \
-                --datadir=%{_datadir}/sepgsql
+                --datadir=%{_datadir}/sepgsql	\
+                --with-system-tzdata=/usr/share/zoneinfo
 
 # parallel build, if possible
 make %{?_smp_mflags}
@@ -206,6 +208,11 @@
 %attr(700,sepgsql,sepgsql) %dir %{_localstatedir}/lib/sepgsql/backups
 
 %changelog
+* Wed Feb  6 2008 <kaigai at kaigai.gr.jp> - 8.2.6-1.206
+- bugfix: blob:{read} is not evaluated correctly
+- add --with-system-tzdata config option
+- policy update: allow db_database:{set_param}
+
 * Tue Jan 22 2008 <kaigai at kaigai.gr.jp> - 8.2.6-1.158
 - backporting bugfixes:
   lack of lacks when refering buffer pages at update/delete hooks


Index: sepostgresql.te
===================================================================
RCS file: /cvs/pkgs/rpms/sepostgresql/F-8/sepostgresql.te,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- sepostgresql.te	22 Jan 2008 12:25:40 -0000	1.10
+++ sepostgresql.te	7 Feb 2008 01:05:33 -0000	1.11
@@ -1,4 +1,4 @@
-policy_module(sepostgresql, 1.158)
+policy_module(sepostgresql, 1.207)
 
 gen_require(`
 	all_userspace_class_perms
@@ -205,7 +205,7 @@
 # SE-PostgreSQL policy for generic domain
 #
 
-allow sepgsql_users_domain sepgsql_db_t : db_database { getattr access };
+allow sepgsql_users_domain sepgsql_db_t : db_database { getattr access get_param set_param };
 
 allow sepgsql_users_domain sepgsql_table_t : db_table { getattr use select update insert delete };
 allow sepgsql_users_domain sepgsql_table_t : db_column { getattr use select update insert };




More information about the fedora-extras-commits mailing list