Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect all selinux calls with try/except #802

Merged
merged 1 commit into from
Aug 8, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 28 additions & 10 deletions library/setup
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,34 @@ class Facts(object):
self.facts['selinux']['status'] = 'disabled'
else:
self.facts['selinux']['status'] = 'enabled'
self.facts['selinux']['policyvers'] = selinux.security_policyvers()
(rc, configmode) = selinux.selinux_getenforcemode()
if rc == 0 and Facts.SELINUX_MODE_DICT.has_key(configmode):
self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT[configmode]
mode = selinux.security_getenforce()
if Facts.SELINUX_MODE_DICT.has_key(mode):
self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT[mode]
(rc, policytype) = selinux.selinux_getpolicytype()
if rc == 0:
self.facts['selinux']['type'] = policytype
try:
self.facts['selinux']['policyvers'] = selinux.security_policyvers()
except:
self.facts['selinux']['policyvers'] = 'unknown'
try:
(rc, configmode) = selinux.selinux_getenforcemode()
if rc == 0 and Facts.SELINUX_MODE_DICT.has_key(configmode):
self.facts['selinux']['config_mode'] = Facts.SELINUX_MODE_DICT[configmode]
else:
self.facts['selinux']['config_mode'] = 'unknown'
except OSError, e:
self.facts['selinux']['config_mode'] = 'unknown'
try:
mode = selinux.security_getenforce()
if Facts.SELINUX_MODE_DICT.has_key(mode):
self.facts['selinux']['mode'] = Facts.SELINUX_MODE_DICT[mode]
else:
self.facts['selinux']['mode'] = 'unknown'
except OSError, e:
self.facts['selinux']['mode'] = 'unknown'
try:
(rc, policytype) = selinux.selinux_getpolicytype()
if rc == 0:
self.facts['selinux']['type'] = policytype
else:
self.facts['selinux']['type'] = 'unknown'
except OSError, e:
self.facts['selinux']['type'] = 'unknown'

class Hardware(Facts):
"""
Expand Down