From 414249c9ace169155da1f19ac82f747e67bf9a0e Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sat, 24 May 2014 15:57:27 +0200 Subject: [PATCH] src/irclib.py: Delay sending SASL authstring until given green light That means wait until receiving 'AUTHENTICATE +' from the server, which means the mechanism is supported and we can proceed to send the authstring. It generally works anyway, but it's better to follow the standards, plus old versions of elemental-ircd may crash if we don't do this. --- src/irclib.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index 504f74c1b..82997942c 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -930,7 +930,7 @@ class Irc(IrcCommandDispatcher): else: if self.sasl_password: if not self.sasl_username: - log.error('SASL username is not set, unable to identify.') + log.warning('SASL username is not set, unable to identify.') else: auth_string = base64.b64encode('\x00'.join([ self.sasl_username, @@ -941,8 +941,6 @@ class Irc(IrcCommandDispatcher): self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) log.debug('Using SASL mechanism PLAIN.') self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=('PLAIN',))) - log.info('Authenticating using SASL.') - self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=(auth_string,))) if self.password: log.info('Sending PASS command, not logging the password.') self.queueMsg(ircmsgs.password(self.password)) @@ -952,6 +950,12 @@ class Irc(IrcCommandDispatcher): self.ident, self.user) self.queueMsg(ircmsgs.user(self.ident, self.user)) + def doAuthenticate(self, msg): + if msg.args[0] == '+': + log.info('Authenticating using SASL.') + self.queueMsg(ircmsgs.IrcMsg(command="AUTHENTICATE", args=(auth_string,))) + + def do903(self, msg): log.info('%s: SASL authentication successful' % self.network) self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('END',)))