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.
53 lines
2.1 KiB
Bash
Executable File
53 lines
2.1 KiB
Bash
Executable File
#!/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"
|