Uses policy-rc.d to prevent dpkg starting daemons

Currently the dpkg element fakes start-stop-daemon, initctl and
invoke-rc.d to stop dpkg from starting a bunch of daemons in the
chroot. This is problematic when packages use service, start, stop or
restart commands.

This patch uses a policy-rc.d instead of faking invoke-rc.d to achieve
the same thing. This approach now aligns exactly with debootstrap.
Without this patch DIB runs on some debian distributions fail
when trying to umount the chroot loop device as there are daemons
running.

The log will now show "invoke-rc.d: policy-rc.d denied execution of
start." instead of "Warning: Fake invoke-rc.s called, doing nothing."

Change-Id: I6db192127aca19b5b7915179b781f5192078bfc7
Related-Bug: #1211564
This commit is contained in:
Thom Leggett 2014-03-26 13:24:51 +00:00 committed by Gerrit Code Review
parent e6e5076698
commit 46a14ae0e6
2 changed files with 8 additions and 6 deletions

View File

@ -5,8 +5,10 @@ set -e
[ -n "$TARGET_ROOT" ]
sudo mv $TARGET_ROOT/sbin/start-stop-daemon.REAL $TARGET_ROOT/sbin/start-stop-daemon
if [ -f $TARGET_ROOT/sbin/initctl.REAL ]
then
sudo mv $TARGET_ROOT/sbin/initctl.REAL $TARGET_ROOT/sbin/initctl
fi
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL $TARGET_ROOT/usr/sbin/invoke-rc.d
sudo rm $TARGET_ROOT/usr/sbin/policy-rc.d

View File

@ -24,10 +24,10 @@ EOF
sudo chmod 755 $TARGET_ROOT/sbin/initctl
fi
sudo mv $TARGET_ROOT/usr/sbin/invoke-rc.d $TARGET_ROOT/usr/sbin/invoke-rc.d.REAL
sudo dd of=$TARGET_ROOT/usr/sbin/invoke-rc.d <<EOF
sudo dd of=$TARGET_ROOT/usr/sbin/policy-rc.d <<EOF
#!/bin/sh
echo "invoke-rc.d (tripleo 1.0)"
echo "Warning: Fake invoke-rc.d called, doing nothing"
# 101 Action not allowed. The requested action will not be performed because
# of runlevel or local policy constraints.
exit 101
EOF
sudo chmod 755 $TARGET_ROOT/usr/sbin/invoke-rc.d
sudo chmod 755 $TARGET_ROOT/usr/sbin/policy-rc.d