[Bug 1828883] Re: systemd sysv-compatibility eats exit codes
Ronny Trommer
1828883 at bugs.launchpad.net
Mon May 13 20:16:57 UTC 2019
I've verified this on Ubuntu 18.04 LTS
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
root at ubuntu:/etc/init.d# systemctl start exitcode
root at ubuntu:/etc/init.d# echo $?
0
root at ubuntu:/etc/init.d# systemctl status exitcodetest
● exitcodetest.service - LSB: Test Exit Code (SysV)
Loaded: loaded (/etc/init.d/exitcodetest; generated)
Active: active (exited) since Mon 2019-05-13 20:14:31 UTC; 9s ago
Docs: man:systemd-sysv-generator(8)
Process: 3141 ExecStop=/etc/init.d/exitcodetest stop (code=exited, status=6)
Process: 3152 ExecStart=/etc/init.d/exitcodetest start (code=exited, status=6)
May 13 20:14:31 ubuntu systemd[1]: Starting LSB: Test Exit Code (SysV)...
May 13 20:14:31 ubuntu systemd[1]: Started LSB: Test Exit Code (SysV).
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/1828883
Title:
systemd sysv-compatibility eats exit codes
Status in systemd package in Ubuntu:
New
Bug description:
Systemd properly honors an exit code of 6 when creating a native
service, like so:
---8<---
ranger at carolina:/lib/systemd/system$ cat exitcode.service
[Unit]
Description=Test Exit Code (Systemd)
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'exit 6'
[Install]
WantedBy=default.target
ranger at carolina:/lib/systemd/system$ sudo systemctl start exitcode
Job for exitcode.service failed because the control process exited with error code.
See "systemctl status exitcode.service" and "journalctl -xe" for details.
ranger at carolina:/lib/systemd/system$ echo $?
1
---8<---
However, the equivalent SysV init file improperly returns an exit code
of 0 when starting under the compatibility layer:
---8<---
ranger at carolina:/etc/init.d$ cat exitcode
#! /bin/sh
### BEGIN INIT INFO
# Provides: exitcode
# Required-Start: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Test Exit Code (SysV)
# Description: Test case for Systemd SysV compatibility layer
### END INIT INFO
exit 6
ranger at carolina:/etc/init.d$ sudo systemctl enable exitcode
exitcode.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable exitcode
ranger at carolina:/etc/init.d$ sudo systemctl start exitcode
ranger at carolina:/etc/init.d$ echo $?
0
---8<---
Even if I change the script to do `exit 1` it still returns exit code
0.
These are tiny examples but we are hitting it in the real world with
the startup scripts for the OpenNMS Debian/Ubuntu packages, which
return exit code 6 (LSB "not configured") when there are leftover
upgrade files in `/etc/opennms`. The OpenNMS startup is not properly
failing on attempted startup in this case.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1828883/+subscriptions
More information about the foundations-bugs
mailing list