I'm attempting to give a script the cap_net_bind_service Linux capability. However using setcap doesn't seem to be working.
$ cat listen.sh
#!/bin/bash
python -m SimpleHTTPServer 80
$ getcap listen.sh
listen.sh =
$ sudo setcap cap_net_bind_service=+eip ./listen.sh
$ getcap listen.sh
listen.sh = cap_net_bind_service+eip
$ ls -al listen.sh
-rwxrwxr-x. 1 eric eric 43 Jul 11 23:01 listen.sh
$ ./listen.sh
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
...
File "/usr/lib64/python2.7/SocketServer.py", line 434, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib64/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 13] Permission denied
Using sudo still works fine.
$ sudo ./listen.sh
Serving HTTP on 0.0.0.0 port 80 ...
This is on Fedora 23 workstation.
$ cat /proc/version
Linux version 4.4.9-300.fc23.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) ) #1 SMP Wed May 4 23:56:27 UTC 2016
I'm a little lost at this point, have tried turning off firewalld to no effect, and can't figure out how to debug this.