pypxe / PyPXE

Pure Python PXE (DHCP-(Proxy)/TFTP/HTTP/NBD) Server
MIT License
539 stars 125 forks source link

Using Effective UID and warning for Python 2 and 3 #158

Closed lathama closed 7 years ago

lathama commented 7 years ago

Using Effective UID in the case that user has been granted access to operate as UID 0. Currently there is a warning and then a failure to bind to port for TFTP which I can note in an issue. Without TFTP running it starts fine.

$ PYTHONPATH='/home/user/sandbox/PyPXE' python pypxe/server.py --no-tftp

WARNING: Not root. Servers will probably fail to bind.

2017-06-29 12:20:25,997 [INFO] PyPXE PyPXE successfully initialized and running! ^C Shutting down PyPXE...

$ PYTHONPATH='/home/user/sandbox/PyPXE' python pypxe/server.py

WARNING: Not root. Servers will probably fail to bind.

2017-06-29 12:20:33,387 [INFO] PyPXE Starting TFTP server... Traceback (most recent call last): File "pypxe/server.py", line 325, in main() File "pypxe/server.py", line 238, in main ip = args.TFTP_SERVER_IP) File "/home/user/sandbox/PyPXE/pypxe/tftp.py", line 243, in init self.sock.bind((self.ip, self.port)) File "/usr/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 13] Permission denied $

And with Python 3 for bonus points $ PYTHONPATH='/home/user/sandbox/PyPXE' python3 pypxe/server.py --no-tftp

WARNING: Not root. Servers will probably fail to bind.

2017-06-29 12:49:51,815 [INFO] PyPXE PyPXE successfully initialized and running! ^C Shutting down PyPXE...

psychomario commented 7 years ago

Why was the sys.stderr part removed?

lathama commented 7 years ago

Sorry, my bad, overly busy will come back with this later.