Bug 1468036

Summary: "chkconfig $service on" and "chkconfig --override $service" inconsistency when there are override files
Product: Red Hat Enterprise Linux 6 Reporter: Paulo Andrade <pandrade>
Component: chkconfigAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.9CC: cww, zpytela
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-16 17:01:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paulo Andrade 2017-07-05 20:03:43 UTC
Steps to reproduce:

# cat /etc/init.d/nxserver
# chkconfig: - 99 01
# description: Starts and stops the NoMachine NX Server.
#
### BEGIN INIT INFO
# Provides:       nxserver
# Required-Start: $local_fs $remote_fs
# Should-Start: $network sshd
# Required-Stop:  $local_fs $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    Starts and stops the NoMachine NX Server.
### END INIT INFO

# cat /etc/chkconfig.d/nxserver
# chkconfig: 35 88 01
# description: Starts and stops the NoMachine NX Server.
# 

# chkconfig nxserver on
# find /etc/rc*.d/*nx*
/etc/rc0.d/K01nxserver
/etc/rc1.d/K01nxserver
/etc/rc2.d/S88nxserver
/etc/rc3.d/S88nxserver
/etc/rc4.d/S88nxserver
/etc/rc5.d/S88nxserver
/etc/rc6.d/K01nxserver

# chkconfig nxserver off
# find /etc/rc*.d/*nx*
/etc/rc0.d/K01nxserver
/etc/rc1.d/K01nxserver
/etc/rc2.d/K01nxserver
/etc/rc3.d/K01nxserver
/etc/rc4.d/K01nxserver
/etc/rc5.d/K01nxserver
/etc/rc6.d/K01nxserver

# chkconfig nxserver on
# find /etc/rc*.d/*nx*
/etc/rc0.d/K01nxserver
/etc/rc1.d/K01nxserver
/etc/rc2.d/S88nxserver
/etc/rc3.d/S88nxserver
/etc/rc4.d/S88nxserver
/etc/rc5.d/S88nxserver
/etc/rc6.d/K01nxserver

# chkconfig nxserver reset
# find /etc/rc*.d/*nx*
/etc/rc0.d/K01nxserver
/etc/rc1.d/K01nxserver
/etc/rc2.d/K01nxserver
/etc/rc3.d/S88nxserver
/etc/rc4.d/K01nxserver
/etc/rc5.d/S88nxserver
/etc/rc6.d/K01nxserver

  It is required to run "chkconfig nxserver reset" to actually use the
overrides. The overrides will only work if:

1. run: chkconfig nxserver off
2. remove /etc/chkconfig.d/nxserver
3. run: chkconfig nxserver on
4. add back /etc/chkconfig.d/nxserver
5. run chkconfig --override nxserver

  First inconsistency is that if one runs "chkconfig nxserver on" with
the override file installed, it will change the priority but not properly
update the run levels, then, if running with --overrride it will fail
due to the checks in the comment:

    /* Apply overrides only if the service has not been changed since
     * being added, and not if the service has never been configured
     * at all.
     */

on a simple test build, with this pseudo patch in overrideService:overrideService()

-    if (configured && doChange) {
+    if (1/*configured && doChange*/) {

executing "chkconfig --override nxserver" works as if "chkconfig nxserver reset"
had been run.

  But, the main issue is that unless one runs the above as:

# chkconfig --level 35 nxserver on

it will just use default values for levels, instead of reading from the
file and/or overrides.

  The problem is that the "reset" option and --override logics are
disjoint. *If* there is an override file, to give the expected results,
setService() should receive a -1 value for state.