1 Technical_Decomp_Systemd
Miguel Jacq edited this page 2025-12-27 20:55:18 -06:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

enroll/systemd.py

UnitInfo (dataclass)

Purpose: parsed subset of systemctl show for services.

Fields:

  • name: unit name
  • fragment_path: main unit file path
  • dropin_paths: list of drop-in config files
  • env_files: resolved EnvironmentFiles entries (minus leading -)
  • exec_paths: parsed executable paths from ExecStart
  • active_state, sub_state, unit_file_state, condition_result

Lifecycle / where its used:

  • Returned by get_unit_info().
  • harvest.harvest() uses it to:
    • infer packages (dpkg_owner on fragment + exec binaries)
    • add /etc/... candidates from dropins/env files

UnitQueryError (exception class)

Purpose: a structured error when systemctl show fails for a unit.

Fields set in init:

  • unit: unit name that failed
  • stderr: trimmed stderr text

Message:

systemctl show failed for :

Lifecycle / where its used:

Raised by get_unit_info() if systemctl returns nonzero.

harvest.harvest() catches it and records a ServiceSnapshot with empty packages/files and a note containing the error string.


TimerInfo (dataclass)

Purpose: parsed subset of systemctl show for timers.

Fields:

  • name
  • fragment_path
  • dropin_paths
  • env_files
  • trigger_unit: parsed from Unit= field (what the timer triggers)
  • active_state, sub_state, unit_file_state, condition_result

Lifecycle / where its used:

Returned by get_timer_info().

harvest.harvest() uses timers to attribute timer override files under /etc to:

  • the triggered service role (preferred), else
  • a package role, else
  • let it fall through and potentially get captured by etc_custom.