Ticket #733: gpg-agent-hawke.patch
| File gpg-agent-hawke.patch, 8.7 KB (added by hawke, 5 years ago) |
|---|
-
src/common/connection.py
1383 1383 #Get bookmarks from private namespace 1384 1384 self.get_bookmarks() 1385 1385 1386 def change_status(self, show, msg, sync = False ):1386 def change_status(self, show, msg, sync = False, auto = False): 1387 1387 if sync: 1388 self.change_status2(show, msg )1388 self.change_status2(show, msg, auto) 1389 1389 else: 1390 t = threading.Thread(target=self.change_status2, args = (show, msg ))1390 t = threading.Thread(target=self.change_status2, args = (show, msg, auto)) 1391 1391 t.start() 1392 1392 1393 def change_status2(self, show, msg ):1393 def change_status2(self, show, msg, auto = False): 1394 1394 if not show in STATUS_LIST: 1395 1395 return -1 1396 1396 sshow = show # show to be send 1397 1397 if show == 'online': 1398 1398 sshow = None 1399 signed = ''1400 1399 if not msg: 1401 1400 lowered_uf_status_msg = helpers.get_uf_show(show).lower() 1402 1401 if lowered_uf_status_msg == _('invisible'): # do not show I'm invisible! 1403 1402 lowered_uf_status_msg = _('offline') 1404 1403 msg = _("I'm %s") % lowered_uf_status_msg 1404 1405 # sign presence 1406 signed = '' 1405 1407 keyID = gajim.config.get_per('accounts', self.name, 'keyid') 1406 if keyID and USE_GPG: 1407 if self.connected < 2 and self.gpg.passphrase is None: 1408 if keyID and USE_GPG and not auto and not show == 'offline': 1409 # translates to: 1410 # if we are not yet online, 1411 # were not given a passphrase 1412 # and won't use the gpg-agent 1413 # then cry out loud. 1414 use_gpg_agent = gajim.config.get('usegpgagent') 1415 if self.connected < 2 and self.gpg.passphrase is None and not use_gpg_agent: 1408 1416 # We didn't set a passphrase 1409 1417 self.dispatch('ERROR', (_('OpenPGP passphrase was not given'), 1410 1418 #%s is the account name here 1411 1419 _('You will be connected to %s without OpenPGP.') % self.name)) 1412 else: 1420 # ... we have a passphrase or use the agent, so we can sign 1421 elif self.gpg.passphrase is not None or use_gpg_agent: 1413 1422 signed = self.gpg.sign(msg, keyID) 1414 1423 if signed == 'BAD_PASSPHRASE': 1415 1424 signed = '' 1416 1425 if self.connected < 2: 1417 1426 self.dispatch('BAD_PASSPHRASE', ()) 1427 else: 1428 signed = '' 1418 1429 self.status = msg 1419 1430 if show != 'offline' and not self.connected: 1420 1431 self.connection = self.connect() … … 1848 1859 1849 1860 def gpg_passphrase(self, passphrase): 1850 1861 if USE_GPG: 1851 self.gpg.passphrase = passphrase 1862 use_gpg_agent = gajim.config.get('usegpgagent') 1863 if use_gpg_agent: 1864 self.gpg.passphrase = None 1865 else: 1866 self.gpg.passphrase = passphrase 1852 1867 1853 1868 def ask_gpg_keys(self): 1854 1869 if USE_GPG: -
src/common/config.py
108 108 'send_os_info': [ opt_bool, True ], 109 109 'check_for_new_version': [ opt_bool, False ], 110 110 'usegpg': [ opt_bool, False ], 111 'usegpgagent': [ opt_bool, False ], 111 112 'log_notif_in_user_file': [ opt_bool, True ], 112 113 'log_notif_in_sep_file': [ opt_bool, True ], 113 114 'change_roster_title': [ opt_bool, True ], -
src/common/GnuPG.py
17 17 ## GNU General Public License for more details. 18 18 ## 19 19 20 from tempfile import * 20 ##from tempfile import * 21 from os import tmpfile 21 22 22 23 USE_GPG = True 23 24 … … 115 116 116 117 try: proc.wait() 117 118 except IOError: pass 118 if resp.has_key('GOOD_PASSPHRASE') :119 if resp.has_key('GOOD_PASSPHRASE') or resp.has_key('SIG_CREATED'): 119 120 return self._stripHeaderFooter(output) 120 121 return 'BAD_PASSPHRASE' 121 122 … … 124 125 return str 125 126 if not str: 126 127 return '' 127 f = TemporaryFile(prefix='gajim') 128 #f = TemporaryFile(prefix='gajim') 129 f = tmpfile() 128 130 fd = f.fileno() 129 131 f.write(str) 130 132 f.seek(0) … … 147 149 keyid = '' 148 150 if resp.has_key('GOODSIG'): 149 151 keyid = resp['GOODSIG'].split()[0] 150 elif resp.has_key('BADSIG'):151 keyid = resp['BADSIG'].split()[0]152 #elif resp.has_key('BADSIG'): 153 # keyid = resp['BADSIG'].split()[0] 152 154 return keyid 153 155 154 156 def get_keys(self, secret = False): -
src/roster_window.py
1171 1171 del self.gpg_passphrase[keyid] 1172 1172 return False 1173 1173 1174 def send_status(self, account, status, txt, sync = False ):1174 def send_status(self, account, status, txt, sync = False, auto = False): 1175 1175 if status != 'offline': 1176 1176 if gajim.connections[account].connected < 2: 1177 1177 model = self.tree.get_model() … … 1202 1202 gajim.config.set_per('accounts', account, 'password', passphrase) 1203 1203 1204 1204 keyid = None 1205 save_gpg_pass = True 1206 save_gpg_pass = gajim.config.get_per('accounts', account, 1207 'savegpgpass') 1205 use_gpg_agent = gajim.config.get('usegpgagent') 1206 # we don't need to bother with the passphrase if we use the agent 1207 if use_gpg_agent: 1208 save_gpg_pass = False 1209 else: 1210 save_gpg_pass = gajim.config.get_per('accounts', account, 1211 'savegpgpass') 1208 1212 keyid = gajim.config.get_per('accounts', account, 'keyid') 1209 1213 if keyid and gajim.connections[account].connected < 2 and \ 1210 1214 gajim.config.get('usegpg'): 1211 if save_gpg_pass:1212 passphrase = gajim.config.get_per('accounts', account,1213 'gpgpassword')1215 1216 if use_gpg_agent: 1217 self.gpg_passphrase[keyid] = None 1214 1218 else: 1215 if self.gpg_passphrase.has_key(keyid): 1216 passphrase = self.gpg_passphrase[keyid] 1217 save = False 1219 if save_gpg_pass: 1220 passphrase = gajim.config.get_per('accounts', account, 'gpgpassword') 1218 1221 else: 1219 w = dialogs.PassphraseDialog( 1220 _('Passphrase Required'), 1221 _('Enter GPG key passphrase for account %s') % account, 1222 _('Save passphrase')) 1223 passphrase, save = w.run() 1224 if passphrase == -1: 1225 passphrase = None 1226 else: 1227 self.gpg_passphrase[keyid] = passphrase 1228 gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid) 1229 if save: 1230 gajim.config.set_per('accounts', account, 'savegpgpass', True) 1231 gajim.config.set_per('accounts', account, 'gpgpassword', 1232 passphrase) 1233 gajim.connections[account].gpg_passphrase(passphrase) 1234 gajim.connections[account].change_status(status, txt, sync) 1222 if self.gpg_passphrase.has_key(keyid): 1223 passphrase = self.gpg_passphrase[keyid] 1224 save = False 1225 else: 1226 w = dialogs.PassphraseDialog( 1227 _('Passphrase Required'), 1228 _('Enter GPG key passphrase for account %s') % account, 1229 _('Save passphrase')) 1230 passphrase, save = w.run() 1231 if passphrase == -1: 1232 passphrase = None 1233 else: 1234 self.gpg_passphrase[keyid] = passphrase 1235 gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid) 1236 if save: 1237 gajim.config.set_per('accounts', account, 'savegpgpass', True) 1238 gajim.config.set_per('accounts', account, 'gpgpassword', 1239 passphrase) 1240 gajim.connections[account].gpg_passphrase(passphrase) 1241 1242 gajim.connections[account].change_status(status, txt, sync, auto) 1235 1243 for room_jid in self.plugin.windows[account]['gc']: 1236 1244 if room_jid != 'tabbed': 1237 1245 nick = self.plugin.windows[account]['gc'][room_jid].nicks[room_jid] -
src/gajim.py
658 658 config.GroupchatConfigWindow(self, account, jid, array[1]) 659 659 660 660 def handle_event_bad_passphrase(self, account, array): 661 use_gpg_agent = gajim.config.get('usegpgagent', False) 662 if use_gpg_agent: 663 return 661 664 keyID = gajim.config.get_per('accounts', account, 'keyid') 662 665 self.roster.forget_gpg_passphrase(keyID) 663 666 dialogs.WarningDialog(_('Your passphrase is incorrect'), … … 822 825 #we save out online status 823 826 gajim.status_before_autoaway[account] = \ 824 827 gajim.connections[account].status 825 #we go away 828 #we go away (noting auto status) 826 829 self.roster.send_status(account, 'away', 827 gajim.config.get('autoaway_message' ))830 gajim.config.get('autoaway_message',True)) 828 831 gajim.sleeper_state[account] = 'autoaway' 829 832 elif state == common.sleepy.STATE_XAWAY and (\ 830 833 gajim.sleeper_state[account] == 'autoaway' or \ … … 832 835 gajim.config.get('autoxa'): 833 836 #we go extended away 834 837 self.roster.send_status(account, 'xa', 835 gajim.config.get('autoxa_message' ))838 gajim.config.get('autoxa_message', True)) 836 839 gajim.sleeper_state[account] = 'autoxa' 837 840 return True # renew timeout (loop for ever) 838 841
