update-rc.d: enabling or disabling S runlevel services incorrectly modifies runlevel
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sysvinit (Ubuntu) |
Won't Fix
|
Medium
|
Matthew Ruffell | ||
Trusty |
Fix Released
|
Medium
|
Matthew Ruffell |
Bug Description
[Impact]
* update-rc.d, in sysv-rc-
* update-rc.d incorrectly modifies symlinks when enabling or disabling
services which are started on the "S" runlevel.
* This can lead to services being changed from S runlevel from where they
would be started on boot, to "0" runlevel, and are run on halt, which is
incorrect.
* The bug is caused by trying to use the runlevel to index into an integer
array of runlevels. When the runlevel in question is "S", an error is
printed
Argument "S" isn't numeric in array element at /usr/sbin/
232.
Perl then sets the index to default to 0, which changes the runlevel.
* The fix is to check if the runlevel is "S", and if it is, set the index to
99 which conforms with other expected usages for the "S" runlevel in the
script. See the "startstop" and "makelinks" subroutines.
[Test Case]
* You can reproduce this with any service that is started on the "S"
runlevel. We will use open-iscsi for an example.
1) Install open-iscsi
$ sudo apt install open-iscsi
2) Check to see symlinks for init.d scripts are set to defaults:
root@trusty-
/etc/rc0.
/etc/rc0.
/etc/rc1.
/etc/rc1.
/etc/rc6.
/etc/rc6.
/etc/rcS.
3) Use update-rc.d to enable open-iscsi service
root@trusty-
update-rc.d: warning: start runlevel arguments (none) do not match open-iscsi Default-Start values (S)
update-rc.d: warning: stop runlevel arguments (none) do not match open-iscsi Default-Stop values (0 1 6)
Argument "S" isn't numeric in array element at /usr/sbin/
Enabling system startup links for /etc/init.
Removing any system startup links for /etc/init.
/etc/rc0.
/etc/rc1.
/etc/rc6.
/etc/rcS.
Adding system startup for /etc/init.
/etc/rc0.
/etc/rc1.
/etc/rc6.
/etc/rc0.
* The problem is the "/etc/rcS.
changed to "/etc/rc0.
* Instead, the correct behaviour is to keep the symlink in /etc/rcS.d/
intact:
root@trusty-
update-rc.d: warning: start runlevel arguments (none) do not match open-iscsi Default-Start values (S)
update-rc.d: warning: stop runlevel arguments (none) do not match open-iscsi Default-Stop values (0 1 6)
Enabling system startup links for /etc/init.
Removing any system startup links for /etc/init.
/etc/rc0.
/etc/rc1.
/etc/rc6.
/etc/rcS.
Adding system startup for /etc/init.
/etc/rc0.
/etc/rc1.
/etc/rc6.
/etc/rcS.
[Regression Potential]
* There is only one file modified, which is the update-rc.d perl script.
Worst case scenario is that users cannot enable or disable their services,
or a symlink is changed such that a service is started / stopped on an
incorrect runlevel.
* If a regression happens, any damage should be easily spotted by a
sysadmin and can be manually repaired by making manual symlinks with
"ln -s".
* I have built and tested the change in a PPA, which you can find here:
https:/
* My only cause for concern is that if a regression does happen, it may
impact packages that run "update-rc.d <service> [en|dis]able" in a
postinstall module, although I haven't managed to find an example that
does this, since most use the "defaults" command instead.
[Other Info]
* trusty is the last Ubuntu release to use sysvinit, and this bug is not
present in newer versions since they use systemd, and the code in question
is removed from update-rc.d.
* The bug exists in debian squeeze, which is now unsupported, and the code
in question is not in any newer versions.
* The bug was introduced in 2009-06-29 and somehow evaded anyone noticing
it.
Changed in sysvinit (Ubuntu Trusty): | |
importance: | Undecided → Medium |
assignee: | nobody → Matthew Ruffell (mruffell) |
description: | updated |
Changed in sysvinit (Ubuntu Trusty): | |
status: | New → In Progress |
tags: | added: sts-sponsor |
tags: | added: sts-sponsor-ddstreet |
tags: | removed: sts-sponsor sts-sponsor-ddstreet |
I have developed a patch which I believe fixes the problem.
https:/ /paste. ubuntu. com/p/QRw4XTkXk V/