OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
apps-services high common DISPUTE

Fix rootless Podman failing with missing subuid/subgid ranges

archomarchyendeavouroscachyosmanjaropodmanflatpaklinux-hardenedcontainers
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

The main fix is right: usermod --add-subuids/--add-subgids, checking /etc/subuid//etc/subgid for overlap, 65536 as the practical range size, and podman system migrate to make Podman pick up the new mapping. bubblewrap-suid does exist in extra, so that note is fine. The secondary step is misleading on Arch: kernel.unprivileged_userns_clone is a hardened-kernel patch knob. It exists on linux-hardened but NOT on the stock linux kernel, where sysctl kernel.unprivileged_userns_clone errors out and the /etc/sysctl.d/99-userns.conf file the record tells you to write is inert. A reader on the stock kernel will chase a non-problem and end up with a dead sysctl drop-in.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.
RISK

Enabling kernel.unprivileged_userns_clone=1 has real security implications, and it is set to 0 on linux-hardened on purpose. Also, overlapping subuid ranges between users breaks isolation, so always check /etc/subuid before picking a block.

Symptom

podman run as a normal user fails with something like:


ERRO[0000] cannot find UID/GID for user myuser: no subuid ranges found for user "myuser" in /etc/subuid

or newuidmap: write to uid_map failed. Running as root works.

Cause

Rootless containers need a range of subordinate UIDs/GIDs allocated to your user. Accounts created before shadow 4.11.1-3 (i.e. most long-lived Arch installs) have no entries in /etc/subuid//etc/subgid, and systemd-homed users never get them.

Fix

Allocate the range and migrate exactly as written:


cat /etc/subuid /etc/subgid            # check the block is free first
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $USER
podman system migrate

(or write myuser:524288:65536 into both files by hand if 100000 is taken).

On the user-namespace check, be kernel-specific: kernel.unprivileged_userns_clone only exists on linux-hardened (and other patched kernels). On the stock linux/linux-lts/linux-zen kernels the sysctl does not exist and unprivileged user namespaces are already enabled. sysctl kernel.unprivileged_userns_clone returning 'cannot stat' there is normal, not a fault, and you should not create /etc/sysctl.d/99-userns.conf. Only on linux-hardened does the knob apply, and there the safer fix for Flatpak specifically is sudo pacman -S bubblewrap-suid rather than relaxing the sysctl globally. Verify with podman unshare cat /proc/self/uid_map and podman run --rm docker.io/library/alpine echo ok.

Verify

podman unshare cat /proc/self/uid_map shows your mapped range, and podman run --rm docker.io/library/alpine echo ok prints ok as a normal user.

Sources

podman-rootless-missing-subuid