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