diff options
| author | Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 2017-03-20 15:27:28 +0100 |
|---|---|---|
| committer | Zygmunt Krynicki <zygmunt.krynicki@canonical.com> | 2017-03-20 15:27:28 +0100 |
| commit | 0d40a0c344e6b6fbb9a6ef2005c316da663b79c8 (patch) | |
| tree | 876296d0bb48585994f979259c239edd72bed1ec | |
| parent | 20c14ce99a55ec03bb3e212ac6285318a3eb9830 (diff) | |
tests: copy updated files with cp -a to preserve mode bitssnap-confine-wrap
When snap-confine was renamed to snap-wrap we noticed that snap-wrap is no longer setuid root. This seems to be caused by "cp" vs "cp -a" done in the test setup script. In the past this worked because both source and destination were +s and then cp didn't have to create a new file. This patch also adds a check that ensures snap-wrap is +s and that snap-confine is not in the core snap if it was removed from the package. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
| -rwxr-xr-x | tests/lib/prepare.sh | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh index 722af0c3db..c8cf6ce22e 100755 --- a/tests/lib/prepare.sh +++ b/tests/lib/prepare.sh @@ -24,16 +24,25 @@ update_core_snap_for_classic_reexec() { # Now unpack the core, inject the new snap-exec/snapctl into it unsquashfs "$snap" - cp /usr/lib/snapd/snap-exec squashfs-root/usr/lib/snapd/ - cp /usr/bin/snapctl squashfs-root/usr/bin/ + cp -a /usr/lib/snapd/snap-exec squashfs-root/usr/lib/snapd/ + cp -a /usr/bin/snapctl squashfs-root/usr/bin/ # also inject new version of snap-wrap and snap-scard-ns - cp /usr/lib/snapd/snap-discard-ns squashfs-root/usr/lib/snapd/ - cp /usr/lib/snapd/snap-wrap squashfs-root/usr/lib/snapd/ + cp -a /usr/lib/snapd/snap-discard-ns squashfs-root/usr/lib/snapd/ + cp -a /usr/lib/snapd/snap-wrap squashfs-root/usr/lib/snapd/ + # also remove snap-confine if it is not in the package anymore + if [ ! -e /usr/lib/snapd/snap-confine ]; then + rm -f squashfs-root/usr/lib/snapd/snap-confine + fi + # also make sure snap-wrap is setuid root + if [ $(stat -c '%a' squashfs-root/usr/lib/snapd/snap-wrap) != 4755 ]; then + echo "snap-wrap is not setuid root?" + exit 1 + fi # also add snap/snapd because we re-exec by default and want to test # this version - cp /usr/lib/snapd/snapd squashfs-root/usr/lib/snapd/ - cp /usr/lib/snapd/info squashfs-root/usr/lib/snapd/ - cp /usr/bin/snap squashfs-root/usr/bin/snap + cp -a /usr/lib/snapd/snapd squashfs-root/usr/lib/snapd/ + cp -a /usr/lib/snapd/info squashfs-root/usr/lib/snapd/ + cp -a /usr/bin/snap squashfs-root/usr/bin/snap # repack, cheating to speed things up (4sec vs 1.5min) mv "$snap" "${snap}.orig" if [[ "$SPREAD_SYSTEM" == ubuntu-14.04-* ]]; then |
