Skip to content

Preserve real systemd unit instances during probe enumeration - #2485

Open
hakarrr wants to merge 5 commits into
OpenSCAP:mainfrom
hakarrr:fix-2012-systemd-unit-instances
Open

hakarrr wants to merge 5 commits into
OpenSCAP:mainfrom
hakarrr:fix-2012-systemd-unit-instances

Conversation

@hakarrr

@hakarrr hakarrr commented Nov 10, 2026

Copy link
Copy Markdown

Fixes #2012.

Keep ListUnitFiles so disabled, unloaded units remain visible, then merge in ListUnits for template instances and transient units. Deduplicate names before calling either probe's collector.

Template names such as user-runtime-dir@.service are skipped instead of losing their @. Instance names, including installed persist@42.service entries, stay intact. Loaded entries with LoadState=not-found are excluded.

Tests:

  • Add a private-bus python-dbusmock fixture that runs the compiled oscap against both systemd probes. It needs neither root nor host systemd.
  • Five scenarios cover installed/loaded overlap, disabled units, template and instance names, transient units, not-found entries, either list empty, and both lists empty. All 90 definition-result checks pass; duplicate callback counts are checked too.
  • The unchanged implementation fails four of the five scenarios. The final implementation passes all five.
  • Native GCC 11.4/CMake build passed. The selected XCCDF/fix/info/systemd tests passed: 122 passed, 11 skipped, 0 failed. The skips require host systemd, RPM, offline/chroot support, or unavailable transformation/platform fixtures.
  • git diff --check passed. Published tree 27c85d3ff7a33944c7354044676284dda1e039ee matches the tested tree.

Local build used released dependency headers/tools supplied outside the source tree, with documentation, Python/Perl bindings, and oscap-docker disabled. No tracked build settings changed. The full project suite, live host-systemd tests, and non-Linux builds were not run.

hakarrr and others added 5 commits November 10, 2026 23:34
Fixes OpenSCAP#2012

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
ListUnits can include known but not-found dependencies. Skip these rather than collecting dummy properties.

Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Author

Could a maintainer review this fix to preserve real systemd unit instances during probe enumeration? Please let me know if changes or additional cases are needed before it can move forward. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Systemd probes process templated units incorrectly

1 participant