[debhelper-devel] Bug#808887: dh_installinit: disable init scripts on removal of package

Andreas Henriksson andreas at fatal.se
Mon Dec 28 19:22:57 UTC 2015


Hello Felipe!

On Thu, Dec 24, 2015 at 12:34:22AM -0300, Felipe Sateler wrote:
> Control: clone -1 -2
> Control: tags -2 -moreinfo
> Control: reassign -2 sysv-rc/2.88dsf-59.2
> Control: retitle -2 update-rc.d: bails out on stop-only services
> Control: severity -2 normal

(Replying to -2 (aka 808887) only as this followup is only related to
sysvinit/update-rc.d....)

I don't really have any prior knowledge on this matter or any historical
perspective on why things where designed as they are, but I looked at
this the best I could and will follow up with my 5c below if anyone is
interested.

> 
> On Thu, 26 Nov 2015 21:43:00 +0000 Niels Thykier <niels at thykier.net> wrote:
[...]
> > Unfortunately, our attempt to solve this bug as caused a severe
> > regression (please see #806276) and had to be reverted.
> >
> > Apparently it is *not* safe to call "update-rc.d #SCRIPT# disable"
> > unconditionally.  It is not entirely clear to me why/when it would work
> > / not work, so I will put this on hold until further notice.
> 
> The problem seems to be that update-rc.d bails out when Default-Start
> is empty. For example, the mdadm-waitidle init script has no
> Default-Start (only Default-Stop). Update-rc.d has the following
> check:
> 
>         ($start_lvls, $stop_lvls) = parse_def_start_stop($lsb_header);
>        @toggle_lvls = @$start_lvls;
>        if ($#toggle_lvls < 0) {
>            error("$name Default-Start contains no runlevels, aborting.");
>        }
> 
> And indeed on mdadm-waitidle neither enable or disable work. It seems
> to me this is just an oversight, and update-rc.d should consider both
> start and stop runlevels. I'm now CCing the sysvinit maintainers and
> Andreas Hendriksson (which expressed interest in update-rc.d earlier)
> for input.

Even getting past this check there are will be issues further down...

eg.

		if ($lvl !~ /^[S2345]$/) {
			warning("$act action will have no effect on runlevel $lvl");
			next;


in other words runlevels 0, 1 and 6 (as specified by mdadm-waitidle)
are not taken into consideration anyway.

see
http://sources.debian.net/src/sysvinit/2.88dsf-59.2/debian/src/sysv-rc/sbin/update-rc.d/#L349

...and...

	if (!@symlinks) {
		error("no runlevel symlinks to modify, aborting!");

.. which makes sure we exit non-0 if we end up with no work.

see
http://sources.debian.net/src/sysvinit/2.88dsf-59.2/debian/src/sysv-rc/sbin/update-rc.d/#L356

> 
> The current update-rc.d behavior has the effect moving S=>K symlinks,
> but it does nothing on K (aka, Default-Stop) symlinks. As an example:
> 
> % sudo 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).
> 
> 
> For update-rc.d, I'm not sure what the correct course of action would
> be. Having disabled scripts start on shutdown is clearly bad. Leaving
> stop-only services untouched is suboptimal, as there is no difference
> between enabled and disabled. And simply removing the links would have
> them recreated at next upgrade.

>From the runlevel filtering mentioned above it seems to me like things
where really designed only for "start" services on purpose. Not really
sure why though. Someone with knowledge of the historical background
shiming in here would be highly appreciated.

I really thought update-rc.d was a more generic utility myself before
looking into this, but right now it seems if we want to change it
to exit 0 on nothing-to-be-done and also consider all runlevels
as well as both start and stop symlinks someone probably needs to
look into this from a bigger design perspective.


> 
> For debhelper, a solution is to apply  0f09b1f8, *not* apply
> 02cd0cec1c, and instead have lintian remove the warning. Another
> solution would be to disable -e, store the error code, only fail if
> _action==remove, and finally restore -e.
> 
> -- 
> Saludos

HTH.

Regards,
Andreas Henriksson




More information about the debhelper-devel mailing list