Skip to content

Commit

Permalink
Merge pull request #181 from simondeziel/apparmor_restrict_unprivileg…
Browse files Browse the repository at this point in the history
…ed_unconfined

Disable Apparmor unprivileged unconfined mediation
  • Loading branch information
tomponline authored Oct 6, 2023
2 parents cf788c8 + 504b745 commit 62568e7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions snapcraft/commands/daemon.start
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,24 @@ if [ "$(stat -c '%u' /proc)" = 0 ]; then
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"
echo 1 > /proc/sys/kernel/unprivileged_userns_clone || true
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"
echo 1 > /proc/sys/kernel/unprivileged_userns_clone || true
if [ -e /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined ]; then
if [ "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined)" = "1" ]; then
echo "==> Disabling Apparmor unprivileged unconfined mediation"
echo 0 > /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined || true
fi
fi
fi
Expand Down
1 change: 1 addition & 0 deletions snapcraft/wrappers/editor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ run_cmd() {
USERNS=1
[ -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
[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined && USERNS=0

find_and_spawn() {
for path in / /usr/ /usr/local/; do
Expand Down
1 change: 1 addition & 0 deletions snapcraft/wrappers/remote-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ run_cmd() {
USERNS=1
[ -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
[ -e /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined ] && grep -qxF 1 /proc/sys/kernel/apparmor_restrict_unprivileged_unconfined && USERNS=0

find_and_spawn() {
for path in / /usr/ /usr/local/; do
Expand Down

0 comments on commit 62568e7

Please sign in to comment.