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

create-keys allows for specifying an export directory #259

Merged
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
21 changes: 17 additions & 4 deletions cmd/sbctl/create-keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ import (
"github.com/spf13/cobra"
)

var (
exportPath string = sbctl.KeysPath
databasePath string = sbctl.DatabasePath
)

var createKeysCmd = &cobra.Command{
Use: "create-keys",
Short: "Create a set of secure boot signing keys",
RunE: func(cmd *cobra.Command, args []string) error {
if err := sbctl.CreateDirectory(sbctl.KeysPath); err != nil {
if err := sbctl.CreateDirectory(exportPath); err != nil {
return err
}
uuid, err := sbctl.CreateGUID(sbctl.DatabasePath)
uuid, err := sbctl.CreateGUID(databasePath)
if err != nil {
return err
}
logging.Print("Created Owner UUID %s\n", uuid)
if !sbctl.CheckIfKeysInitialized(sbctl.KeysPath) {
if !sbctl.CheckIfKeysInitialized(exportPath) {
logging.Print("Creating secure boot keys...")
err := sbctl.InitializeSecureBootKeys(sbctl.KeysPath)
err := sbctl.InitializeSecureBootKeys(exportPath)
if err != nil {
logging.NotOk("")
return fmt.Errorf("couldn't initialize secure boot: %w", err)
Expand All @@ -36,7 +41,15 @@ var createKeysCmd = &cobra.Command{
},
}

func createKeysCmdFlags(cmd *cobra.Command) {
f := cmd.Flags()
f.StringVarP(&exportPath, "export", "e", "", "export file path. defaults to "+sbctl.KeysPath)
f.StringVarP(&databasePath, "database-path", "d", "", "location to create GUID file. defaults to "+sbctl.DatabasePath)
}

func init() {
createKeysCmdFlags(createKeysCmd)

CliCommands = append(CliCommands, cliCommand{
Cmd: createKeysCmd,
})
Expand Down
12 changes: 11 additions & 1 deletion docs/sbctl.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ EFI signing commands
Creates a set of signing keys used to sign EFI binaries. Currently, it
will create the following keys:
* Platform Key
* Key Exchange key
* Key Exchange Key
* Signature Database Key

*-e*, *--export*;;
The directory to persist the exported keys.

Default: "/usr/share/secureboot/keys/"

*-d*, *--database-path*;;
Path to save the GUID file when generating keys.

Default: "/usr/share/secureboot/"

**enroll-keys**::
Enrolls the creates key into the EFI variables. This puts the computer
out of SetupMode and enables Secure Boot.
Expand Down