diff --git a/README.md b/README.md index c2c8003..b3425ce 100644 --- a/README.md +++ b/README.md @@ -408,3 +408,15 @@ WEBTOP=1 tests/container-test.sh lscr.io/linuxserver/webtop:fedora-kde full webt - Plasma only applies panel changes from plasma-manager at the next login. Its panel script deletes `plasma-org.kde.plasma.desktop-appletsrc` first, so `daynight-hooks` re-applies the wallpapers 20 s after login. - Sensor IDs in the panel monitors are regexes. Avoid backslashes in them: KConfig unescapes them, and the JSON list then fails to parse. - Managed browser policies show "Managed by your organization" in Chrome and Edge. That's expected. +- `dot boxes` fails mid-pull with `potentially insufficient UIDs or GIDs available in + user namespace (requested 998:998 for /var/lib/unbound)` when rootless podman has no + `/etc/subuid`/`/etc/subgid` range for you: the fedora-toolbox image contains uid 998 + and the layer unpack cannot map it. `dot boxes` preflights this and `dot doctor` + reports it, but the fix is root: + ```bash + grep -E "^$(id -un):" /etc/subuid /etc/subgid # empty or a tiny range? + sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$(id -un)" + podman system migrate # rebuild the mapping; keeps images + ``` + If the store was created without a mapping, `podman system reset` (deletes images and + containers) then `dot boxes` again. diff --git a/bin/dot b/bin/dot index fcb44aa..5c76a86 100755 --- a/bin/dot +++ b/bin/dot @@ -367,9 +367,37 @@ seed_xpipe() { ok "XPipe set to sync from RustyRaptor/xpipe-sync (enter the GitHub token on first launch)" } +# Rootless podman unpacks each image layer inside a user namespace. Without +# /etc/subuid and /etc/subgid ranges for this user, every pull dies in the middle +# with "potentially insufficient UIDs or GIDs available in user namespace". +subid_count() { + local file="$1" total=0 name start count + [ -r "$file" ] || { echo 0; return 0; } + while IFS=: read -r name start count; do + [ "$name" = "$(id -un)" ] || continue + case "$count" in ''|*[!0-9]*) continue ;; esac + total=$(( total + count )) + done <"$file" + echo "$total" +} + +podman_subid_ok() { + [ "$(subid_count "${SUBUID_FILE:-/etc/subuid}")" -ge 65536 ] && + [ "$(subid_count "${SUBGID_FILE:-/etc/subgid}")" -ge 65536 ] +} + +podman_subid_hint() { + local me; me="$(id -un)" + warn "rootless podman has no subuid/subgid range for $me" + warn " ${SUBUID_FILE:-/etc/subuid} has $(subid_count "${SUBUID_FILE:-/etc/subuid}") ids, ${SUBGID_FILE:-/etc/subgid} has $(subid_count "${SUBGID_FILE:-/etc/subgid}") (65536 needed)" + warn " fix: sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $me && podman system migrate" + warn " last resort (deletes images/containers): podman system reset" +} + cmd_boxes() { if in_container; then ok "skipping distrobox inside a container"; return; fi have distrobox || die "distrobox missing (dot system)" + if have podman && [ "$(id -u)" != 0 ] && ! podman_subid_ok; then podman_subid_hint; fi distrobox assemble create --file "$HOME/.config/distrobox/distrobox.ini" } @@ -891,6 +919,7 @@ cmd_doctor() { chk "claude" "[ -x ~/.local/bin/claude ]" "dot apps" if ! in_container; then chk "podman" "have podman" "dot system" + chk "podman subuid/subgid" "podman_subid_ok" "dot boxes explains the usermod fix" chk "distrobox" "have distrobox" "dot system" fi chk "ssh key" "[ -f ~/.ssh/id_ed25519 ]" "dot secrets pull" diff --git a/tests/boxes-subid.sh b/tests/boxes-subid.sh new file mode 100755 index 0000000..8800e60 --- /dev/null +++ b/tests/boxes-subid.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Rootless podman needs /etc/subuid and /etc/subgid ranges; without them every +# image pull fails inside the user namespace, which is what `dot boxes` preflights. +set -euo pipefail +cd "$(dirname "$0")/.." + +fixture="$(mktemp -d)" +trap 'rm -rf "$fixture"' EXIT +export HOME="$fixture/home" +mkdir -p "$HOME/.config/dotfiles" "$fixture/repo" +DOTFILES_DIR="$fixture/repo" +export DOTFILES_DIR +source <(sed '$d' bin/dot) +STATE_DIR="$HOME/.config/dotfiles" + +me="$(id -un)" + +# Counts only this user's ranges, and sums several lines. +{ + echo "someoneelse:100000:65536" + echo "$me:100000:65536" + echo "$me:1000000:65536" +} >"$fixture/subuid" +[ "$(subid_count "$fixture/subuid")" = 131072 ] || { echo "FAIL: range sum"; exit 1; } +[ "$(subid_count "$fixture/missing")" = 0 ] || { echo "FAIL: missing file"; exit 1; } + +# Empty file means no mapping for us. +: >"$fixture/empty" +SUBUID_FILE="$fixture/empty" SUBGID_FILE="$fixture/empty" +export SUBUID_FILE SUBGID_FILE +if podman_subid_ok; then echo "FAIL: empty subid files reported as ok"; exit 1; fi +SUBUID_FILE="$fixture/subuid" SUBGID_FILE="$fixture/subuid" +if ! podman_subid_ok; then echo "FAIL: sufficient ranges rejected"; exit 1; fi + +# A too-small range is the failure mode from the bug report. +printf '%s\n' "$me:100000:1024" >"$fixture/small" +SUBUID_FILE="$fixture/small" SUBGID_FILE="$fixture/small" +if podman_subid_ok; then echo "FAIL: 1024 ids accepted"; exit 1; fi + +# dot boxes warns before the pull instead of dying mid-unpack, and still runs. +have() { case "$1" in distrobox|podman) return 0;; *) return 1;; esac; } +in_container() { return 1; } +distrobox() { printf 'distrobox %s\n' "$*"; } +out="$(cmd_boxes 2>&1)" +grep -q 'usermod --add-subuids 100000-165535' <<<"$out" || { echo "FAIL: no fix hint"; echo "$out"; exit 1; } +grep -q '^distrobox assemble create' <<<"$out" || { echo "FAIL: assemble skipped"; echo "$out"; exit 1; } + +SUBUID_FILE="$fixture/subuid" SUBGID_FILE="$fixture/subuid" +out="$(cmd_boxes 2>&1)" +if grep -q 'usermod' <<<"$out"; then echo "FAIL: warned with sufficient ranges"; exit 1; fi + +echo "ok dot boxes subid preflight"