Skip to content

Commit 48a3109

Browse files
committed
sbctl: include db_additions inn config file
Signed-off-by: Morten Linderud <[email protected]>
1 parent de3aafc commit 48a3109

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

cmd/sbctl/enroll-keys.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"slices"
67
"strings"
78

89
"github.com/foxboron/go-uefi/efi/signature"
@@ -294,6 +295,15 @@ func RunEnrollKeys(state *config.State) error {
294295
if len(enrollKeysCmdOptions.BuiltinFirmwareCerts) >= 1 {
295296
oems = append(oems, "firmware-builtin")
296297
}
298+
299+
if len(state.Config.DbAdditions) != 0 {
300+
for _, k := range state.Config.DbAdditions {
301+
if !slices.Contains(oems, k) {
302+
oems = append(oems, k)
303+
}
304+
}
305+
}
306+
297307
if !enrollKeysCmdOptions.IgnoreImmutable && enrollKeysCmdOptions.Export.Value == "" {
298308
if err := sbctl.CheckImmutable(state.Fs); err != nil {
299309
return err

cmd/sbctl/setup.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func PrintConfig(state *config.State) error {
5555
return err
5656
}
5757
state.Config.Keys = kh.GetConfig(state.Config.Keydir)
58+
state.Config.DbAdditions = sbctl.GetEnrolledVendorCerts()
5859
}
5960

6061
// Setup the files

config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ func (k *Keys) GetKeysConfigs() []*KeyConfig {
5252
// Note: Anything serialized as part of this struct will end up in a public
5353
// debug dump at some point, probably.
5454
type Config struct {
55-
Landlock bool `json:"landlock"`
56-
Keydir string `json:"keydir"`
57-
GUID string `json:"guid"`
58-
FilesDb string `json:"files_db"`
59-
BundlesDb string `json:"bundles_db"`
60-
VendorKeys []string `json:"vendor_keys,omitempty"`
61-
Files []*FileConfig `json:"files,omitempty"`
62-
Keys *Keys `json:"keys"`
55+
Landlock bool `json:"landlock"`
56+
Keydir string `json:"keydir"`
57+
GUID string `json:"guid"`
58+
FilesDb string `json:"files_db"`
59+
BundlesDb string `json:"bundles_db"`
60+
DbAdditions []string `json:"db_additions,omitempty"`
61+
Files []*FileConfig `json:"files,omitempty"`
62+
Keys *Keys `json:"keys"`
6363
}
6464

6565
func (c *Config) GetGUID(vfs afero.Fs) (*util.EFIGUID, error) {

config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ keydir: /etc/sbctl/keys
1111
guid: /var/lib/sbctl/GUID
1212
files_db: /var/lib/sbctl/files.db
1313
bundles_db: /var/lib/sbctl/bundles.db
14-
vendor_keys:
14+
db_additions:
1515
- microsoft
1616
files:
1717
- path: /boot/vmlinuz-linux-lts

docs/sbctl.conf.5.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ Options
5656
+
5757
Default: true
5858

59+
*db_additions:* [ options... ]
60+
Include additional keys or checksums into the authorization database for
61+
Secure Boot. These values are synonymous with the flags passed to *sbctl enroll-keys*.
62+
+
63+
Valid values: microsoft, tpm-eventlog, firmware-builtin, custom
64+
5965
*files:* [ [*path:* /path/to/file *output:* /path/to/output ], ... ]::
6066
A list of files sbctl will sign upon setup. It will be used to seed the
6167
files_db during initial setup.
@@ -117,6 +123,8 @@ An example of a /etc/sbctl/sbctl.conf file with the default values.
117123
files_db: /var/lib/sbctl/files.json
118124
bundles_db: /var/lib/sbctl/bundles.json
119125
landlock: true
126+
db_additions:
127+
- microsoft
120128
files:
121129
- path: /boot/vmlinuz-linux
122130
output: /boot/vmlinuz-linux

0 commit comments

Comments
 (0)