Skip to content

Commit

Permalink
libsepol: Quote paths when generating policy.conf from binary policy
Browse files Browse the repository at this point in the history
Christian Göttsche <cgzones@googlemail.com> submitted a similar patch
to quote paths when generating CIL policy from a binary policy.

Since genfscon and devicetreecon rules have paths which are allowed
to contain spaces, always quote the path when writing out these rules.

Signed-off-by: James Carter <jwcart2@gmail.com>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
  • Loading branch information
jwcart2 committed Jun 22, 2021
1 parent 4a60fd7 commit ce1025b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libsepol/src/kernel_to_conf.c
Expand Up @@ -2527,7 +2527,7 @@ static int write_genfscon_rules_to_conf(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 @@ -2992,7 +2992,7 @@ static int write_xen_devicetree_rules_to_conf(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

0 comments on commit ce1025b

Please sign in to comment.