** Tags removed: sts-sponsor sts-sponsor-ddstreet

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to sysvinit in Ubuntu.
https://bugs.launchpad.net/bugs/1827172

Title:
  update-rc.d: enabling or disabling S runlevel services incorrectly
  modifies runlevel

Status in sysvinit package in Ubuntu:
  New
Status in sysvinit source package in Trusty:
  In Progress

Bug description:
  [Impact]

   * update-rc.d, in sysv-rc-2.88dsf-41ubuntu6.3 is broken in trusty.

   * 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/update-rc.d line
     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-openiscsi:/etc# ls -l /etc/rc[0123456S].d/*iscsi*
  /etc/rc0.d/K80umountiscsi.sh -> ../init.d/umountiscsi.sh
  /etc/rc0.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc1.d/K80umountiscsi.sh -> ../init.d/umountiscsi.sh
  /etc/rc1.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc6.d/K80umountiscsi.sh -> ../init.d/umountiscsi.sh
  /etc/rc6.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rcS.d/S45open-iscsi -> ../init.d/open-iscsi

  3) Use update-rc.d to enable open-iscsi service

  root@trusty-openiscsi:/etc# update-rc.d open-iscsi enable
  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/update-rc.d line 232.
  Enabling system startup links for /etc/init.d/open-iscsi ...
  Removing any system startup links for /etc/init.d/open-iscsi ...
  /etc/rc0.d/K81open-iscsi
  /etc/rc1.d/K81open-iscsi
  /etc/rc6.d/K81open-iscsi
  /etc/rcS.d/S45open-iscsi
  Adding system startup for /etc/init.d/open-iscsi ...
  /etc/rc0.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc1.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc6.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc0.d/S45open-iscsi -> ../init.d/open-iscsi

  * The problem is the "/etc/rcS.d/S45open-iscsi" symlink is incorrectly
    changed to "/etc/rc0.d/S45open-iscsi".

  * Instead, the correct behaviour is to keep the symlink in /etc/rcS.d/
    intact:

  root@trusty-openiscsi:/etc# update-rc.d open-iscsi enable
  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.d/open-iscsi ...
  Removing any system startup links for /etc/init.d/open-iscsi ...
  /etc/rc0.d/K81open-iscsi
  /etc/rc1.d/K81open-iscsi
  /etc/rc6.d/K81open-iscsi
  /etc/rcS.d/S45open-iscsi
  Adding system startup for /etc/init.d/open-iscsi ...
  /etc/rc0.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc1.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rc6.d/K81open-iscsi -> ../init.d/open-iscsi
  /etc/rcS.d/S45open-iscsi -> ../init.d/open-iscsi

  [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://launchpad.net/~mruffell/+archive/ubuntu/sysvinit-testing

   * 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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/sysvinit/+bug/1827172/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to