[Debconf-devel] Bug#469354: debconf: dpkg-reconfigure should acquire dpkg lock

Joey Hess joeyh at debian.org
Tue Mar 4 20:47:53 UTC 2008


Colin Watson wrote:
> Ian Jackson pointed out that dpkg-reconfigure doesn't acquire the dpkg
> lock while running maintainer scripts, and should; otherwise it could
> race with a simultaneous 'dpkg -i' provided that the other package
> doesn't use debconf, and bad things could conceivably happen. This will
> become of more practical importance once dpkg supports triggers, because
> then dpkg-reconfigure ought to arrange to process any triggers activated
> by the maintainer scripts, and some confusion would arise if dpkg were
> running at the same time.

Hmm, this seems a bit theoretical. The main likelihood of conflict would be
if it were the same package being installed and dpkg-reconfigured at the
same time, but then the package would use debconf and debconf's existing
locks would prevent it in most cases (a few dbdrivers don't need any
locking).

The sort of races or other conflicts that occur when installing and
configuring two separate packages can probably just as likely occur when
installing a package and doing other random sysadmin work concurrently.
(This is a bit theoretical too. :-) For example, dpkg-divert can lose
information in /var/lib/dpkg/diversions if two instances are run
concurrently and race just right; neither it nor update-alternatives do
any locking. I frequently run these as an admin -- I also sometimes run
postinst scripts directly as an admin.

> +sub linux_struct_flock {
> +	my $type = shift;
> +	my $whence = shift;
> +
> +	# On Linux, l_start and l_len might be either 4 bytes or 8 bytes
> +	# depending on how perl was compiled. Since everything from l_start
> +	# onwards will be zero, we just say 8 bytes for both and hope. (In
> +	# other words, strictly speaking the pack format should be 's2l2i'.)
> +	return pack('s2l4i', $type, $whence, 0, 0, 0, 0, 0);
> +}

Trying do flock locking from perl reliably and portably is in my
experience a nightmare^Wlosing proposition, and I have no desire to try
to maintain code that does it. I've gone as far as to completly redesign
programs that needed a flock lock from perl in the past.

Note that this bug would be much easier to fix in cdebconf's
dpkg-reconfigure ..

-- 
see shy jo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/debconf-devel/attachments/20080304/640d74d2/attachment.pgp 


More information about the Debconf-devel mailing list