aboutgitcode
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-08-08 20:22:03 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-08-08 20:22:03 +0200
commit8c0bccc91f8c44de2c6b01ef056142d567df6ad5 (patch)
tree3bddc51a3db827e528f878bf794a6e45b6ca5099
parent7bca683c7db6b314d7ef81542dd6ff844262e38f (diff)
downloadmbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar.gz
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar.bz2
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar.lz
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar.xz
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.tar.zst
mbuto-8c0bccc91f8c44de2c6b01ef056142d567df6ad5.zip
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 <sbrivio@redhat.com>
-rwxr-xr-xmbuto9
1 files changed, 8 insertions, 1 deletions
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