cmd: rework reexec detection #3608

Merged
merged 5 commits into from Jul 20, 2017

Conversation

Projects
None yet
4 participants
Collaborator

mvo5 commented Jul 20, 2017

This reworked the detection if we already re-execed or not. The logic is simply to check if the /proc/self/exe points inside the /snap/* directory. If that is the case we did already re-exec and there is no need to do anything further.

This also contains the bugfix when re-execing from snapd 2.21 which used to set SNAP_REEXEC=0.

mvo5 added some commits Jul 20, 2017

Fix re-exec bug when starting from snapd 2.21
We need to special case the env handling for snapd re-execing
from 2.21. In this version of snap/snapd we did set SNAP_REEXEC=0
when we re-execed.

In this case we need to unset the reExecKey to ensure that subsequent
run of snap/snapd (e.g. when using classic confinement) will *not*
prevented from re-execing.
Do not use SNAP_DID_REEXEC, use /proc/self/exe instead
Check /proc/self/exe directly to determine if we already re-execed
instead of relying on a environement key.

This looks OK; if the tests pass then let's merge it

tests: add recursive classic confinement call test
This test validates that a snap using classic confinement can call into
the snap itself. We discovered several bugs related to this behavior
so the test will help to ensure this does not regress anymore.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

codecov-io commented Jul 20, 2017

Codecov Report

Merging #3608 into master will decrease coverage by 0.02%.
The diff coverage is 47.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3608      +/-   ##
==========================================
- Coverage    74.9%   74.88%   -0.03%     
==========================================
  Files         380      380              
  Lines       32952    32961       +9     
==========================================
  Hits        24682    24682              
- Misses       6477     6485       +8     
- Partials     1793     1794       +1
Impacted Files Coverage Δ
cmd/cmd.go 83.87% <47.05%> (-8.99%) ⬇️
overlord/ifacestate/helpers.go 62.33% <0%> (ø) ⬆️
interfaces/sorting.go 91.42% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a462005...8401774. Read the comment docs.

mvo5 added some commits Jul 20, 2017

@zyga zyga merged commit fa7cae5 into snapcore:master Jul 20, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment