policycoreutils: semanage: good error message is sepolgen python module missing

We only need the sepolgen python module if we are setting up permissive
types.  As this has been removed from the core code in Fedora/RHEL we
include a better user error message pointing them how to find the
required module.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Dan Walsh 2012-11-19 16:10:27 -05:00 committed by Eric Paris
parent c247992d38
commit da867f68b2
2 changed files with 8 additions and 4 deletions

View file

@ -375,8 +375,8 @@ Object-specific Options (see above):
OBJECT = seobject.moduleRecords(store)
if object == "permissive":
OBJECT = seobject.permissiveRecords(store)
OBJECT = seobject.permissiveRecords(store)
if object == "dontaudit":
OBJECT = seobject.dontauditClass(store)

View file

@ -27,7 +27,6 @@ PROGNAME = "policycoreutils"
import sepolicy
from sepolicy import boolean_desc, boolean_category, gen_bool_dict
gen_bool_dict()
import sepolgen.module as module
from IPy import IP
import gettext
@ -258,7 +257,7 @@ class semanageRecords:
class moduleRecords(semanageRecords):
def __init__(self, store):
semanageRecords.__init__(self, store)
semanageRecords.__init__(self, store)
def get_all(self):
l = []
@ -375,6 +374,11 @@ class permissiveRecords(semanageRecords):
def add(self, type):
import glob
try:
import sepolgen.module as module
except ImportError:
raise ValueError(_("The sepolgen python module is required to setup permissive domains.\nIn some distributions it is included in the policycoreutils-devel patckage.\n# yum install policycoreutils-devel\nOr similar for your distro."))
name = "permissive_%s" % type
dirname = "/var/lib/selinux"
os.chdir(dirname)