Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
os.setuid(userinfo[2])
except:
Log.error("Failed to find user 'bbs'!")
sys.exit(1)
Config.Config.LoadConfig();
UCache.UCache.Init()
Utmp.Utmp.Init()
commondata.CommonData.Init()
hostname = Config.Config.GetString("BBS_XMPP_HOST", 'localhost')
server = xmpp.Server({
'plugins': [(xmppserver.XMPPServer, { 'rosters': rosters.Rosters() , 'host': hostname})],
'auth': xmppauth.XMPPAuth('xmpp', hostname, 'bbs'),
'mechanisms': (sasl.Plain, bbsauth.BBSAuth),
'certfile': Config.BBS_XMPP_CERT_FILE,
'keyfile': Config.BBS_XMPP_KEY_FILE,
})
SP = xmpp.TCPServer(server).bind('0.0.0.0', 5222)
xmpp.start([SP])
## ---------- Common ----------
def negotiate(self):
self.starttls(self.done, **self.options)
def done(self):
self._active = False
self.trigger(StreamSecured).reset_stream()
### SASL
class Mechanisms(plugin.Feature):
__xmlns__ = 'urn:ietf:params:xml:ns:xmpp-sasl'
DEFAULT_MECHANISMS = (sasl.Plain, )
def __init__(self, auth, mechanisms=None):
self.auth = auth
self.mechanisms = mechanisms or self.DEFAULT_MECHANISMS
self.jid = None
def active(self):
return not self.jid
## ---------- Server ----------
def include(self):
self.bind(
auth=self.begin,
abort=self.terminate,
success=self.terminate,