-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathauth.go
More file actions
47 lines (38 loc) · 1.03 KB
/
auth.go
File metadata and controls
47 lines (38 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) The go-boot authors. All Rights Reserved.
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.
package cmd
import (
"fmt"
"regexp"
"strings"
"github.com/usbarmory/go-boot/shell"
"github.com/usbarmory/go-boot/transparency"
)
func init() {
shell.Add(shell.Cmd{
Name: "bt",
Args: 1,
Pattern: regexp.MustCompile(`^(?:bt)( none| offline| online)?$`),
Syntax: "(none|offline|online)?",
Help: "show/set boot-transparency status",
Fn: btCmd,
})
}
func btCmd(_ *shell.Interface, arg []string) (res string, err error) {
if len(arg[0]) > 0 {
transparency.Config.Status = strings.TrimSpace(arg[0])
}
switch transparency.Config.Status {
case "none":
transparency.CleanupConfig()
return fmt.Sprintf("boot-transparency is disabled\n"), nil
case "offline","online":
if err = transparency.LoadConfig(); err != nil {
return "", err
}
return fmt.Sprintf("boot-transparency is enabled in %s mode\n", transparency.Config.Status), nil
}
return
}