In order to bring Merry closer to existing container runtimes, I added proper support for configuring user namespaces. This, in effect, means setting up UID maps (and GID maps). User namespaces are nested (to a maximum depth of 32) and users in child namespaces inherent their meaning from maps that translate UIDs from a child to their parent.
A freshly created child process in a new user namespace defaults to no map. This, in effect, results in any UID mapping to the overlow UID and you get nobody.
$ unshare --user /bin/sh -c "whoami; id"
nobody
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
This is how you get the "fake root" set up.
$ unshare --user --map-root-user /bin/sh -c "whoami; cat /proc/self/uid_map"
root
0 1000 1
Lines in /proc/self/uid_map are of the form <start user> <start host> <length>. In the example, this says "map the next <length> users in the user namespace, starting at <start user>, to the users on the host starting at <start host>".
With a length of 1, this reduces to a 1-1 mapping saying that the root user in the user namespace maps onto user 1000 (most likely the default user on the host). UID maps (and GID maps) can only be written to once. Moreover, users without CAP_SETUID can only map a single UID into the namespace (themselves).
This is why newuidmap and newgidmap exist, allowing "rootless" containers to be able to do more sophisticated mapping.
Void now supports setting up proper UID mappings, which in turn allows it to reuse more complicated OCI images like ocaml/opam:debian which require becoming the opam user.