Bug#1009963: deb-systemd-helper: Misleading error message in "sub enable" if systemctl fails

Ansgar ansgar at 43-1.org
Thu Apr 21 17:37:20 BST 2022


Hi,

On Thu, 2022-04-21 at 18:13 +0200, Michael Biebl wrote:
> 
> So /usr/bin/systemctl is provided by the "systemctl" package?
> Can you post the output of apt-cache policy systemctl

I think the bug reporter suggest to replace the

  system(...) == 0 or error("systemctl preset failed on $scriptname: $!");

with a more correct (and verbose)

  system(...);
  if ($? == -1) {
    error("systemctl preset failed on $scriptname: $!");
  }
  elsif ($? & 127) {
    error("systemctl preset died with signal " . ($? & 127));
  }
  else {
    error("systemctl preset failed with return status " . ($? >> 8));
  }

as `perldoc -f system` suggest. (Untested, so might contain typos and
the like.)

Currently it always give "$!" as the reason, even when not correct.
This would also be incorrect if the real systemctl is used if the
command fails because of syntax errors or so.

Ansgar



More information about the Pkg-systemd-maintainers mailing list