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

dirs: fix classic support detection #3940

Merged

Conversation

chipaca
Copy link
Contributor

@chipaca chipaca commented Sep 19, 2017

dirs.SupportsClassicConfinement() was (mostly) just checking

dirs.SnapMountDir == "/snap"

without looking at dirs.GlobalRootDir, meaning that any and all
tests that (properly) called dirs.SetRootDir(c.MkDir()),
dirs.SupportsClassicConfinement() was returning false.

This was hidden by the fact that most tests that cared would simply
return on getting false, instead of skipping, so they quietly passed
without testing anything.

This PR addresses both of these issues.

`dirs.SupportsClassicConfinement()` was (mostly) just checking

    dirs.SnapMountDir == "/snap"

without looking at `dirs.GlobalRootDir`, meaning that any and all
tests that (properly) called `dirs.SetRootDir(c.MkDir())`,
`dirs.SupportsClassicConfinement()` was returning `false`.

This was hidden by the fact that most tests that cared would simply
return on getting `false`, instead of skipping, so they quietly passed
without testing anything.

This PR addresses both of these issues.
Copy link
Contributor

@zyga zyga left a comment

Choose a reason for hiding this comment

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

Looks good, thank you

chipaca added a commit to chipaca/snappy that referenced this pull request Sep 19, 2017
…thing

Currently, if a snap is installed with any flags, refreshed
(preserving those flags), and reverted, the flags are lost.

This means that a classic snap suddenly finds itself confined in
strict mode (ditto for devmode; ditto again for jailmode). The current
reply to this was "revert needs explicit flags", which is surprising
to most users. The reasoning being that a snap can be classic at
revision N, and strict at revision M, and as flags are per snap and
not per revision we can't make a sensible decision.

> The  right fix is to make flags per revision, obviously (in retrospect)

While we find time to implement the right fix, this PR changes the
behaviour so that explicit flags are needed to _change_ the flags that
the snap is installed with; if nothing is specified, flags are
preserved.

This will break the aforementioned flip-flopping snaps, but preserve
the apparently more common case. So the breakage is moved from a
bigger corner case to a smaller one, which is a win.

This builds on canonical#3940.
@codecov-io
Copy link

codecov-io commented Sep 19, 2017

Codecov Report

Merging #3940 into master will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3940      +/-   ##
=========================================
+ Coverage   75.86%   75.9%   +0.03%     
=========================================
  Files         416     417       +1     
  Lines       36130   36194      +64     
=========================================
+ Hits        27410   27472      +62     
- Misses       6794    6798       +4     
+ Partials     1926    1924       -2
Impacted Files Coverage Δ
dirs/dirs.go 98.07% <ø> (+0.07%) ⬆️
interfaces/builtin/desktop.go 86.84% <0%> (-13.16%) ⬇️
overlord/snapstate/handlers.go 65.53% <0%> (-0.07%) ⬇️
release/release.go 100% <0%> (ø) ⬆️
overlord/snapstate/snapmgr.go 82.29% <0%> (ø) ⬆️
apparmor/probe.go
release/apparmor.go 94.11% <0%> (ø)
interfaces/backends/backends.go 100% <0%> (ø)
overlord/snapstate/snapstate.go 80.09% <0%> (+0.09%) ⬆️
interfaces/apparmor/backend.go 72.04% <0%> (+0.53%) ⬆️
... and 2 more

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 c23401a...564bec8. Read the comment docs.

@mvo5 mvo5 merged commit ad0f069 into canonical:master Sep 20, 2017
chipaca added a commit that referenced this pull request Sep 29, 2017
…thing (#3941)

* overlord/snapstate: prefer a smaller corner case for doing the wrong thing

Currently, if a snap is installed with any flags, refreshed
(preserving those flags), and reverted, the flags are lost.

This means that a classic snap suddenly finds itself confined in
strict mode (ditto for devmode; ditto again for jailmode). The current
reply to this was "revert needs explicit flags", which is surprising
to most users. The reasoning being that a snap can be classic at
revision N, and strict at revision M, and as flags are per snap and
not per revision we can't make a sensible decision.

> The  right fix is to make flags per revision, obviously (in retrospect)

While we find time to implement the right fix, this PR changes the
behaviour so that explicit flags are needed to _change_ the flags that
the snap is installed with; if nothing is specified, flags are
preserved.

This will break the aforementioned flip-flopping snaps, but preserve
the apparently more common case. So the breakage is moved from a
bigger corner case to a smaller one, which is a win.

This builds on #3940.

* add comments; fix spreads

* skip the jailmode check on distros with no strict confinement
@chipaca chipaca deleted the fix-classic-support-detection-and-skip-tests branch November 14, 2017 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants