这是indexloc提供的服务,不要输入任何密码

Debian Bug report logs - #109691
[CONFFILE] dpkg: conffiles vs replaces

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: Richard A Nelson <cowboy@vnet.ibm.com>

Date: Wed, 22 Aug 2001 22:33:02 UTC

Severity: important

Tags: patch

Merged with 10879, 33046, 47267, 90623, 98210, 146167, 155456, 204275

Found in versions 1.4.0.8, 1.4.1.1, 1.9.16, 1.9.21

Fixed in version dpkg/1.10.21

Done: Scott James Remnant <scott@netsplit.com>

Bug is archived. No further changes may be made.

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


Report forwarded to debian-bugs-dist@lists.debian.org, Wichert Akkerman <wakkerma@debian.org>:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Richard A Nelson <cowboy@vnet.ibm.com>:
New Bug report received and forwarded. Copy sent to Wichert Akkerman <wakkerma@debian.org>. (full text, mbox, link).


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

From: Richard A Nelson <cowboy@vnet.ibm.com>
To: submit@bugs.debian.org
Subject: dpkg: conffiles vs replaces
Date: Wed, 22 Aug 2001 18:24:41 -0400
Package: dpkg
Version: 1.9.16
Severity: important

hrm... it seems dpkg is behaving in violation of Policy section
`7.5.1 Overwriting files in other packages'

I've been trying to get a sendmail-tls package setup so that one could
seemlessly change from sendmail to sendmail-tls (and back again).

The conffiles names and contents are *identicle* in the two packages,
and they each 'Replaces:' the other.

After installing sendmail, then sendmail-tls, sendmail doesn't disapear,
and a dpkg --purge on it will incorrectly (according to policy) remove
the conffiles!

The source package is built with debhelper v3, so there isn't any
*.conffile files in debian/ - the list is built by debhelper scripts.

I'm including a small snippet of a session showing the relevant portions
of commands and outputs.

********************************************************************************
# dpkg --install sendmail
# dpkg --install sendmail-tls
# dpkg --remove sendmail
dpkg - warning: ignoring request to remove sendmail, only the config
 files of which are on the system.  Use --purge to remove them too.

********************************************************************************
# dpkg -s sendmail
Package: sendmail
Status: install ok config-files
Priority: extra
Section: mail
Installed-Size: 3804
Maintainer: Richard A Nelson (Rick) <cowboy@debian.org>
Version: 8.11.6+8.12.0.Beta19-1
Config-Version: 8.11.6+8.12.0.Beta19-1
Replaces: mail-transport-agent, sendmail-tls
Provides: mail-transport-agent
Depends: m4, gawk, logrotate, libc6 (>= 2.2.3-7), libdb3 (>= 3.2.9-1), libldap2 (>= 2.0.11-1), liblockfile1 (>= 1.0), libsasl7, libwrap0, perl | perl
Suggests: sendmail-doc (>= 8.11.6+8.12.0.Beta19-1), mail-reader, procmail | mailagent | maildrop | deliver, logcheck, make
Conflicts: mail-transport-agent
Conffiles:
 /etc/cron.daily/sendmail ff39b86434c63c4847aa1471844f8d3c
 /etc/init.d/sendmail df7dbf659153c35a8cb60880f3d99fd7
 /etc/logcheck/ignore.d.paranoid/sendmail 3ed591a89001d8ee88589aa0c381124a
 /etc/logcheck/ignore.d.server/sendmail 3ed591a89001d8ee88589aa0c381124a
 /etc/logcheck/ignore.d.workstation/sendmail 2276531190a430fc0b9873c7331b991a
 /etc/logcheck/violations.ignore.d/sendmail 5b115ccc2e5116f56d8b90cdad2096c6
 /etc/logrotate.d/sendmail dc4efe3db0678dee66ef0ef757bda9b4
 /etc/mail/peers/provider 2f05d682a8fd4b9a175c0d6e36bc394d
 /etc/mail/helpfile ec9b3d66802589133bf4fecaef14e574
 /etc/mail/service.switch 6791868ea38079cb94e54048973ee716
 /etc/mail/service.switch-nodns 6aa914ad67c820bcdd5fda8a257355f1
 /etc/pam.d/smtp 035fa4dbcf7721e5d6f783a3b4f19b61
 /etc/ppp/ip-up.d/sendmail 7af7b3d4ae8f6b2fb30e5705fee5ace8
 /etc/ppp/ip-down.d/sendmail 330469680f0c7a1a6d57592328967c2f
Description: A powerful, efficient, and scalable Mail Transport Agent.
[snip]

********************************************************************************
# dpkg -s sendmail-tls
Package: sendmail-tls
Status: install ok installed
Priority: extra
Section: mail
Installed-Size: 3856
Maintainer: Sendmail Maintainer <sendmail@packages.debian.org>
Version: 8.11.6+8.12.0.Beta19-1
Replaces: mail-transport-agent, sendmail
Provides: mail-transport-agent, sendmail
Depends: m4, gawk, logrotate, libc6 (>= 2.2.3-7), libdb3 (>= 3.2.9-1), libldap2 (>= 2.0.11-1), liblockfile1 (>= 1.0), libsasl7, libssl0.9.6, libwrap0, perl | perl
Suggests: sendmail-doc (>= 8.11.6+8.12.0.Beta19-1), mail-reader, procmail | mailagent | maildrop | deliver, logcheck, make
Conflicts: mail-transport-agent
Conffiles:
 /etc/cron.daily/sendmail ff39b86434c63c4847aa1471844f8d3c
 /etc/init.d/sendmail df7dbf659153c35a8cb60880f3d99fd7
 /etc/logcheck/ignore.d.paranoid/sendmail 3ed591a89001d8ee88589aa0c381124a
 /etc/logcheck/ignore.d.server/sendmail 3ed591a89001d8ee88589aa0c381124a
 /etc/logcheck/ignore.d.workstation/sendmail 2276531190a430fc0b9873c7331b991a
 /etc/logcheck/violations.ignore.d/sendmail 5b115ccc2e5116f56d8b90cdad2096c6
 /etc/logrotate.d/sendmail dc4efe3db0678dee66ef0ef757bda9b4
 /etc/mail/peers/provider 2f05d682a8fd4b9a175c0d6e36bc394d
 /etc/mail/helpfile ec9b3d66802589133bf4fecaef14e574
 /etc/mail/service.switch 6791868ea38079cb94e54048973ee716
 /etc/mail/service.switch-nodns 6aa914ad67c820bcdd5fda8a257355f1
 /etc/pam.d/smtp 035fa4dbcf7721e5d6f783a3b4f19b61
 /etc/ppp/ip-up.d/sendmail 7af7b3d4ae8f6b2fb30e5705fee5ace8
 /etc/ppp/ip-down.d/sendmail 330469680f0c7a1a6d57592328967c2f
Description: A powerful, efficient, and scalable Mail Transport Agent.
[snip]

********************************************************************************
# ls -l /var/lib/dpkg/info/sendmail*
-rw-r--r-- 1 root root   409 Aug 22 16:53 sendmail-tls.conffiles
-rw-r--r-- 1 root root 14243 Aug 22 18:03 sendmail-tls.list
-rw-r--r-- 1 root root 20461 Aug 22 16:53 sendmail-tls.md5sums
-rwxr-xr-x 1 root root  9354 Aug 22 16:53 sendmail-tls.postinst
-rwxr-xr-x 1 root root  3537 Aug 22 16:53 sendmail-tls.postrm
-rwxr-xr-x 1 root root   867 Aug 22 16:53 sendmail-tls.preinst
-rwxr-xr-x 1 root root  2645 Aug 22 16:53 sendmail-tls.prerm
-rw-r--r-- 1 root root     0 Aug 22 18:03 sendmail.list
-rwxr-xr-x 1 root root  3537 Aug 22 17:13 sendmail.postrm

********************************************************************************
# dpkg --purge sendmail
(Reading database ... 11600 files and directories currently installed.)
Removing sendmail ...
Purging configuration files for sendmail ...
Purging replaced package sendmail, nothing to do...

********************************************************************************
# ls -l /etc/init.d/sendmail /etc/pam.d/sendmail
ls: /etc/init.d/sendmail: No such file or directory
ls: /etc/pam.d/sendmail: No such file or directory

-- System Information
Debian Release: testing/unstable
Kernel Version: Linux badlands.lexington.ibm.com 2.4.8-ac7 #12 Sun Aug 19 16:11:45 EDT 2001 i686 unknown

Versions of the packages dpkg depends on:
ii  libc6          2.2.4-1        GNU C Library: Shared libraries and Timezone
ii  libncurses5    5.2.20010318-3 Shared libraries for terminal handling
ii  libstdc++2.10- 2.95.4-0.01081 The GNU stdc++ library



Merged 109691 129697. Request was from Josip Rodin <joy@gkvk.hr> to control@bugs.debian.org. (full text, mbox, link).


Merged 38230 47267 109691 129697. Request was from Josip Rodin <joy@gkvk.hr> to control@bugs.debian.org. (full text, mbox, link).


Merged 38230 47267 68703 109691 129697. Request was from Josip Rodin <joy@gkvk.hr> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and forwarded to list. Copy sent to Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org. (full text, mbox, link).


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

From: Thomas Hood <jdthood@yahoo.co.uk>
To: 109691@bugs.debian.org, control@bugs.debian.org, Richard A Nelson <cowboy@debian.org>
Subject: Still a bug?
Date: 03 Oct 2002 10:41:50 +0200
severity 109691 normal
tags 109691 moreinfo
thanks

> I've been trying to get a sendmail-tls package setup so that one could
> seemlessly change from sendmail to sendmail-tls (and back again).

> The conffiles names and contents are *identicle* in the two packages,
> and they each 'Replaces:' the other.

If the packages Replace: each other then they are *not* designed
to be used simultaneously.  But there may still be a bug here ...

The sendmail package has changed enormously since this report was
filed, so it's hard to reproduce the original bug.  I don't find
sendmail-tls in the archive at all.

Interestingly, the woody version of sendmail has *no* conffiles.

> After installing sendmail, then sendmail-tls, sendmail doesn't
> disapear, and a dpkg --purge on it will incorrectly (according
> to policy) remove the conffiles!

I wonder whether sendmail-tls failed to declare sendmail's conffiles
as conffiles.  That would explain why, after installing sendmail-tls,
there were still sendmail conffiles on the system, and why, when
purging sendmail, these conffiles were removed.  But then, I suppose
the conffiles would still have been listed in
/var/lib/dpkg/info/sendmail.list, right?

It seems the bug is that dpkg can delete conffiles that have been
"taken over" by a replacing package.  Is this still your view?

--
Thomas




Severity set to `normal'. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Tags added: moreinfo Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Disconnected #38230 from all other report(s). Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Disconnected #68703 from all other report(s). Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Disconnected #129697 from all other report(s). Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and forwarded to list. Copy sent to Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org. (full text, mbox, link).


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

From: Thomas Hood <jdthood@yahoo.co.uk>
To: control@bugs.debian.org, 109691@bugs.debian.org
Cc: Richard A Nelson <cowboy@debian.org>, Josip Rodin <joy@gkvk.hr>, Wichert Akkerman <wakkerma@debian.org>
Subject: clone 109691; reassign 109691 sendmail
Date: 03 Oct 2002 12:10:09 +0200
clone 109691 -1
unmerge -1
reassign -1 sendmail
tags -1 - moreinfo
severity -1 normal
retitle -1 postrm should not rm conffiles
thanks

There *is* a bug in sendmail.  The postrm rm's the conffiles
on purge.  It should not.  The management of conffiles should
be left up to dpkg.

What happens:
   Install sendmail      ... installs sendmail's conffiles
   Install sendmail-tls  ... sendmail-tls now owns the conffiles
   Purge sendmail        ... sendmail's postrm rm's the conffiles

I am cloning this so that 109691 can still be used to track the
allegation that dpkg sometimes purges conffiles that have been
taken over by replacing packages.  The thing is that every
case of this phenomenon I have investigated can be attributed
to a misbehaving postrm.  Therefore, I am inclined to think that
109691 can be closed soon unless someone can prove that there 
really is a fault in dpkg.

--
Thomas Hood




Merged 47267 68703 109691. Request was from Anthony Towns <netbase@packages.debian.org> to control@bugs.debian.org. (full text, mbox, link).


Disconnected #68703 from all other report(s). Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Disconnected #109691 from all other report(s). Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Bug 109691 cloned as bug 163193. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Merged 47267 109691. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and forwarded to list. Copy sent to Dpkg Development <debian-dpkg@lists.debian.org>, dpkg@packages.qa.debian.org. (full text, mbox, link).


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

From: Thomas Hood <jdthood@yahoo.co.uk>
To: 109691@bugs.debian.org
Cc: Richard A Nelson <cowboy@debian.org>, Josip Rodin <joy@gkvk.hr>, Wichert Akkerman <wakkerma@debian.org>
Subject: #109691 probably not a bug in dpkg
Date: 03 Oct 2002 17:00:54 +0200
I have tested the hypothesis that dpkg will delete a
conffile that has been taken over by a Conflicts:ing
package.  I used two packages that both declare the
same conffile, the second package Conflicts:ing with
the first package.
    1. Install #1 (which installs the conffile)
    2. Install #2 (which removes #1 and takes over the conffile)
    3. Purge #1
The last step did *not* delete the conffile.

I have found that in each of the cases in which dpkg
was thought to exhibit this bug, it was (or might have
been) the first package's postrm that was at fault. 

Unless someone can prove that dpkg has this bug,
this report should be closed.

--
Thomas





Information forwarded to dpkg@packages.qa.debian.org:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and filed, but not forwarded. Copy sent to dpkg@packages.qa.debian.org. (full text, mbox, link).


Message #51 received at 109691-quiet@bugs.debian.org (full text, mbox, reply):

From: Thomas Hood <jdthood@yahoo.co.uk>
To: 109691-quiet@bugs.debian.org, 47267@bugs.debian.org
Cc: Ben Collins <bcollins@debian.org>, Bill Gribble <grib@cs.utexas.edu>, Adam Heath <adam@doogie.org>
Subject: in tests, conffile never deleted by purge after replacement
Date: 04 Oct 2002 12:51:48 +0200
Adam Heath wrote:
> I don't care what you have seen.

Regardless, I went ahead and conducted more experiments using
a couple of packages I cooked up to test dpkg.

I found that when the two packages had the same conffile,
and the second was declared as either Conflicts:ing with the first
or Replaces:ing the first or both, and regardless of whether the
conffile was modified or unmodified after it was installed by the
first package, the conffile was *never* deleted when the first
package was purged at the end of the following sequence:
   1. dpkg --install foo1
   2. dpkg --remove  foo1
   3. dpkg --install foo2
   4. dpkg --purge foo1

I also tried the case where the second package Replaces: the
first but does not Conflicts: with it, and found that
regardless of whether or not the conffile was modified after
it was installed by the first package, the conffile was *not*
deleted when the first package was purged at the end of the
following sequence:
   1. dpkg --install foo1
   2. dpkg --install foo2
   3. dpkg --purge foo1

Possibly there was once a bug, but it was inadvertently fixed?

--
Thomas




Merged 47267 90623 98210 109691. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to dpkg@packages.qa.debian.org:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and filed, but not forwarded. Copy sent to dpkg@packages.qa.debian.org. (full text, mbox, link).


Message #58 received at 109691-quiet@bugs.debian.org (full text, mbox, reply):

From: Thomas Hood <jdthood@yahoo.co.uk>
To: 109691-quiet@bugs.debian.org, 33046@bugs.debian.org
Cc: Cesar.Barros@web4u.com.br
Subject: #33046 hard to reproduce
Date: 06 Oct 2002 19:37:39 +0200
This report (#33046) concerns a package that is no longer in
the archive, namely xbase.  Important details are missing,
including the version(s) of xbase involved, so it is
hard to reproduce.

The report is that a conffile was deleted when xbase
was purged which did not belong to xbase.  This problem
may be related to #109691 and the reports merged with it.
(I am cc:ing #109691 on this.)

Anyone have any more info?

--
Thomas Hood




Merged 47267 90623 98210 109691 155456. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Tags removed: moreinfo Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Merged 33046 47267 90623 98210 109691 155456. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Merged 10879 33046 47267 90623 98210 109691 155456. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Severity set to `important'. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Tags removed: moreinfo Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Information stored:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Thomas Hood <jdthood@yahoo.co.uk>:
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #75 received at 109691-quiet@bugs.debian.org (full text, mbox, reply):

From: Thomas Hood <jdthood@yahoo.co.uk>
To: 10879-quiet@bugs.debian.org, 47267-quiet@bugs.debian.org, 90623-quiet@bugs.debian.org, 98210-quiet@bugs.debian.org, 109691-quiet@bugs.debian.org, 155456-quiet@bugs.debian.org
Subject: Disappearance of conffiles confirmed
Date: 06 Jul 2003 18:19:17 +0200
I have been able to reproduce the improper deletion of conffiles.
Please see #47267 for details.

Please follow up at #47267.




Changed Bug title. Request was from Adam Heath <doogie@brainfood.com> to control@bugs.debian.org. (full text, mbox, link).


Merged 10879 33046 47267 90623 98210 109691 155456 204275. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Merged 10879 33046 47267 90623 98210 109691 146167 155456 204275. Request was from Thomas Hood <jdthood@yahoo.co.uk> to control@bugs.debian.org. (full text, mbox, link).


Tags added: patch, pending Request was from Scott James Remnant <scott@netsplit.com> to control@bugs.debian.org. (full text, mbox, link).


Information stored:
Bug#109691; Package dpkg. (full text, mbox, link).


Acknowledgement sent to Scott James Remnant <scott@netsplit.com>:
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #88 received at 109691-quiet@bugs.debian.org (full text, mbox, reply):

From: Scott James Remnant <scott@netsplit.com>
To: debian-dpkg@lists.debian.org, debian-bugs-dist@lists.debian.org, 10879-quiet@bugs.debian.org, 33046-quiet@bugs.debian.org, 47267-quiet@bugs.debian.org, 90623-quiet@bugs.debian.org, 98210-quiet@bugs.debian.org, 109691-quiet@bugs.debian.org, 146167-quiet@bugs.debian.org, 155456-quiet@bugs.debian.org, 204275-quiet@bugs.debian.org
Cc: rjk@greenend.org.uk, Cesar Eduardo Barros <cesarb@nitnet.com.br>, Bill Gribble <grib@cs.utexas.edu>, Gabor FLEISCHER <flocsy@mail.mtesz.hu>, Matthew Swift <swift@alum.mit.edu>, Richard A Nelson <cowboy@vnet.ibm.com>, Andrew Ferrier <andrew@new-destiny.co.uk>, Karl Erik <oyoy@oyoy.org>, Vincent Lefevre <vincent@vinc17.org>, Bdale Garbee <bdale@gag.com>, Thomas Hood <jdthood@yahoo.co.uk>, Randolph Chung <tausq@debian.org>, Anthony Towns <aj@azure.humbug.org.au>, Colin Watson <cjwatson@debian.org>, Eneko Lacunza <enlar@endymion.enlar.net>
Subject: dpkg removes conffiles when purging a package that no longer owns them
Date: Fri, 12 Mar 2004 20:26:23 +0000
[Message part 1 (text/plain, inline)]
tags 10879 patch pending
thanks

There's quite a few people on this list, so I'll start out by saying
that if you don't care about this bug anymore, or are just glad I think
I've fixed it, then you don't really need to read this mail.  There's a
patch at the bottom, the rest is going to be pretty technical :-)


First a summary of this bug, picking on bind as it's a handy package
that can be used to reliably produce the symptoms.

 1. Install bind
 2. Install bind9, this will remove bind.
 3. Purge bind

You'll now find that a random selection of bind9's configuration files
have been removed.


The clue to solving this bug occurred when we realised that the
selection wasn't random at all, and in fact was the same on every
machine.

Here's the important bit of debug output concerning the purging of bind:

D000200: removal_bulk set to new conffile `/etc/init.d/bind'
D000020: removal_bulk conffile not ours any more `/etc/bind/named.conf'
D000020: removal_bulk conffile not ours any more `/etc/bind/named.conf.local'
D000020: removal_bulk conffile not ours any more `/etc/bind/named.conf.options'
D000020: removal_bulk conffile not ours any more `/etc/bind/db.0'
D000020: removal_bulk conffile not ours any more `/etc/bind/db.127'
D000020: removal_bulk conffile not ours any more `/etc/bind/db.255'
D000020: removal_bulk conffile not ours any more `/etc/bind/db.local'
D000020: removal_bulk conffile not ours any more `/etc/bind/db.root'

dpkg is correctly realising that the only conffile it needs to remove is
‘/etc/init.d/bind’ and that the rest should be kept because bind9 has
taken them over.

However it's removing some of them, and fortunately the ones it removes
is constant.  It removes ‘named.conf.local’, ‘db.0’, ‘db.255’ and
‘db.root’.

If we number the configuration files that it shouldn't remove, starting
at 1, it's removing #2, #4, #6 and #8.


That's a pretty damned specific pattern!  It also explains why the
single-conffile test package pairs don't exhibit the bug, if they had
two conffiles the second would get wrongly deleted.

A more extreme example (a test package I created):

 #1 should be kept
 #2 needs deleting
 #3 should be kept
 #4 should be kept
 #5 needs deleting

#4 gets incorrectly deleted by dpkg.

To put the problem into words; every second conffile in a consecutive
subset that need to be kept get incorrectly deleted.


Old C hands should already be thinking ‘linked list bug’ at this point.


We now cast our attention on the removal_bulk_remove_configfiles()
function in main/remove.c.  What it does can be summed up as follows:

 1. Iterate the conffiles list, removing nodes if the conffile isn't
    ours anymore or is part of a diversion.

 2. Iterate the conffiles list again (which will have the nodes removed)
    and do the actual work.


Reading the debug output, during the second iteration there are nodes
that were supposed to have been removed that weren't.  We're really
thinking ‘linked list bug’ at this point, almost certainly a classic
‘bad node removal’ problem.

So we focus our attention on the first loop, and walk through it.  I'm
going to assume you've got the code in front of you at this point, feel
free to grab it if you're interested.

Our players in this are:

pkg->installed.conffiles
	A pointer to the first node in a linked list of conffile
	structures.  Each structure has a ‘next’ pointer which either
	points to the next one in the list, or NULL.

lconffp
	At the start of the loop, this points to the linked list pointer
	itself (pkg->installed.conffiles), otherwise it points to the
	‘next’ member of the previous node.

conff
	A pointer to a node.  This is set at the start of each iteration
	to the contents of whatever lconffp points to, so the first node
	for the first iteration, and each subsequent node.


Let's go back to using bind/bind9 as our example pair, because that's
quite an elegant example.

The first conffile needs to be deleted, so nothing interesting happens
until the loop's step statement:

	lconffp= &conff->next;

This alters lconffp to point to the current node's ‘next’ pointer, and
when the list begins, conff will point at the next node.


The second conffile needs to be kept, so the node needs to be removed
from the linked list.  Here's the code that does that:

	*lconffp= conff->next;

This alters either the linked list pointer, or the previous node's
‘next’ pointer (which is pointed to by lconffp) to point to the next
node, not the current one.  In other words, it removes the current node
from the linked list.

Now we get to the step instruction:

	lconffp= &conff->next;

This alters lconffp to point to the current node's ‘next‘ pointer. 
Hopefully your brain just threw an exception there.  That's right,
lconffp is now pointing to *the wrong thing*; if the next node needs to
be removed as well, the ‘next’ pointer of a node that's been removed
from the linked list will be changed.

We start off with:

	[  |--->[  |--->[  |x]
	   ^     ^
	[**]	[--]

([**] is lconffp, [--] is conff)

We alter the pointer to remove the node:

	[  |----------->[  |x]
	   ^    [  |--->
	   |     ^
	[**]    [--]

Then we end up pointing at the wrong next node:

	[  |----------->[  |x]
	        [  |---> ^
	           ^     |
	        [**]    [--]

If we need to remove the next node as well, we'll end up altering the
wrong pointer:

	[  |----------->[  |x]
	        [  |x]
	           ^
	        [**]    [--]

In fact, we didn't need to move lconffp at all.  If we remove a node,
the linked list pointer itself or the previous ‘next’ pointer is still
the previous node pointer.

In other words, we only need to run the step statement if we don't
remove the node.  If we modify the code to do that, and run that
simulation again:

We start off with:

	[  |--->[  |--->[  |x]
	   ^     ^
	[**]	[--]

([**] is lconffp, [--] is conff)

We alter the pointer to remove the node:

	[  |----------->[  |x]
	   ^    [  |--->
	   |     ^
	[**]    [--]

And we begin the new iteration of the loop with no step condition:

	[  |----------->[  |x]
	   ^    [  |---> ^
	   |             |
	[**]            [--]

The removed node has now become irrelevant.  First let's simulate
removing the next node, as that's what's failing.  We alter the pointer
to remove the node:

	[  |x]          [  |x]
	   ^             
	[**]    [--]

That's done the right thing, both nodes have been removed.  Now let's
assume that node needed keeping.  We don't alter the pointer to remove
the node, instead we *do* run the loop's step condition:

	[  |----------->[  |x]
	                   ^
	                [**]    [--]

This correctly removes the second node, but keeps the third in the
list.  If the next node was to be removed, the right pointer would be
modified.


So in summary, what was causing this bug was some incorrect code to
remove nodes from a linked list.  The step condition caused a pointer to
be moved that should've been kept where it was.  By only running this
step condition when we haven't removed a node, the right pointers are
modified and the list can be traversed properly the second time around.

Patch attached and committed.


I'm a little nervous about trying to push this change for sarge without
some extensive testing.

Scott
-- 
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?

[dpkg-conffile-list.patch (text/x-patch, inline)]
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 1897)
+++ ChangeLog	(working copy)
@@ -1,3 +1,13 @@
+Fri Mar 12 19:02:21 GMT 2004 Scott James Remnant <scott@netsplit.com>
+
+  * main/remove.c (removal_bulk_remove_configfiles): Don't change the
+  "previous pointer" pointer if we remove the node from the linked list,
+  ensuring that if the next node is to be removed the right thing will
+  happen.
+
+  This corrects the bug where every second shared or diverted conffile
+  would be incorrectly deleted by dpkg.
+ 
 Fri Mar 12 15:05:52 GMT 2004 Scott James Remnant <scott@netsplit.com>
 
   * utils/start-stop-daemon.c: Don't require an argument for -V (version).
Index: debian/changelog
===================================================================
--- debian/changelog	(revision 1897)
+++ debian/changelog	(working copy)
@@ -1,6 +1,10 @@
 dpkg (1.10.21) unstable; urgency=low
 
   * Don't require argument for start-stop-daemon -V.  Closes: #237589.
+  * Fix incorrect linked list node removal code that caused every second
+    shared or diverted conffile to be deleted by dpkg.
+    Closes: #10879, #33046, #47267, #90623, #98210, #109691, #146167.
+    Closes: #155456, #204275.
 
  -- Scott James Remnant <scott@netsplit.com>  UNRELEASED
 
Index: main/remove.c
===================================================================
--- main/remove.c	(revision 1891)
+++ main/remove.c	(working copy)
@@ -403,9 +403,7 @@
      * are involved in diversions, except if we are the package doing the
      * diverting.
      */
-    for (lconffp= &pkg->installed.conffiles;
-         (conff= *lconffp) != 0;
-         lconffp= &conff->next) {
+    for (lconffp= &pkg->installed.conffiles; (conff= *lconffp) != 0; ) {
       for (searchfile= pkg->clientdata->files;
            searchfile && strcmp(searchfile->namenode->name,conff->name);
            searchfile= searchfile->next);
@@ -422,6 +420,7 @@
       } else {
         debug(dbg_conffdetail,"removal_bulk set to new conffile `%s'",conff->name);
         conff->hash= NEWCONFFILEFLAG; /* yes, cast away const */
+        lconffp= &conff->next;
       }
     }
     modstatdb_note(pkg);
[signature.asc (application/pgp-signature, inline)]

Reply sent to Scott James Remnant <scott@netsplit.com>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Richard A Nelson <cowboy@vnet.ibm.com>:
Bug acknowledged by developer. (full text, mbox, link).


Message #93 received at 10879-close@bugs.debian.org (full text, mbox, reply):

From: Scott James Remnant <scott@netsplit.com>
To: 10879-close@bugs.debian.org
Subject: Bug#10879: fixed in dpkg 1.10.21
Date: Sun, 25 Apr 2004 14:17:03 -0400
Source: dpkg
Source-Version: 1.10.21

We believe that the bug you reported is fixed in the latest version of
dpkg, which is due to be installed in the Debian FTP archive:

dpkg-dev_1.10.21_all.deb
  to pool/main/d/dpkg/dpkg-dev_1.10.21_all.deb
dpkg-doc_1.10.21_all.deb
  to pool/main/d/dpkg/dpkg-doc_1.10.21_all.deb
dpkg_1.10.21.dsc
  to pool/main/d/dpkg/dpkg_1.10.21.dsc
dpkg_1.10.21.tar.gz
  to pool/main/d/dpkg/dpkg_1.10.21.tar.gz
dpkg_1.10.21_i386.deb
  to pool/main/d/dpkg/dpkg_1.10.21_i386.deb
dselect_1.10.21_i386.deb
  to pool/main/d/dpkg/dselect_1.10.21_i386.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 10879@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Scott James Remnant <scott@netsplit.com> (supplier of updated dpkg package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sun, 25 Apr 2004 18:55:10 +0100
Source: dpkg
Binary: dpkg-doc dpkg dselect dpkg-dev dpkg-static
Architecture: source all i386
Version: 1.10.21
Distribution: unstable
Urgency: low
Maintainer: Dpkg Development <debian-dpkg@lists.debian.org>
Changed-By: Scott James Remnant <scott@netsplit.com>
Description: 
 dpkg       - Package maintenance system for Debian
 dpkg-dev   - Package building tools for Debian
 dpkg-doc   - Dpkg Internals Documentation
 dselect    - a user tool to manage Debian packages
Closes: 10879 33046 47267 90623 98210 102094 109669 109691 115352 120970 124225 146167 151799 155456 158916 160761 161156 166052 171489 174973 174978 179192 187952 200701 200763 204275 207758 214699 219210 220776 225086 233614 237589 237624 237864 239000 240081 241503 242870 243191 244098 244316
Changes: 
 dpkg (1.10.21) unstable; urgency=low
 .
   * Fix incorrect linked list node removal code that caused every second
     shared or diverted conffile to be deleted by dpkg.
     Closes: #10879, #33046, #47267, #90623, #98210, #109691, #146167.
     Closes: #155456, #204275.
   * Call mknod with the required device type.  Closes: #158916.
   * Correct the default query output format to be consistent with
     what the underlying library expects.  Closes: #174973.
   * Fix missing NULL-termination in dpkg-query -W display of dependency
     fields.  Closes: #174978
   * Strip output from md5sum(1) after the first whitespace character.
     Closes: #200763.
   * Output a warning if we cannot open a configuration file instead of
     treating it as a fatal error, in case our home directory is not readable
     by root.  Closes: #200701.
   * Set LC_ALL to C before spawning off dpkg --search, to avoid searching
     on localized strings.  Closes: #244316.
   * Don't require argument for start-stop-daemon -V.  Closes: #237589.
   * Correct use of @ARGV within dpkg-scanpackages, allowing -u to work
     once again.  Closes: #225086, #241503.
   * Make sure file permissions passed to dpkg-statoverride are numeric.
     Closes: #161156.
   * Correctly break out of the loop in install-info.
     Closes: #124225, #160761.
   * Add --dir-file option to install-info for GNU install-info
     compatibility.  Closes: #179192
   * Refer to debian-policy in dpkg-doc's description instead of the
     non-existant packaging-manual.  Closes: #120970.
   * Remove incorrect mention of build-essential from dpkg-checkbuilddeps
     manpage.  Closes: #219210.
   * Add a note about diverting shared libraries to the dpkg-divert
     manpage.  Closes: #214699.
   * Updated Translations:
     - Brazilian Portugese (Andre Luis Lopes).  Closes: #237864.
     - Catalan (Jordi Mallach).
     - Danish (Claus Hindsgaul).  Closes: #237624.
     - Dutch (Pieter-Paul Spiertz, Bart Cornelis, Erwin).
       Closes: #102094, #151799, #207758.
     - French (Sam Hocevar).  Closes: #243191.
     - German (Florian Ernst).  Closes: #109669, #115352, #187952, #244098.
     - Japanese manpages (KISE Hiroshi).  Closes: #220776.
     - Polish (Bartosz Fenski).  Closes: #242870.
     - Spanish (Javier Fernández-Sanguino Peña).  Closes: #166052.
     - Swedish (Peter Karlsson).
   * New Translations:
     - Japanese dpkg-source manpage (KISE Hiroshi).  Closes: #239000.
     - Norwegian Nynorsk (Gaute Hvoslef Kvalnes).  Closes: #233614.
     - Portguese (Miguel Figueiredo).  Closes: #240081.
     - Spanish dpkg-source manpage (Ruben Porras).  Closes: #171489.
Files: 
 3c0ee1d26bd55362b92eee8e6255aee0 798 base required dpkg_1.10.21.dsc
 a9f6c43891db74d727beab7dfc0ee663 1682647 base required dpkg_1.10.21.tar.gz
 e492251ba4cf345982782b7880056e1f 1220962 base required dpkg_1.10.21_i386.deb
 132ac9df0f3dd8fd8b7adbf409f8ed3e 105530 base required dselect_1.10.21_i386.deb
 48e0a00caea19997c46ad2d7539b2731 137490 utils standard dpkg-dev_1.10.21_all.deb
 794381a64e07416e48af7d6bb4ae52d0 10620 doc optional dpkg-doc_1.10.21_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAi/2fIexP3IStZ2wRAn8pAJ9/rxk0uozGIQta1eA1i+IQZIQx9QCgpA1B
Hn7++hlhNM0b38XnzfCRzhg=
=GiSq
-----END PGP SIGNATURE-----




Message #94 received at 109691-close@bugs.debian.org (full text, mbox, reply):

From: Scott James Remnant <scott@netsplit.com>
To: 109691-close@bugs.debian.org
Subject: Bug#109691: fixed in dpkg 1.10.21
Date: Sun, 25 Apr 2004 14:17:03 -0400
Source: dpkg
Source-Version: 1.10.21

We believe that the bug you reported is fixed in the latest version of
dpkg, which is due to be installed in the Debian FTP archive:

dpkg-dev_1.10.21_all.deb
  to pool/main/d/dpkg/dpkg-dev_1.10.21_all.deb
dpkg-doc_1.10.21_all.deb
  to pool/main/d/dpkg/dpkg-doc_1.10.21_all.deb
dpkg_1.10.21.dsc
  to pool/main/d/dpkg/dpkg_1.10.21.dsc
dpkg_1.10.21.tar.gz
  to pool/main/d/dpkg/dpkg_1.10.21.tar.gz
dpkg_1.10.21_i386.deb
  to pool/main/d/dpkg/dpkg_1.10.21_i386.deb
dselect_1.10.21_i386.deb
  to pool/main/d/dpkg/dselect_1.10.21_i386.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 109691@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Scott James Remnant <scott@netsplit.com> (supplier of updated dpkg package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sun, 25 Apr 2004 18:55:10 +0100
Source: dpkg
Binary: dpkg-doc dpkg dselect dpkg-dev dpkg-static
Architecture: source all i386
Version: 1.10.21
Distribution: unstable
Urgency: low
Maintainer: Dpkg Development <debian-dpkg@lists.debian.org>
Changed-By: Scott James Remnant <scott@netsplit.com>
Description: 
 dpkg       - Package maintenance system for Debian
 dpkg-dev   - Package building tools for Debian
 dpkg-doc   - Dpkg Internals Documentation
 dselect    - a user tool to manage Debian packages
Closes: 10879 33046 47267 90623 98210 102094 109669 109691 115352 120970 124225 146167 151799 155456 158916 160761 161156 166052 171489 174973 174978 179192 187952 200701 200763 204275 207758 214699 219210 220776 225086 233614 237589 237624 237864 239000 240081 241503 242870 243191 244098 244316
Changes: 
 dpkg (1.10.21) unstable; urgency=low
 .
   * Fix incorrect linked list node removal code that caused every second
     shared or diverted conffile to be deleted by dpkg.
     Closes: #10879, #33046, #47267, #90623, #98210, #109691, #146167.
     Closes: #155456, #204275.
   * Call mknod with the required device type.  Closes: #158916.
   * Correct the default query output format to be consistent with
     what the underlying library expects.  Closes: #174973.
   * Fix missing NULL-termination in dpkg-query -W display of dependency
     fields.  Closes: #174978
   * Strip output from md5sum(1) after the first whitespace character.
     Closes: #200763.
   * Output a warning if we cannot open a configuration file instead of
     treating it as a fatal error, in case our home directory is not readable
     by root.  Closes: #200701.
   * Set LC_ALL to C before spawning off dpkg --search, to avoid searching
     on localized strings.  Closes: #244316.
   * Don't require argument for start-stop-daemon -V.  Closes: #237589.
   * Correct use of @ARGV within dpkg-scanpackages, allowing -u to work
     once again.  Closes: #225086, #241503.
   * Make sure file permissions passed to dpkg-statoverride are numeric.
     Closes: #161156.
   * Correctly break out of the loop in install-info.
     Closes: #124225, #160761.
   * Add --dir-file option to install-info for GNU install-info
     compatibility.  Closes: #179192
   * Refer to debian-policy in dpkg-doc's description instead of the
     non-existant packaging-manual.  Closes: #120970.
   * Remove incorrect mention of build-essential from dpkg-checkbuilddeps
     manpage.  Closes: #219210.
   * Add a note about diverting shared libraries to the dpkg-divert
     manpage.  Closes: #214699.
   * Updated Translations:
     - Brazilian Portugese (Andre Luis Lopes).  Closes: #237864.
     - Catalan (Jordi Mallach).
     - Danish (Claus Hindsgaul).  Closes: #237624.
     - Dutch (Pieter-Paul Spiertz, Bart Cornelis, Erwin).
       Closes: #102094, #151799, #207758.
     - French (Sam Hocevar).  Closes: #243191.
     - German (Florian Ernst).  Closes: #109669, #115352, #187952, #244098.
     - Japanese manpages (KISE Hiroshi).  Closes: #220776.
     - Polish (Bartosz Fenski).  Closes: #242870.
     - Spanish (Javier Fernández-Sanguino Peña).  Closes: #166052.
     - Swedish (Peter Karlsson).
   * New Translations:
     - Japanese dpkg-source manpage (KISE Hiroshi).  Closes: #239000.
     - Norwegian Nynorsk (Gaute Hvoslef Kvalnes).  Closes: #233614.
     - Portguese (Miguel Figueiredo).  Closes: #240081.
     - Spanish dpkg-source manpage (Ruben Porras).  Closes: #171489.
Files: 
 3c0ee1d26bd55362b92eee8e6255aee0 798 base required dpkg_1.10.21.dsc
 a9f6c43891db74d727beab7dfc0ee663 1682647 base required dpkg_1.10.21.tar.gz
 e492251ba4cf345982782b7880056e1f 1220962 base required dpkg_1.10.21_i386.deb
 132ac9df0f3dd8fd8b7adbf409f8ed3e 105530 base required dselect_1.10.21_i386.deb
 48e0a00caea19997c46ad2d7539b2731 137490 utils standard dpkg-dev_1.10.21_all.deb
 794381a64e07416e48af7d6bb4ae52d0 10620 doc optional dpkg-doc_1.10.21_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAi/2fIexP3IStZ2wRAn8pAJ9/rxk0uozGIQta1eA1i+IQZIQx9QCgpA1B
Hn7++hlhNM0b38XnzfCRzhg=
=GiSq
-----END PGP SIGNATURE-----




Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Mon Jul 28 17:53:39 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General 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.