mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-08-02 18:48:49 -04:00
Allow to listen on privileged ports when running without root #197
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @the-maldridge on GitHub (Jun 1, 2022).
Some part of the code base is naively checking the effective UID and is dissallowing bind of system ports when not running as root. This ignores the case where CAP_NET_BIND is available in the current context.
I can't find in a cursory search where the check happens in the code, otherwise I would have sent a patch.
@brzd commented on GitHub (Sep 1, 2022):
Is this the reason that I am not able to change webUI port to other than 8000?
@qdm12 commented on GitHub (Jun 12, 2023):
@the-maldridge sure but what's your use case really? Why would you want to listen on privileged ports?
@brzd no, you can set the listening port between 1024 and 65535
@drewstopherlee commented on GitHub (Jun 12, 2023):
Not sure if it's directly related, but I'm running into a similar issue when starting the container since updating to latest:
(EDIT: my bug is only present in the 'latest' image, but when I manually set version 2.5.0, this bug goes away.)
Due to split DNS, I have to use the
RESOLVER_ADDRESSenvironment variable and it kicks this error every time I restart the container. It's currently running on a Ubuntu Server 22.04 on a Raspberry Pi, so when I try to adduser: rootto the docker-compose, it fails to deploy.If this needs to be a separate issue, please let me know and I'll open one.
@qdm12 commented on GitHub (Jun 12, 2023):
@drewstopherlee unrelated-ish, but that's a bug that got introduced after v2.5.0 (on the latest image, you can check your logs for the version you're running). I just fixed it in
4922b1db0bsince the resolver address should NOT be validated as a listening address anyway.@drewstopherlee commented on GitHub (Jun 12, 2023):
Yep, I noticed it and edited my comment right before you replied. Thanks so much!
@the-maldridge commented on GitHub (Dec 23, 2023):
Been a while since I looked back into this since I worked around the bug via other means, but I'm refactoring some things and ran back into this. At its core that this is a bug due to incorrect assumptions around bind permissions. A service need not be root nor even have any capabilities to bind "privileged" ports, and given that its entirely feasible to adjust the port boundary or remove it entirely, the check is flawed at best.
Since you wanted a use case though I can explain what I'm currently refactoring to, which is that I have containers using a dynamic macvlan architecture for networking where BGP is announcing a service VIP per-host per-container based on wherever the container happens to be at the moment. This is the one container in my entire fleet which does not put a webserver on port 80, and it is the last one I have notes for that I have to access it on a non-standard port. I guess I can kludge around it by running an nginx sidecar and having that map the traffic, but that's pretty clunky.
Edit: For those curious how to adjust the start of privileged ports on your system, the tunable you're looking for is
net.ipv4.ip_unprivileged_port_start, which takes a port number inclusive of the lower bound you desire.@qdm12 commented on GitHub (Jan 19, 2024):
This makes sense, thanks for sharing! I'll get to it right now, sorry for the delay.
@qdm12 commented on GitHub (Jan 19, 2024):
Hi @the-maldridge
c51a41e1a4has fixes for the settings validation library (juicy details at75485e040f) such that:/proc/sys/net/ipv4/ip_unprivileged_port_starton Linux platformsLet me know how it goes 😉 !
@xiaoxiyao commented on GitHub (Aug 27, 2024):
ERROR settings validation: server settings: listening address: getting unprivileged port start: opening file: open /proc/sys/net/ipv4/ip_unprivileged_port_start: permission denied
Run in Termux throw this error,any one know about it?
@qdm12 commented on GitHub (Aug 27, 2024):
Interesting; I guess I can change the validation library to just assume it's 1024 if we get a permission denied. Have you tried
cat /proc/sys/net/ipv4/ip_unprivileged_port_starton your host?@xiaoxiyao commented on GitHub (Aug 27, 2024):
Permission denied too
@qdm12 commented on GitHub (Aug 28, 2024):
Even as root, for example using
sudo?@qdm12 commented on GitHub (Aug 28, 2024):
Also what does this command give
@xiaoxiyao commented on GitHub (Aug 28, 2024):
I can't use sudo without rooting my phone,and
lsalso denied@qdm12 commented on GitHub (Aug 28, 2024):
This makes sense; I've updated the settings library to handle "permission denied" as just assume the start is
1024, can you please confirm it's working:qmcgaw/ddns-updaterand restart the containergo build -o ddns-updater github.com/qdm12/ddns-updater/cmd/ddns-updater, and you can cross compile it by prefixing thego buildcommand for example withGOARCH=arm64orGOARCH=arm GOARM=7, depending on your phone CPU architecture.