Skip to content

Commit

Permalink
libsepol: include prefix for module policy versions
Browse files Browse the repository at this point in the history
If writing a policy fails due to a limitation by the requested policy
version include a prefix if the version refers to a module policy.

Signed-off-by: Christian Göttsche <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed May 24, 2024
1 parent df10ff9 commit ef35345
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libsepol/src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,10 @@ static int class_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
buf[1] = cpu_to_le32(cladatum->default_role);
if (!glblub_version && default_range == DEFAULT_GLBLUB) {
WARN(fp->handle,
"class %s default_range set to GLBLUB but policy version is %d (%d required), discarding",
p->p_class_val_to_name[cladatum->s.value - 1], p->policyvers,
"class %s default_range set to GLBLUB but %spolicy version is %d (%d required), discarding",
p->p_class_val_to_name[cladatum->s.value - 1],
p->policy_type == POLICY_KERN ? "" : "module ",
p->policyvers,
p->policy_type == POLICY_KERN? POLICYDB_VERSION_GLBLUB:MOD_POLICYDB_VERSION_GLBLUB);
default_range = 0;
}
Expand Down Expand Up @@ -2219,7 +2221,8 @@ int policydb_write(policydb_t * p, struct policy_file *fp)
p->policy_type == POLICY_BASE) ||
(p->policyvers < MOD_POLICYDB_VERSION_MLS &&
p->policy_type == POLICY_MOD)) {
ERR(fp->handle, "policy version %d cannot support MLS",
ERR(fp->handle, "%spolicy version %d cannot support MLS",
p->policy_type == POLICY_KERN ? "" : "module ",
p->policyvers);
return POLICYDB_ERROR;
}
Expand Down

0 comments on commit ef35345

Please sign in to comment.