mirror of
https://github.com/SELinuxProject/selinux
synced 2025-04-04 23:49:19 +00:00
secilc/secil2tree: Add option to write CIL AST after post processing
This will show the resulting CIL AST after deny rules have been processed. Signed-off-by: James Carter <jwcart2@gmail.com> Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com> Acked-by: Petr Lautrbach <lautrbach@redhat.com>
This commit is contained in:
parent
5d5a871cb1
commit
409b4d3bd4
@ -45,6 +45,7 @@ enum write_ast_phase {
|
|||||||
WRITE_AST_PHASE_PARSE = 0,
|
WRITE_AST_PHASE_PARSE = 0,
|
||||||
WRITE_AST_PHASE_BUILD,
|
WRITE_AST_PHASE_BUILD,
|
||||||
WRITE_AST_PHASE_RESOLVE,
|
WRITE_AST_PHASE_RESOLVE,
|
||||||
|
WRITE_AST_PHASE_POST,
|
||||||
};
|
};
|
||||||
|
|
||||||
static __attribute__((__noreturn__)) void usage(const char *prog)
|
static __attribute__((__noreturn__)) void usage(const char *prog)
|
||||||
@ -58,7 +59,7 @@ static __attribute__((__noreturn__)) void usage(const char *prog)
|
|||||||
printf(" Blocks, blockinherits, blockabstracts, and\n");
|
printf(" Blocks, blockinherits, blockabstracts, and\n");
|
||||||
printf(" in-statements will not be allowed.\n");
|
printf(" in-statements will not be allowed.\n");
|
||||||
printf(" -A, --ast-phase=<phase> write AST of phase <phase>. Phase must be parse, \n");
|
printf(" -A, --ast-phase=<phase> write AST of phase <phase>. Phase must be parse, \n");
|
||||||
printf(" build, or resolve. (default: resolve)\n");
|
printf(" build, resolve, or post. (default: resolve)\n");
|
||||||
printf(" -v, --verbose increment verbosity level\n");
|
printf(" -v, --verbose increment verbosity level\n");
|
||||||
printf(" -h, --help display usage information\n");
|
printf(" -h, --help display usage information\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -115,6 +116,8 @@ int main(int argc, char *argv[])
|
|||||||
write_ast = WRITE_AST_PHASE_BUILD;
|
write_ast = WRITE_AST_PHASE_BUILD;
|
||||||
} else if (!strcasecmp(optarg, "resolve")) {
|
} else if (!strcasecmp(optarg, "resolve")) {
|
||||||
write_ast = WRITE_AST_PHASE_RESOLVE;
|
write_ast = WRITE_AST_PHASE_RESOLVE;
|
||||||
|
} else if (!strcasecmp(optarg, "post")) {
|
||||||
|
write_ast = WRITE_AST_PHASE_POST;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invalid AST phase: %s\n", optarg);
|
fprintf(stderr, "Invalid AST phase: %s\n", optarg);
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
@ -203,6 +206,9 @@ int main(int argc, char *argv[])
|
|||||||
case WRITE_AST_PHASE_RESOLVE:
|
case WRITE_AST_PHASE_RESOLVE:
|
||||||
rc = cil_write_resolve_ast(file, db);
|
rc = cil_write_resolve_ast(file, db);
|
||||||
break;
|
break;
|
||||||
|
case WRITE_AST_PHASE_POST:
|
||||||
|
rc = cil_write_post_ast(file, db);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc != SEPOL_OK) {
|
if (rc != SEPOL_OK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user