package nagios2-common 2.9-1 failed to upgrade:

Bug #220208 reported by krangal
8
Affects Status Importance Assigned to Milestone
nagios2 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: nagios2

Upgrading via Internet from Gutsy to Hardy RC1.
Nagios start/stop script not working.

ProblemType: Package
Architecture: amd64
Date: Mon Apr 21 13:48:21 2008
DistroRelease: Ubuntu 8.04
ErrorMessage:
 ErrorMessage: Paket ist in einem sehr schlechten inkonsistenten Zustand - Sie sollten es
Package: nagios2-common 2.9-1
PackageArchitecture: all
SourcePackage: nagios2
Title: package nagios2-common 2.9-1 failed to install/upgrade:
Uname: Linux 2.6.18-6-xen-amd64 x86_64

CVE References

Revision history for this message
krangal (eduard-mengel) wrote :
Revision history for this message
Thierry Carrez (ttx) wrote :

I can't reproduce it on gutsy -> hardy final using do-release-upgrade on a server setup.
Could you describe the method you used to upgrade (update-manager/do-release-upgrade/apt-get dist-upgrade) ?

Changed in nagios2:
status: New → Incomplete
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I think I may have reproduced this on hardy while preparing a security update. Steps to reproduce on hardy:

1. apt-get remove --purge nagios2 nagios2-common nagios3-doc
2. apt-get install nagios2 (from hardy release)
3. apt-get -u upgrade to 2.11-1ubuntu1.1 (will provide an apt-repository soon)

At this point apt will show failures and require you to press Ctrl-C because it hangs.

Note that this upgrade does not change the packaging, and is likely the same problem as the gutsy to hardy upgrade. Also note there is no configuration taking place between steps 2 and 3.

Output from apt-get:
Preparing to replace nagios2 2.11-1ubuntu1 (using .../nagios2_2.11-1ubuntu1.1_amd64.deb) ...
 * Stopping nagios2 monitoring daemon nagios2 [ OK ]
Unpacking replacement nagios2 ...
Preparing to replace nagios2-common 2.11-1ubuntu1 (using .../nagios2-common_2.11-1ubuntu1.1_all.deb) ...
 * Stopping nagios2 monitoring daemon nagios2 invoke-rc.d: initscript nagios2, action "stop" failed.
dpkg: warning - old pre-removal script returned error exit status 3
dpkg - trying script from the new package instead ...
 * Stopping nagios2 monitoring daemon nagios2 invoke-rc.d: initscript nagios2, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/nagios2-common_2.11-1ubuntu1.1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 3
 * Starting nagios2 monitoring daemon nagios2 [ OK ]
dpkg: error while cleaning up:
 subprocess post-installation script killed by signal (Interrupt)
Errors were encountered while processing:
 /var/cache/apt/archives/nagios2-common_2.11-1ubuntu1.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

do-release-upgrade does a lot more than a 'apt-get dist-upgrade' which is why this problem isn't hit in Thierry's upgrade. Sounds like this may be http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=476466

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Marking confirmed. The -security package I mentioned will be in the main archive soon, so hardy to hardy-security upgrades can be tested.

Changed in nagios2:
status: Incomplete → Confirmed
Revision history for this message
Thierry Carrez (ttx) wrote :

Analysis: both nagios2 and nagios2-common try to stop nagios2 in prerm. The prerm in nagios2 tries to fail gracefully using a "|| true" stanza:

-----------------------
#!/bin/sh -e

# we attempt to stop nagios2 twice, once in nagios2-common's prerm
# and once here. otherwise, if nagios2+nagios2-common are being purged,
# the /usr/sbin/nagios2 binary could disappear before nagios2-common's
# prerm script runs, which would prevent it from being able to stop
# the binary.
if [ -x "/etc/init.d/nagios2" ]; then
 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  invoke-rc.d nagios2 stop || true
 else
  /etc/init.d/nagios2 stop || true
 fi
fi
-----------------------

However, usage of "-e" option renders the "|| true" inefficient, prerm returns 3 in invoke-rc.d fails, therefore breaking the update.

Revision history for this message
Thierry Carrez (ttx) wrote :

I am wrong, "-e" should work OK... but for some reason this prerm still returns 3 on invoke-rc.d failure.

Revision history for this message
Thierry Carrez (ttx) wrote :

In fact it's not the nagios2 prerm that fails, it's the nagios2-common one. It is run after the nagios2 one in upgrade situations.
This minimal patch fixes it.

Test :

Preparing to replace nagios2 2.9-1 (using .../nagios2_2.11-1ubuntu2_amd64.deb) ...
 * Stopping nagios2 monitoring daemon nagios2 [ OK ]
Unpacking replacement nagios2 ...
Preparing to replace nagios2-common 2.9-1 (using .../nagios2-common_2.11-1ubuntu2_all.deb) ...
 * Stopping nagios2 monitoring daemon nagios2 invoke-rc.d: initscript nagios2, action "stop" failed.
dpkg: warning - old pre-removal script returned error exit status 3
dpkg - trying script from the new package instead ...
 * Stopping nagios2 monitoring daemon nagios2 invoke-rc.d: initscript nagios2, action "stop" failed.
dpkg: ... it looks like that went OK.
Unpacking replacement nagios2-common ...
Setting up nagios2-common (2.11-1ubuntu2) ...
Installing new version of config file /etc/nagios2/commands.cfg ...
Installing new version of config file /etc/nagios2/conf.d/localhost_nagios2.cfg ...
Installing new version of config file /etc/nagios2/nagios.cfg ...
Installing new version of config file /etc/nagios2/cgi.cfg ...
Installing new version of config file /etc/init.d/nagios2 ...
Replacing config file /etc/nagios2/apache2.conf with new version
 * Reloading web server config apache2 [ OK ]
 * Starting nagios2 monitoring daemon nagios2 [ OK ]

Setting up nagios2 (2.11-1ubuntu2) ...
koon@hardy-test:~$

I'll post a cleaner (but heavier) patch soon, that will make use of dh_installinit --error-handler option to show a "Nagios was probably already stopped" message (and avoid the lintian warning about lack of #DEBHELPER# in nagios2-common.prerm).

Revision history for this message
Thierry Carrez (ttx) wrote :

Cleaner and not heavier patch, thanks to mathiaz advice.
The test gives the same messages, since the code used is the same.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thanks Thierry for your patch! I have incorporated this into the -security update and it will hit the archives soon.

Changed in nagios2:
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nagios2 - 2.11-1ubuntu1.2

---------------
nagios2 (2.11-1ubuntu1.2) hardy-security; urgency=low

  * SECURITY UPDATE: fix XSS issues in CGI scripts thanks to Thierry Carrez
  * debian/rules: fix nagios2-common upgrade failure. Thanks to Thierry Carrez
  * References
    CVE-2007-5803
    LP: #238516
    LP: #220208

 -- Jamie Strandboge <email address hidden> Thu, 19 Jun 2008 12:30:11 -0400

Changed in nagios2:
status: Fix Committed → Fix Released
Revision history for this message
Ethan (ethan-bonick) wrote :

I am getting the same issue on a fresh installation of 8.04. I pasted what I get after running an apt-get upgrade since the install failed.

Setting up nagios2-common (2.11-1ubuntu1.2) ...
Not replacing deleted config file /etc/nagios2/apache2.conf
Not replacing deleted config file /etc/nagios2/conf.d/host-gateway_nagios2.cfg
include file /etc/nagios2/apache2.conf does not exist!
dpkg: error processing nagios2-common (--configure):
 subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nagios2:
 nagios2 depends on nagios2-common (= 2.11-1ubuntu1.2); however:
  Package nagios2-common is not configured yet.
dpkg: error processing nagios2 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 nagios2-common
 nagios2
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
Thierry Carrez (ttx) wrote :

Hello Ethan,
Thanks for submitting your problem. I believe this is a different issue than the one reported for this bug. Your upgrade issue seem related to the loss of the /etc/nagios2/apache2.conf file, while this bug was about a problem in stopping nagios2 during the upgrade.

Could you please submit a separate bug against nagios2 so that we can clearly distinguish between this (fixed) bug and yours ? Thanks in advance.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.