[policycoreutils/f14/master] - Stop polgengui from crashing if selinux policy is not installed

Daniel J Walsh dwalsh at fedoraproject.org
Fri Sep 10 15:47:51 UTC 2010


commit 7bbaa602fec05433b95140f8ad3e287e94363e37
Author: Dan Walsh <dwalsh at redhat.com>
Date:   Fri Sep 10 11:47:40 2010 -0400

    - Stop polgengui from crashing if selinux policy is not installed

 policycoreutils-gui.patch |   44 ++++++++++++++++++++++++++++++--------------
 policycoreutils.spec      |    7 +++++--
 2 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/policycoreutils-gui.patch b/policycoreutils-gui.patch
index 51b4347..d5c3964 100644
--- a/policycoreutils-gui.patch
+++ b/policycoreutils-gui.patch
@@ -5783,8 +5783,8 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgen.gladep policy
 +</glade-project>
 diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policycoreutils-2.0.83/gui/polgengui.py
 --- nsapolicycoreutils/gui/polgengui.py	1969-12-31 19:00:00.000000000 -0500
-+++ policycoreutils-2.0.83/gui/polgengui.py	2010-08-05 17:40:33.000000000 -0400
-@@ -0,0 +1,650 @@
++++ policycoreutils-2.0.83/gui/polgengui.py	2010-09-10 11:45:24.000000000 -0400
+@@ -0,0 +1,657 @@
 +#!/usr/bin/python -Es
 +#
 +# polgengui.py - GUI for SELinux Config tool in system-config-selinux
@@ -5878,8 +5878,18 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policyc
 +    
 +    def __init__(self):
 +        self.xml = xml
-+        self.all_types=polgen.get_all_types()
-+        self.all_modules=polgen.get_all_modules()
++        try:
++            self.all_types = polgen.get_all_types()
++            self.all_modules = polgen.get_all_modules()
++            self.all_roles = polgen.get_all_roles()
++            self.all_users = polgen.get_all_users()
++        except RuntimeError, e:
++            self.all_types = []
++            self.all_modules = []
++            self.all_roles = []
++            self.all_users = []
++            self.error(str(e))
++
 +        self.name=""
 +        xml.signal_connect("on_delete_clicked", self.delete)
 +        xml.signal_connect("on_delete_boolean_clicked", self.delete_boolean)
@@ -5970,13 +5980,10 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policyc
 +        col = gtk.TreeViewColumn(_("Existing_User"), gtk.CellRendererText(), text = 0)
 +        self.existing_user_treeview.append_column(col)
 +
-+        roles = polgen.get_all_roles()
-+        for i in roles:
++        for i in self.all_roles:
 +            iter = self.role_store.append()
 +            self.role_store.set_value(iter, 0, i[:-2])
 +
-+        self.types = polgen.get_all_types()
-+
 +        self.transition_treeview = self.xml.get_widget("transition_treeview")
 +        self.transition_store = gtk.ListStore(gobject.TYPE_STRING)
 +        self.transition_treeview.set_model(self.transition_store)
@@ -5993,7 +6000,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policyc
 +        col = gtk.TreeViewColumn(_("Application"), gtk.CellRendererText(), text = 0)
 +        self.user_transition_treeview.append_column(col)
 +
-+        for i in polgen.get_all_users():
++        for i in self.all_users:
 +            iter = self.user_transition_store.append()
 +            self.user_transition_store.set_value(iter, 0, i[:-2])
 +            iter = self.existing_user_store.append()
@@ -6010,7 +6017,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policyc
 +        for i in polgen.methods:
 +            m = re.findall("(.*)%s" % polgen.USER_TRANSITION_INTERFACE, i) 
 +            if len(m) > 0:
-+                if "%s_exec_t" % m[0] in self.types:
++                if "%s_exec_t" % m[0] in self.all_types:
 +                    iter = self.transition_store.append()
 +                    self.transition_store.set_value(iter, 0, m[0])
 +                continue
@@ -6437,8 +6444,8 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgengui.py policyc
 +    app.stand_alone()
 diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgen.py policycoreutils-2.0.83/gui/polgen.py
 --- nsapolicycoreutils/gui/polgen.py	1969-12-31 19:00:00.000000000 -0500
-+++ policycoreutils-2.0.83/gui/polgen.py	2010-08-05 17:40:15.000000000 -0400
-@@ -0,0 +1,1309 @@
++++ policycoreutils-2.0.83/gui/polgen.py	2010-09-10 11:45:43.000000000 -0400
+@@ -0,0 +1,1318 @@
 +#!/usr/bin/python -Es
 +#
 +# Copyright (C) 2007-2010 Red Hat 
@@ -6638,6 +6645,8 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgen.py policycore
 +                    self.ports = get_all_ports()
 +                except ValueError, e:
 +                    print "Can not get port types, must be root for this information"
++                except RuntimeError, e:
++                    print "Can not get port types", e
 +
 +                self.symbols = {} 
 +                self.symbols["openlog"] = "set_use_kerberos(True)"
@@ -6786,7 +6795,6 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgen.py policycore
 +		self.transition_domains = []
 +		self.transition_users = []
 +                self.roles = []
-+                self.all_roles = get_all_roles()
 +
 +        def __isnetset(self, l):
 +            return l[ALL] or l[RESERVED] or l[UNRESERVED] or len(l[PORTS]) > 0
@@ -7157,10 +7165,18 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/gui/polgen.py policycore
 +                    tmp = re.sub("TEMPLATETYPE", self.name, user.te_admin_domain_rules)
 +                    newte += re.sub("APPLICATION", app, tmp)
 +
++                all_roles = []
++                try:
++                    all_roles = get_all_roles()
++                except ValueError, e:
++                    print "Can not get all roles, must be root for this information"
++                except RuntimeError, e:
++                    print "Can not get all roles", e
++
 +                for u in self.transition_users:
 +                    role = u.split("_u")[0]
 +                    
-+                    if (role + "_r") in self.all_roles:
++                    if (role + "_r") in all_roles:
 +                        tmp =  re.sub("TEMPLATETYPE", self.name, user.te_admin_trans_rules)
 +                        newte += re.sub("USER", role, tmp)
 +
diff --git a/policycoreutils.spec b/policycoreutils.spec
index 1df53c5..bd9075d 100644
--- a/policycoreutils.spec
+++ b/policycoreutils.spec
@@ -7,7 +7,7 @@
 Summary: SELinux policy core utilities
 Name:	 policycoreutils
 Version: 2.0.83
-Release: 25%{?dist}
+Release: 26%{?dist}
 License: GPLv2
 Group:	 System Environment/Base
 Source:  http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz
@@ -315,7 +315,10 @@ fi
 exit 0
 
 %changelog
-* Thu Sep 8 2010 Dan Walsh <dwalsh at redhat.com> 2.0.83-25
+* Fri Sep 10 2010 Dan Walsh <dwalsh at redhat.com> 2.0.83-26
+- Stop polgengui from crashing if selinux policy is not installed
+
+* Thu Sep 9 2010 Dan Walsh <dwalsh at redhat.com> 2.0.83-25
 - Fix bug preventing sandbox from using -l 
 
 * Tue Sep 7 2010 Dan Walsh <dwalsh at redhat.com> 2.0.83-24


More information about the scm-commits mailing list