fix setup module on Fedora Core 5 (#17175)

setup module fails with AttributeError: 'module' object has no attribute
'selinux_getpolicytype' in get_selinux_facts on Fedora Core 5
This commit is contained in:
Yann Autissier 2016-08-22 12:36:22 +02:00 committed by Brian Coca
parent 8e38f7475f
commit c048198567

View file

@ -427,7 +427,7 @@ class Facts(object):
self.facts['selinux']['status'] = 'enabled' self.facts['selinux']['status'] = 'enabled'
try: try:
self.facts['selinux']['policyvers'] = selinux.security_policyvers() self.facts['selinux']['policyvers'] = selinux.security_policyvers()
except OSError: except (AttributeError,OSError):
self.facts['selinux']['policyvers'] = 'unknown' self.facts['selinux']['policyvers'] = 'unknown'
try: try:
(rc, configmode) = selinux.selinux_getenforcemode() (rc, configmode) = selinux.selinux_getenforcemode()
@ -435,12 +435,12 @@ class Facts(object):
self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT.get(configmode, 'unknown') self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT.get(configmode, 'unknown')
else: else:
self.facts['selinux']['config_mode'] = 'unknown' self.facts['selinux']['config_mode'] = 'unknown'
except OSError: except (AttributeError,OSError):
self.facts['selinux']['config_mode'] = 'unknown' self.facts['selinux']['config_mode'] = 'unknown'
try: try:
mode = selinux.security_getenforce() mode = selinux.security_getenforce()
self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT.get(mode, 'unknown') self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT.get(mode, 'unknown')
except OSError: except (AttributeError,OSError):
self.facts['selinux']['mode'] = 'unknown' self.facts['selinux']['mode'] = 'unknown'
try: try:
(rc, policytype) = selinux.selinux_getpolicytype() (rc, policytype) = selinux.selinux_getpolicytype()
@ -448,7 +448,7 @@ class Facts(object):
self.facts['selinux']['type'] = policytype self.facts['selinux']['type'] = policytype
else: else:
self.facts['selinux']['type'] = 'unknown' self.facts['selinux']['type'] = 'unknown'
except OSError: except (AttributeError,OSError):
self.facts['selinux']['type'] = 'unknown' self.facts['selinux']['type'] = 'unknown'
def get_caps_facts(self): def get_caps_facts(self):