update ping privileged/unprivileged logic#1586
Conversation
|
I really don't know about this approach. I think it makes the code really tricky and convoluted. It's hard to understand what happens. I guess it works, but I'm not happy with having 2 binaries. Also the shell script is cluttered with new line breaks. Please use a standalone shell script (entrypoint.sh) instead of printf to file. If this get cleaned up I hope I will merge it. |
Yeah, I agree with all your points. I've been racking my brains trying to figure out a more elegant solution to this that wouldn't require two binaries. Also, I was originally going to do an entrypoint.sh as a file but was really trying to keep everything self-contained in the Dockerfile since that seemed to be how things are at the moment. |
|
While I would like to be able to drop all capabilities and run the container unprivileged with unprivileged pings, I'm also not keen on the complexity added here. If running the
Very much agreed. As an alternative, perhaps the That said, I'm wondering if there's a simpler way still to support privileged and unprivileged use cases. Can we get away with not setting capabilities on FWIW, I think distros might be moving toward the |
I'm going to look into this but what you wrote above sounds great if it works.
If you don't |
|
Still working on this. BTW, we can't run Also, another way is to have a separate unprivileged build with a different tag. The regular nginx Docker image, for example, can run as non-root, but another (and IMHO, better) way is to run nginx-unprivileged at https://hub.docker.com/r/nginxinc/nginx-unprivileged |
f39f57e to
41c05f0
Compare
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
41c05f0 to
beb52a6
Compare
|
@ZeroKnight Okay, based on your VERY useful suggestions/comments, here's what I did and it seems to work: Changes:
I would GREATLY appreciate comments, input, TESTING (especially this). Thanks! |
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
|
Latest commit, didn't change code significantly. Refactored the code to only separate only the |
|
Thanks for all your work you've put into this! I've just cleaned up some minor things. I've run some tests:
Will merge and release a beta once i looked at the other pr's. |
|
Thanks for merge and all the fixes and the testing! |
Resolves #1574
The following changes were made:1.Dockerfilecreates two copies of theUpSnapexecutable: a so-called privileged one withNET_RAWcapability (which is already the current case) and an un-privileged one.2.Dockerfilewill generate anentrypoint.shwhich will detect theUPSNAP_PING_PRIVILEGEDuser defined setting,NET_RAWcapability, UID/GID, no-new-privs flag, andnet.ipv4.ping_group_range.3. IfUPSNAP_PING_PRIVILEGEDis not set tofalse or (0), it will default toTRUEand will attempt to run the privileged executable if all conditions are met. Otherwise, it will halt and display an error. I can reconfigure this behavior if you wish and have it "fall back" to attempt the unprivileged executable in (4) below4. If it is set toFALSE, it will run the unprivileged executable if the GID is within the configurednet.ipv4.ping_group_range. If not, fail with error.5. Removedroot.goandroot_windows.goand default to true for privileged ping since theisRoot()function isn't needed. Windows requiressetPrivileged(true)regardless of user/admin, and not beingrooton Linux is not an automatic disqualification for 'privileged' ping.6. Updatedocker-compose.ymlwith additional notes and also explicitlycap_addNET_RAWandcap_dropeverything else.See this post below for the latest
To Do:
Submitted for yours and anyone else's reviews. Open to comments, suggestions ,etc. Especially regarding item 3.