Is there a way on Linux (CentOS if that matters) to enable regular users to use ports below 1024? (open listening TCP socket on that port)
Currently I understand that only root has privileges to use those ports.
|
Is there a way on Linux (CentOS if that matters) to enable regular users to use ports below 1024? (open listening TCP socket on that port) Currently I understand that only root has privileges to use those ports. |
||||
|
|
Not on CentOS 3/4/5 (Lack of filesystem capabilities): You can set the CAP_NET_BIND_SERVICE capability to the program that needs to open this port. Root will set the capability on the executable, then any user may run that executable, it will be able to use ports <1024. To set the capability on the executable:
|
|||
|
|
IIRC this is not possible, or if it is it is not recommended for security reasons. But if you want users to be able to listen on a specific port you could always use a TCP forwarder like For instance the line
in rinetd's configuration would forward connections to port 80 on address
Either way gives you much more fine grained control than letting any user listen on any port. The iptables approach has the advantage that the listening application will see the IP address of the calling client (with the rinetd method it would see all connections as coming from the local host). The iptables method would also allow for UDP as well as TCP. |
||||
|
You could create a wrapper which runs SUID and drops privileges after opening the port. |
|||||||
|
|
authbind rocks. capabilities is great stuff, but it requires properly configured certain kernel versions. some programs, like sun java, do not with capabilieis. authbind works on all linux versions. authbind, however, supports only IPv4. |
|||
|
|
|
Are these totally out of context, or am I missing something fundamental ? http://smarden.org/runit/chpst.8.html & http://cr.yp.to/daemontools/setuidgid.html |
|||||
|
|
http://isptools.sourceforge.net/suid-wrap.html This will do all the work for you. |
|||||
|