-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlD+poEACgkQrlYvE4MpobPTkQCeP/PvgnS8tBg3Py06ANXUYQZ3 RRkAn2XGKh85bmqQKOYrd64MgKHtmtys =euwM -----END PGP SIGNATURE-----
>From 6c781a97ac0e0532a1b6cf33eb9f30910210a2b9 Mon Sep 17 00:00:00 2001 From: rhatdan <dwalsh@xxxxxxxxxx> Date: Thu, 4 Oct 2012 16:03:16 -0400 Subject: [PATCH 37/84] policycoreutils: semanage: use sepolicy for boolean dictionary Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- policycoreutils/semanage/seobject.py | 49 ++++-------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py index 22eac14..83d04b1 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -24,6 +24,9 @@ import pwd, grp, string, selinux, tempfile, os, re, sys, stat from semanage import *; PROGNAME = "policycoreutils" +import sepolicy +from sepolicy import boolean_desc, boolean_category, gen_bool_dict +gen_bool_dict() import sepolgen.module as module from IPy import IP @@ -122,39 +125,6 @@ class nulllogger: def commit(self,success): pass -import xml.etree.ElementTree - -booleans_dict = {} -try: - tree = xml.etree.ElementTree.parse("/usr/share/selinux/devel/policy.xml") - for l in tree.findall("layer"): - for m in l.findall("module"): - for b in m.findall("tunable"): - desc = b.find("desc").find("p").text.strip("\n") - desc = re.sub("\n", " ", desc) - booleans_dict[b.get('name')] = (m.get("name"), b.get('dftval'), desc) - for b in m.findall("bool"): - desc = b.find("desc").find("p").text.strip("\n") - desc = re.sub("\n", " ", desc) - booleans_dict[b.get('name')] = (m.get("name"), b.get('dftval'), desc) - for i in tree.findall("bool"): - desc = i.find("desc").find("p").text.strip("\n") - desc = re.sub("\n", " ", desc) - booleans_dict[i.get('name')] = (_("global"), i.get('dftval'), desc) - for i in tree.findall("tunable"): - desc = i.find("desc").find("p").text.strip("\n") - desc = re.sub("\n", " ", desc) - booleans_dict[i.get('name')] = (_("global"), i.get('dftval'), desc) -except IOError, e: - #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]*" @@ -383,13 +353,7 @@ class permissiveRecords(semanageRecords): return l def list(self, heading = 1, locallist = 0): - try: - import setools - except: - print "only able to list permissive types when setools is installed" - return - - all = map(lambda y: y["name"], filter(lambda x: x["permissive"], setools.seinfo(setools.TYPE))) + all = map(lambda y: y["name"], filter(lambda x: x["permissive"], sepolicy.info(sepolicy.TYPE))) if len(all) == 0: return @@ -2125,10 +2089,7 @@ class booleanRecords(semanageRecords): def get_category(self, name): name = selinux.selinux_boolean_sub(name) - if name in booleans_dict: - return _(booleans_dict[name][0]) - else: - return _("unknown") + return boolean_category(name) def customized(self): l = [] -- 1.8.1