From 94580579789410daea7031dca6df463aada9cdf2 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Tue, 29 Sep 2026 22:24:52 +0200 Subject: [PATCH] Fix `start_unit` reporting success when `journalctl` lookup follows a failed start --- systemd/systemd-lib.pl | 5 +++-- systemd/t/run-tests.t | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/systemd/systemd-lib.pl b/systemd/systemd-lib.pl index fd9b3db2d..8cbe8a777 100644 --- a/systemd/systemd-lib.pl +++ b/systemd/systemd-lib.pl @@ -585,10 +585,11 @@ my ($name) = @_; return (0, $text{'systemd_ename'}) if (!valid_unit_name($name)); my $out = backquote_logged( "systemctl start ".quotemeta($name)." 2>&1 /dev/null"); } -return (!$?, $out); +return (!$rv, $out); } =head2 stop_unit(name) diff --git a/systemd/t/run-tests.t b/systemd/t/run-tests.t index 58a24136b..8dcae4e32 100644 --- a/systemd/t/run-tests.t +++ b/systemd/t/run-tests.t @@ -846,6 +846,15 @@ like(get_unit_root(), qr{^/(etc|usr/lib|lib)/systemd/system$}, 'dependency command uses full non-paged output'); } +# Failed starts must remain failures even when journal diagnostics succeed. +{ + local *main::backquote_logged = sub { $? = 256; return 'See journalctl for details'; }; + local *main::backquote_command = sub { $? = 0; return 'Start failed'; }; + my ($ok, $out) = start_unit('broken.service'); + ok(!$ok, 'journal lookup cannot hide a failed start'); + like($out, qr/Start failed/, 'failed start includes diagnostics'); +} + { my @cmds; my $reloaded = 0;