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§
- Detect
Error - Errors returned by
detectwhen reading/etc/os-releasefrom disk. - Distro
Family - Broad distro family, useful for choosing a package-manager backend.
- Distro
Id - Typed distro identity derived from
OsRelease. - Parse
Error - 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 withParseError::FileTooLarge.
Functions§
- detect
- Read
/etc/os-releasefrom disk and return a typedDistroId. - detect_
distro - Classify an
OsReleaseinto aDistroId. - parse_
os_ release - Parse the contents of an
/etc/os-releasefile.