-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5yTmMACgkQrlYvE4MpobOHuACdHBHq9xOiB7nzEBt74nR7ZYGr XIcAoKar2TBFGIbf9Bw2J2Qkr+IPWkzN =CaRC -----END PGP SIGNATURE-----
>From 807ec599da45da8956106ff09a9ec1e429d37f93 Mon Sep 17 00:00:00 2001 From: Eric Paris <eparis@xxxxxxxxxx> Date: Thu, 8 Sep 2011 17:25:22 -0400 Subject: [PATCH 07/67] policycoreutils: audit2allow: use alternate policy file Add a --policy option to audit2allow to make it use an alternate use specified policy instead of the running policy. Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- policycoreutils/audit2allow/audit2allow | 14 +++++++++++--- policycoreutils/audit2allow/audit2allow.1 | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/policycoreutils/audit2allow/audit2allow b/policycoreutils/audit2allow/audit2allow index 5435e9d..ffc1f4c 100644 --- a/policycoreutils/audit2allow/audit2allow +++ b/policycoreutils/audit2allow/audit2allow @@ -1,4 +1,4 @@ -#! /usr/bin/python -E +#! /usr/bin/python -Es # Authors: Karl MacMillan <kmacmillan@xxxxxxxxxxxxxxxxx> # # Copyright (C) 2006-2007 Red Hat @@ -28,6 +28,7 @@ import sepolgen.objectmodel as objectmodel import sepolgen.defaults as defaults import sepolgen.module as module from sepolgen.sepolgeni18n import _ +import selinux.audit2why as audit2why class AuditToPolicy: VERSION = "%prog .1" @@ -46,6 +47,7 @@ class AuditToPolicy: help="audit messages since last boot conflicts with -i") parser.add_option("-a", "--all", action="store_true", dest="audit", default=False, help="read input from audit log - conflicts with -i") + parser.add_option("-p", "--policy", dest="policy", default=None, help="Policy file to use for analysis") parser.add_option("-d", "--dmesg", action="store_true", dest="dmesg", default=False, help="read input from dmesg - conflicts with --all and --input") parser.add_option("-i", "--input", dest="input", @@ -231,9 +233,7 @@ class AuditToPolicy: def __output_audit2why(self): import selinux - import selinux.audit2why as audit2why import seobject - audit2why.init() for i in self.__parser.avc_msgs: rc, bools = audit2why.analyze(i.scontext.to_string(), i.tcontext.to_string(), i.tclass, i.accesses) if rc >= 0: @@ -350,11 +350,19 @@ class AuditToPolicy: def main(self): try: self.__parse_options() + if self.__options.policy: + audit2why.init(self.__options.policy) + else: + audit2why.init() + self.__read_input() self.__process_input() self.__output() except KeyboardInterrupt: sys.exit(0) + except ValueError, e: + print e + sys.exit(1) if __name__ == "__main__": app = AuditToPolicy() diff --git a/policycoreutils/audit2allow/audit2allow.1 b/policycoreutils/audit2allow/audit2allow.1 index fd9eb88..a854a45 100644 --- a/policycoreutils/audit2allow/audit2allow.1 +++ b/policycoreutils/audit2allow/audit2allow.1 @@ -67,6 +67,9 @@ Generate module/require output <modulename> .B "\-M <modulename>" Generate loadable module package, conflicts with -o .TP +.B "\-p <policyfile>" | "\-\-policy <policyfile>" +Policy file to use for analysis +.TP .B "\-o <outputfile>" | "\-\-output <outputfile>" append output to .I <outputfile> -- 1.7.6.2