add some simple error checking at startup
This commit is contained in:
parent
aab8672229
commit
54a6c6eff9
5
esgd.py
5
esgd.py
|
@ -193,6 +193,7 @@ location = "/tmp/test"
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
switchgrp = grp.getgrnam("nobody").gr_gid
|
switchgrp = grp.getgrnam("nobody").gr_gid
|
||||||
switchusr = pwd.getpwnam("nobody").pw_uid
|
switchusr = pwd.getpwnam("nobody").pw_uid
|
||||||
|
try:
|
||||||
with socketserver.TCPServer((host, port), GopherHandler) as server:
|
with socketserver.TCPServer((host, port), GopherHandler) as server:
|
||||||
os.setgid(switchgrp)
|
os.setgid(switchgrp)
|
||||||
os.seteuid(switchusr)
|
os.seteuid(switchusr)
|
||||||
|
@ -200,3 +201,7 @@ if __name__ == "__main__":
|
||||||
os.chdir(location)
|
os.chdir(location)
|
||||||
log.log("change directory successful")
|
log.log("change directory successful")
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
except PermissionError:
|
||||||
|
log.error("invalid permissions")
|
||||||
|
except OSError:
|
||||||
|
log.error("address already in use")
|
||||||
|
|
Loading…
Reference in New Issue