@@ -36,10 +36,14 @@
static policydb_t policydb;
+int menu(int interactive);
+
static __attribute__((__noreturn__)) void usage(const char *progname,
int status)
{
printf("usage: %s [-h] [-b cmds] binary_pol_file\n\n", progname);
+ printf("acceptable commands for -b option:\n");
+ menu(0);
exit(status);
}
@@ -361,25 +365,30 @@ static void display_filename_trans(policydb_t *p, FILE *fp)
hashtab_map(p->filename_trans, filenametr_display, &args);
}
-int menu(void)
+int menu(int interactive)
{
- printf("\nSelect a command:\n");
+ if (interactive)
+ printf("\nSelect a command:\n");
printf("1) display unconditional AVTAB\n");
printf("2) display conditional AVTAB (entirely)\n");
printf("3) display conditional AVTAB (only ENABLED rules)\n");
printf("4) display conditional AVTAB (only DISABLED rules)\n");
printf("5) display conditional bools\n");
printf("6) display conditional expressions\n");
- printf("7) change a boolean value\n");
+ if (interactive)
+ printf("7) change a boolean value\n");
printf("8) display role transitions\n");
- printf("\n");
+ if (interactive)
+ printf("\n");
printf("c) display policy capabilities\n");
printf("p) display the list of permissive types\n");
printf("u) display unknown handling setting\n");
printf("F) display filename_trans rules\n");
- printf("\n");
- printf("f) set output file\n");
- printf("m) display menu\n");
+ if (interactive) {
+ printf("\n");
+ printf("f) set output file\n");
+ printf("m) display menu\n");
+ }
printf("q) quit\n");
return 0;
}
@@ -454,7 +463,7 @@ int main(int argc, char **argv)
close(fd);
if (!cmds)
- menu();
+ menu(cmds == NULL);
for (;;) {
if (cmds) {
ans[0] = *cmds++;
@@ -570,7 +579,7 @@ int main(int argc, char **argv)
exit(0);
break;
case 'm':
- menu();
+ menu(1);
break;
default:
if (cmds) {
@@ -579,7 +588,7 @@ int main(int argc, char **argv)
exit(1);
}
printf("\nInvalid choice\n");
- menu();
+ menu(1);
break;
}
Signed-off-by: Masatake YAMATO <yamato@redhat.com> --- checkpolicy/test/dispol.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)