Preflight the rootless podman subuid/subgid ranges in dot boxes
A fedora-toolbox pull dies inside the user namespace ('requested 998:998
for /var/lib/unbound') when the user has no /etc/subuid and /etc/subgid
range, and distrobox only shows podman's unpack error. dot boxes now
checks both files and prints the usermod + podman system migrate fix
before pulling; dot doctor reports the same condition.
tests/boxes-subid.sh covers range summing, small ranges and the hint.
This commit is contained in:
1 parent
12258063ce
commit
d3b9e0d333
3 files changed
+93
No files matched your search
@@ -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.
|
||||
@@ -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"
|
||||
|
||||
Executable
+52
@@ -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"
|
||||
Reference in new issue
Block a user