mirror of
https://github.com/webmin/webmin.git
synced 2026-10-01 01:40:39 +01:00
Fix start_unit reporting success when journalctl lookup follows a failed start
This commit is contained in:
@@ -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");
|
||||
if ($? && $out =~ /journalctl/) {
|
||||
my $rv = $?;
|
||||
if ($rv && $out =~ /journalctl/) {
|
||||
$out .= backquote_command("journalctl -xe 2>/dev/null");
|
||||
}
|
||||
return (!$?, $out);
|
||||
return (!$rv, $out);
|
||||
}
|
||||
|
||||
=head2 stop_unit(name)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user