Skip to content

Commit

Permalink
fixup! overlord/fdestate/fdestate.go: use HashAlg type from secboot
Browse files Browse the repository at this point in the history
  • Loading branch information
valentindavid committed Nov 5, 2024
1 parent d6a7b55 commit 505073e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
10 changes: 4 additions & 6 deletions overlord/fdestate/fdemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ func Manager(st *state.State, runner *state.TaskRunner) (*FDEManager, error) {
preseed: snapdenv.Preseeding(),
}

if secboot.WithSecbootSupport {
boot.ResealKeyForBootChains = m.resealKeyForBootChains
boot.ResealKeyForBootChains = m.resealKeyForBootChains

if !m.preseed {
if err := initModeFromModeenv(m); err != nil {
return nil, err
}
if secboot.WithSecbootSupport && !m.preseed {
if err := initModeFromModeenv(m); err != nil {
return nil, err
}
}

Expand Down
27 changes: 27 additions & 0 deletions overlord/fdestate/fdemgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ func (s *fdeMgrSuite) testMountResolveError(c *C, tc mountResolveTestCase) {
}

func (s *fdeMgrSuite) TestStateInitMountResolveError_StatePresentNoError(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

s.st.Lock()
s.st.Set("fde", fdestate.FdeState{})
s.st.Unlock()
Expand All @@ -325,27 +329,42 @@ func (s *fdeMgrSuite) TestStateInitMountResolveError_StatePresentNoError(c *C) {
}

func (s *fdeMgrSuite) TestStateInitMountResolveError_NoDataNoSaveNoError(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

s.testMountResolveError(c, mountResolveTestCase{
dataResolveErr: disks.ErrNoDmUUID,
saveResolveErr: disks.ErrNoDmUUID,
})
}

func (s *fdeMgrSuite) TestStateInitMountResolveError_NoDataFails(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

s.testMountResolveError(c, mountResolveTestCase{
dataResolveErr: fmt.Errorf("mock error data"),
expectedError: "cannot initialize FDE state: cannot resolve data partition mount: mock error data",
})
}

func (s *fdeMgrSuite) TestStatetInitMountResolveError_NoSaveFails(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}
s.testMountResolveError(c, mountResolveTestCase{
saveResolveErr: fmt.Errorf("mock error save"),
expectedError: "cannot initialize FDE state: cannot resolve save partition mount: mock error save",
})
}

func (s *fdeMgrSuite) TestStateInitMountResolveError_Recover(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

m := boot.Modeenv{
Mode: boot.ModeRecover,
RecoverySystem: "1234",
Expand All @@ -361,6 +380,10 @@ func (s *fdeMgrSuite) TestStateInitMountResolveError_Recover(c *C) {
}

func (s *fdeMgrSuite) TestMountResolveError_FactoryReset(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

m := boot.Modeenv{
Mode: boot.ModeFactoryReset,
RecoverySystem: "1234",
Expand Down Expand Up @@ -389,6 +412,10 @@ func (s *fdeMgrSuite) TestManagerUC_16_18(c *C) {
}

func (s *fdeMgrSuite) TestManagerPreseeding(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}

defer snapdenv.MockPreseeding(true)()

manager, err := fdestate.Manager(s.st, s.runner)
Expand Down
3 changes: 3 additions & 0 deletions overlord/managers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7851,6 +7851,9 @@ func (s *mgrsSuiteCore) testRemodelUC20WithRecoverySystem(c *C, encrypted bool)
}

func (s *mgrsSuiteCore) TestRemodelUC20WithRecoverySystemEncrypted(c *C) {
if !secboot.WithSecbootSupport {
c.Skip("secboot is not available")
}
const encrypted bool = true
s.testRemodelUC20WithRecoverySystem(c, encrypted)
}
Expand Down

0 comments on commit 505073e

Please sign in to comment.