helper

package
v0.0.0-...-8357b5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DiskPrefix linux disk device prefix.
	DiskPrefix = "/dev/"
	// TPM2ReservedSlot TPMv2 reserved slot.
	TPM2ReservedSlot = "31"
	// TPM2ReservedSlotContent TPMv2 reserved slot configuration (to disable PCR protection).
	TPM2ReservedSlotContent = `: tpm2 '{"hash":"sha256","key":"ecc"}'`
)

Variables

This section is empty.

Functions

func GetClevisLuksListOutput

func GetClevisLuksListOutput() (string, error)

GetClevisLuksListOutput Run the clevis luks list -d /dev/sdX command and returns the output.

func GetEncryptedDriveList

func GetEncryptedDriveList(lsblkoutput string) []string

GetEncryptedDriveList returns the list of encrypted drives present in the host.

func GetTPMLockoutCounter

func GetTPMLockoutCounter() (int64, error)

GetTPMLockoutCounter Gets TPM max failed retries as an int64 decimal number.

func GetTPMMaxRetries

func GetTPMMaxRetries() (int64, error)

GetTPMMaxRetries Gets TPM max failed retries as an int64 decimal number.

func IsDiskRoot

func IsDiskRoot(lsblkMounts string) bool

IsDiskRoot returs true if the "diskName" drive is the root drive (e.g. /). processes the output of the lsblk -o mountpoints -l /dev/sdaX command.

func IsTTYConsole

func IsTTYConsole() (bool, error)

IsTTYConsole is true if the TTY console is configure on the kernel command line, false otherwise.

func LuksListContainsPCR1And7

func LuksListContainsPCR1And7(input string) (found bool)

LuksListContainsPCR1And7 checks the output of sudo clevis luks list -d /dev/sdX for PCR 1 and 7 configuration.

func LuksListContainsReservedSlot

func LuksListContainsReservedSlot(input string) bool

LuksListContainsReservedSlot checks the output of sudo clevis luks list -d /dev/sdX for the reserved slot.

func SetTPMLockoutCounterZero

func SetTPMLockoutCounterZero() error

SetTPMLockoutCounterZero sets the TPM lockout counter to zero.

func SetTPMMaxRetries

func SetTPMMaxRetries(maxRetries int64) error

SetTPMMaxRetries sets TPM max failed retries as an int64 decimal number. This function also resets the lockout counter to zero.

func StringInSlice

func StringInSlice[T ~string](s []T, str T, contains bool) bool

StringInSlice checks a slice for a given string.

func SubSlice

func SubSlice(s, sub []string) bool

SubSlice checks if a slice's elements all exist within a slice.

func SwapFirstAndSecondSliceItems

func SwapFirstAndSecondSliceItems(slice []string) ([]string, error)

SwapFirstAndSecondSliceItems swaps the first and second items in a string slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL