update-rc.d enable/disable actions doesn't work correctly with only 1 argument given

Bug #953604 reported by Patrick Börjesson on 2012-03-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sysvinit (Ubuntu)
Undecided
Unassigned

Bug Description

When giving only one argument to the update-rc.d enable/disable actions, it discards the argument altogether because of a fault in a conditional inside the update-rc.d script.

The command: "update-rc.d <service> enable 3" results in the default from /etc/init.d/<service> being used instead of enabling the service for only runlevel 3 (as specified in the command). When giving more than one runlevel, it works as intended.

The fault is at row 224 in update-rc.d, where it uses "if ($#argv > 1)" to check if there are any arguments to the actions. This evaluates to false if there's only 1 argument to the enable/disable actions (argv containing (enable, 3) in my case) because of [1].
Changing this if-conditional to "if ($#argv > 0)" or equivalent would correct this issue and allow the enable/disable actions of update-rc.d to accept only one argument.

Version of sysv-rc: 2.88dsf-12.10ubuntu4.1
Ubuntu-release: 11.10

[1]: "$#array" only reports the index of the last element of the array (indexing beginning at 0) instead of the number of elements in the array. "$#array+1" would be the number of elements.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers