From c15b616ddd409afb634ccd1efdf9a4ad7a8752fb Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 25 Oct 2007 12:36:57 +0000 Subject: [PATCH] remove the ability to save GPG password, show in GUI use_gpg_agent optin. fixes #2791 --- data/glade/accounts_window.glade | 81 +++++++------------------------- src/advanced.py | 5 +- src/common/config.py | 2 - src/config.py | 51 +++++--------------- src/roster_window.py | 66 ++++++++++---------------- 5 files changed, 58 insertions(+), 147 deletions(-) diff --git a/data/glade/accounts_window.glade b/data/glade/accounts_window.glade index ecd00cea6..4915193f9 100644 --- a/data/glade/accounts_window.glade +++ b/data/glade/accounts_window.glade @@ -780,42 +780,19 @@ - + True - 6 - - - True - False - True - If checked, Gajim will store the password in ~/.gajim/config with 'read' permission only for you - Save _passphrase (insecure) - True - True - - - - False - False - - - - - True - False - True - False - * - - - - 1 - - + False + True + If checked, Gajim will get the password from a GPG agent like seahorse + Use GPG _Agent + True + True + False - 1 + False @@ -1218,40 +1195,18 @@ You might consider to change possible firewall settings. - + True - 6 - - - True - True - If checked, Gajim will store the password in ~/.gajim/config with 'read' permission only for you - Save _passphrase (insecure) - True - True - - - - False - False - - - - - True - False - True - False - * - - - - 1 - - + True + If checked, Gajim will get the password from a GPG agent like seahorse + Use GPG _Agent + True + True + - 2 + False + False diff --git a/src/advanced.py b/src/advanced.py index 3fe2db136..e7d9647ff 100644 --- a/src/advanced.py +++ b/src/advanced.py @@ -103,8 +103,7 @@ class AdvancedConfigurationWindow(object): make the cellrenderertext not editable else it's editable''' optname = model[iter][C_PREFNAME] opttype = model[iter][C_TYPE] - if opttype == self.types['boolean'] or optname in ('password', - 'gpgpassword'): + if opttype == self.types['boolean'] or optname == 'password': cell.set_property('editable', False) else: cell.set_property('editable', True) @@ -239,7 +238,7 @@ class AdvancedConfigurationWindow(object): type = val[OPT_TYPE][0] type = self.types[type] # i18n value = val[OPT_VAL] - if name in ('password', 'gpgpassword'): + if name == 'password': #we talk about password value = _('Hidden') # override passwords with this string if value in self.right_true_dict: diff --git a/src/common/config.py b/src/common/config.py index edbfbeb69..5408fe14e 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -266,8 +266,6 @@ class Config: 'use_custom_host': [ opt_bool, False, '', True ], 'custom_port': [ opt_int, 5222, '', True ], 'custom_host': [ opt_str, '', '', True ], - 'savegpgpass': [ opt_bool, False, '', True ], - 'gpgpassword': [ opt_str, '' ], 'sync_with_global_status': [ opt_bool, False, ], 'no_log_for': [ opt_str, '' ], 'minimized_gc': [ opt_str, '' ], diff --git a/src/config.py b/src/config.py index 5701dc72a..17b43884d 100644 --- a/src/config.py +++ b/src/config.py @@ -1509,7 +1509,7 @@ class AccountsWindow: account = self.current_account keyid = gajim.config.get_per('accounts', account, 'keyid') keyname = gajim.config.get_per('accounts', account, 'keyname') - savegpgpass = gajim.config.get_per('accounts', account, 'savegpgpass') + use_gpg_agent = gajim.config.get('use_gpg_agent') if account == gajim.ZEROCONF_ACC_NAME: widget_name_add = '2' @@ -1518,27 +1518,19 @@ class AccountsWindow: gpg_key_label = self.xml.get_widget('gpg_key_label' + widget_name_add) gpg_name_label = self.xml.get_widget('gpg_name_label' + widget_name_add) - gpg_save_password_checkbutton = \ - self.xml.get_widget('gpg_save_password_checkbutton' + widget_name_add) - gpg_password_entry = self.xml.get_widget('gpg_password_entry' + \ - widget_name_add) + use_gpg_agent_checkbutton = self.xml.get_widget( + 'use_gpg_agent_checkbutton' + widget_name_add) if not keyid or not gajim.config.get('usegpg'): - gpg_save_password_checkbutton.set_sensitive(False) - gpg_password_entry.set_sensitive(False) + use_gpg_agent_checkbutton.set_sensitive(False) gpg_key_label.set_text(_('No key selected')) gpg_name_label.set_text('') return gpg_key_label.set_text(keyid) gpg_name_label.set_text(keyname) - gpg_save_password_checkbutton.set_sensitive(True) - gpg_save_password_checkbutton.set_active(savegpgpass) - - if savegpgpass: - gpg_password_entry.set_sensitive(True) - gpgpassword = gajim.config.get_per('accounts', account, 'gpgpassword') - gpg_password_entry.set_text(gpgpassword) + use_gpg_agent_checkbutton.set_sensitive(True) + use_gpg_agent_checkbutton.set_active(use_gpg_agent) def init_normal_account(self): account = self.current_account @@ -2002,17 +1994,14 @@ class AccountsWindow: wiget_name_ext = '2' else: wiget_name_ext = '1' - checkbutton = self.xml.get_widget('gpg_save_password_checkbutton' + \ - wiget_name_ext) gpg_key_label = self.xml.get_widget('gpg_key_label' + wiget_name_ext) gpg_name_label = self.xml.get_widget('gpg_name_label' + wiget_name_ext) - gpg_password_entry = self.xml.get_widget('gpg_password_entry' + \ - wiget_name_ext) + use_gpg_agent_checkbutton = self.xml.get_widget( + 'use_gpg_agent_checkbutton' + wiget_name_ext) if keyID[0] == _('None'): gpg_key_label.set_text(_('No key selected')) gpg_name_label.set_text('') - checkbutton.set_sensitive(False) - gpg_password_entry.set_sensitive(False) + use_gpg_agent_checkbutton.set_sensitive(False) if self.option_changed('keyid', ''): self.need_relogin = True gajim.config.set_per('accounts', self.current_account, 'keyname', '') @@ -2020,34 +2009,20 @@ class AccountsWindow: else: gpg_key_label.set_text(keyID[0]) gpg_name_label.set_text(keyID[1]) - checkbutton.set_sensitive(True) + use_gpg_agent_checkbutton.set_sensitive(True) if self.option_changed('keyid', keyID[0]): self.need_relogin = True gajim.config.set_per('accounts', self.current_account, 'keyname', keyID[1]) gajim.config.set_per('accounts', self.current_account, 'keyid', keyID[0]) - gajim.config.set_per('accounts', self.current_account, 'savegpgpass', - False) - gajim.config.set_per('accounts', self.current_account, 'gpgpassword', '') - checkbutton.set_active(False) - gpg_password_entry.set_text('') - def on_gpg_save_password_checkbutton_toggled(self, widget): + def on_use_gpg_agent_checkbutton_toggled(self, widget): if self.current_account == gajim.ZEROCONF_ACC_NAME: wiget_name_ext = '2' else: wiget_name_ext = '1' - self.xml.get_widget('gpg_password_entry' + wiget_name_ext).set_sensitive( - widget.get_active()) - self.on_checkbutton_toggled(widget, 'savegpgpass', - account = self.current_account) - - def on_gpg_password_entry_changed(self, widget): - if self.ignore_events: - return - gajim.config.set_per('accounts', self.current_account, 'gpgpassword', - widget.get_text().decode('utf-8')) + self.on_checkbutton_toggled(widget, 'use_gpg_agent') def on_edit_details_button1_clicked(self, widget): if not gajim.interface.instances.has_key(self.current_account): @@ -3317,8 +3292,6 @@ class AccountCreationWizardWindow: config['custom_host'] = '' config['keyname'] = '' config['keyid'] = '' - config['savegpgpass'] = False - config['gpgpassword'] = '' return config def save_account(self, login, server, savepass, password): diff --git a/src/roster_window.py b/src/roster_window.py index ee94e575a..ae3f40e7c 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -3442,11 +3442,6 @@ class RosterWindow: keyid = None use_gpg_agent = gajim.config.get('use_gpg_agent') # we don't need to bother with the passphrase if we use the agent - if use_gpg_agent: - save_gpg_pass = False - else: - save_gpg_pass = gajim.config.get_per('accounts', account, - 'savegpgpass') keyid = gajim.config.get_per('accounts', account, 'keyid') if keyid and not gajim.config.get('usegpg'): dialog = dialogs.WarningDialog(_('GPG is not usable'), _('You will be connected to %s without OpenPGP.') % account) @@ -3456,42 +3451,33 @@ class RosterWindow: if use_gpg_agent: self.gpg_passphrase[keyid] = None else: - if save_gpg_pass: - passphrase = gajim.config.get_per('accounts', account, - 'gpgpassword') + if self.gpg_passphrase.has_key(keyid): + passphrase = self.gpg_passphrase[keyid] + save = False else: - if self.gpg_passphrase.has_key(keyid): - passphrase = self.gpg_passphrase[keyid] - save = False - else: - password_ok = False - count = 0 - title = _('Passphrase Required') - second = _('Enter GPG key passphrase for account %s.') % \ - account - while not password_ok and count < 3: - count += 1 - w = dialogs.PassphraseDialog(title, second, - _('Save passphrase')) - passphrase, save = w.run() - if passphrase == -1: - passphrase = None - password_ok = True - else: - password_ok = gajim.connections[account].\ - test_gpg_passphrase(passphrase) - title = _('Wrong Passphrase') - second = _('Please retype your GPG passphrase or ' - 'press Cancel.') - if passphrase != None: - self.gpg_passphrase[keyid] = passphrase - gobject.timeout_add(30000, self.forget_gpg_passphrase, - keyid) - if save: - gajim.config.set_per('accounts', account, 'savegpgpass', - True) - gajim.config.set_per('accounts', account, 'gpgpassword', - passphrase) + password_ok = False + count = 0 + title = _('Passphrase Required') + second = _('Enter GPG key passphrase for account %s.') % \ + account + while not password_ok and count < 3: + count += 1 + w = dialogs.PassphraseDialog(title, second, + _('Save passphrase')) + passphrase, save = w.run() + if passphrase == -1: + passphrase = None + password_ok = True + else: + password_ok = gajim.connections[account].\ + test_gpg_passphrase(passphrase) + title = _('Wrong Passphrase') + second = _('Please retype your GPG passphrase or ' + 'press Cancel.') + if passphrase != None: + self.gpg_passphrase[keyid] = passphrase + gobject.timeout_add(30000, self.forget_gpg_passphrase, + keyid) gajim.connections[account].gpg_passphrase(passphrase) if gajim.account_is_connected(account):