Source: base-passwd
Severity: wishlist
Tags: patch
User: debian-d...@lists.debian.org
Usertags: dpkg-root-support

Hi,

We're working on a way to install packages into a chroot without
actually using the chroot system call. A consequence of doing so is that
maintainer scripts are run outside the chroot and are supposed to still
operate on the chroot whose location is communicated via the DPKG_ROOT
environment variable.

base-passwd contains two maintainer scripts that manage /etc/passwd and
/etc/group. These need to be adapted to work with the mode depicted
above.

Please refer to https://wiki.debian.org/Teams/Dpkg/Spec/InstallBootstrap
for more information.

Please consider applying the attached patch (post bullseye). We tested
the patch using the scripts at
https://salsa.debian.org/helmutg/dpkg-root-demo and can show that a
chroot created that way is bit-by-bit identical to one that was created
normally.

Thanks!

cheers, josch
diff -Nru base-passwd-3.5.49/debian/postinst 
base-passwd-3.5.49+nmu1/debian/postinst
--- base-passwd-3.5.49/debian/postinst  2021-02-06 18:48:56.000000000 +0100
+++ base-passwd-3.5.49+nmu1/debian/postinst     2021-06-17 15:11:24.000000000 
+0200
@@ -55,12 +55,12 @@
     exit 0
 fi

-if [ ! -e /etc/passwd ] ; then
-       cp /usr/share/base-passwd/passwd.master /etc/passwd
+if [ ! -e "$DPKG_ROOT/etc/passwd" ] ; then
+       cp "$DPKG_ROOT/usr/share/base-passwd/passwd.master" 
"$DPKG_ROOT/etc/passwd"
 fi

-if [ ! -e /etc/group ] ; then
-       cp /usr/share/base-passwd/group.master /etc/group
+if [ ! -e "$DPKG_ROOT/etc/group" ] ; then
+       cp "$DPKG_ROOT/usr/share/base-passwd/group.master" 
"$DPKG_ROOT/etc/group"
 fi

 if [ "$2" = "3.2.2" ] && [ -f /etc/passwd.org ] ; then
@@ -82,7 +82,7 @@
 fi

 tmp=`mktemp`
-if ! update-passwd --dry-run > $tmp ; then
+if [ -n "$2" ] && ! update-passwd --dry-run > $tmp ; then
        if [ -f /usr/share/debconf/confmodule ] ; then
                db_version 2.0
                update-passwd --verbose
diff -Nru base-passwd-3.5.49/debian/preinst 
base-passwd-3.5.49+nmu1/debian/preinst
--- base-passwd-3.5.49/debian/preinst   2021-02-06 18:48:56.000000000 +0100
+++ base-passwd-3.5.49+nmu1/debian/preinst      2021-06-17 15:11:24.000000000 
+0200
@@ -1,15 +1,15 @@
 #! /bin/sh
 set -e

 if [ "$1" = install ]; then
-       if [ ! -e /etc/passwd ]; then
-               cat > /etc/passwd <<'EOF'
+       if [ ! -e "$DPKG_ROOT/etc/passwd" ]; then
+               cat > "$DPKG_ROOT/etc/passwd" <<'EOF'
 @PASSWD@
 EOF
        fi

-       if [ ! -e /etc/group ]; then
-               cat > /etc/group <<'EOF'
+       if [ ! -e "$DPKG_ROOT/etc/group" ]; then
+               cat > "$DPKG_ROOT/etc/group" <<'EOF'
 @GROUP@
 EOF
        fi

Reply via email to