Documentation
¶
Overview ¶
Package protocol is plymouthd's socket protocol: the requests systemd, its password agents and the plymouth client send, and the responses the daemon answers with, encoded and decoded over a byte stream.
A request is one command byte followed by either a NUL (no argument) or 0x02, a length byte counting the argument and its trailing NUL, and the NUL-terminated argument. A response is one type byte; ANSWER and MULTIPLE_ANSWERS follow it with a little-endian uint32 length and the bytes.
Index ¶
- Constants
- func AppendRequest(dst []byte, r Request) ([]byte, error)
- func AppendResponse(dst []byte, r Response) ([]byte, error)
- type Ack
- type Answer
- type CachedPassword
- type ChangeMode
- type Command
- type Deactivate
- type DecodeError
- type Decoder
- type Error
- type ErrorKind
- type HasActiveVT
- type HideMessage
- type HideSplash
- type IgnoreKeystroke
- type MultipleAnswers
- type Nak
- type NewRoot
- type NoAnswer
- type Password
- type PauseProgress
- type Percent
- type Ping
- type Question
- type Quit
- type Reactivate
- type Reload
- type Request
- type Response
- type ResponseType
- type ResumeProgress
- type ShowMessage
- type ShowSplash
- type SystemInitialized
- type SystemUpdate
- type Update
- type WatchKeystroke
Constants ¶
const MaxAnswer = 1 << 20
MaxAnswer is the longest ANSWER or MULTIPLE_ANSWERS payload the plymouth client reads, in bytes.
const MaxArgument = 254
MaxArgument is the longest argument a request carries, in bytes: its length byte also counts the trailing NUL.
const SocketName = "@/org/freedesktop/plymouthd"
SocketName is the abstract Unix socket plymouthd listens on, as Go's net package spells an abstract address.
Variables ¶
This section is empty.
Functions ¶
func AppendRequest ¶
AppendRequest appends r's encoding to dst. It fails on an argument longer than MaxArgument or holding a NUL, which the wire cannot carry.
func AppendResponse ¶
AppendResponse appends r's encoding to dst. It fails on an answer holding a NUL, which the client would split, on MultipleAnswers with no answer, which is NoAnswer on the wire, and on a payload longer than MaxAnswer. The appended bytes copy any secret in r; the caller zeroes them once written.
Types ¶
type Ack ¶
type Ack struct{}
Ack acknowledges a request.
func (Ack) Type ¶
func (Ack) Type() ResponseType
type Answer ¶
type Answer struct{ Data []byte }
Answer answers a password, question or keystroke request. Its bytes may be a secret; whoever holds the Answer zeroes them once sent.
func (Answer) Type ¶
func (Answer) Type() ResponseType
type CachedPassword ¶
type CachedPassword struct{}
CachedPassword asks for every password typed so far.
func (CachedPassword) Command ¶
func (CachedPassword) Command() Command
type ChangeMode ¶
type ChangeMode struct{ Mode string }
ChangeMode switches the splash's mode, such as "updates" or "shutdown".
func (ChangeMode) Command ¶
func (ChangeMode) Command() Command
type Command ¶
type Command byte
Command is a request's command byte, as ply-boot-protocol.h defines them.
const ( CmdPing Command = 'P' CmdUpdate Command = 'U' CmdChangeMode Command = 'C' CmdSystemUpdate Command = 'u' CmdSystemInitialized Command = 'S' CmdDeactivate Command = 'D' CmdReactivate Command = 'r' CmdQuit Command = 'Q' CmdReload Command = 'l' CmdPassword Command = '*' CmdCachedPassword Command = 'c' CmdQuestion Command = 'W' CmdShowMessage Command = 'M' CmdHideMessage Command = 'm' CmdWatchKeystroke Command = 'K' CmdIgnoreKeystroke Command = 'L' CmdPauseProgress Command = 'A' CmdResumeProgress Command = 'a' CmdShowSplash Command = '$' CmdHideSplash Command = 'H' CmdNewRoot Command = 'R' CmdHasActiveVT Command = 'V' CmdError Command = '!' )
The request commands.
type Deactivate ¶
type Deactivate struct{}
Deactivate stops drawing and gives up the display, leaving the frame.
func (Deactivate) Command ¶
func (Deactivate) Command() Command
type DecodeError ¶
DecodeError is a request Decode could not decode: what was wrong, and the offending byte and its offset in the stream.
func (*DecodeError) Error ¶
func (e *DecodeError) Error() string
func (*DecodeError) Fatal ¶
func (e *DecodeError) Fatal() bool
Fatal reports whether the stream is unreadable past e.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads requests from a byte stream.
func NewDecoder ¶
NewDecoder returns a Decoder reading from r.
type ErrorKind ¶
type ErrorKind uint8
ErrorKind tells what made a request undecodable.
const ( // Malformed is broken framing: the stream cannot be read further. Malformed ErrorKind = iota // UnknownCommand is a well-framed request with a command byte this // protocol lacks; the stream continues after it. UnknownCommand // BadArgument is a well-framed request whose argument does not parse; // the stream continues after it. BadArgument )
type HasActiveVT ¶
type HasActiveVT struct{}
HasActiveVT asks whether the kernel has virtual terminals.
func (HasActiveVT) Command ¶
func (HasActiveVT) Command() Command
type HideMessage ¶
type HideMessage struct{ Text string }
HideMessage hides Text from the splash.
func (HideMessage) Command ¶
func (HideMessage) Command() Command
type HideSplash ¶
type HideSplash struct{}
HideSplash hides the splash.
func (HideSplash) Command ¶
func (HideSplash) Command() Command
type IgnoreKeystroke ¶
type IgnoreKeystroke struct{ Keys string }
IgnoreKeystroke stops waiting for Keys.
func (IgnoreKeystroke) Command ¶
func (IgnoreKeystroke) Command() Command
type MultipleAnswers ¶
type MultipleAnswers struct{ Answers [][]byte }
MultipleAnswers answers a cached-password request with every password typed so far, at least one. Like Answer, its bytes are secrets.
func (MultipleAnswers) Type ¶
func (MultipleAnswers) Type() ResponseType
type Nak ¶
type Nak struct{}
Nak refuses a request.
func (Nak) Type ¶
func (Nak) Type() ResponseType
type NewRoot ¶
type NewRoot struct{ Dir string }
NewRoot announces the root the boot is about to switch to.
type NoAnswer ¶
type NoAnswer struct{}
NoAnswer answers a request the daemon has no answer for.
func (NoAnswer) Type ¶
func (NoAnswer) Type() ResponseType
type Password ¶
type Password struct{ Prompt string }
Password asks for a secret with Prompt, answered later.
type PauseProgress ¶
type PauseProgress struct{}
PauseProgress stops the progress animation.
func (PauseProgress) Command ¶
func (PauseProgress) Command() Command
type Percent ¶
type Percent uint8
Percent is a progress in percent, 0 to 100.
const MaxPercent Percent = 100
MaxPercent is the largest Percent, a finished update.
func ParsePercent ¶
ParsePercent reads a decimal percentage as plymouthd accepts it: digits only, 0 to 100.
type Question ¶
type Question struct{ Prompt string }
Question asks a question with Prompt whose answer is echoed, answered later.
type Quit ¶
type Quit struct{ Retain bool }
Quit ends the daemon; Retain keeps its last frame on screen.
type Reactivate ¶
type Reactivate struct{}
Reactivate takes the display back after Deactivate.
func (Reactivate) Command ¶
func (Reactivate) Command() Command
type Request ¶
type Request interface {
// Command is the request's command byte.
Command() Command
// contains filtered or unexported methods
}
Request is one decoded request, one of the types in this file.
type Response ¶
type Response interface {
// Type is the response's type byte.
Type() ResponseType
}
Response is one response, one of the types in this file.
type ResponseType ¶
type ResponseType byte
ResponseType is a response's type byte.
const ( TypeAck ResponseType = 0x06 TypeNak ResponseType = 0x15 TypeAnswer ResponseType = 0x02 TypeMultipleAnswers ResponseType = '\t' TypeNoAnswer ResponseType = 0x05 )
The response types.
type ResumeProgress ¶
type ResumeProgress struct{}
ResumeProgress restarts the progress animation.
func (ResumeProgress) Command ¶
func (ResumeProgress) Command() Command
type ShowMessage ¶
type ShowMessage struct{ Text string }
ShowMessage shows Text on the splash.
func (ShowMessage) Command ¶
func (ShowMessage) Command() Command
type ShowSplash ¶
type ShowSplash struct{}
ShowSplash shows the splash.
func (ShowSplash) Command ¶
func (ShowSplash) Command() Command
type SystemInitialized ¶
type SystemInitialized struct{}
SystemInitialized reports that the root file system is writable.
func (SystemInitialized) Command ¶
func (SystemInitialized) Command() Command
type SystemUpdate ¶
type SystemUpdate struct{ Progress Percent }
SystemUpdate reports an offline update's progress.
func (SystemUpdate) Command ¶
func (SystemUpdate) Command() Command
type Update ¶
type Update struct{ Status string }
Update reports a status, the name of each unit systemd starts.
type WatchKeystroke ¶
type WatchKeystroke struct{ Keys string }
WatchKeystroke waits for one of Keys, or any key when Keys is empty.
func (WatchKeystroke) Command ¶
func (WatchKeystroke) Command() Command