From: Tobias Kaufmann Date: Thu, 9 Sep 2021 08:05:04 +0000 (+0200) Subject: mount-copybind: add SELinux support X-Git-Tag: uninative-3.5~1342 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=6f3e231dc9bc11772573bf9683de9804460362d1;p=openembedded-core.git 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 --- 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