Documentation
¶
Overview ¶
Package host exposes functionality to interact with the host mashine.
Package host exposes functionality to interact with the host mashine.
Index ¶
Constants ¶
const ( HostConfigInitrdPath = "/etc/host_configuration.json" HostConfigEFIVarName = "STHostConfig-f401f2c1-b005-4be0-8cee-f2e5945bcbe7" HostConfigProvisionOSPKGName = "provision.zip" )
Sources used by ConfigAutodetect.
const ( ErrOpTryMount sterror.Op = "tryMount" ErrOpMountCdrom sterror.Op = "mountCdrom" )
Operations used for raising Errors of this package.
const ( ErrScope sterror.Scope = "Host" ErrOpMeasureTPM sterror.Op = "MeasureTPM" ErrOpIdentity sterror.Op = "Identity" )
Scope and operations used for raising Errors of this package.
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.
Operations used for raising Errors of this package.
Operations used for raising Errors of this package.
const (
MountPoint = "boot"
)
Variables ¶
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,-,_]") )
var ( ErrTPM = errors.New("failed to measure TPM") ErrNoInit = errors.New("TPM not initialized") )
Errors which may be raised and wrapped in this package.
Errors which may be raised and wrapped in this package.
Errors which may be raised and wrapped in this package.
Errors which may be raised and wrapped in this package.
Functions ¶
func ConfigAutodetect ¶
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 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) 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
NewConfig returns a new Config from template. It is not save to further use template.
func (Config) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type Event ¶ added in v0.2.1
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) 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 (*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