Skip to content
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

Allow exporting keys without efivars present and update CI staticcheck #363

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ clean:
.PHONY: lint
lint:
go vet ./...
go run honnef.co/go/tools/cmd/staticcheck@v0.4.7 ./...
go run honnef.co/go/tools/cmd/staticcheck@v0.5.1 ./...

.PHONY: test
test:
Expand Down
5 changes: 3 additions & 2 deletions cmd/sbctl/enroll-keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,12 @@ func KeySync(state *config.State, oems []string) error {
}

func RunEnrollKeys(state *config.State) error {
// SetupMode is not necessarily required on a partial enrollment
ok, err := state.Efivarfs.GetSetupMode()
if err != nil {
// EFI variables are missing in some CI / build environments and setup mode is not needed for exporting keys
if err != nil && enrollKeysCmdOptions.Export.Value == "" {
Foxboron marked this conversation as resolved.
Show resolved Hide resolved
return err
}
// SetupMode is not necessarily required for a partial enrollment and not needed for exporting keys
if !ok && enrollKeysCmdOptions.Partial.Value == "" && enrollKeysCmdOptions.Export.Value == "" {
return ErrSetupModeDisabled
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/sbctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ func main() {
} else if errors.Is(err, sbctl.ErrImmutable) {
logging.Println("You need to chattr -i files in efivarfs")
} else if errors.Is(err, sbctl.ErrOprom) {
logging.Error(fmt.Errorf(opromErrorMsg))
logging.Error(errors.New(opromErrorMsg))
} else if errors.Is(err, sbctl.ErrNoEventlog) {
logging.Error(fmt.Errorf(noEventlogErrorMsg))
logging.Error(errors.New(noEventlogErrorMsg))
} else if errors.Is(err, ErrSetupModeDisabled) {
logging.Error(fmt.Errorf(setupModeDisabled))
logging.Error(errors.New(setupModeDisabled))
} else if !errors.Is(err, ErrSilent) {
logging.Error(err)
}
Expand Down
Loading