[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#264451: di-utils: apt-install should not start daemons

Package:  di-utils
Version:  1.00
Severity: important
Tags:     d-i

Packages installing daemons should not be allowed to start the daemon
inside /target/.  Packages installed with debootstrap will not do
this, because debootstrap replaces start-stop-daemon, but apt-install
do not do anything to avoid this.

See debian-boot thread "cardmgr start message during base install
(extra packages)" for a discussion around this issue.

Here is an untested patch with a proposed solution:

From: Per Olofsson
Subject: Re: cardmgr start message during base install (extra packages)
To: debian-boot
Date: Thu, 29 Jul 2004 18:09:17 +0200

Petter Reinholdtsen wrote:
> Here is a patch to divert start-stop-daemon.  Mostly unsteded, but
> half of it is cut-n-paste from my upgrade-testing script.

And here's an (untested) patch which also adds policy-rc.d
support. Furthermore it corrects a problem in your patch: it runs
cleanup code if apt-get fails.

Index: apt-install
--- apt-install	(revision 18584)
+++ apt-install	(working copy)
@@ -36,6 +36,42 @@
+# Create a policy-rc.d to stop maintainer scripts using invoke-rc.d from
+# running init scripts
+make_policy-rc.d() {
+	cat > /target/usr/sbin/policy-rc.d <<EOF
+exit 101
+	chmod a+rx /target/usr/sbin/policy-rc.d
+remove_policy-rc.d() {
+	rm -f /target/usr/sbin/policy-rc.d
+# This way to make start-stop-daemon do not work on upgrades, when
+# start-stop-daemon is replaced with a new version.  I tried to use
+# dpkg-divert to solve this, but am not sure I got it right. [pere
+# 2004-07-29]
+make_dummy_start_stop_daemon() {
+	cat > /target/sbin/start-stop-daemon.dummy <<EOF
+echo 1>&2
+echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2
+exit 0
+	chmod a+rx /target/sbin/start-stop-daemon.dummy
+	chroot /target dpkg-divert --add --local --rename /sbin/start-stop-daemon
+	ln -s start-stop-daemon.dummy /target/sbin/start-stop-daemon
+remove_dummy_start_stop_daemon() {
+	rm /target/sbin/start-stop-daemon
+	chroot /target dpkg-divert --remove --local --rename /sbin/start-stop-daemon
 # Unset to avoid problems with packages using debconf.  This should
 # avoid the following error when installing dash:
 # "/var/lib/dpkg/info/ash/config: 1: Bad file descriptor"
@@ -59,8 +95,12 @@
     mount -t proc proc /target/proc
-DEBIAN_FRONTEND=noninteractive \
-chroot /target apt-get -y install $@ < /dev/null >> $log 2>&1
+if ! DEBIAN_FRONTEND=noninteractive \
+	chroot /target apt-get -y install $@ < /dev/null >> $log 2>&1; then
+	remove_dummy_start_stop_daemon
+	remove_policy-rc.d
+	exit 1
 # Undo the mounts done by the packages during installation.
 # Reverse sorting to umount the deepest mount points first.
@@ -77,4 +117,7 @@
 rm -f /tmp/mount.pre
 exit 0


Reply to: