Add role attribute support when generating pp files.
Add support to read/write the flavor flag and roles ebitmap in the role_datum_t structure from/to policy module, if its version is no less than MOD_POLICYDB_VERSION_ROLEATTRIB. Since the role ebitmap would be expanded and won't be written into policy.X, neither is the flavor flag, kernel SELinux security server needs no change, the maximum version number for policy.X needs no bump. Signed-off-by: Harry Ciao <qingtao.cao@windriver.com> Signed-off-by: Steve Lawrence <slawrence@tresys.com>
This commit is contained in:
parent
16675b7f96
commit
8072dba146
|
@ -682,9 +682,10 @@ extern int policydb_set_target_platform(policydb_t *p, int platform);
|
|||
#define MOD_POLICYDB_VERSION_BOUNDARY_ALIAS 10
|
||||
#define MOD_POLICYDB_VERSION_FILENAME_TRANS 11
|
||||
#define MOD_POLICYDB_VERSION_ROLETRANS 12
|
||||
#define MOD_POLICYDB_VERSION_ROLEATTRIB 13
|
||||
|
||||
#define MOD_POLICYDB_VERSION_MIN MOD_POLICYDB_VERSION_BASE
|
||||
#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_ROLETRANS
|
||||
#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_ROLEATTRIB
|
||||
|
||||
#define POLICYDB_CONFIG_MLS 1
|
||||
|
||||
|
|
|
@ -213,6 +213,13 @@ static struct policydb_compat_info policydb_compat[] = {
|
|||
.ocon_num = OCON_NODE6 + 1,
|
||||
.target_platform = SEPOL_TARGET_SELINUX,
|
||||
},
|
||||
{
|
||||
.type = POLICY_BASE,
|
||||
.version = MOD_POLICYDB_VERSION_ROLEATTRIB,
|
||||
.sym_num = SYM_NUM,
|
||||
.ocon_num = OCON_NODE6 + 1,
|
||||
.target_platform = SEPOL_TARGET_SELINUX,
|
||||
},
|
||||
{
|
||||
.type = POLICY_MOD,
|
||||
.version = MOD_POLICYDB_VERSION_BASE,
|
||||
|
@ -276,6 +283,13 @@ static struct policydb_compat_info policydb_compat[] = {
|
|||
.ocon_num = 0,
|
||||
.target_platform = SEPOL_TARGET_SELINUX,
|
||||
},
|
||||
{
|
||||
.type = POLICY_MOD,
|
||||
.version = MOD_POLICYDB_VERSION_ROLEATTRIB,
|
||||
.sym_num = SYM_NUM,
|
||||
.ocon_num = 0,
|
||||
.target_platform = SEPOL_TARGET_SELINUX,
|
||||
},
|
||||
};
|
||||
|
||||
#if 0
|
||||
|
@ -2091,6 +2105,18 @@ static int role_read(policydb_t * p
|
|||
goto bad;
|
||||
}
|
||||
|
||||
if (p->policy_type != POLICY_KERN &&
|
||||
p->policyvers >= MOD_POLICYDB_VERSION_ROLEATTRIB) {
|
||||
rc = next_entry(buf, fp, sizeof(uint32_t));
|
||||
if (rc < 0)
|
||||
goto bad;
|
||||
|
||||
role->flavor = le32_to_cpu(buf[0]);
|
||||
|
||||
if (ebitmap_read(&role->roles, fp))
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (strcmp(key, OBJECT_R) == 0) {
|
||||
if (role->s.value != OBJECT_R_VAL) {
|
||||
ERR(fp->handle, "role %s has wrong value %d",
|
||||
|
|
|
@ -996,6 +996,17 @@ static int role_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
|
|||
return POLICYDB_ERROR;
|
||||
}
|
||||
|
||||
if (p->policy_type != POLICY_KERN &&
|
||||
p->policyvers >= MOD_POLICYDB_VERSION_ROLEATTRIB) {
|
||||
buf[0] = cpu_to_le32(role->flavor);
|
||||
items = put_entry(buf, sizeof(uint32_t), 1, fp);
|
||||
if (items != 1)
|
||||
return POLICYDB_ERROR;
|
||||
|
||||
if (ebitmap_write(&role->roles, fp))
|
||||
return POLICYDB_ERROR;
|
||||
}
|
||||
|
||||
return POLICYDB_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue