Use the same option "-C" used to ouput CIL from a policy.conf, but
now
generate CIL from a binary policy instead of giving an error.
Use the option "-F" to generate a policy.conf file from a binary
policy.
Signed-off-by: James Carter <jwcart2@xxxxxxxxxxxxx>
---
checkpolicy/checkpolicy.c | 60 +++++++++++++++++++++++++++++++++--
------------
1 file changed, 42 insertions(+), 18 deletions(-)
diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c
index b98bfcd..9694f57 100644
--- a/checkpolicy/checkpolicy.c
+++ b/checkpolicy/checkpolicy.c
@@ -75,6 +75,8 @@
#include <sys/mman.h>
#include <sepol/module_to_cil.h>
+#include <sepol/kernel_to_cil.h>
+#include <sepol/kernel_to_conf.h>
#include <sepol/policydb/policydb.h>
#include <sepol/policydb/services.h>
#include <sepol/policydb/conditional.h>
@@ -105,7 +107,7 @@ unsigned int policyvers = POLICYDB_VERSION_MAX;
static __attribute__((__noreturn__)) void usage(const char
*progname)
{
printf
- ("usage: %s [-b] [-C] [-d] [-U handle_unknown
(allow,deny,reject)] [-M]"
+ ("usage: %s [-b] [-C] [-F] [-d] [-U handle_unknown
(allow,deny,reject)] [-M]"
"[-c policyvers (%d-%d)] [-o output_file] [-t
target_platform (selinux,xen)]"
"[input_file]\n",
progname, POLICYDB_VERSION_MIN, POLICYDB_VERSION_MAX);
@@ -388,7 +390,7 @@ int main(int argc, char **argv)
size_t scontext_len, pathlen;
unsigned int i;
unsigned int protocol, port;
- unsigned int binary = 0, debug = 0, cil = 0;
+ unsigned int binary = 0, debug = 0, cil = 0, conf = 0;
struct val_to_name v;
int ret, ch, fd, target = SEPOL_TARGET_SELINUX;
unsigned int nel, uret;
@@ -411,11 +413,12 @@ int main(int argc, char **argv)
{"handle-unknown", required_argument, NULL, 'U'},
{"mls", no_argument, NULL, 'M'},
{"cil", no_argument, NULL, 'C'},
+ {"conf",no_argument, NULL, 'F'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
- while ((ch = getopt_long(argc, argv, "o:t:dbU:MCVc:h",
long_options, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "o:t:dbU:MCFVc:h",
long_options, NULL)) != -1) {
switch (ch) {
case 'o':
outfile = optarg;
@@ -461,6 +464,9 @@ int main(int argc, char **argv)
case 'C':
cil = 1;
break;
+ case 'F':
+ conf = 1;
+ break;
case 'c':{
long int n;
errno = 0;
@@ -510,12 +516,17 @@ int main(int argc, char **argv)
sepol_set_policydb(&policydb);
sepol_set_sidtab(&sidtab);
+ if (cil && conf) {
+ fprintf(stderr, "Can't convert to CIL and
policy.conf at the same time\n");
+ exit(1);
+ }
+
if (binary) {
- if (cil) {
- fprintf(stderr, "%s: Converting
kernel policy to CIL is not supported\n",
- argv[0]);
- exit(1);
- }
+ /* if (cil) { */
+ /* fprintf(stderr, "%s: Converting
kernel policy to CIL is not supported\n", */
+ /* argv[0]); */
+ /* exit(1); */
+ /* } */