Package: libpam-runtime Version: 1.4.0-4.1 Severity: wishlist Tags: patch User: debian-d...@lists.debian.org Usertags: dpkg-root-support
Hi, since dpkg 1.18.5, dpkg sets the variable DPKG_ROOT when invoking maintainer scripts. Usually that variable is empty but when calling dpkg with --root and --force-script-chrootless, dpkg will set DPKG_ROOT to the new root directory. In that mode, maintainer scripts are called without chroot(1) around them, and thus have to be able to possibly operate on the path from DPKG_ROOT instead of working on /. This is useful for bootstrapping, creating chroots for foreign architectures where utilities from inside the chroot cannot be executed, avoiding dependency loops between postinst scripts, installation without requiring superuser privileges and for creating installations that do not even contain dpkg. See https://wiki.debian.org/Teams/Dpkg/Spec/InstallBootstrap for more information. To see the problem, you can run: $ mmdebstrap --mode=chrootless --variant=custom --include=libpam-runtime unstable /dev/null [...] Setting up libpam-runtime (1.4.0-4.1) ... open(/var/lib/pam/seen) failed: Permission denied at /usr/sbin/pam-auth-update line 232, <STDIN> line 11. dpkg: error processing package libpam-runtime (--configure): installed libpam-runtime package post-installation script subprocess returned error exit status 13 Errors were encountered while processing: libpam-runtime E: Sub-process /usr/bin/dpkg returned an error code (1) The following patch fixes the problem: diff --git a/debian/libpam-runtime.postinst b/debian/libpam-runtime.postinst index 518e8d24..053fdae2 100644 --- a/debian/libpam-runtime.postinst +++ b/debian/libpam-runtime.postinst @@ -29,7 +29,7 @@ then done fi -pam-auth-update --package $force +pam-auth-update --root "$DPKG_ROOT" --package $force if [ -n "$force" ]; then rm -f /etc/pam.d/common-auth.pam-old \ diff --git a/debian/local/pam-auth-update b/debian/local/pam-auth-update index 6d17ab72..18fd898c 100644 --- a/debian/local/pam-auth-update +++ b/debian/local/pam-auth-update @@ -82,6 +82,11 @@ while ($#ARGV >= 0) { $force = 1; } elsif ($opt eq '--package') { $package = 1; + } elsif ($opt eq '--root') { + my $rootdir = shift @ARGV; + $savedir = "$rootdir/$savedir"; + $confdir = "$rootdir/$confdir"; + $inputdir = "$rootdir/$inputdir"; } elsif ($opt eq '--remove') { while ($#ARGV >= 0) { last if ($ARGV[0] =~ /^--/); Possibly, more is needed to correctly implement DPKG_ROOT support, but with above patch, it is possible to run above mmdebstrap command successfully. Thanks! cheers, josch