mirror of
https://github.com/ceph/ceph
synced 2024-12-30 15:33:31 +00:00
Merge pull request #31809 from jan--f/c-v-check-selinux
ceph-volume: check if we run in an selinux environment Reviewed-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
commit
842b10180d
@ -4,6 +4,7 @@ import getpass
|
||||
import pytest
|
||||
from textwrap import dedent
|
||||
from ceph_volume.util import system
|
||||
from mock.mock import patch
|
||||
|
||||
|
||||
class TestMkdirP(object):
|
||||
@ -260,8 +261,9 @@ class TestSetContext(object):
|
||||
system.set_context('/tmp/foo')
|
||||
assert len(fake_run.calls)
|
||||
|
||||
def test_selinuxenabled_doesnt_exist(self, stub_call, fake_run):
|
||||
stub_call(('', 'command not found: selinuxenabled', 127))
|
||||
@patch('ceph_volume.process.call')
|
||||
def test_selinuxenabled_doesnt_exist(self, mocked_call, fake_run):
|
||||
mocked_call.side_effect = FileNotFoundError()
|
||||
system.set_context('/tmp/foo')
|
||||
assert fake_run.calls == []
|
||||
|
||||
|
@ -297,7 +297,13 @@ def set_context(path, recursive=False):
|
||||
)
|
||||
return
|
||||
|
||||
stdout, stderr, code = process.call(['selinuxenabled'], verbose_on_failure=False)
|
||||
try:
|
||||
stdout, stderr, code = process.call(['selinuxenabled'],
|
||||
verbose_on_failure=False)
|
||||
except FileNotFoundError:
|
||||
logger.info('No SELinux found, skipping call to restorecon')
|
||||
return
|
||||
|
||||
if code != 0:
|
||||
logger.info('SELinux is not enabled, will not call restorecon')
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user