host

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: BSD-2-Clause Imports: 24 Imported by: 4

Documentation

Overview

Package host exposes functionality to interact with the host mashine.

Package host exposes functionality to interact with the host mashine.

Index

Constants

View Source
const (
	HostConfigInitrdPath = "/etc/host_configuration.json"
	HostConfigEFIVarName = "STHostConfig-f401f2c1-b005-4be0-8cee-f2e5945bcbe7"

	HostConfigProvisionOSPKGName = "provision.zip"
)

Sources used by ConfigAutodetect.

View Source
const (
	ErrOpTryMount   sterror.Op = "tryMount"
	ErrOpMountCdrom sterror.Op = "mountCdrom"
)

Operations used for raising Errors of this package.

View Source
const (
	ErrScope        sterror.Scope = "Host"
	ErrOpMeasureTPM sterror.Op    = "MeasureTPM"
	ErrOpIdentity   sterror.Op    = "Identity"
)

Scope and operations used for raising Errors of this package.

View Source
const (

	// The SHA-256 hash of ospkg zip archive. The event log note is the archive's
	// file name. Only measured once.
	OspkgArchive EventType = 0xa0000000

	// The SHA-256 hash of the ospkg JSON manifest. The event log note is the
	// manifest itself. Only measured once.
	OspkgManifest EventType = 0xa0000001

	// The SHA-256 hash of the stboot trust policy. The event log note is the
	// policy itself. Only measured once.
	SecurityConfig EventType = 0xa0000002

	// The SHA-256 hash of the root X.509 certificate used to verify the ospkg
	// signing key. The event log note is the X.509 DER certificate. Only measured once.
	SigningRoot EventType = 0xa0000003

	// The SHA-256 hash of all X.509 certificate used to verify the TLS connection
	// used to fetch the ospkg. The X.509 certificates are concatenated. The
	// event log note is the X.509 DER certificate. Only measured once.
	HTTPSRoot EventType = 0xa0000004

	// The SHA-256 hash of the platform's human-readable identity. The event log
	// note is the identity itself.
	UxIdentity EventType = 0xa0000005

	DetailPcr    uint32 = 12
	AuthorityPcr uint32 = 13
	IdentityPcr  uint32 = 14
)

stboot events.

View Source
const (
	ErrOpAutodetect sterror.Op = "config autodetect"
)

Operations used for raising Errors of this package.

View Source
const (
	ErrOpRecover sterror.Op = "Recover"
)

Operations used for raising Errors of this package.

View Source
const (
	MountPoint = "boot"
)

Variables

View Source
var (
	ErrMissingJSONKey           = errors.New("missing JSON key")
	ErrMissingIPAddrMode        = errors.New("field IP address mode must be set")
	ErrUnknownIPAddrMode        = errors.New("unknown IP address mode")
	ErrUnknownBondingMode       = errors.New("unknown bonding mode")
	ErrMissingBondName          = errors.New("bond name must be set")
	ErrInvalidBondMode          = errors.New("bond mode is unknown")
	ErrMissingNetworkInterfaces = errors.New("one or more network interfaces must be set")
	ErrEmptyNetworkInterfaces   = errors.New("network interfaces are set but empty")
	ErrMissingOSPkgPointer      = errors.New("missing OS package pointer")
	ErrMissingIPAddr            = errors.New("field IP address must not be empty when static IP mode is set")
	ErrMissingGateway           = errors.New("default gateway must not be empty when static IP mode is set")
	ErrMissingID                = errors.New("field ID must not be empty when a URL contains '$ID'")
	ErrInvalidID                = errors.New("invalid ID string, min 1 char, allowed chars are [a-z,A-Z,0-9,-,_]")
	ErrMissingAuth              = errors.New("field Auth must be set when a URL contains '$AUTH'")
	ErrInvalidAuth              = errors.New("invalid auth string, min 1 char, allowed chars are [a-z,A-Z,0-9,-,_]")
)
View Source
var (
	ErrTPM    = errors.New("failed to measure TPM")
	ErrNoInit = errors.New("TPM not initialized")
)

Errors which may be raised and wrapped in this package.

View Source
var (
	ErrConfigNotFound = errors.New("no host configuration found")
)

Errors which may be raised and wrapped in this package.

View Source
var ErrInvalidConfig = errors.New("invalid host configuration")
View Source
var (
	ErrMount = errors.New("failed to mount")
)

Errors which may be raised and wrapped in this package.

View Source
var (
	ErrRecover = errors.New("reboot of the system failed")
)

Errors which may be raised and wrapped in this package.

Functions

func ConfigAutodetect

func ConfigAutodetect() (io.Reader, error)

ConfigAutodetect looks for a known host configuration name in following order: - inside the initramfs at HostConfigInitrdPath - at the efivar filesystem for HostConfigEFIVarName

If no host configuration is found, a special provisioning host config is created and taken as return value. This config points to "ospkg/provision.zip"

It returns with a non-nil io.Reader, if an item exists with the defined name at a probed location. In case there is no match an ErrConfigNotFound is returned.

Note: No validation is made on found configuration.

func MountCdrom

func MountCdrom() error

func Recover

func Recover()

Recover reboots the system after RecoverTimeout secounds. If reboot fails, it will try rebooting forever.

Types

type BondingMode

type BondingMode int

BondingMode sets the mode for bonding.

const (
	BondingUnset BondingMode = iota
	BondingBalanceRR
	BondingActiveBackup
	BondingBalanceXOR
	BondingBroadcast
	Bonding8023AD
	BondingBalanceTLB
	BondingBalanceALB
	BondingUnknown
)

func StringToBondingMode

func StringToBondingMode(str string) BondingMode

func (BondingMode) MarshalJSON

func (b BondingMode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (BondingMode) String

func (b BondingMode) String() string

String implements fmt.Stringer.

func (*BondingMode) UnmarshalJSON

func (b *BondingMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Config

type Config struct {
	IPAddrMode        *IPAddrMode          `json:"network_mode"`
	HostIP            *netlink.Addr        `json:"host_ip"`
	DefaultGateway    *net.IP              `json:"gateway"`
	DNSServer         *[]*net.IP           `json:"dns"`
	NetworkInterfaces *[]*NetworkInterface `json:"network_interfaces"`
	OSPkgPointer      *string              `json:"ospkg_pointer"`
	ID                *string              `json:"identity"`
	Auth              *string              `json:"authentication"`
	BondingMode       BondingMode          `json:"bonding_mode"`
	BondName          *string              `json:"bond_name"`
}

Config stores host specific configuration.

func NewConfig added in v0.1.0

func NewConfig(template Config) (Config, error)

NewConfig returns a new Config from template. It is not save to further use template.

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

All fields of Config need to be present in JSON.

type Event added in v0.2.1

type Event struct {
	Index  uint32
	Type   EventType
	Data   []byte
	Sha256 []byte
}

type EventType added in v0.2.1

type EventType uint32

type IPAddrMode

type IPAddrMode int

IPAddrMode sets the method for network setup.

const (
	IPUnset IPAddrMode = iota
	IPStatic
	IPDynamic
)

func (IPAddrMode) MarshalJSON

func (i IPAddrMode) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (IPAddrMode) String

func (i IPAddrMode) String() string

String implements fmt.Stringer.

func (*IPAddrMode) UnmarshalJSON

func (i *IPAddrMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Measurements added in v0.2.1

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

func NewMeasurements added in v0.2.1

func NewMeasurements() *Measurements

func (*Measurements) Add added in v0.2.1

func (m *Measurements) Add(index uint32, typ EventType, sha256 [32]byte, data []byte) error

func (*Measurements) Finalize added in v0.2.1

func (m *Measurements) Finalize() ([]byte, error)

returns serialized TPM 2.0 event log.

func (*Measurements) Identity added in v0.2.1

func (m *Measurements) Identity() (string, error)

func (*Measurements) Info added in v0.2.1

func (m *Measurements) Info() (*tss.TPMInfo, error)

type NetworkInterface added in v0.1.0

type NetworkInterface struct {
	InterfaceName *string           `json:"interface_name"`
	MACAddress    *net.HardwareAddr `json:"mac_address"`
}

func (NetworkInterface) MarshalJSON added in v0.1.0

func (n NetworkInterface) MarshalJSON() ([]byte, error)

func (*NetworkInterface) UnmarshalJSON added in v0.1.0

func (n *NetworkInterface) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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