|
|
0b05ab |
From c667dbb3ebf05eafeb4fb55d3ffa22d27c25420c Mon Sep 17 00:00:00 2001
|
|
|
0b05ab |
From: David Lehman <dlehman@redhat.com>
|
|
|
0b05ab |
Date: Wed, 24 Oct 2018 20:12:20 -0400
|
|
|
0b05ab |
Subject: [PATCH 1/3] Don't try to update sysfs path for non-block devices.
|
|
|
0b05ab |
(#1579375)
|
|
|
0b05ab |
|
|
|
0b05ab |
---
|
|
|
0b05ab |
blivet/devices/file.py | 3 +++
|
|
|
0b05ab |
blivet/devices/nfs.py | 3 +++
|
|
|
0b05ab |
blivet/devices/nodev.py | 3 +++
|
|
|
0b05ab |
3 files changed, 9 insertions(+)
|
|
|
0b05ab |
|
|
|
0b05ab |
diff --git a/blivet/devices/file.py b/blivet/devices/file.py
|
|
|
0b05ab |
index 55522c1d..fa3dfb8a 100644
|
|
|
0b05ab |
--- a/blivet/devices/file.py
|
|
|
0b05ab |
+++ b/blivet/devices/file.py
|
|
|
0b05ab |
@@ -132,6 +132,9 @@ def is_name_valid(self, name):
|
|
|
0b05ab |
# Override StorageDevice.is_name_valid to allow /
|
|
|
0b05ab |
return not('\x00' in name or name == '.' or name == '..')
|
|
|
0b05ab |
|
|
|
0b05ab |
+ def update_sysfs_path(self):
|
|
|
0b05ab |
+ pass
|
|
|
0b05ab |
+
|
|
|
0b05ab |
|
|
|
0b05ab |
class SparseFileDevice(FileDevice):
|
|
|
0b05ab |
|
|
|
0b05ab |
diff --git a/blivet/devices/nfs.py b/blivet/devices/nfs.py
|
|
|
0b05ab |
index 97cbe01e..a0142f91 100644
|
|
|
0b05ab |
--- a/blivet/devices/nfs.py
|
|
|
0b05ab |
+++ b/blivet/devices/nfs.py
|
|
|
0b05ab |
@@ -77,3 +77,6 @@ def update_size(self, newsize=None):
|
|
|
0b05ab |
def is_name_valid(self, name):
|
|
|
0b05ab |
# Override StorageDevice.is_name_valid to allow /
|
|
|
0b05ab |
return not('\x00' in name or name == '.' or name == '..')
|
|
|
0b05ab |
+
|
|
|
0b05ab |
+ def update_sysfs_path(self):
|
|
|
0b05ab |
+ pass
|
|
|
0b05ab |
diff --git a/blivet/devices/nodev.py b/blivet/devices/nodev.py
|
|
|
0b05ab |
index f6129258..f1b87392 100644
|
|
|
0b05ab |
--- a/blivet/devices/nodev.py
|
|
|
0b05ab |
+++ b/blivet/devices/nodev.py
|
|
|
0b05ab |
@@ -75,6 +75,9 @@ def destroy(self):
|
|
|
0b05ab |
def update_size(self, newsize=None):
|
|
|
0b05ab |
pass
|
|
|
0b05ab |
|
|
|
0b05ab |
+ def update_sysfs_path(self):
|
|
|
0b05ab |
+ pass
|
|
|
0b05ab |
+
|
|
|
0b05ab |
|
|
|
0b05ab |
class TmpFSDevice(NoDevice):
|
|
|
0b05ab |
|
|
|
0b05ab |
|
|
|
0b05ab |
From acb0953ad89327b3ffd3571b6d45565762548203 Mon Sep 17 00:00:00 2001
|
|
|
0b05ab |
From: David Lehman <dlehman@redhat.com>
|
|
|
0b05ab |
Date: Wed, 24 Oct 2018 20:27:22 -0400
|
|
|
0b05ab |
Subject: [PATCH 2/3] Only try to set selinux context for lost+found on ext
|
|
|
0b05ab |
file systems.
|
|
|
0b05ab |
|
|
|
0b05ab |
Related: rhbz#1579375
|
|
|
0b05ab |
---
|
|
|
0b05ab |
blivet/formats/fs.py | 19 ++++++++++++++-----
|
|
|
0b05ab |
tests/formats_test/selinux_test.py | 5 ++++-
|
|
|
0b05ab |
2 files changed, 18 insertions(+), 6 deletions(-)
|
|
|
0b05ab |
|
|
|
0b05ab |
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
|
|
|
0b05ab |
index 81e367f4..b915a2de 100644
|
|
|
0b05ab |
--- a/blivet/formats/fs.py
|
|
|
0b05ab |
+++ b/blivet/formats/fs.py
|
|
|
0b05ab |
@@ -569,11 +569,6 @@ def _post_setup(self, **kwargs):
|
|
|
0b05ab |
ret = util.reset_file_context(mountpoint, chroot)
|
|
|
0b05ab |
if not ret:
|
|
|
0b05ab |
log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.")
|
|
|
0b05ab |
- lost_and_found_context = util.match_path_context("/lost+found")
|
|
|
0b05ab |
- lost_and_found_path = os.path.join(mountpoint, "lost+found")
|
|
|
0b05ab |
- ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot)
|
|
|
0b05ab |
- if not ret:
|
|
|
0b05ab |
- log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)
|
|
|
0b05ab |
|
|
|
0b05ab |
def _pre_teardown(self, **kwargs):
|
|
|
0b05ab |
if not super(FS, self)._pre_teardown(**kwargs):
|
|
|
0b05ab |
@@ -840,6 +835,20 @@ class Ext2FS(FS):
|
|
|
0b05ab |
parted_system = fileSystemType["ext2"]
|
|
|
0b05ab |
_metadata_size_factor = 0.93 # ext2 metadata may take 7% of space
|
|
|
0b05ab |
|
|
|
0b05ab |
+ def _post_setup(self, **kwargs):
|
|
|
0b05ab |
+ super(Ext2FS, self)._post_setup(**kwargs)
|
|
|
0b05ab |
+
|
|
|
0b05ab |
+ options = kwargs.get("options", "")
|
|
|
0b05ab |
+ chroot = kwargs.get("chroot", "/")
|
|
|
0b05ab |
+ mountpoint = kwargs.get("mountpoint") or self.mountpoint
|
|
|
0b05ab |
+
|
|
|
0b05ab |
+ if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
|
|
0b05ab |
+ lost_and_found_context = util.match_path_context("/lost+found")
|
|
|
0b05ab |
+ lost_and_found_path = os.path.join(mountpoint, "lost+found")
|
|
|
0b05ab |
+ ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot)
|
|
|
0b05ab |
+ if not ret:
|
|
|
0b05ab |
+ log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)
|
|
|
0b05ab |
+
|
|
|
0b05ab |
register_device_format(Ext2FS)
|
|
|
0b05ab |
|
|
|
0b05ab |
|
|
|
0b05ab |
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py
|
|
|
0b05ab |
index 79c10327..028e084e 100644
|
|
|
0b05ab |
--- a/tests/formats_test/selinux_test.py
|
|
|
0b05ab |
+++ b/tests/formats_test/selinux_test.py
|
|
|
0b05ab |
@@ -43,7 +43,10 @@ def exec_mount_selinux_format(self, formt, *args):
|
|
|
0b05ab |
|
|
|
0b05ab |
blivet.flags.flags.selinux_reset_fcon = True
|
|
|
0b05ab |
fmt.setup(mountpoint="dummy") # param needed to pass string check
|
|
|
0b05ab |
- lsetfilecon.assert_called_with(ANY, lost_found_context)
|
|
|
0b05ab |
+ if isinstance(fmt, fs.Ext2FS):
|
|
|
0b05ab |
+ lsetfilecon.assert_called_with(ANY, lost_found_context)
|
|
|
0b05ab |
+ else:
|
|
|
0b05ab |
+ lsetfilecon.assert_not_called()
|
|
|
0b05ab |
|
|
|
0b05ab |
lsetfilecon.reset_mock()
|
|
|
0b05ab |
|
|
|
0b05ab |
|
|
|
0b05ab |
From 1b4e658f098bda3161ff0d5ffee07ea9be5c1d15 Mon Sep 17 00:00:00 2001
|
|
|
0b05ab |
From: David Lehman <dlehman@redhat.com>
|
|
|
0b05ab |
Date: Wed, 24 Oct 2018 20:33:36 -0400
|
|
|
0b05ab |
Subject: [PATCH 3/3] Don't try to set selinux context for nodev or vfat file
|
|
|
0b05ab |
systems.
|
|
|
0b05ab |
|
|
|
0b05ab |
Related: rhbz#1579375
|
|
|
0b05ab |
---
|
|
|
0b05ab |
blivet/formats/fs.py | 5 ++++-
|
|
|
0b05ab |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
0b05ab |
|
|
|
0b05ab |
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
|
|
|
0b05ab |
index b915a2de..6f09eaff 100644
|
|
|
0b05ab |
--- a/blivet/formats/fs.py
|
|
|
0b05ab |
+++ b/blivet/formats/fs.py
|
|
|
0b05ab |
@@ -76,6 +76,7 @@ class FS(DeviceFormat):
|
|
|
0b05ab |
_sync_class = fssync.UnimplementedFSSync
|
|
|
0b05ab |
_writelabel_class = fswritelabel.UnimplementedFSWriteLabel
|
|
|
0b05ab |
_writeuuid_class = fswriteuuid.UnimplementedFSWriteUUID
|
|
|
0b05ab |
+ _selinux_supported = True
|
|
|
0b05ab |
# This constant is aquired by testing some filesystems
|
|
|
0b05ab |
# and it's giving us percentage of space left after the format.
|
|
|
0b05ab |
# This number is more guess than precise number because this
|
|
|
0b05ab |
@@ -565,7 +566,7 @@ def _post_setup(self, **kwargs):
|
|
|
0b05ab |
chroot = kwargs.get("chroot", "/")
|
|
|
0b05ab |
mountpoint = kwargs.get("mountpoint") or self.mountpoint
|
|
|
0b05ab |
|
|
|
0b05ab |
- if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
|
|
0b05ab |
+ if self._selinux_supported and flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
|
|
0b05ab |
ret = util.reset_file_context(mountpoint, chroot)
|
|
|
0b05ab |
if not ret:
|
|
|
0b05ab |
log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.")
|
|
|
0b05ab |
@@ -902,6 +903,7 @@ class FATFS(FS):
|
|
|
0b05ab |
_metadata_size_factor = 0.99 # fat metadata may take 1% of space
|
|
|
0b05ab |
# FIXME this should be fat32 in some cases
|
|
|
0b05ab |
parted_system = fileSystemType["fat16"]
|
|
|
0b05ab |
+ _selinux_supported = False
|
|
|
0b05ab |
|
|
|
0b05ab |
def generate_new_uuid(self):
|
|
|
0b05ab |
ret = ""
|
|
|
0b05ab |
@@ -1235,6 +1237,7 @@ class NoDevFS(FS):
|
|
|
0b05ab |
""" nodev filesystem base class """
|
|
|
0b05ab |
_type = "nodev"
|
|
|
0b05ab |
_mount_class = fsmount.NoDevFSMount
|
|
|
0b05ab |
+ _selinux_supported = False
|
|
|
0b05ab |
|
|
|
0b05ab |
def __init__(self, **kwargs):
|
|
|
0b05ab |
FS.__init__(self, **kwargs)
|