-
Notifications
You must be signed in to change notification settings - Fork 587
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
snapstate: do not allow classic mode for strict snaps #6039
Changes from 7 commits
c611736
21c6993
9dbe291
b55a5db
a82c8ba
ccd4623
a960454
b9c8127
e0c146b
563744b
4b243d1
0afa031
c21e3a2
be6bd59
99eab3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,6 +731,11 @@ func UpdateMany(ctx context.Context, st *state.State, names []string, userID int | |
|
||
params := func(update *snap.Info) (string, Flags, *SnapState) { | ||
snapst := stateByInstanceName[update.InstanceName()] | ||
updateFlags := snapst.Flags | ||
if !update.NeedsClassic() && updateFlags.Classic { | ||
// allow updating from classic to strict | ||
updateFlags.Classic = false | ||
} | ||
return snapst.Channel, snapst.Flags, snapst | ||
|
||
} | ||
|
@@ -1118,7 +1123,12 @@ func Update(st *state.State, name, channel string, revision snap.Revision, userI | |
} | ||
|
||
params := func(update *snap.Info) (string, Flags, *SnapState) { | ||
return channel, flags, &snapst | ||
updateFlags := flags | ||
if !update.NeedsClassic() && updateFlags.Classic { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly sad that our code requires to duplicate this with the code above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually given that infoForUpdate is also changed (below) - do we need this change here or is the change in infoForUpdate sufficient? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Snap info is verified twice, once in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bboozzoo Thanks for checking this! Would be great if you could double check, the less code the better :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropped the part in |
||
// allow updating from classic to strict | ||
updateFlags.Classic = false | ||
} | ||
return channel, updateFlags, &snapst | ||
} | ||
|
||
_, tts, err := doUpdate(context.TODO(), st, []string{name}, updates, params, userID, &flags) | ||
|
@@ -1192,6 +1202,12 @@ func infoForUpdate(st *state.State, snapst *SnapState, name, channel string, rev | |
if err != nil { | ||
return nil, err | ||
} | ||
if !info.NeedsClassic() && flags.Classic { | ||
// thw new revision is no longer classic, but the one | ||
mvo5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// installed is, allow such transition so do not fail | ||
// validation | ||
flags.Classic = false | ||
} | ||
if err := validateInfoAndFlags(info, snapst, flags); err != nil { | ||
return nil, err | ||
} | ||
|
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.
👍