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