diff --git a/snapcraft/commands/daemon.start b/snapcraft/commands/daemon.start index 8622927bd..b4d92af07 100755 --- a/snapcraft/commands/daemon.start +++ b/snapcraft/commands/daemon.start @@ -418,6 +418,13 @@ if [ "$(stat -c '%u' /proc)" = 0 ]; then fi fi + if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then + if [ "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns)" = "1" ]; then + echo "==> Disabling Apparmor unprivileged userns mediation" + echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true + fi + fi + if [ -e /proc/sys/kernel/unprivileged_userns_clone ]; then if [ "$(cat /proc/sys/kernel/unprivileged_userns_clone)" = "0" ]; then echo "==> Enabling unprivileged containers kernel support" diff --git a/snapcraft/wrappers/editor b/snapcraft/wrappers/editor index fde501685..3611cb88d 100755 --- a/snapcraft/wrappers/editor +++ b/snapcraft/wrappers/editor @@ -16,7 +16,8 @@ run_cmd() { } USERNS=1 -[ -e /proc/sys/kernel/unprivileged_userns_clone ] && grep -q 0 /proc/sys/kernel/unprivileged_userns_clone && USERNS=0 +[ -e /proc/sys/kernel/unprivileged_userns_clone ] && grep -qxF 0 /proc/sys/kernel/unprivileged_userns_clone && USERNS=0 +[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_userns && USERNS=0 find_and_spawn() { for path in / /usr/ /usr/local/; do diff --git a/snapcraft/wrappers/remote-viewer b/snapcraft/wrappers/remote-viewer index b8f178421..87429d3c7 100755 --- a/snapcraft/wrappers/remote-viewer +++ b/snapcraft/wrappers/remote-viewer @@ -15,7 +15,8 @@ run_cmd() { } USERNS=1 -[ -e /proc/sys/kernel/unprivileged_userns_clone ] && grep -q 0 /proc/sys/kernel/unprivileged_userns_clone && USERNS=0 +[ -e /proc/sys/kernel/unprivileged_userns_clone ] && grep -qxF 0 /proc/sys/kernel/unprivileged_userns_clone && USERNS=0 +[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_userns ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_userns && USERNS=0 find_and_spawn() { for path in / /usr/ /usr/local/; do