Debian Bug report logs - #363524
Problem diverting conffile

version graph

Package: dpkg; Maintainer for dpkg is Dpkg Developers <debian-dpkg@lists.debian.org>; Source for dpkg is src:dpkg (PTS, buildd, popcon).

Reported by: adrian@smop.co.uk

Date: Wed, 19 Apr 2006 16:18:08 UTC

Severity: normal

Found in version dpkg/1.13.18

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Dpkg Developers <team@dpkg.org>:
Bug#363524; Package dpkg. (full text, mbox, link).


Acknowledgement sent to adrian@smop.co.uk:
New Bug report received and forwarded. Copy sent to Dpkg Developers <team@dpkg.org>. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Adrian Bridgett <adrian@smop.co.uk>
To: submit@bugs.debian.org
Subject: dpkg: dpkg-divert problems
Date: Wed, 19 Apr 2006 16:58:26 +0100
Package: dpkg
Version: 1.13.18

I'm trying to override a config file provided by nagios-plugins with a
custom version.  As such I have this in my preinst:

if [ "$1" = "install" ]; then
  dpkg-divert --package nagios-plugins-custom --add --rename \
       --divert /etc/nagios/nrpe.cfg.divert.custom /etc/nagios/nrpe.cfg
fi

and in the postrm:

if [ "$1" = "remove" ]; then
  dpkg-divert --package nagios-plugins-custom --remove --rename \
        --divert /etc/nagios/nrpe.cfg.divert.custom /etc/nagios/nrpe.cfg
fi

However if I try and install this I get this:

dpkg -i nagios-plugins-custom_1.0_i386.deb 
Selecting previously deselected package nagios-plugins-custom.
(Reading database ... 131893 files and directories currently installed.)
Unpacking nagios-plugins-custom (from
nagios-plugins-custom_1.0_i386.deb) ..
.
Adding `diversion of /etc/nagios/nrpe.cfg to
/etc/nagios/nrpe.cfg.divert.custom by 
nagios-plugins-custom'
[[ looks good ]]
Setting up nagios-plugins-custom (1.0) ...

[[ Not convinced about this - I have diverted it after all. ]]
Configuration file `/etc/nagios/nrpe.cfg'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
   Y or I  : install the package maintainer's version
   N or O  : keep your currently-installed version
     D     : show the differences between the versions
     Z     : background this process to examine the situation
The default action is to keep your current version.
*** nrpe.cfg (Y/I/N/O/D/Z) [default=N] ? y 
Installing new version of config file /etc/nagios/nrpe.cfg ...

The right thing has happened, but I don't think the user should have
been asked the question - this is the first version since the divert.

The thing that's really going wrong is the remove:

dpkg --purge nagios-plugins-custom
(Reading database ... 131899 files and directories currently installed.)
Removing nagios-plugins-custom ...
Removing `diversion of /etc/nagios/nrpe.cfg to
/etc/nagios/nrpe.cfg.divert.custom by nagios-plugins-custom'
dpkg-divert: rename involves overwriting `/etc/nagios/nrpe.cfg' with
  different file `/etc/nagios/nrpe.cfg.divert.custom', not allowed
Restarting nagios-nrpe: nagios-nrpe.
Purging configuration files for nagios-plugins-custom ...
  
FWIW I also get all these issues on sarge (and an additional one which
seems to be #312931/140222/351361):

dpkg -i nagios-plugins-custom_1.0_i386.deb 
Selecting previously deselected package nagios-plugins-custom.
(Reading database ... 12234 files and directories currently installed.)
Unpacking nagios-plugins-custom (from
nagios-plugins-custom_1.0_i386.deb) ...
Adding `diversion of /etc/nagios/nrpe.cfg to
/etc/nagios/nrpe.cfg.divert.custom by nagios-plugins-custom'
Setting up nagios-plugins-custom (1.0) ...

Configuration file `/etc/nagios/nrpe.cfg'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
  What would you like to do about it ?  Your options are:
   Y or I  : install the package maintainer's version
   N or O  : keep your currently-installed version
     D     : show the differences between the versions
     Z     : background this process to examine the situation
 The default action is to keep your current version.
*** nrpe.cfg (Y/I/N/O/D/Z) [default=N] ? y
dpkg: nagios-plugins-custom: warning - failed to link `/etc/nagios/nrpe.cfg' to
`/etc/nagios/nrpe.cfg.dpkg-old': No such file or directory
Installing new version of config file /etc/nagios/nrpe.cfg ...



Information forwarded to debian-bugs-dist@lists.debian.org, Dpkg Developers <team@dpkg.org>:
Bug#363524; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Frank Lichtenheld <djpig@debian.org>:
Extra info received and forwarded to list. Copy sent to Dpkg Developers <team@dpkg.org>. (full text, mbox, link).


Message #10 received at 363524@bugs.debian.org (full text, mbox, reply):

From: Frank Lichtenheld <djpig@debian.org>
To: adrian@smop.co.uk, 363524@bugs.debian.org
Subject: Re: Bug#363524: dpkg: dpkg-divert problems
Date: Thu, 11 May 2006 17:11:07 -0500
On Wed, Apr 19, 2006 at 04:58:26PM +0100, Adrian Bridgett wrote:
> However if I try and install this I get this:
> 
> dpkg -i nagios-plugins-custom_1.0_i386.deb 
> Selecting previously deselected package nagios-plugins-custom.
> (Reading database ... 131893 files and directories currently installed.)
> Unpacking nagios-plugins-custom (from
> nagios-plugins-custom_1.0_i386.deb) ..
> .
> Adding `diversion of /etc/nagios/nrpe.cfg to
> /etc/nagios/nrpe.cfg.divert.custom by 
> nagios-plugins-custom'
> [[ looks good ]]
> Setting up nagios-plugins-custom (1.0) ...
> 
> [[ Not convinced about this - I have diverted it after all. ]]
> Configuration file `/etc/nagios/nrpe.cfg'
>  ==> Deleted (by you or by a script) since installation.
>  ==> Package distributor has shipped an updated version.
>    What would you like to do about it ?  Your options are:
>    Y or I  : install the package maintainer's version
>    N or O  : keep your currently-installed version
>      D     : show the differences between the versions
>      Z     : background this process to examine the situation
> The default action is to keep your current version.
> *** nrpe.cfg (Y/I/N/O/D/Z) [default=N] ? y 
> Installing new version of config file /etc/nagios/nrpe.cfg ...
> 
> The right thing has happened, but I don't think the user should have
> been asked the question - this is the first version since the divert.
> 
> The thing that's really going wrong is the remove:
> 
> dpkg --purge nagios-plugins-custom
> (Reading database ... 131899 files and directories currently installed.)
> Removing nagios-plugins-custom ...
> Removing `diversion of /etc/nagios/nrpe.cfg to
> /etc/nagios/nrpe.cfg.divert.custom by nagios-plugins-custom'
> dpkg-divert: rename involves overwriting `/etc/nagios/nrpe.cfg' with
>   different file `/etc/nagios/nrpe.cfg.divert.custom', not allowed
> Restarting nagios-nrpe: nagios-nrpe.
> Purging configuration files for nagios-plugins-custom ...

Could you please send us the output of dpkg --debug=7777
for these actions? This would help to determine what dpkg
is actually doing and why.

Gruesse,
-- 
Frank Lichtenheld <djpig@debian.org>
www: http://www.djpig.de/



Changed Bug title to Problem diverting conffile from dpkg: dpkg-divert problems. Request was from Guillem Jover <guillem@debian.org> to control@bugs.debian.org. (Sun, 25 Mar 2007 04:57:10 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Dpkg Developers <debian-dpkg@lists.debian.org>:
Bug#363524; Package dpkg. (Wed, 10 Dec 2008 13:57:05 GMT) (full text, mbox, link).


Acknowledgement sent to "Durk Strooisma" <durk@kern.nl>:
Extra info received and forwarded to list. Copy sent to Dpkg Developers <debian-dpkg@lists.debian.org>. (Wed, 10 Dec 2008 13:57:05 GMT) (full text, mbox, link).


Message #17 received at 363524@bugs.debian.org (full text, mbox, reply):

From: "Durk Strooisma" <durk@kern.nl>
To: <363524@bugs.debian.org>
Subject: Additional information + testpackages
Date: Wed, 10 Dec 2008 14:53:48 +0100 (CET)
[Message part 1 (text/plain, inline)]
Hi,

I encountered the same issue; the unnecessary question for overwriting a
conffile that does not exist anymore, because it's already diverted. But
in contrast to the original bug poster, removing the package in question
wasn't a problem, unless the dpkg-divert removal statement in put in the
right postrm target.

Another observation is that if the overwriting package has the new
configuration file not marked as conffile, no question is asked (as it
should be).

I created some test packages (all attached) to demonstrate the issue.

test-pkg-c
----------

Installs /etc/test-pkg-c/config-file as conffile.

test-pkg-d
----------

Diverts /etc/test-pkg-c/config-file to /etc/test-pkg-c/config-file.diverted
and installs a different /etc/test-pkg-c/config-file (also) as conffile.

test-pkg-e
----------

Diverts /etc/test-pkg-c/config-file to /etc/test-pkg-c/config-file.diverted
and installs a different /etc/test-pkg-c/config-file, but not marking it as
conffile.

Demonstration
-------------------------

First we install test-pkg-c:

# dpkg -i test-pkg-c_0.1_all.deb
Selecting previously deselected package test-pkg-c.
(Reading database ... 15719 files and directories currently installed.)
Unpacking test-pkg-c (from test-pkg-c_0.1_all.deb) ...
Setting up test-pkg-c (0.1) ...
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file

Okay, everything seems fine. Next, test-pkg-e:

# dpkg -i test-pkg-e_0.1_all.deb
Selecting previously deselected package test-pkg-e.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-e (from test-pkg-e_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e'
Setting up test-pkg-e (0.1) ...
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root 19 2008-12-10 11:35 config-file
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e

Okay, seems fine. As said before, if the overwriting file is not marked as
conffile, no question is asked. Let's remove/purge test-pkg-e:

# dpkg -P test-pkg-e
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-e ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-e'
Purging configuration files for test-pkg-e ...
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Okay, package was nicely removed, nothing left and original file restored.
Now we're going to install test-pkg-d:

# dpkg -i test-pkg-d_0.1_all.deb
Selecting previously deselected package test-pkg-d.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-d (from test-pkg-d_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
Setting up test-pkg-d (0.1) ...

Configuration file `/etc/test-pkg-c/config-file'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : background this process to examine the situation
 The default action is to keep your current version.
*** config-file (Y/I/N/O/D/Z) [default=N] ? Y
Installing new version of config file /etc/test-pkg-c/config-file ...
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root 13 2008-12-10 11:07 config-file
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d

Everything went alright, but as said before the question is pointless here.
Even more strange: if chosen to do a diff (D), dpkg diffs the new file
against an empty file, which doesn't make sense. Chosing N instead of Y
will leave an inconsistent system, we will demonstrate this later, first we
need to remove/purge test-pkg-d:

# dpkg -P test-pkg-d
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-d ...
Purging configuration files for test-pkg-d ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Okay, package was nicely removed, nothing left and original file restored.
Now we're going to install test-pkg-d and answer N:

# dpkg -i test-pkg-d_0.1_all.deb
Selecting previously deselected package test-pkg-d.
(Reading database ... 15724 files and directories currently installed.)
Unpacking test-pkg-d (from test-pkg-d_0.1_all.deb) ...
Adding `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
Setting up test-pkg-d (0.1) ...

Configuration file `/etc/test-pkg-c/config-file'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : background this process to examine the situation
 The default action is to keep your current version.
*** config-file (Y/I/N/O/D/Z) [default=N] ? N
# ls -l /etc/test-pkg-c
total 8
-rw-r--r-- 1 root root  9 2008-12-10 11:04 config-file.diverted
-rw-r--r-- 1 root root 13 2008-12-10 11:07 config-file.dpkg-dist
# dpkg-divert --list /etc/test-pkg-c/config-file
diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d

As you see, there's no /etc/test-pkg-c/config-file anymore. Not cool. This
pleads even more for preventing this question. Let's see what happens if we
remove/purge test-pkg-d:

# dpkg -P test-pkg-d
(Reading database ... 15727 files and directories currently installed.)
Removing test-pkg-d ...
Purging configuration files for test-pkg-d ...
Removing `diversion of /etc/test-pkg-c/config-file to
/etc/test-pkg-c/config-file.diverted by test-pkg-d'
# ls -l /etc/test-pkg-c
total 4
-rw-r--r-- 1 root root 9 2008-12-10 11:04 config-file
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Surprisingly, the removal of test-pkg-d restores the original file and
removes the config-file.dpkg-dist. So at least we are able to fix the
state of the system if the wrong answer was chosen. To end the
demonstration will remove test-pkg-c as well:

# dpkg -P test-pkg-c
(Reading database ... 15723 files and directories currently installed.)
Removing test-pkg-c ...
Purging configuration files for test-pkg-c ...
# ls -l /etc/test-pkg-c
ls: cannot access /etc/test-pkg-c: No such file or directory
# dpkg-divert --list /etc/test-pkg-c/config-file
#

Works perfectly, of course.

As requested in this bug post, I provided the dpkg debug output of the
installation of test-pkg-d (answering Y) as well.

I hope this helps to resolve the issue.


[test-packages.tar.gz (application/x-gzip, attachment)]
[dpkg-debug_2008-12-10.txt.gz (application/x-gzip, attachment)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Fri Jan 12 21:39:46 2018; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.