host

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: BSD-2-Clause Imports: 22 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 (

	// 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.
	UxIdentityEvent EventType = 0xa0000005

	DataChannel EventType = 0xa0000006

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

stboot events.

View Source
const (
	Null = "null"
)

Variables

View Source
var (
	ErrMissingIPAddrMode        = errors.New("field IP address mode must be set")
	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")
)
View Source
var (
	ErrConfigNotFound = errors.New("no host configuration found")
)

Errors which may be raised and wrapped in this package.

View Source
var (
	ErrNoInit = errors.New("TPM not initialized")
)

Errors which may be raised and wrapped in this package.

Functions

func ConfigAutodetect

func ConfigAutodetect(ctx context.Context) (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 DataChannelIdentity added in v0.3.0

func DataChannelIdentity(ctx context.Context) (*x509.Certificate, error)

func Recover

func Recover()

Recover reboots the system after a few seconds. If reboot fails, it will try rebooting forever.

func UxIdentity added in v0.2.1

func UxIdentity(ctx context.Context) (string, error)

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"`
	BondingMode       BondingMode          `json:"bonding_mode"`
	BondName          *string              `json:"bond_name"`
}

Config stores host specific configuration.

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(ctx context.Context) *Measurements

func (*Measurements) Add added in v0.2.1

func (m *Measurements) Add(index uint32, typ EventType, event []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) 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