Skip to content

Commit

Permalink
sbctl: include db_additions inn config file
Browse files Browse the repository at this point in the history
Signed-off-by: Morten Linderud <[email protected]>
  • Loading branch information
Foxboron committed Jul 31, 2024
1 parent de3aafc commit 48a3109
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
10 changes: 10 additions & 0 deletions cmd/sbctl/enroll-keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"
"slices"
"strings"

"github.com/foxboron/go-uefi/efi/signature"
Expand Down Expand Up @@ -294,6 +295,15 @@ func RunEnrollKeys(state *config.State) error {
if len(enrollKeysCmdOptions.BuiltinFirmwareCerts) >= 1 {
oems = append(oems, "firmware-builtin")
}

if len(state.Config.DbAdditions) != 0 {
for _, k := range state.Config.DbAdditions {
if !slices.Contains(oems, k) {
oems = append(oems, k)
}
}
}

if !enrollKeysCmdOptions.IgnoreImmutable && enrollKeysCmdOptions.Export.Value == "" {
if err := sbctl.CheckImmutable(state.Fs); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions cmd/sbctl/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func PrintConfig(state *config.State) error {
return err
}
state.Config.Keys = kh.GetConfig(state.Config.Keydir)
state.Config.DbAdditions = sbctl.GetEnrolledVendorCerts()
}

// Setup the files
Expand Down
16 changes: 8 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func (k *Keys) GetKeysConfigs() []*KeyConfig {
// Note: Anything serialized as part of this struct will end up in a public
// debug dump at some point, probably.
type Config struct {
Landlock bool `json:"landlock"`
Keydir string `json:"keydir"`
GUID string `json:"guid"`
FilesDb string `json:"files_db"`
BundlesDb string `json:"bundles_db"`
VendorKeys []string `json:"vendor_keys,omitempty"`
Files []*FileConfig `json:"files,omitempty"`
Keys *Keys `json:"keys"`
Landlock bool `json:"landlock"`
Keydir string `json:"keydir"`
GUID string `json:"guid"`
FilesDb string `json:"files_db"`
BundlesDb string `json:"bundles_db"`
DbAdditions []string `json:"db_additions,omitempty"`
Files []*FileConfig `json:"files,omitempty"`
Keys *Keys `json:"keys"`
}

func (c *Config) GetGUID(vfs afero.Fs) (*util.EFIGUID, error) {
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keydir: /etc/sbctl/keys
guid: /var/lib/sbctl/GUID
files_db: /var/lib/sbctl/files.db
bundles_db: /var/lib/sbctl/bundles.db
vendor_keys:
db_additions:
- microsoft
files:
- path: /boot/vmlinuz-linux-lts
Expand Down
8 changes: 8 additions & 0 deletions docs/sbctl.conf.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ Options
+
Default: true

*db_additions:* [ options... ]
Include additional keys or checksums into the authorization database for
Secure Boot. These values are synonymous with the flags passed to *sbctl enroll-keys*.
+
Valid values: microsoft, tpm-eventlog, firmware-builtin, custom

*files:* [ [*path:* /path/to/file *output:* /path/to/output ], ... ]::
A list of files sbctl will sign upon setup. It will be used to seed the
files_db during initial setup.
Expand Down Expand Up @@ -117,6 +123,8 @@ An example of a /etc/sbctl/sbctl.conf file with the default values.
files_db: /var/lib/sbctl/files.json
bundles_db: /var/lib/sbctl/bundles.json
landlock: true
db_additions:
- microsoft
files:
- path: /boot/vmlinuz-linux
output: /boot/vmlinuz-linux
Expand Down

0 comments on commit 48a3109

Please sign in to comment.