invoke-rc.d don't return same anwswer when the variable RUNLEVEL is setup at boot time

Bug #619246 reported by Christophe GUILLOUX on 2010-08-17
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
sysvinit (Ubuntu)
Undecided
Unassigned
Lucid
Undecided
Dave Walker

Bug Description

Binary package hint: sysvinit

IMPACT: puppet tool uses invoke-rc.d to determine if a service is launched at boot time. But at boot time, a variable RUNLEVEL is setup and invoke-rc.d doesn't work after that.

FIX: have invoke-rc.d to use 'RUNLEVELHELPER' as the variable name for the full path to the runlevel(8) binary instead of 'RUNLEVEL'.

PATCH: See comment #3, or diff for (2.87dsf-4ubuntu24) oneiric.

REPRODUCE:
RUNLEVEL=2 bash -x /usr/sbin/invoke-rc.d --quiet --query ssh start
-> we can see an exit 105
but :
bash -x /usr/sbin/invoke-rc.d --quiet --query ssh start
-> we can see an exit 104 (the good answer)

With debian lenny :
RUNLEVEL=2 bash -x /usr/sbin/invoke-rc.d --quiet --query ssh start
-> we can see an exit 104

DISCUSSION: Regression potential is low, it is a back-ported fix from oneiric. This fix is currently in production use on some Canonical Lucid servers.

description: updated
Dan Urist (durist-ucar) wrote :

I can confirm this bug. I've also confirmed that the bug doesn't exist in jaunty, so is definitely new (since switch to upstart?). This probably affects other services besides puppet, since invoke-rc.d is supposed to be the interface to sysv init. From the debian policy manual:

> 9.3.3 Interfacing with the initscript system

> Maintainers should use the abstraction layer provided by the update-rc.d and invoke-rc.d programs to deal
> with initscripts in their packages' scripts such as postinst, prerm and postrm.

> Directly managing the /etc/rc?.d links and directly invoking the /etc/init.d/ initscripts should be done only
> by packages providing the initscript subsystem (such as sysv-rc and file-rc).

James Troup (elmo) wrote :

This bug is still present in Oneiric.

The root cause is that invoke-rc.d misuses 'RUNLEVEL' as a local
variable for the full path to the runlevel(8) binary. As long as
'RUNLEVEL' isn't defined in the environment this doesn't have any
particular ill effects. However, if 'RUNLEVEL' is defined in the
environment (as it is during bootup), the local variable gets marked
for export[1] and thus when runlevel(8) is invoked it sees RUNLEVEL as
'/sbin/runlevel' which causes it to give bad output ('/ N').

One easy/obvious way to avoid this is to have invoke-rc.d to use
'RUNLEVELHELPER' as the variable name for the full path to the
runlevel(8) binary instead of 'RUNLEVEL'.

I've attached a debdiff which does this and I've tested patched
packages on both lucid (server) and natty (desktop), including a full
reboot cycle. It both fixes the originally reported problem and
doesn't seem to introduce any other problems. It'd be nice if we
could get this into Oneiric and then SRU it into Lucid (as the current
and affected LTS).

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_03
    [With thanks to Colin Watson and Robert Collins.]

Changed in sysvinit (Ubuntu):
status: New → Confirmed
James Troup (elmo) wrote :
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sysvinit - 2.87dsf-4ubuntu24

---------------
sysvinit (2.87dsf-4ubuntu24) oneiric; urgency=low

  * debian/sysv-rc/sbin/invoke-rc.d: replace RUNLEVEL with RUNLEVELHELPER.
    Using RUNLEVEL causes spurious failures when invoke-rc.d is invoked
    with RUNLEVEL already defined in the environment (as it is e.g. during
    bootup) since invoke-rc.d's RUNLEVEL will become an exported variable
    at that point and cause /sbin/runlevel to return bad data. (LP: #619246)
 -- James Troup <email address hidden> Tue, 24 May 2011 11:41:45 +0000

Changed in sysvinit (Ubuntu):
status: Confirmed → Fix Released
Dave Walker (davewalker) on 2011-05-26
Changed in sysvinit (Ubuntu Lucid):
status: New → Confirmed
assignee: nobody → Dave Walker (davewalker)
Dave Walker (davewalker) on 2011-05-26
description: updated

Accepted sysvinit into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in sysvinit (Ubuntu Lucid):
status: Confirmed → Fix Committed
tags: added: verification-needed
LaMont Jones (lamont) wrote :

2.87dsf-4ubuntu17.3 behaves as expected for us.

Jean-Baptiste Lallement (jibel) wrote :

thanks for testing. marking as verification-done

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package sysvinit - 2.87dsf-4ubuntu17.3

---------------
sysvinit (2.87dsf-4ubuntu17.3) lucid-proposed; urgency=low

  * debian/sysv-rc/sbin/invoke-rc.d: replace RUNLEVEL with RUNLEVELHELPER.
    Using RUNLEVEL causes spurious failures when invoke-rc.d is invoked
    with RUNLEVEL already defined in the environment (as it is e.g. during
    bootup) since invoke-rc.d's RUNLEVEL will become an exported variable
    at that point and cause /sbin/runlevel to return bad data. (LP: #619246)
 -- James Troup <email address hidden> Tue, 24 May 2011 11:41:45 +0000

Changed in sysvinit (Ubuntu Lucid):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers