From 6f3e231dc9bc11772573bf9683de9804460362d1 Mon Sep 17 00:00:00 2001 From: Tobias Kaufmann Date: Thu, 9 Sep 2021 10:05:04 +0200 Subject: mount-copybind: add SELinux support bind mounts don't use the SELinux label of the target, but the SELinux label of the source. This patch restores the SELinux context of the bind mount recursively using restorecon. Signed-off-by: Tobias Kaufmann Signed-off-by: Alexandre Belloni --- meta/recipes-core/volatile-binds/files/mount-copybind | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'meta/recipes-core') diff --git a/meta/recipes-core/volatile-binds/files/mount-copybind b/meta/recipes-core/volatile-binds/files/mount-copybind index e32e675308..57a5ce5f21 100755 --- a/meta/recipes-core/volatile-binds/files/mount-copybind +++ b/meta/recipes-core/volatile-binds/files/mount-copybind @@ -46,6 +46,12 @@ if [ -d "$mountpoint" ]; then fi mount -o "bind$options" "$spec" "$mountpoint" + # restore the selinux context. + if command -v selinuxenabled > /dev/null 2>&1; then + if selinuxenabled; then + restorecon -R "$mountpoint" + fi + fi fi elif [ -f "$mountpoint" ]; then if [ ! -f "$spec" ]; then @@ -53,4 +59,10 @@ elif [ -f "$mountpoint" ]; then fi mount -o "bind$options" "$spec" "$mountpoint" + # restore the selinux context. + if command -v selinuxenabled > /dev/null 2>&1; then + if selinuxenabled; then + restorecon -R "$mountpoint" + fi + fi fi -- cgit 1.2.3-korg