add a perimitive nobody switch user call
This commit is contained in:
parent
4585792396
commit
7d8b259a2f
8
esgd.py
8
esgd.py
|
@ -2,6 +2,8 @@ import socketserver
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import pwd
|
||||||
|
import grp
|
||||||
|
|
||||||
class GopherError(BaseException): pass
|
class GopherError(BaseException): pass
|
||||||
class RequestError(GopherError): pass
|
class RequestError(GopherError): pass
|
||||||
|
@ -185,8 +187,12 @@ class GopherHandler(socketserver.BaseRequestHandler, GopherServerLogic):
|
||||||
|
|
||||||
log = Logger()
|
log = Logger()
|
||||||
host = "localhost"
|
host = "localhost"
|
||||||
port = 77
|
port = 70
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
switchgrp = grp.getgrnam("nobody").gr_gid
|
||||||
|
switchusr = pwd.getpwnam("nobody").pw_uid
|
||||||
with socketserver.TCPServer((host, port), GopherHandler) as server:
|
with socketserver.TCPServer((host, port), GopherHandler) as server:
|
||||||
|
os.setgid(switchgrp)
|
||||||
|
os.seteuid(switchusr)
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
Loading…
Reference in New Issue