Update to upstream

* Only call role_fix_callback for base.p_roles during expansion.
	* use mapped role number instead of module role number
This commit is contained in:
Dan Walsh 2011-08-18 06:58:25 -04:00
parent a98ce44d26
commit 6eec04097e
4 changed files with 85 additions and 48 deletions

2
.gitignore vendored
View File

@ -153,3 +153,5 @@ libsepol-2.0.41.tgz
/libsepol-2.0.44.tgz /libsepol-2.0.44.tgz
/libsepol-2.0.45.tgz /libsepol-2.0.45.tgz
/libsepol-2.1.0.tgz /libsepol-2.1.0.tgz
/libsepol-2.1.1.tgz
/libsepol-2.1.2.tgz

View File

@ -1,48 +1,74 @@
diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c diff --git a/libsepol/src/write.c b/libsepol/src/write.c
index b1af365..42bc931 100644 index 290e036..7257b0b 100644
--- a/libsepol/src/expand.c --- a/libsepol/src/write.c
+++ b/libsepol/src/expand.c +++ b/libsepol/src/write.c
@@ -1181,23 +1181,26 @@ static int copy_role_trans(expand_state_t * state, role_trans_rule_t * rules) @@ -972,6 +972,19 @@ static int role_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
cur_trans = state->out->role_tr; role = (role_datum_t *) datum;
while (cur_trans) {
+ unsigned int mapped_role; + /*
+ * Role attributes are redundant for policy.X, skip them
+ * when writing the roles symbol table. They are also skipped
+ * when pp is downgraded.
+ *
+ * Their numbers would be deducted in policydb_write().
+ */
+ if ((role->flavor == ROLE_ATTRIB) &&
+ ((p->policy_type == POLICY_KERN) ||
+ (p->policy_type != POLICY_KERN &&
+ p->policyvers < MOD_POLICYDB_VERSION_ROLEATTRIB)))
+ return POLICYDB_SUCCESS;
+ +
+ mapped_role = state->rolemap[cur->new_role - 1]; len = strlen(key);
items = 0;
buf[items++] = cpu_to_le32(len);
@@ -1795,6 +1808,19 @@ static int type_attr_uncount(hashtab_key_t key __attribute__ ((unused)),
return 0;
}
+static int role_attr_uncount(hashtab_key_t key __attribute__ ((unused)),
+ hashtab_datum_t datum, void *args)
+{
+ role_datum_t *role = datum;
+ uint32_t *p_nel = args;
+ +
if ((cur_trans->role == + if (role->flavor == ROLE_ATTRIB) {
i + 1) && + /* uncount attribute from total number of roles */
(cur_trans->type == + (*p_nel)--;
j + 1) && + }
(cur_trans->tclass == + return 0;
k + 1)) { +}
- if (cur_trans-> +
- new_role == /*
- cur->new_role) { * Write the configuration data in a policy database
+ if (cur_trans->new_role == mapped_role) { * structure to a policy database binary representation
break; @@ -1926,7 +1952,7 @@ int policydb_write(policydb_t * p, struct policy_file *fp)
} else { num_syms = info->sym_num;
ERR(state->handle, for (i = 0; i < num_syms; i++) {
- "Conflicting role trans rule %s %s : %s %s", buf[0] = cpu_to_le32(p->symtab[i].nprim);
+ "Conflicting role trans rule %s %s : %s { %s vs %s }", - buf[1] = cpu_to_le32(p->symtab[i].table->nel);
state->out->p_role_val_to_name[i], + buf[1] = p->symtab[i].table->nel;
state->out->p_type_val_to_name[j],
state->out->p_class_val_to_name[k], /*
- state->out->p_role_val_to_name[cur->new_role - 1]); * A special case when writing type/attribute symbol table.
+ state->out->p_role_val_to_name[mapped_role], @@ -1939,6 +1965,20 @@ int policydb_write(policydb_t * p, struct policy_file *fp)
+ state->out->p_role_val_to_name[cur_trans->new_role - 1]); p->policy_type == POLICY_KERN) {
return -1; hashtab_map(p->symtab[i].table, type_attr_uncount, &buf[1]);
} }
} +
diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c + /*
index 6d8ff91..3d8dc80 100644 + * Another special case when writing role/attribute symbol
--- a/libsepol/src/policydb.c + * table, role attributes are redundant for policy.X, or
+++ b/libsepol/src/policydb.c + * when the pp's version is not big enough. So deduct
@@ -2280,6 +2280,7 @@ int filename_trans_read(filename_trans_t **t, struct policy_file *fp) + * their numbers from p_roles.table->nel.
lft->next = ft; + */
else + if ((i == SYM_ROLES) &&
*t = ft; + ((p->policy_type == POLICY_KERN) ||
+ lft = ft; + (p->policy_type != POLICY_KERN &&
rc = next_entry(buf, fp, sizeof(uint32_t)); + p->policyvers < MOD_POLICYDB_VERSION_ROLEATTRIB)))
if (rc < 0) + hashtab_map(p->symtab[i].table, role_attr_uncount, &buf[1]);
return -1; +
+ buf[1] = cpu_to_le32(buf[1]);
items = put_entry(buf, sizeof(uint32_t), 2, fp);
if (items != 2)
return POLICYDB_ERROR;

View File

@ -1,6 +1,6 @@
Summary: SELinux binary policy manipulation library Summary: SELinux binary policy manipulation library
Name: libsepol Name: libsepol
Version: 2.1.0 Version: 2.1.2
Release: 1%{?dist} Release: 1%{?dist}
License: LGPLv2+ License: LGPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
@ -98,7 +98,16 @@ exit 0
/%{_lib}/libsepol.so.1 /%{_lib}/libsepol.so.1
%changelog %changelog
* Thu May 3 2011 Dan Walsh <dwalsh@redhat.com> 2.1.0-1 * Thu Aug 18 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.2-0
- Update to upstream
* Only call role_fix_callback for base.p_roles during expansion.
* use mapped role number instead of module role number
* Mon Aug 1 2011 Dan Walsh <dwalsh@redhat.com> 2.1.1-1
- Update to upstream
* Minor fix to reading policy with filename transition rules
* Wed Jul 27 2011 Dan Walsh <dwalsh@redhat.com> 2.1.0-1
- Update to upstream - Update to upstream
* Release, minor version bump * Release, minor version bump

View File

@ -1 +1 @@
c151def95fc51a5ebffabceb6d749e0b libsepol-2.1.0.tgz b5633c3d0326cf492b88eb5e010923f0 libsepol-2.1.2.tgz