From fccf7f5af7a6a62ffb15cd7f37a23d52d0bbaf0d Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 28 Jul 2014 14:57:48 +0200 Subject: Do not traceback when we receive a message from a JID with no resource --- src/core/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/handlers.py b/src/core/handlers.py index 119d9e74..462ba4d7 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -212,7 +212,7 @@ def on_normal_message(self, message): return conversation = self.get_conversation_by_jid(conv_jid, create=True) - if isinstance(conversation, tabs.DynamicConversationTab): + if isinstance(conversation, tabs.DynamicConversationTab) and conv_jid.resource: conversation.lock(conv_jid.resource) if not own and not conversation.nick: -- cgit v1.2.3 From dc4f9cc35a180aff708c9693f6cef8ab992d0fa5 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 3 Oct 2014 22:46:21 +0200 Subject: Fix #2692 (ad-hoc mistakes show /help list) --- src/core/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/commands.py b/src/core/commands.py index c2e453e9..7c0f56fa 100644 --- a/src/core/commands.py +++ b/src/core/commands.py @@ -943,7 +943,7 @@ def command_xml_tab(self, arg=''): def command_adhoc(self, arg): arg = arg.split() if len(arg) > 1: - return self.command_help('list') + return self.command_help('ad-hoc') elif arg: jid = safeJID(arg[0]).server else: -- cgit v1.2.3 From 8d2408c16943ca3c7beb70905690e3b1e24079b2 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 8 Oct 2014 12:55:22 +0200 Subject: Use SHA-2 (SHA-512) to store the certificate fingerprint instead of SHA-1 Because SHA-1 is not really relevant anymore. Too bad it's significantly longer and tiring to check, even if that is to be expected. --- src/core/handlers.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/handlers.py b/src/core/handlers.py index 462ba4d7..96a0f7e8 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -8,7 +8,7 @@ log = logging.getLogger(__name__) import curses import ssl import time -from hashlib import sha1 +from hashlib import sha1, sha512 from gettext import gettext as _ from sleekxmpp import InvalidJID @@ -1069,16 +1069,27 @@ def validate_ssl(self, pem): config.set_and_save('certificate', cert) der = ssl.PEM_cert_to_DER_cert(pem) - digest = sha1(der).hexdigest().upper() - found_cert = ':'.join(i + j for i, j in zip(digest[::2], digest[1::2])) + sha1_digest = sha1(der).hexdigest().upper() + sha1_found_cert = ':'.join(i + j for i, j in zip(sha1_digest[::2], sha1_digest[1::2])) + sha2_digest = sha512(der).hexdigest().upper() + sha2_found_cert = ':'.join(i + j for i, j in zip(sha2_digest[::2], sha2_digest[1::2])) if cert: - if found_cert == cert: - log.debug('Cert %s OK', found_cert) + if sha1_found_cert == cert: + log.debug('Cert %s OK', sha1_found_cert) + log.debug('Current hash is SHA-1, moving to SHA-2 (%s)', + sha2_found_cert) + config.set_and_save('certificate', sha2_found_cert) + return + elif sha2_found_cert == cert: + log.debug('Cert %s OK', sha2_found_cert) return else: saved_input = self.current_tab().input - log.debug('\nWARNING: CERTIFICATE CHANGED old: %s, new: %s\n', cert, found_cert) - input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n) (%s)" % found_cert) + log.debug('\nWARNING: CERTIFICATE CHANGED old: %s, new: %s\n', cert, sha2_found_cert) + self.information('New certificate found (sha-2 hash:' + ' %s)\nPlease validate or abort' % sha2_found_cert, + 'Warning') + input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n)") self.current_tab().input = input input.resize(1, self.current_tab().width, self.current_tab().height-1, 0) input.refresh() @@ -1089,16 +1100,16 @@ def validate_ssl(self, pem): self.current_tab().input = saved_input self.paused = False if input.value: - self.information('Setting new certificate: old: %s, new: %s' % (cert, found_cert), 'Info') - log.debug('Setting certificate to %s', found_cert) - if not config.silent_set('certificate', found_cert): + self.information('Setting new certificate: old: %s, new: %s' % (cert, sha2_found_cert), 'Info') + log.debug('Setting certificate to %s', sha2_found_cert) + if not config.silent_set('certificate', sha2_found_cert): self.information(_('Unable to write in the config file'), 'Error') else: self.information('You refused to validate the certificate. You are now disconnected', 'Info') self.xmpp.disconnect() else: - log.debug('First time. Setting certificate to %s', found_cert) - if not config.silent_set('certificate', found_cert): + log.debug('First time. Setting certificate to %s', sha2_found_cert) + if not config.silent_set('certificate', sha2_found_cert): self.information(_('Unable to write in the config file'), 'Error') def _composing_tab_state(tab, state): -- cgit v1.2.3 From 5a5d5812edeb852232ea22f8b10e6d2073ca05d1 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 12 Oct 2014 23:06:44 +0200 Subject: Add an open_all_bookmarks option this option determines if the non-autojoin bookmarks will be opened on startup or not. It is false by default. --- src/core/handlers.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/core') diff --git a/src/core/handlers.py b/src/core/handlers.py index 96a0f7e8..ea67eaa6 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -869,24 +869,25 @@ def on_session_start(self, event): if not self.xmpp.anon and config.get('use_remote_bookmarks', True): bookmark.get_remote(self.xmpp) for bm in bookmark.bookmarks: - tab = self.get_tab_by_name(bm.jid, tabs.MucTab) - nick = bm.nick if bm.nick else self.own_nick - if not tab: - self.open_new_room(bm.jid, nick, False) - self.initial_joins.append(bm.jid) - histo_length = config.get('muc_history_length', 20) - if histo_length == -1: - histo_length = None - if histo_length is not None: - histo_length = str(histo_length) - # do not join rooms that do not have autojoin - # but display them anyway - if bm.autojoin: - muc.join_groupchat(self, bm.jid, nick, - passwd=bm.password, - maxhistory=histo_length, - status=self.status.message, - show=self.status.show) + if bm.autojoin or config.get('open_all_bookmarks', False): + tab = self.get_tab_by_name(bm.jid, tabs.MucTab) + nick = bm.nick if bm.nick else self.own_nick + if not tab: + self.open_new_room(bm.jid, nick, False) + self.initial_joins.append(bm.jid) + histo_length = config.get('muc_history_length', 20) + if histo_length == -1: + histo_length = None + if histo_length is not None: + histo_length = str(histo_length) + # do not join rooms that do not have autojoin + # but display them anyway + if bm.autojoin: + muc.join_groupchat(self, bm.jid, nick, + passwd=bm.password, + maxhistory=histo_length, + status=self.status.message, + show=self.status.show) if config.get('enable_user_nick', True): self.xmpp.plugin['xep_0172'].publish_nick(nick=self.own_nick, callback=dumb_callback, block=False) -- cgit v1.2.3