From 5de504deb36c9e6d4cb65f0e524de19dad7fa50a Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 15 Jul 2026 06:02:12 +0200 Subject: [PATCH] feat: Improve rootless container detection (#1256) --- src/reset.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/reset.sh b/src/reset.sh index c76e79d..e29f7cc 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -25,8 +25,8 @@ detectEngine() { if [ -f "/run/.containerenv" ]; then ENGINE="${container:-}" + if [[ "${ENGINE,,}" == *"podman"* ]]; then - ROOTLESS="Y" ENGINE="Podman" else [ -z "$ENGINE" ] && ENGINE="Kubernetes" @@ -36,6 +36,21 @@ detectEngine() { return 0 } +detectRootless() { + + local uid_map="" + + uid_map=$(awk '{$1=$1; print}' /proc/self/uid_map 2>/dev/null || true) + + if [[ "$uid_map" == "0 0 4294967295" ]]; then + ROOTLESS="N" + else + ROOTLESS="Y" + fi + + return 0 +} + checkPrivileged() { local cap_bnd @@ -53,7 +68,6 @@ checkPrivileged() { max_cap=$(((1 << (last_cap + 1)) - 1)) if [ "$cap_bnd" -eq "$max_cap" ]; then - ROOTLESS="N" PRIVILEGED="Y" fi @@ -232,6 +246,7 @@ PROCESS="${APP,,}" PROCESS="${PROCESS// /-}" detectEngine +detectRootless echo "❯ Starting $APP for $ENGINE v$(