efivarfs

package
v0.0.0-...-48be911 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImmutable           = attr.ErrIsImmutable
	ErrIncorrectAttributes = errors.New("efivar has the wrong attributes")
)

Functions

This section is empty.

Types

type EFIFS

type EFIFS struct {
	*FSWrapper
}

EFIFS is a struct that combines reading variables from the file system while also ensuring we are

func NewFS

func NewFS() *EFIFS

NewFS creates a new instance of *EFIFS

func (*EFIFS) CheckImmutable

func (f *EFIFS) CheckImmutable() *EFIFS

Check if file is immutable before writing to the file. Returns ErrImmutable if the file is immutable.

func (*EFIFS) GetVar

func (t *EFIFS) GetVar(v efivar.Efivar, e efivar.Unmarshallable) error

GetVar parses and unmarshalls a EFI variable.

func (*EFIFS) GetVarWithAttributes

func (t *EFIFS) GetVarWithAttributes(v efivar.Efivar, e efivar.Unmarshallable) (attributes.Attributes, error)

GetVarWithAttributes parses and unmarshalls a EFI variable, while also returning the parsed attributes.

func (*EFIFS) Open

func (f *EFIFS) Open() *Efivarfs

Open returns a initialization Efivarfs for high-level abstractions.

func (*EFIFS) UnsetImmutable

func (f *EFIFS) UnsetImmutable() *EFIFS

UnsetImmutable implicitly when writing towards a file.

func (*EFIFS) WriteVar

func (t *EFIFS) WriteVar(v efivar.Efivar, e efivar.Marshallable) error

WriteVar writes an EFI variables to the EFIFS.

type EFIVars

type EFIVars interface {
	GetVar(efivar.Efivar, efivar.Unmarshallable) error
	GetVarWithAttributes(efivar.Efivar, efivar.Unmarshallable) (attributes.Attributes, error)
	WriteVar(efivar.Efivar, efivar.Marshallable) error
}

EFIVars is the interface for interacting with writing and getting EFI variables.

type Efivarfs

type Efivarfs struct {
	EFIVars
}

func Open

func Open(e EFIVars) *Efivarfs

func (*Efivarfs) GetKEK

func (e *Efivarfs) GetKEK() (*signature.SignatureDatabase, error)

func (*Efivarfs) GetPK

func (e *Efivarfs) GetPK() (*signature.SignatureDatabase, error)

func (*Efivarfs) GetSecureBoot

func (e *Efivarfs) GetSecureBoot() (bool, error)

func (*Efivarfs) GetSetupMode

func (e *Efivarfs) GetSetupMode() (bool, error)

func (*Efivarfs) Getdb

func (e *Efivarfs) Getdb() (*signature.SignatureDatabase, error)

func (*Efivarfs) Getdbx

func (e *Efivarfs) Getdbx() (*signature.SignatureDatabase, error)

func (*Efivarfs) WriteSignedUpdate

func (e *Efivarfs) WriteSignedUpdate(v efivar.Efivar, m efivar.Marshallable, key crypto.Signer, cert *x509.Certificate) error

Writes a signed variable update

type FSWrapper

type FSWrapper struct {
	// contains filtered or unexported fields
}

func NewFSWrapper

func NewFSWrapper() *FSWrapper

func NewMemoryWrapper

func NewMemoryWrapper() *FSWrapper

func (*FSWrapper) CheckImmutable

func (e *FSWrapper) CheckImmutable()

func (*FSWrapper) Open

func (t *FSWrapper) Open(name string) (fs.File, error)

func (*FSWrapper) OpenFile

func (t *FSWrapper) OpenFile(name string, flag int, perm os.FileMode) (io.ReadWriteCloser, error)

func (*FSWrapper) ParseEfivars

func (t *FSWrapper) ParseEfivars(f io.Reader, size int) (attributes.Attributes, *bytes.Buffer, error)

func (*FSWrapper) ReadEfivarsFile

func (t *FSWrapper) ReadEfivarsFile(filename string) (attributes.Attributes, *bytes.Buffer, error)

For a full path instead of the inferred efivars path

func (*FSWrapper) ReadEfivarsWithGuid

func (t *FSWrapper) ReadEfivarsWithGuid(filename string, guid util.EFIGUID) (attributes.Attributes, *bytes.Buffer, error)

func (*FSWrapper) ReadFile

func (t *FSWrapper) ReadFile(name string) ([]byte, error)

func (*FSWrapper) UnsetImmutable

func (e *FSWrapper) UnsetImmutable()

func (*FSWrapper) WriteEfivarsWithGuid

func (t *FSWrapper) WriteEfivarsWithGuid(name string, attrs attributes.Attributes, b []byte, guid util.EFIGUID) error

Write an EFI variable to sysfs TODO: Fix retryable writes

func (*FSWrapper) WriteFile

func (t *FSWrapper) WriteFile(name string, data []byte, perm os.FileMode) error

type TestFS

type TestFS struct {
	*EFIFS
	// contains filtered or unexported fields
}

This is the a wrapper around MapFS to easily inject data and convert it to afero.fs

func NewTestFS

func NewTestFS() *TestFS

func (*TestFS) Open

func (f *TestFS) Open() *Efivarfs

Open opens TestFS as Efivarfs

func (*TestFS) With

func (f *TestFS) With(files ...fstest.MapFS) *TestFS

With allows you to compose several overlay files into the in-memory filesystem.

func (*TestFS) WriteVar

func (f *TestFS) WriteVar(v efivar.Efivar, t efivar.Marshallable) error

WriteVar is a shim around EFIFS.WriteVar and ensures variables written to the in-memory filesystem is "unwrapped" of things like authentication headers if they exist.

Jump to

Keyboard shortcuts

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