Skip to content

fix(logsource.py): find_units() refuses arguments that are not unit names - #504

Merged
markuslf merged 1 commit into
mainfrom
fix/logsource-find-units-arguments
Nov 24, 2026
Merged

markuslf merged 1 commit into
mainfrom
fix/logsource-find-units-arguments

Conversation

@markuslf

Copy link
Copy Markdown
Member

The lib guidelines treat every argument as hostile. find_units() took
whatever it got: a bare string was searched character by character and
found nothing, a candidate with a path separator was globbed outside
the unit directories, and a non-string raised deep inside re.sub().
All three now raise before anything is looked up, also where systemd
does not run the host, so the mistake shows on every test host.

The candidates are consumed once up front, so a generator still works.

Tests cover no candidates, a generator, a string, and candidates with
a path, None and an int; the last two fail without the fix.

Checks: tests/logsource/unit-test/run (232 tests) and tox py39 to py314 passed locally.

…ames

The lib guidelines treat every argument as hostile. find_units() took
whatever it got: a bare string was searched character by character and
found nothing, a candidate with a path separator was globbed outside
the unit directories, and a non-string raised deep inside re.sub().
All three now raise before anything is looked up, also where systemd
does not run the host, so the mistake shows on every test host.

The candidates are consumed once up front, so a generator still works.

Tests cover no candidates, a generator, a string, and candidates with
a path, None and an int; the last two fail without the fix.
@markuslf
markuslf merged commit cbaba9a into main Nov 24, 2026
8 checks passed
@markuslf
markuslf deleted the fix/logsource-find-units-arguments branch November 24, 2026 20:47
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.

1 participant