how do i claim a low-numbered port as non-root the "right way"
- by qbxk
I have a script that I want to run as a daemon listening on a low-numbered port (< 1024)
Script is in python, though answers in perl are also acceptable.
The script is being daemonized using start-stop-daemon in a startup script, which may complicate the answer
What I really (think) don't want is to type ps -few and see this process running with a "root" on it's line.
How do I do it?
( from my less-than-fully-educated-about-system-calls perspective, I can see 3 avenues,
Run the script as root (no --user/--group/--chuid to start-stop-daemon), and have it de-escalate it's user after it claims the port
Setuid root on the script (chmod u+s), and run the script as the running user, (via --user/--group/--chuid to start-stop-daemon, the startup script still has to be called as root), in the script, acquire root privileges, claim the port, and then revert back to normal user
something else i'm unaware of
)