[PATCH] libsemanage: improve semanage_migrate_store import failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The python module import error in semanage_migrate_store was misleading.
Before, it would print that the module is not installed, even though
it is in fact on the system.

Now the python module import failure is correctly reported if the module
is not installed or the exact reason for failure is reported to the user.

Signed-off-by: Yuli Khodorkovskiy <yuli@xxxxxxxxxxxxxxx>
---
 libsemanage/utils/semanage_migrate_store | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libsemanage/utils/semanage_migrate_store b/libsemanage/utils/semanage_migrate_store
index 2e6cb278..50eb59ef 100755
--- a/libsemanage/utils/semanage_migrate_store
+++ b/libsemanage/utils/semanage_migrate_store
@@ -15,10 +15,12 @@ sepol = ctypes.cdll.LoadLibrary('libsepol.so.1')
 try:
 	import selinux
 	import semanage
-except:
+except ImportError:
 	print("You must install libselinux-python and libsemanage-python before running this tool", file=sys.stderr)
 	exit(1)
-
+except Exception as e:
+	print("Failed to import libselinux-python/libsemanage-python: %s" % str(e))
+	exit(1)
 
 def copy_file(src, dst):
 	if DEBUG:
-- 
2.19.0

_______________________________________________
Selinux mailing list
Selinux@xxxxxxxxxxxxx
To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx.
To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux