Skip to content

systemd: unit list filtered on typed ActiveState fails on an unknown state #209

Description

@JanZachmann

active_units_by_patterns() in src/systemd/unit.rs:71-87 filters the reply of list_units_by_patterns() on the typed systemd_zbus::ActiveState. The typed bindings reject a state string they do not know, and that fails the whole reply, not just the entry:

  • systemd-zbus 5.3.2 (newest release) deserializes the states with from_str (src/lib.rs:26-33), which errors on anything unknown (:96).
  • SubState is missing 5 states systemd 255 reports: dead-before-auto-restart, failed-before-auto-restart, dead-resources-pinned, reload-notify, reload-signal. ActiveState and LoadState are complete for systemd 250 (kirkstone) and 255 (scarthgap), but a systemd bump in the Yocto layer can add a state at any time.

So a wifi-commissioning-service@*.service instance in a state the crate does not know makes active_iface() (src/twin/wifi_commissioning.rs:252) return an error instead of the interface name. The blast radius is small: the pattern limits the reply to the wifi commissioning units, and the failure is not silent.

The update validation had the same problem with a much larger blast radius (it lists all units, and a failed poll can roll a healthy update back). It was fixed in #206 by reading the unit list through a local proxy whose struct has the states as String (src/systemd/mod.rs, commit f9ee5cc), with a test that asserts the zvariant signature (ssssssouso).

Suggested fix: read the patterned unit list the same way, so an unknown state stays uninteresting instead of fatal. The ListedUnit struct and the SystemdManager proxy in src/systemd/mod.rs can be shared; ListUnitsByPatterns has the same return signature as ListUnits.

Found during the review of #206.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions