The following set of patches tries to fix semanage in non-standard environments. A backtrace when semanage was run on a system without installed policy, see https://github.com/SELinuxProject/selinux/issues/81 https://bugzilla.redhat.com/show_bug.cgi?id=1558861 The fix is based on https://github.com/fishilico/selinux/commit/00eb0cc86185d2145ea3ec61df08c587faba1375 by Nicolas Iooss <nicolas.iooss@xxxxxxx> And when semanage was run -S <store>, sepolicy module was initialized with the default policy file (targeted) and also selinux module used the same default. It meant that semanage either backtraced when the default policy was not installed or used wrong store and therefore didn't behave correctly. E.g. # semanage login -S minimum -d -s unconfined_u -r s0-s0:c0.c1023 __default__ libsemanage.dbase_llist_query: could not query record value OSError: [Errno 0] Error