#1052471 mmdebstrap: with libpam-tmpdir, fails to use temp dir created by --format=tar/squashfs/ext2/null code: Permission denied #1052471
- Package:
- mmdebstrap
- Source:
- mmdebstrap
- Submitter:
- Paul Wise
- Date:
- 2024-11-24 05:09:02 UTC
- Severity:
- normal
The code for --format=tar/squashfs/ext2/null creates a temporary directory in the $TMP dir. When libpam-tmpdir is being used, $TMP is set to a directory that the current user can access but no other user can access. Consequently because mmdebstrap uses a separate user namespace(?) it cannot access the temporary dir it just created. In addition, it fails to clean up that temporary dir after the error. This does not happen when TMP is set to /tmp with libpam-tmpdir off. Probably the solution would be to reset TMP to /tmp when the current value isn't usable after the namespace change, or to create the temporary dir in the same directory as the output if there is one. The same should happen to the TMPDIR/TEMP/TEMPDIR variables, since usage of TMP is not universal across all packages. $ env | grep -E 'TE?MP' TEMPDIR=/tmp/user/1000 TMPDIR=/tmp/user/1000 TEMP=/tmp/user/1000 TMP=/tmp/user/1000 $ ls -ld /tmp /tmp/user /tmp/user/1000 drwxrwxrwt 25 root root 16K Sep 22 23:39 /tmp/ drwx--x--x 7 root root 4.0K Sep 16 13:22 /tmp/user/ drwx------ 16 pabs root 4.0K Sep 22 23:51 /tmp/user/1000/ $ mmdebstrap unstable /dev/null I: automatically chosen mode: unshare I: chroot architecture amd64 is equal to the host's architecture I: finding correct signed-by value... done I: automatically chosen format: null I: using /tmp/user/1000/mmdebstrap.mAT11ELelW as tempdir E: cannot create /tmp/user/1000/mmdebstrap.mAT11ELelW: Permission denied; cannot create /tmp/user/1000/mmdebstrap.mAT11ELelW//etc: Permission denied; cannot create /tmp/user/1000/mmdebstrap.mAT11ELelW//etc/apt: Permission denied; cannot create /tmp/user/1000/mmdebstrap.mAT11ELelW//etc/apt/apt.conf.d: Permission denied I: main() received signal PIPE: waiting for setup... I: removing tempdir /tmp/user/1000/mmdebstrap.mAT11ELelW... env: cannot change directory to '/tmp/user/1000/mmdebstrap.mAT11ELelW': Permission denied E: rm failed: 32000 E: remove_tree failed $ echo $? 29 $ find /tmp/user/1000/mmdebstrap.mAT11ELelW /tmp/user/1000/mmdebstrap.mAT11ELelW $ ls -ld /tmp/user/1000/mmdebstrap.mAT11ELelW drwxr-xr-x 2 296608 296608 4.0K Sep 22 23:54 /tmp/user/1000/mmdebstrap.mAT11ELelW $ rmdir /tmp/user/1000/mmdebstrap.mAT11ELelW
I ran into the same problem as pabs: $ mmdebstrap --include=ccache --customize-hook='chroot "$1" update-ccache-symlinks' --include=eatmydata --variant=buildd unstable ~/.cache/sbuild/unstable-amd64.tar.zst https://deb.debian.org/debian I: automatically chosen mode: unshare I: chroot architecture amd64 is equal to the host's architecture I: finding correct signed-by value... done I: automatically chosen format: tar I: using /tmp/user/1000/mmdebstrap.wx2t2Z4_xd as tempdir E: cannot create /tmp/user/1000/mmdebstrap.wx2t2Z4_xd: Permission denied; cannot create /tmp/user/1000/mmdebstrap.wx2t2Z4_xd//etc: Permission denied; cannot create /tmp/user/1000/mmdebstrap.wx2t2Z4_xd//etc/apt: Permission denied; cannot create /tmp/user/1000/mmdebstrap.wx2t2Z4_xd//etc/apt/apt.conf.d: Permission denied W: hooklistener errored out: E: received eof on socket I: main() received signal PIPE: waiting for setup... I: removing tempdir /tmp/user/1000/mmdebstrap.wx2t2Z4_xd... env: cannot change directory to '/tmp/user/1000/mmdebstrap.wx2t2Z4_xd': Permission denied E: rm failed: 32000 E: remove_tree failed and here's the work-around that worked for me: $ TMPDIR=/dev/shm/mmdebstrap mmdebstrap --include=ccache --customize-hook='chroot "$1" update-ccache-symlinks' --include=eatmydata --variant=buildd unstable ~/.cache/sbuild/unstable-amd64.tar.zst https://deb.debian.org/debian I: automatically chosen mode: unshare I: chroot architecture amd64 is equal to the host's architecture I: finding correct signed-by value... done I: automatically chosen format: tar I: using /dev/shm/mmdebstrap/mmdebstrap.WGXoajHVS6 as tempdir I: running apt-get update... done I: downloading packages with apt... done I: extracting archives... done I: installing essential packages... done I: installing remaining packages inside the chroot... done done I: running --customize-hook in shell: sh -c 'chroot "$1" update-ccache-symlinks' exec /dev/shm/mmdebstrap/mmdebstrap.WGXoajHVS6 I: cleaning package lists and apt cache... done done I: creating tarball... I: done I: removing tempdir /dev/shm/mmdebstrap/mmdebstrap.WGXoajHVS6... I: success in 14.4525 seconds Francois