Skip to content

Commit 5fc7550

Browse files
o/snapstate: set userID from snapst and from opts as fallback for component installation
1 parent a0d8e70 commit 5fc7550

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

overlord/snapstate/component.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ func componentSetupsForInstall(ctx context.Context, st *state.State, names []str
188188
return nil, err
189189
}
190190

191-
// TODO:COMPS: figure out which user to use here
192-
user, err := userFromUserID(st, opts.UserID)
191+
userID, err := userIDForSnap(st, &snapst, opts.UserID)
192+
if err != nil {
193+
return nil, err
194+
}
195+
user, err := userFromUserID(st, userID)
193196
if err != nil {
194197
return nil, err
195198
}

overlord/snapstate/component_install_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,13 @@ func (s *snapmgrTestSuite) testInstallComponents(c *C, opts testInstallComponent
10851085
}
10861086
c.Assert(snapsupSetupProfiles.UserID, Equals, expectedUserID)
10871087

1088+
for _, op := range s.fakeBackend.ops {
1089+
if op.op == "storesvc-snap-action" || op.op == "storesvc-snap-action:action" {
1090+
c.Assert(op.userID, Equals, expectedUserID,
1091+
Commentf("expected userID %d in op %q but got %d", expectedUserID, op.op, op.userID))
1092+
}
1093+
}
1094+
10881095
prepareKmodComps := setupTs.Tasks()[1]
10891096
c.Assert(prepareKmodComps.Kind(), Equals, "prepare-kernel-modules-components")
10901097

0 commit comments

Comments
 (0)