def test_set_context_doesnt_skip_with_env(self, stub_call, stub_which, fake_run, value): stub_call(('', '', 0)) stub_which() os.environ['CEPH_VOLUME_SKIP_RESTORECON'] = value system.set_context('/tmp/foo') assert len(fake_run.calls)
def mount_tmpfs(path): process.run([ 'mount', '-t', 'tmpfs', 'tmpfs', path ]) # Restore SELinux context system.set_context(path)
def mount_osd(device, osd_id, **kw): extras = [] is_vdo = kw.get('is_vdo', '0') if is_vdo == '1': extras = ['discard'] destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id) command = ['mount', '-t', 'xfs', '-o'] flags = conf.ceph.get_list( 'osd', 'osd_mount_options_xfs', default=constants.mount.get('xfs'), split=' ', ) command.append(_normalize_mount_flags(flags, extras=extras)) command.append(device) command.append(destination) process.run(command) # Restore SELinux context system.set_context(destination)
def mount_osd(device, osd_id, **kw): extras = [] is_vdo = kw.get('is_vdo', '0') if is_vdo == '1': extras = ['discard'] destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id) command = ['mount', '-t', 'xfs', '-o'] flags = conf.ceph.get_list( 'osd', 'osd_mount_options_xfs', default=constants.mount.get('xfs'), split=' ', ) command.append( _normalize_mount_flags(flags, extras=extras) ) command.append(device) command.append(destination) process.run(command) # Restore SELinux context system.set_context(destination)
def test_selinuxenabled_is_not_enabled(self, stub_call, fake_run): stub_call(('', '', 1)) system.set_context('/tmp/foo') assert fake_run.calls == []
def test_selinuxenabled_doesnt_exist(self, mocked_call, fake_run): mocked_call.side_effect = FileNotFoundError() system.set_context('/tmp/foo') assert fake_run.calls == []
def test_set_context_no_skip_on_executable(self, stub_call, stub_which, fake_run): stub_call(('', '', 0)) stub_which('/bin/restorecon') system.set_context('/tmp/foo') assert len(fake_run.calls)
def test_set_context_skips(self, stub_call, fake_run, value): stub_call(('', '', 0)) os.environ['CEPH_VOLUME_SKIP_RESTORECON'] = value system.set_context('/tmp/foo') assert fake_run.calls == []
def test_selinuxenabled_doesnt_exist(self, stub_call, fake_run): stub_call(('', 'command not found: selinuxenabled', 127)) system.set_context('/tmp/foo') assert fake_run.calls == []