Skip to content

Commit

Permalink
libsepol: quote paths in CIL conversion
Browse files Browse the repository at this point in the history
When generating CIL policy from kernel or module policy quote paths,
which are allowed to contain spaces, in the statements `genfscon` and
`devicetreecon`.

Reported by LuK1337 while building policy for Android via IRC.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
  • Loading branch information
cgzones authored and jwcart2 committed Jun 14, 2021
1 parent ea02e0a commit 644c5bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libsepol/src/kernel_to_cil.c
Expand Up @@ -2654,7 +2654,7 @@ static int write_genfscon_rules_to_cil(FILE *out, struct policydb *pdb)
goto exit;
}

rc = strs_create_and_add(strs, "(genfscon %s %s %s)", 3,
rc = strs_create_and_add(strs, "(genfscon %s \"%s\" %s)", 3,
fstype, name, ctx);
free(ctx);
if (rc != 0) {
Expand Down Expand Up @@ -3115,7 +3115,7 @@ static int write_xen_devicetree_rules_to_cil(FILE *out, struct policydb *pdb)
goto exit;
}

sepol_printf(out, "(devicetreecon %s %s)\n", name, ctx);
sepol_printf(out, "(devicetreecon \"%s\" %s)\n", name, ctx);

free(ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion libsepol/src/module_to_cil.c
Expand Up @@ -2963,7 +2963,7 @@ static int genfscon_to_cil(struct policydb *pdb)

for (genfs = pdb->genfs; genfs != NULL; genfs = genfs->next) {
for (ocon = genfs->head; ocon != NULL; ocon = ocon->next) {
cil_printf("(genfscon %s %s ", genfs->fstype, ocon->u.name);
cil_printf("(genfscon %s \"%s\" ", genfs->fstype, ocon->u.name);
context_to_cil(pdb, &ocon->context[0]);
cil_printf(")\n");
}
Expand Down

0 comments on commit 644c5bb

Please sign in to comment.