forked from canonical/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request canonical#1857 from mvo5/bugfix/regression-home-sn…
…ap-root-owned snap/snapenv, tests: use root's data dirs when running via sudo
- Loading branch information
Showing
3 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
summary: Regression test that ensures that $HOME/snap is not root owned for sudo commands | ||
|
||
prepare: | | ||
# ensure we have no snap user data directory yet | ||
rm -rf /home/test/snap | ||
rm -rf /root/snap | ||
snap install test-snapd-tools | ||
execute: | | ||
# run a snap command via sudo | ||
output=$(su -l -c "sudo /snap/bin/test-snapd-tools.env" test) | ||
# ensure SNAP_USER_DATA points to the right place | ||
echo $output | grep -E SNAP_USER_DATA=/root/snap/test-snapd-tools/[0-9]+ | ||
echo $output | grep SNAP_USER_COMMON=/root/snap/test-snapd-tools/common | ||
echo "Verify that the /root/snap directory created and root owned" | ||
if [ $(stat -c '%U' /root/snap) != "root" ]; then | ||
echo "The /root/snap directory is not owned by root" | ||
ls -ld /snap/snap | ||
exit 1 | ||
fi | ||
echo "Verify that there is no /home/test/snap appearing" | ||
if [ -e /home/test/snap ]; then | ||
user=$(stat -c '%U' /home/test/snap) | ||
echo "An unexpected /home/test/snap directory got created (owner $user)" | ||
ls -ld /home/test/snap | ||
exit 1 | ||
fi |