daemon.WithCommonOptions() fix detection of user-namespaces#42736
daemon.WithCommonOptions() fix detection of user-namespaces#42736AkihiroSuda merged 1 commit intomoby:masterfrom
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; |
|
With this patch, and |
|
@AkihiroSuda PTAL |
1 similar comment
|
@AkihiroSuda PTAL |
AkihiroSuda
left a comment
There was a problem hiding this comment.
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 <[email protected]>
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)