protocol

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MaxAnswer = 1 << 20

MaxAnswer is the longest ANSWER or MULTIPLE_ANSWERS payload the plymouth client reads, in bytes.

View Source
const MaxArgument = 254

MaxArgument is the longest argument a request carries, in bytes: its length byte also counts the trailing NUL.

View Source
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

func AppendRequest(dst []byte, r Request) ([]byte, error)

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

func AppendResponse(dst []byte, r Response) ([]byte, error)

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

type DecodeError struct {
	Kind   ErrorKind
	Offset int64
	Byte   byte
	Reason string
}

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

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a Decoder reading from r.

func (*Decoder) Decode

func (d *Decoder) Decode() (Request, error)

Decode reads the next request. It returns io.EOF when the stream ends between requests, an error wrapping io.ErrUnexpectedEOF when it ends inside one, and a *DecodeError for a request it cannot decode; after a fatal one the stream is unreadable.

type Error

type Error struct{}

Error reports that the boot hit an error.

func (Error) Command

func (Error) Command() Command

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

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.

func (NewRoot) Command

func (NewRoot) Command() Command

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.

func (Password) Command

func (Password) Command() Command

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

func ParsePercent(s string) (Percent, error)

ParsePercent reads a decimal percentage as plymouthd accepts it: digits only, 0 to 100.

type Ping

type Ping struct{}

Ping asks whether the daemon is running.

func (Ping) Command

func (Ping) Command() Command

type Question

type Question struct{ Prompt string }

Question asks a question with Prompt whose answer is echoed, answered later.

func (Question) Command

func (Question) Command() Command

type Quit

type Quit struct{ Retain bool }

Quit ends the daemon; Retain keeps its last frame on screen.

func (Quit) Command

func (Quit) Command() Command

type Reactivate

type Reactivate struct{}

Reactivate takes the display back after Deactivate.

func (Reactivate) Command

func (Reactivate) Command() Command

type Reload

type Reload struct{}

Reload reloads the splash.

func (Reload) Command

func (Reload) 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.

func ReadResponse

func ReadResponse(r io.Reader) (Response, error)

ReadResponse reads one response from r as the plymouth client does: a payload longer than MaxAnswer, an ANSWER holding a NUL, a MULTIPLE_ANSWERS payload that is empty or not NUL-terminated, and an unknown type byte are errors.

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.

func (Update) Command

func (Update) Command() Command

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

Jump to

Keyboard shortcuts

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