Skip to content

Commit

Permalink
tests: fix snap-seccomp-blocks-tty-injection on partially confined sy…
Browse files Browse the repository at this point in the history
…stems and on ubuntu core
  • Loading branch information
mvo5 committed May 27, 2023
1 parent 64cf6b0 commit 2e93f91
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/main/snap-seccomp-blocks-tty-injection/task.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
summary: Ensure that the snap-seccomp blocks tty command injection

# ubuntu-core: excluded because there is no gcc there
systems: [-ubuntu-core-*]

prepare: |
echo "Install a helper snap (for seccomp confinement testing)"
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
Expand All @@ -16,8 +19,10 @@ execute: |
# use /dev/tty1 as input so that we use a real virtual console which
# supports TIOCSTI / TIOCLINUX - but first make sure the snap can access it
# through AppArmor
sed -i 's|^}$| /dev/tty1 rw,\n}|' /var/lib/snapd/apparmor/profiles/snap.test-snapd-sh.sh
apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.test-snapd-sh.sh
if [ "$(snap debug confinement)" = strict ]; then
sed -i 's|^}$| /dev/tty1 rw,\n}|' /var/lib/snapd/apparmor/profiles/snap.test-snapd-sh.sh
apparmor_parser -r /var/lib/snapd/apparmor/profiles/snap.test-snapd-sh.sh
fi
snap run test-snapd-sh.sh -c "\$SNAP_COMMON/test-tiocsti" < /dev/tty1 2>&1 | MATCH 'normal TIOCSTI: -1 \(Operation not permitted\)'
snap run test-snapd-sh.sh -c "\$SNAP_COMMON/test-tiocsti" < /dev/tty1 2>&1 | MATCH 'high-bit-set TIOCSTI: -1 \(Operation not permitted\)'
Expand Down

0 comments on commit 2e93f91

Please sign in to comment.