-
Notifications
You must be signed in to change notification settings - Fork 601
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
dirs: fix classic support detection #3940
Conversation
`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.
There was a problem hiding this 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
…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 Report
@@ 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
Continue to review full report at Codecov.
|
…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
dirs.SupportsClassicConfinement()
was (mostly) just checkingwithout looking at
dirs.GlobalRootDir
, meaning that any and alltests that (properly) called
dirs.SetRootDir(c.MkDir())
,dirs.SupportsClassicConfinement()
was returningfalse
.This was hidden by the fact that most tests that cared would simply
return on getting
false
, instead of skipping, so they quietly passedwithout testing anything.
This PR addresses both of these issues.