-
Notifications
You must be signed in to change notification settings - Fork 251
Description
Reproduction:
- Make
/etc/subuid
a symlink - In your favourite shell run:
newuidmap
with any valid args, e.g.newuidmap $$ ...
The process will exit with 1 and no message printed.
strace
shows the cause of the issue:
$ strace --failed-only -e trace=openat -- newuidmap $$
openat(AT_FDCWD, "/etc/subuid", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC) = -1 ELOOP (Too many levels of symbolic links)
+++ exited with 1 +++
This is a bit painful to debug, I think it would be helpful if the program could print the message from the error, e.g.
newuidmap: cannot open /etc/subuid: Too many levels of symbolic links
Here's a naive patch that achieves this (a better solution would be using the standard logging process for this repo, but I didn't look too deep to see what those are)
diff --git i/src/newuidmap.c w/src/newuidmap.c
index 8deb06f0..e62649d0 100644
--- i/src/newuidmap.c
+++ w/src/newuidmap.c
@@ -139,6 +139,9 @@ int main(int argc, char **argv)
}
if (!sub_uid_open(O_RDONLY)) {
+ fprintf (stderr,
+ _("%s: cannot open %s: %s\n"),
+ Prog, sub_uid_dbname (), strerror (errno));
return EXIT_FAILURE;
}
My real-world use case: was running rootless docker (specifically the one packaged here: https://aur.archlinux.org/packages/docker-rootless-extras) with /etc/subuid
as a symlink, and was left debugging from a log:
<-- SNIP -->
Mar 18 20:17:04 desktop dockerd-rootless.sh[14113]: + exec rootlesskit --state-dir=/run/user/1000/dockerd-rootless --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propag>
Mar 18 20:17:04 desktop dockerd-rootless.sh[14113]: [rootlesskit:parent] error: failed to setup UID/GID map: newuidmap 14124 [0 1000 1 1 165536 65536] failed: : exit status 1
<-- SNIP -->
Debugging with the message, i.e. newuidmap 14124 [0 1000 1 1 165536 65536] failed: newuidmap: cannot open /etc/subuid: Too many levels of symbolic links: exit status 1
would've saved me some time