All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>, SE Linux <selinux@tycho.nsa.gov>
Subject: audit2allow patch
Date: Wed, 23 Jan 2008 17:22:43 -0500	[thread overview]
Message-ID: <4797BE33.1070504@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fan through pychecker and cleaned up some bugs.

Also added booleans description from policy.xml file

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkeXvjMACgkQrlYvE4MpobOsgwCfbTTJxThRmfUw5LHQGhsG99vj
rtwAoMTo1ms2h6dOQXmrtLpHrwB1Ec5Z
=mNcO
-----END PGP SIGNATURE-----

[-- Attachment #2: audit2allow.patch --]
[-- Type: text/plain, Size: 4503 bytes --]

--- nsapolicycoreutils/audit2allow/audit2allow	2008-01-23 16:47:07.000000000 -0500
+++ policycoreutils-2.0.37/audit2allow/audit2allow	2008-01-23 17:15:21.000000000 -0500
@@ -19,7 +19,6 @@
 #
 
 import sys
-import tempfile
 
 import sepolgen.audit as audit
 import sepolgen.policygen as policygen
@@ -153,9 +152,9 @@
 
     def __process_input(self):
         if self.__options.type:
-            filter = audit.TypeFilter(self.__options.type)
-            self.__avs = self.__parser.to_access(filter)
-            self.__selinux_errs = self.__parser.to_role(filter)
+            avcfilter = audit.TypeFilter(self.__options.type)
+            self.__avs = self.__parser.to_access(avcfilter)
+            self.__selinux_errs = self.__parser.to_role(avcfilter)
         else:
             self.__avs = self.__parser.to_access()
             self.__selinux_errs = self.__parser.to_role()
@@ -221,13 +220,14 @@
     def __output_audit2why(self):
             import selinux
             import selinux.audit2why as audit2why
+            import seobject
             audit2why.init("%s.%s" % (selinux.selinux_binary_policy_path(), selinux.security_policyvers()))
             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:
                     print "%s\n\tWas caused by:" % i.message
                 if rc == audit2why.NOPOLICY:
-                    raise "Must call policy_init first"
+                    raise RuntimeError("Must call policy_init first")
                 if rc == audit2why.BADTCON:
                     print "Invalid Target Context %s\n" % i.tcontext
                     continue
@@ -241,7 +241,7 @@
                     print "Invalid permission %s\n" % i.accesses
                     continue
                 if rc == audit2why. BADCOMPUTE:
-                    raise "Error during access vector computation"
+                    raise RuntimeError("Error during access vector computation")
                 if rc == audit2why.ALLOW:
                     print "\t\tUnknown - would be allowed by active policy\n",
                     print "\t\tPossible mismatch between this policy and the one under which the audit message was generated.\n"
@@ -251,12 +251,14 @@
                     if len(bools) > 1:
                         print "\tOne of the following booleans was set incorrectly."
                         for b in bools:
-                            print "\n\tBoolean %s is %d. Allow access by executing:" % (b[0], not b[1])
-                            print "\t# setsebool -P %s %d"  % (b[0], b[1])
+                            print "\n\tBoolean %s is %d." % (b[0], not b[1])
+                            print "\tDescription:\n\t%s\n"  % seobject.boolean_desc(b[0])
+                            print "\tAllow access by executing:\n\t# setsebool -P %s %d"  % (b[0], b[1])
                     else:
-                        print "\tThe boolean %s was set incorrectly.  Allow access by executing:" % bools[0][0]
-                        print "\t# setsebool -P %s %d\n"  % (bools[0][0], bools[0][1])
-
+                        print "\tThe boolean %s set incorrectly. " % (bools[0][0])
+                        print "\n\tBoolean %s is %d." % (bools[0][0], bools[0][1])
+                        print "\tDescription:\n\t%s\n"  % seobject.boolean_desc(bools[0][0])
+                        print "\tAllow access by executing:\n\t# setsebool -P %s %d"  % (bools[0][0], bools[0][1])
                     continue
 
                 if rc == audit2why.TERULE:
--- nsapolicycoreutils/semanage/seobject.py	2007-12-10 21:42:27.000000000 -0500
+++ policycoreutils-2.0.37/semanage/seobject.py	2008-01-23 17:13:45.000000000 -0500
@@ -117,6 +117,12 @@
        #print _("Failed to translate booleans.\n%s") % e
        pass
 
+def boolean_desc(boolean):
+       if boolean in booleans_dict:
+              return _(booleans_dict[boolean][2])
+       else:
+              return boolean
+
 def validate_level(raw):
 	sensitivity = "s[0-9]*"
 	category = "c[0-9]*"
@@ -1456,10 +1462,7 @@
 		return ddict
 			
         def get_desc(self, boolean):
-               if boolean in booleans_dict:
-                      return _(booleans_dict[boolean][2])
-               else:
-                      return boolean
+               return boolean_desc(boolean)
 
         def get_category(self, boolean):
                if boolean in booleans_dict:

[-- Attachment #3: audit2allow.patch.sig --]
[-- Type: application/octet-stream, Size: 72 bytes --]

             reply	other threads:[~2008-01-23 22:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-23 22:22 Daniel J Walsh [this message]
2008-01-24 18:37 ` audit2allow patch Stephen Smalley
2008-01-24 18:56   ` Stephen Smalley
2008-01-24 19:30     ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2009-01-13 13:52 Daniel J Walsh
2009-02-18 21:16 ` Joshua Brindle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4797BE33.1070504@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.