From ff1d9c4f69bd03d8cf5f426d67c38eef94d79be2 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 14:54:07 +0100 Subject: [PATCH 1/7] supybot-botchk: Use a different method for creating pidfile if it doesn't exist --- scripts/supybot-botchk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/supybot-botchk b/scripts/supybot-botchk index de6e4e802..31fa7ed8a 100644 --- a/scripts/supybot-botchk +++ b/scripts/supybot-botchk @@ -97,8 +97,8 @@ if __name__ == '__main__': parser.error('No conffile given.') os.chdir(options.botdir) - pidfile = open(options.pidfile, 'ab') - pidfile.close() + if not os.path.exists(options.pidfile): + open(options.pidfile, 'x').close() pid = None try: From f1198fb4e8eb6105cb613d2c8529e16db8ae1268 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 15:08:36 +0100 Subject: [PATCH 2/7] irclib.py: Fix SASL on py3k --- src/irclib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/irclib.py b/src/irclib.py index 5b7d93095..8b1898424 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -906,7 +906,8 @@ class Irc(IrcCommandDispatcher): if not self.sasl_username: log.error('SASL username is not set, unable to identify.') else: - auth_string = base64.b64encode('%s\x00%s\x00%s' % (self.sasl_username, + auth_string = + base64.b64encode('%s\x00%s\x00%s'.encode('utf-8') % (self.sasl_username, self.sasl_username, self.sasl_password)) log.debug('Sending CAP REQ command, requesting capability \'sasl\'.') self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) From 4b10ea3329442f3426ca19c02febc8536b160ec3 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 15:14:03 +0100 Subject: [PATCH 3/7] Fix previous commit --- src/irclib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index 8b1898424..0342214c1 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -906,9 +906,9 @@ class Irc(IrcCommandDispatcher): if not self.sasl_username: log.error('SASL username is not set, unable to identify.') else: - auth_string = - base64.b64encode('%s\x00%s\x00%s'.encode('utf-8') % (self.sasl_username, - self.sasl_username, self.sasl_password)) + auth_string = base64.b64encode('%s\x00%s\x00%s'.encode( + 'utf-8') % (self.sasl_username, self.sasl_username, + self.sasl_password)) log.debug('Sending CAP REQ command, requesting capability \'sasl\'.') self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) log.debug('Sending AUTHENTICATE command, using mechanism PLAIN.') From 66e46e514387f92fdadb20fd4ec4310b1aafb368 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 15:30:28 +0100 Subject: [PATCH 4/7] Fix previous commit (again) --- src/irclib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index 0342214c1..bcde29b76 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -906,9 +906,9 @@ class Irc(IrcCommandDispatcher): if not self.sasl_username: log.error('SASL username is not set, unable to identify.') else: - auth_string = base64.b64encode('%s\x00%s\x00%s'.encode( - 'utf-8') % (self.sasl_username, self.sasl_username, - self.sasl_password)) + auth_string = base64.b64encode(('%s\x00%s\x00%s' % + (self.sasl_username, self.sasl_username, + self.sasl_password)).encode('utf-8')) log.debug('Sending CAP REQ command, requesting capability \'sasl\'.') self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) log.debug('Sending AUTHENTICATE command, using mechanism PLAIN.') From 4170a873b203969f38c0268b0c91ef675bc7a556 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 15:58:45 +0100 Subject: [PATCH 5/7] Fix previous commit (yet again) --- src/irclib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/irclib.py b/src/irclib.py index bcde29b76..d048753ab 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -908,7 +908,8 @@ class Irc(IrcCommandDispatcher): else: auth_string = base64.b64encode(('%s\x00%s\x00%s' % (self.sasl_username, self.sasl_username, - self.sasl_password)).encode('utf-8')) + self.sasl_password)).encode('utf-8')).decode( + 'utf-8') log.debug('Sending CAP REQ command, requesting capability \'sasl\'.') self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) log.debug('Sending AUTHENTICATE command, using mechanism PLAIN.') From e491e14bc30d911ecc15839fe8632568980b7554 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Sun, 3 Feb 2013 18:50:20 +0100 Subject: [PATCH 6/7] Final fix for SASL and py3k --- src/irclib.py | 22 ++++++++++++++++------ src/ircutils.py | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index d048753ab..1d31faa20 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -887,8 +887,16 @@ class Irc(IrcCommandDispatcher): self.ident = conf.supybot.ident() self.alternateNicks = conf.supybot.nick.alternates()[:] self.password = conf.supybot.networks.get(self.network).password() - self.sasl_username = conf.supybot.networks.get(self.network).sasl.username() - self.sasl_password = conf.supybot.networks.get(self.network).sasl.password() + self.sasl_username = \ + conf.supybot.networks.get(self.network).sasl.username() + # TODO Find a better way to fix this + if hasattr(self.sasl_username, 'decode'): + self.sasl_username = self.sasl_username.decode('utf-8') + self.sasl_password = \ + conf.supybot.networks.get(self.network).sasl.password() + # TODO Find a better way to fix this + if hasattr(self.sasl_password, 'decode'): + self.sasl_password = self.sasl_password.decode('utf-8') self.prefix = '%s!%s@%s' % (self.nick, self.ident, 'unset.domain') # The rest. self.lastTake = 0 @@ -897,6 +905,7 @@ class Irc(IrcCommandDispatcher): self.lastping = time.time() self.outstandingPing = False + def _queueConnectMessages(self): if self.zombie: self.driver.die() @@ -906,10 +915,11 @@ class Irc(IrcCommandDispatcher): if not self.sasl_username: log.error('SASL username is not set, unable to identify.') else: - auth_string = base64.b64encode(('%s\x00%s\x00%s' % - (self.sasl_username, self.sasl_username, - self.sasl_password)).encode('utf-8')).decode( - 'utf-8') + auth_string = base64.b64encode('\x00'.join([ + self.sasl_username, + self.sasl_username, + self.sasl_password + ]).encode('utf-8')).decode('utf-8') log.debug('Sending CAP REQ command, requesting capability \'sasl\'.') self.queueMsg(ircmsgs.IrcMsg(command="CAP", args=('REQ', 'sasl'))) log.debug('Sending AUTHENTICATE command, using mechanism PLAIN.') diff --git a/src/ircutils.py b/src/ircutils.py index fa340458e..abb6f69f0 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -461,6 +461,7 @@ def wrap(s, length, break_on_hyphens = False, break_long_words = False): def isValidArgument(s): """Returns whether s is strictly a valid argument for an IRC message.""" + return '\r' not in s and '\n' not in s and '\x00' not in s def safeArgument(s): From c234d683d1ddde6dc64db849b6709487eef9d498 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Thu, 7 Feb 2013 15:37:20 +0100 Subject: [PATCH 7/7] scripts/supybot-botchk: Open pidfile in append mode because 'x' is not supported on Python 2 --- scripts/supybot-botchk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/supybot-botchk b/scripts/supybot-botchk index 31fa7ed8a..8d59e8068 100644 --- a/scripts/supybot-botchk +++ b/scripts/supybot-botchk @@ -97,8 +97,7 @@ if __name__ == '__main__': parser.error('No conffile given.') os.chdir(options.botdir) - if not os.path.exists(options.pidfile): - open(options.pidfile, 'x').close() + open(options.pidfile, 'a').close() pid = None try: