Blame SOURCES/0021-python-semanage-Do-not-traceback-when-the-default-po.patch

9bbebd
From 5938d18536f4c0a76521d1f0721e981e6570b012 Mon Sep 17 00:00:00 2001
9bbebd
From: Petr Lautrbach <plautrba@redhat.com>
9bbebd
Date: Thu, 4 Apr 2019 23:02:56 +0200
9bbebd
Subject: [PATCH] python/semanage: Do not traceback when the default policy is
9bbebd
 not available
9bbebd
9bbebd
"import seobject" causes "import sepolicy" which crashes when the system policy
9bbebd
is not available. It's better to provide an error message instead.
9bbebd
9bbebd
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
9bbebd
---
9bbebd
 python/semanage/semanage | 37 +++++++++++++++++++++----------------
9bbebd
 1 file changed, 21 insertions(+), 16 deletions(-)
9bbebd
9bbebd
diff --git a/python/semanage/semanage b/python/semanage/semanage
9bbebd
index 56db3e0d..4c766ae3 100644
9bbebd
--- a/python/semanage/semanage
9bbebd
+++ b/python/semanage/semanage
9bbebd
@@ -25,7 +25,6 @@
9bbebd
 
9bbebd
 import traceback
9bbebd
 import argparse
9bbebd
-import seobject
9bbebd
 import sys
9bbebd
 PROGNAME = "selinux-python"
9bbebd
 try:
9bbebd
@@ -129,21 +128,6 @@ class SetImportFile(argparse.Action):
9bbebd
                 sys.exit(1)
9bbebd
         setattr(namespace, self.dest, values)
9bbebd
 
9bbebd
-# define dictonary for seobject OBEJCTS
9bbebd
-object_dict = {
9bbebd
-    'login': seobject.loginRecords,
9bbebd
-    'user': seobject.seluserRecords,
9bbebd
-    'port': seobject.portRecords,
9bbebd
-    'module': seobject.moduleRecords,
9bbebd
-    'interface': seobject.interfaceRecords,
9bbebd
-    'node': seobject.nodeRecords,
9bbebd
-    'fcontext': seobject.fcontextRecords,
9bbebd
-    'boolean': seobject.booleanRecords,
9bbebd
-    'permissive': seobject.permissiveRecords,
9bbebd
-    'dontaudit': seobject.dontauditClass,
9bbebd
-    'ibpkey': seobject.ibpkeyRecords,
9bbebd
-    'ibendport': seobject.ibendportRecords
9bbebd
-}
9bbebd
 
9bbebd
 def generate_custom_usage(usage_text, usage_dict):
9bbebd
     # generate custom usage from given text and dictonary
9bbebd
@@ -608,6 +592,7 @@ def setupInterfaceParser(subparsers):
9bbebd
 
9bbebd
 
9bbebd
 def handleModule(args):
9bbebd
+    import seobject
9bbebd
     OBJECT = seobject.moduleRecords(args)
9bbebd
     if args.action_add:
9bbebd
         OBJECT.add(args.action_add[0], args.priority)
9bbebd
@@ -846,6 +831,7 @@ def mkargv(line):
9bbebd
 
9bbebd
 
9bbebd
 def handleImport(args):
9bbebd
+    import seobject
9bbebd
     trans = seobject.semanageRecords(args)
9bbebd
     trans.start()
9bbebd
 
9bbebd
@@ -887,6 +873,25 @@ def createCommandParser():
9bbebd
     #To add a new subcommand define the parser for it in a function above and call it here.
9bbebd
     subparsers = commandParser.add_subparsers(dest='subcommand')
9bbebd
     subparsers.required = True
9bbebd
+
9bbebd
+    import seobject
9bbebd
+    # define dictonary for seobject OBEJCTS
9bbebd
+    global object_dict
9bbebd
+    object_dict = {
9bbebd
+        'login': seobject.loginRecords,
9bbebd
+        'user': seobject.seluserRecords,
9bbebd
+        'port': seobject.portRecords,
9bbebd
+        'module': seobject.moduleRecords,
9bbebd
+        'interface': seobject.interfaceRecords,
9bbebd
+        'node': seobject.nodeRecords,
9bbebd
+        'fcontext': seobject.fcontextRecords,
9bbebd
+        'boolean': seobject.booleanRecords,
9bbebd
+        'permissive': seobject.permissiveRecords,
9bbebd
+        'dontaudit': seobject.dontauditClass,
9bbebd
+        'ibpkey': seobject.ibpkeyRecords,
9bbebd
+        'ibendport': seobject.ibendportRecords
9bbebd
+    }
9bbebd
+
9bbebd
     setupImportParser(subparsers)
9bbebd
     setupExportParser(subparsers)
9bbebd
     setupLoginParser(subparsers)
9bbebd
-- 
9bbebd
2.21.0
9bbebd