cmd,tests: fix classic confinement confusing re-execution code (#3598) #3674

Merged
merged 1 commit into from Aug 7, 2017
Jump to file or symbol
Failed to load files and symbols.
+30 −1
Split
View
@@ -20,6 +20,7 @@
package cmd
import (
+ "fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -136,6 +137,7 @@ func InternalToolPath(tool string) string {
}
if !strings.HasPrefix(exe, dirs.SnapMountDir) {
+ logger.Noticef("exe doesn't have snap mount dir prefix: %q vs %q", exe, dirs.SnapMountDir)
return distroTool
}
View
@@ -17,6 +17,10 @@ install_local_devmode() {
install_local "$1" --devmode
}
+install_local_classic() {
+ install_local "$1" --classic
+}
+
# mksnap_fast creates a snap using a faster compress algorithm (gzip)
# than the regular snaps (which are lzma)
mksnap_fast() {
@@ -16,7 +16,7 @@ prepare: |
restart avahi-daemon
else
systemctl daemon-reload
- systemctl restart avahi-daemon.{service,socket}
+ systemctl restart avahi-daemon.{socket,service}
fi
restore: |
@@ -0,0 +1 @@
+env
@@ -0,0 +1,22 @@
+summary: Work-in-progress on reproducing lp:1704860
+systems: [ubuntu-16.04-64]
+details: |
+ In this bug, an app belonging go a snap using classic confinement confuses
+ the re-execution system in a way that causes distribution version of
+ snap-confine to be used, instead of the one from the core snap. If the
+ version outside and inside are different and incompatible the classily
+ confined snap will malfunction.
+
+ This specifically happens when the distribution uses snapd 2.25 and the
+ core snap has snapd 2.26.9
+
+ Testing is somewhat complex but we can approximate by observing the value
+ of SNAP_DID_REEXEC as set inside the environment set up by snap run
+ --shell. Since neither snap-confine nor snap-exec re-execute themselves
+ (instead they rely on snap run to run the right tool in the first place)
+ this is safe to do.
+execute: |
+ . $TESTSLIB/snaps.sh
+ install_local_classic test-snapd-classic-confinement
+ # We don't want to see SNAP_DID_REEXEC being set.
+ snap run --shell test-snapd-classic-confinement ./snap-env-query.sh | MATCH -v 'SNAP_DID_REEXEC='