blob: 8281ba149aa3c84a57db936f60b561e74de58901 (
plain) (
tree)
|
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, os, pwd, grp, socket
#sys.path.insert(0, "/home/bai/public_html/cgi")
import bjoern
import weabot
USER="bai"
GROUP="bai"
U_PATH="/var/run/weabot-bjoern.sock"
U_USER="www-data"
U_GROUP="www-data"
U_UMASK='137'
uid=pwd.getpwnam(USER)[2]
gid=grp.getgrnam(GROUP)[2]
u_uid=pwd.getpwnam(U_USER)[2]
u_gid=grp.getgrnam(U_GROUP)[2]
if __name__ == '__main__':
print("Running weabot bjoern server...")
try:
sock = socket.socket(socket.AF_UNIX)
try:
os.unlink(U_PATH)
except OSError:
pass
oldumask = os.umask(int(U_UMASK, 8))
sock.bind(U_PATH)
sock.listen(1024)
os.umask(oldumask)
os.chown(U_PATH, u_uid, u_gid)
os.setgid(gid)
os.setuid(uid)
bjoern.server_run(sock, weabot.weabot)
finally:
sock.close()
os.unlink(U_PATH)
#bjoern.run(weabot.weabot, "unix:" + U_HOST)
|