[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 Created: 2018/01/15  Updated: 2018/05/21

Status: Accepted
Project: Puppet
Component/s: Types and Providers
Affects Version/s: PUP 5.3.3
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: Laurent Declercq Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: debian, linux, service, systemd, type_and_provider
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian


Template: PUP Bug Template
Team: Platform OS
Method Found: Needs Assessment
QA Risk 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
        ;;
    *)
...


Generated at Mon Sep 23 06:31:40 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.