-
Notifications
You must be signed in to change notification settings - Fork 18.9k
daemon.WithCommonOptions() fix detection of user-namespaces #42736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
daemon.WithCommonOptions() fix detection of user-namespaces #42736
Conversation
|
ping @justincormack @AkihiroSuda @tianon ptal |
|
Looks like it's missing detection for rootless now |
021f848 to
ba60f2a
Compare
|
Rootless looks ok now, but hitting a flaky test. Opened a ticket for that: #42739 |
|
Another flaky: |
|
CI is green; I was trying to test some things, but ... Interesting; Busybox: docker run --rm -u 1000:1000 busybox ping -c1 example.com
ping: permission denied (are you root?)
PING example.com (93.184.216.34): 56 data bytes
docker run --rm busybox ls -la /bin/ping
-rwxr-xr-x 400 root root 1149184 Jun 7 17:34 /bin/pingAlpine: docker run --rm -u 1000:1000 alpine ping -c1 example.com
PING example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: seq=0 ttl=42 time=93.436 ms
--- example.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 93.436/93.436/93.436 ms
docker run --rm alpine ls -la /bin/ping
lrwxrwxrwx 1 root root 12 Aug 5 12:25 /bin/ping -> /bin/busyboxSo the alpine image uses busybox for |
|
Note that on docker 20.10.8, I get the same for both; docker run --rm -u 1000:1000 busybox ping -c1 example.com
PING example.com (93.184.216.34): 56 data bytes
ping: permission denied (are you root?)
docker run --rm -u 1000:1000 alpine ping -c1 example.com
ping: permission denied (are you root?)
PING example.com (93.184.216.34): 56 data bytesVersions of busybox are the same in both: docker run --rm -u 1000:1000 alpine sh -c 'busybox | head -n1'
BusyBox v1.33.1 () multi-call binary.
docker run --rm -u 1000:1000 busybox sh -c 'busybox | head -n1'
BusyBox v1.33.1 (2021-06-07 17:33:50 UTC) multi-call binary. |
|
Tianon found this; apparently by design; https://git.alpinelinux.org/aports/tree/main/busybox/0006-ping-make-ping-work-without-root-privileges.patch?h=3.14-stable And that patch was rejected by the busybox maintainers; http://lists.busybox.net/pipermail/busybox/2014-January/080224.html |
|
With this patch, and |
|
@AkihiroSuda PTAL |
1 similar comment
|
@AkihiroSuda PTAL |
AkihiroSuda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but would like to see an integration test too if possible
076d48d to
2b826b7
Compare
Commit dae652e added support for non-privileged containers to use ICMP_PROTO (used for `ping`). This option cannot be set for containers that have user-namespaces enabled. However, the detection looks to be incorrect; HostConfig.UsernsMode was added in 6993e89 / ee21838, and the property only has meaning if the daemon is running with user namespaces enabled. In other situations, the property has no meaning. As a result of the above, the sysctl would only be set for containers running with UsernsMode=host on a daemon running with user-namespaces enabled. This patch adds a check if the daemon has user-namespaces enabled (RemappedRoot having a non-empty value), or if the daemon is running inside a user namespace (e.g. rootless mode) to fix the detection. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2b826b7 to
a826ca3
Compare
|
@AkihiroSuda updated; added an integration test, PTAL |
|
@AkihiroSuda PTAL; this ready to merge? |
Commit dae652e (#41030) added support for non-privileged containers to use ICMP_PROTO (used for
ping). This option cannot be set for containers that have user-namespaces enabled.However, the detection looks to be incorrect; HostConfig.UsernsMode was added in 6993e89 (#20111) / ee21838 (#20913), and the property only has meaning if the daemon is running with user namespaces enabled. In other situations, the property has no meaning.
As a result of the above, the sysctl would only be set for containers running with UsernsMode=host on a daemon running with user-namespaces enabled.
This patch adds a check if the daemon has user-namespaces enabled (RemappedRoot having a non-empty value) to fix the detection.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)