remove the ability to save GPG password, show in GUI use_gpg_agent optin. fixes #2791

This commit is contained in:
Yann Leboulanger 2007-10-25 12:36:57 +00:00
parent 97f4c470b5
commit c15b616ddd
5 changed files with 58 additions and 147 deletions

View File

@ -780,42 +780,19 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox4">
<widget class="GtkCheckButton" id="use_gpg_agent_checkbutton1">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkCheckButton" id="gpg_save_password_checkbutton1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will store the password in ~/.gajim/config with 'read' permission only for you</property>
<property name="label" translatable="yes">Save _passphrase (insecure)</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_gpg_save_password_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="gpg_password_entry1">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">*</property>
<signal name="changed" handler="on_gpg_password_entry_changed"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will get the password from a GPG agent like seahorse</property>
<property name="label" translatable="yes">Use GPG _Agent</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_use_gpg_agent_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
@ -1218,40 +1195,18 @@ You might consider to change possible firewall settings.</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox7">
<widget class="GtkCheckButton" id="use_gpg_agent_checkbutton2">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkCheckButton" id="gpg_save_password_checkbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will store the password in ~/.gajim/config with 'read' permission only for you</property>
<property name="label" translatable="yes">Save _passphrase (insecure)</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_gpg_save_password_checkbutton_toggled"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="gpg_password_entry2">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">*</property>
<signal name="changed" handler="on_gpg_password_entry_changed"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">If checked, Gajim will get the password from a GPG agent like seahorse</property>
<property name="label" translatable="yes">Use GPG _Agent</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_use_gpg_agent_checkbutton_toggled"/>
</widget>
<packing>
<property name="position">2</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>

View File

@ -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:

View File

@ -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, '' ],

View File

@ -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):

View File

@ -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):