
I have an embedded Linux System built using Yocto. Just out of build, it only had a root user. I created a new user. This new user is not able to open any ports on the system even though they are greater than 1024.
For a quick test when I run python -m SimpleHTTPServer
as root
, it just works.
~ # python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
However, when I run it using the non-root user, it fails due to access issues.
~ $ python -m SimpleHTTPServer
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/lib/python2.7/SimpleHTTPServer.py", line 235, in <module>
test()
File "/usr/lib/python2.7/SimpleHTTPServer.py", line 231, in test
BaseHTTPServer.test(HandlerClass, ServerClass)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 606, in test
httpd = ServerClass(server_address, HandlerClass)
File "/usr/lib/python2.7/SocketServer.py", line 414, in __init__
self.socket_type)
File "/usr/lib/python2.7/socket.py", line 191, in __init__
_sock = _realsocket(family, type, proto)
socket.error: [Errno 13] Permission denied
I tried different ports for this and non-root user can't open any of them.
My understanding is only root user can access ports < 1024 but other ports are usable by non-root users as far as they are free. However, I am not able to use any ports at all. Any pointers will be really helpful.
Antwort1
There is a group inet(3003)
, which was assigned to user but not to any new users. Once I add the non-root user to this group, they are able to open the ports and python -m SimpleHTTPServer
runs just fine.
I was able to get to this specifics, by running /sbin/ifconfig
as non-root user. Running it specifically mentioned inet
socket not being available and fiddling around for a bit led me to above solution.