Skip to main content

Module distro

Module distro 

Source
Expand description

Distro detection — Phase 2a.

Parses /etc/os-release (or a caller-supplied string) and classifies the running Linux distribution into a typed DistroId.

§Security note

parse_os_release is strict-by-design: it rejects any line that does not match the ^([A-Z][A-Z0-9_]*)=(.+)$ grammar, refuses to evaluate shell escapes, and caps the accepted file size at MAX_OS_RELEASE_BYTES. The result is used to decide which package-manager backend the daemon invokes, so a corrupt or adversarially crafted /etc/os-release must not silently produce a plausible-looking wrong answer.

Structs§

OsRelease
Parsed representation of /etc/os-release.

Enums§

DetectError
Errors returned by detect when reading /etc/os-release from disk.
DistroFamily
Broad distro family, useful for choosing a package-manager backend.
DistroId
Typed distro identity derived from OsRelease.
ParseError
Errors returned by parse_os_release.

Constants§

MAX_OS_RELEASE_BYTES
Maximum number of bytes accepted from /etc/os-release (or a test fixture string). Files larger than this are rejected with ParseError::FileTooLarge.

Functions§

detect
Read /etc/os-release from disk and return a typed DistroId.
detect_distro
Classify an OsRelease into a DistroId.
parse_os_release
Parse the contents of an /etc/os-release file.