Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-8355

Debian - SysVinit/Systemd service providers - Making use of the invoke-rc.d command to know whether or not a service is enabled can lead to unexpected results

    XMLWordPrintable

Details

    • Night's Watch
    • Needs Assessment
    • Needs Assessment

    Description

      Good morning,

      I've looked your service providers for both SysVinit and Systemd (Debian). In your implementation, you make use of invoke-rc.d command to know whether or not a service is enabled:

      1. https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/service/debian.rb#L41
      2. https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/service/systemd.rb#L104

      Problem: If the policyrcd-script-zg2 package is installed, you will always get 104, even for unknown services...

      Howto reproduce

      1. Behavior without the policyrcd-script-zg2 package installed:

      root@stretch:~# update-rc.d apache2 defaults
      root@stretch:~# update-rc.d apache2 disable
      insserv: warning: current start runlevel(s) (empty) of script `apache2' overrides LSB defaults (2 3 4 5).
      insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apache2' overrides LSB defaults (0 1 6).
      root@stretch:~# invoke-rc.d --quiet --query apache2 start
      root@stretch:~# echo $?
      101
      

      That is the expected behavior.

      2. Behavior with the policyrcd-script-zg2 package installed:

      root@stretch:~# update-rc.d apache2 defaults
      root@stretch:~# update-rc.d apache2 disable
      insserv: warning: current start runlevel(s) (empty) of script `apache2' overrides LSB defaults (2 3 4 5).
      insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `apache2' overrides LSB defaults (0 1 6).
      root@stretch:~# invoke-rc.d --quiet --query apache2 start
      root@stretch:~# echo $?
      104
      

      With dummy (inexistent) package:

      root@stretch:~# invoke-rc.d --quiet --query dummy start
      root@stretch:~# echo $?
      104
      

      From my point of view, you should just mimic Debian behavior as done in the systemd in the Debian /lib/systemd/systemd-sysv-install script:

      ...
      is-enabled)
              # exit with 0 if $NAME is enabled, non-zero if it is disabled
              ls $ROOT/etc/rc[S5].d/S??$NAME >/dev/null 2>/dev/null
              ;;
          *)
      ...
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            nuxwin Laurent Declercq
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Zendesk Support