Files
snapd/randutil/export_test.go
Fred Lotter 9a5accce42 secboot: UUID generator error instead of panic
The randutil.RandomKernelUUID() used to generate a panic on failure.

The process of consolidating common code used by Pebble and Snapd
(e.g. randutil) highlighted the fact that an error return, as relied on by
Pebble, is a more flexibie approach and allows application code to decide
the severity, instead of the library function.

- Make secboot unlock code to deal with an error that can now be returned
  from the UUID generator.

- Add unit tests to cover the new error paths in the code.

Signed-off-by: Fred Lotter <fred.lotter@canonical.com>
2023-05-25 09:10:43 +02:00

31 lines
920 B
Go

// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2022 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package randutil
import "github.com/snapcore/snapd/testutil"
var KernelUUIDPath = kernelUUIDPath
func MockKernelUUIDPath(newPath string) (restore func()) {
restore = testutil.Backup(&kernelUUIDPath)
kernelUUIDPath = newPath
return restore
}