From ed200b218d860c32cae15525d9958fceb44e36da Mon Sep 17 00:00:00 2001 From: neptune Date: Fri, 25 Nov 2022 18:25:39 -0300 Subject: Agregado servidor bjoern para weabot --- cgi/weabot.bjoern | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 cgi/weabot.bjoern diff --git a/cgi/weabot.bjoern b/cgi/weabot.bjoern new file mode 100755 index 0000000..8281ba1 --- /dev/null +++ b/cgi/weabot.bjoern @@ -0,0 +1,47 @@ +#!/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) -- cgit v1.2.1-18-gbd029