From 8c0bccc91f8c44de2c6b01ef056142d567df6ad5 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 8 Aug 2022 20:22:03 +0200 Subject: mbuto: UID 0 doesn't mean we're root, check uid_map too Make mbuto run as expected in a detached user namespace: we'll still need to use fakeroot(1), change $PATH, and we can't use fusermount(1) to keep the CPIO archive mounted. Signed-off-by: Stefano Brivio --- mbuto | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mbuto b/mbuto index 7530c72..0609e7e 100755 --- a/mbuto +++ b/mbuto @@ -1210,7 +1210,14 @@ usage() { # If we're not running as root, re-run with fakeroot -if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ "$(id -u)" -ne 0 ]; then +if [ "$(id -u)" -eq 0 ] && \ + [ "$(cat /proc/self/uid_map)" = " 0 0 4294967295" ]; then + __as_root=1 +else + __as_root=0 +fi + +if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ ${__as_root} -eq 0 ]; then if ! FAKEROOT="$(command -v fakeroot)"; then __fakeroot_missing="y" else -- cgit v1.2.3