Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: new regression test to reproduce lp-2061981 #13848

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions tests/regression/lp-2061981/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
summary: Ensure that the personal-files interface works with a non-standard home dir

details: |
Check that the personal-files interface works with a non-standard home directory
like /home/department/user_name. The issue raise shows how the snap connected
to the personal-files interface returns an error like:
cannot use invalid home directory "/home/department/user_name": permission denied

systems: [ubuntu-22.04-64]

environment:
TEST_USER: test2
TEST_USER_HOME: /home/subdir/test2

prepare: |
useradd --create-home --home-dir "$TEST_USER_HOME" "$TEST_USER"
tests.cleanup defer rmdir /home/subdir
tests.cleanup defer userdel --remove "$TEST_USER"
mkdir "$TEST_USER_HOME"/other-subdir
touch "$TEST_USER_HOME"/other-subdir/testfile
chown -R "$TEST_USER" -R "$TEST_USER_HOME"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to install a re-packaged snapd snap here.

"$TESTSTOOLS"/snaps-state install-local test-snapd-sh

tests.session prepare -u "$TEST_USER"
tests.cleanup defer tests.session restore -u "$TEST_USER"

restore: |
tests.cleanup restore

debug: |
set +x
journalctl | grep DENIED
cat /etc/apparmor.d/tunables/home
cat /etc/apparmor.d/tunables/home.d/snapd
set -e

execute: |
snap set system homedirs="$(dirname "$TEST_USER_HOME")"
snap connect test-snapd-sh:personal-files

tests.session -u "$TEST_USER" exec test-snapd-sh.with-personal-files-plug -c 'ls other-subdir/' | MATCH testfile
3 changes: 3 additions & 0 deletions tests/regression/lp-2061981/test-snapd-sh/bin/sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
PS1='$ '
exec /bin/sh "$@"
12 changes: 12 additions & 0 deletions tests/regression/lp-2061981/test-snapd-sh/meta/snap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test-snapd-sh
summary: A no-strings-attached, no-fuss shell for writing tests
version: 1.0

plugs:
personal-files:
write: [$HOME/other-subdir]

apps:
with-personal-files-plug:
command: bin/sh
plugs: [personal-files]