Skip to contentSkip to conversation

Make yum/extract_rpms optional so that apt based systems can use tool

PATCH In review Dan Walsh 2 participants 2 messages Oct 31, 2013 SELinux security module

lore
Share & tools
lore

Dan Walsh

author
#0 lore raw

PATCH 1/1 Make yum/extract_rpms optional so that apt based systems can use tool

---
 policycoreutils/sepolicy/sepolicy/generate.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
policycoreutils/sepolicy/sepolicy/generate.py +5 -2
index 15366c3..6b53035 100644
@@ -26,7 +26,6 @@ import re
 import sepolicy
 from sepolicy import get_all_types, get_all_attributes, get_all_roles
 import time
-import yum
 
 from templates import executable
 from templates import boolean
@@ -1252,6 +1251,7 @@ allow %s_t %s_t:%s_socket name_%s;
 		return fcfile
 
         def __extract_rpms(self):
+            import yum
             yb = yum.YumBase()
             yb.setCacheDir()
 
@@ -1293,7 +1293,10 @@ allow %s_t %s_t:%s_socket name_%s;
                                 self.add_dir(fname)
 
         def gen_writeable(self):
-            self.__extract_rpms()
+            try:
+                self.__extract_rpms()
+            except ImportError:
+                pass
 
             if os.path.isfile("/var/run/%s.pid"  % self.name):
                 self.add_file("/var/run/%s.pid"  % self.name)
Signature · 7 lines
1.8.3.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 27 lines · Dan Walsh
---
 policycoreutils/sepolicy/sepolicy/generate.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
policycoreutils/sepolicy/sepolicy/generate.py +1 -1
index 15366c3..6b53035 100644
@@ -26,7 +26,6 @@ import re
 import sepolicy
 from sepolicy import get_all_types, get_all_attributes, get_all_roles
 import time
-import yum
 
 from templates import executable
 from templates import boolean
@@ -1252,6 +1251,7 @@ allow %s_t %s_t:%s_socket name_%s;
 		return fcfile
 
         def __extract_rpms(self):
+            import yum
             yb = yum.YumBase()
             yb.setCacheDir()
 
@@ -1293,7 +1293,10 @@ allow %s_t %s_t:%s_socket name_%s;
                                 self.add_dir(fname)

policycoreutils/sepolicy/sepolicy/generate.py allow %s_t %s_t:%s_socket name_%s; · line 1302

Quoted 10 lines
policycoreutils/sepolicy/sepolicy/generate.py +4 -1
 
         def gen_writeable(self):
-            self.__extract_rpms()
+            try:
+                self.__extract_rpms()
+            except ImportError:
+                pass
 
             if os.path.isfile("/var/run/%s.pid"  % self.name):
                 self.add_file("/var/run/%s.pid"  % self.name)

I pushed this as policycoreutils-2.2.1 since it fixes a bug in using sepolicy generate on non-yum-based distros.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.