108"""@since: 0.42"""109assertvalid_sigs110111gtk.Dialog.__init__(self)112ifhasattr(self,'set_has_separator'):113self.set_has_separator(False)114self.set_position(gtk.WIN_POS_CENTER)115self.set_transient_for(parent)116117self.closed=tasks.Blocker(_("confirming keys with user"))118119domain=trust.domain_from_url(pending.url)120assertdomain121122defdestroy(box):123self.closed.trigger()
124125self.connect('destroy',destroy)126127self.set_title(_('Confirm trust'))128129vbox=gtk.VBox(False,4)130vbox.set_border_width(4)131self.vbox.pack_start(vbox,True,True,0)132133notebook=gtk.Notebook()134135iflen(valid_sigs)==1:136notebook.set_show_tabs(False)137138label=left(_('Checking: %s')%pending.url)139label.set_padding(4,4)140vbox.pack_start(label,False,True,0)141142currently_trusted_keys=trust.trust_db.get_keys_for_domain(domain)143ifcurrently_trusted_keys:144keys=[gpg.load_key(fingerprint)forfingerprintincurrently_trusted_keys]145descriptions=[_("%(key_name)s\n(fingerprint: %(key_fingerprint)s)")%{'key_name':key.name,'key_fingerprint':pretty_fp(key.fingerprint)}146forkeyinkeys]147else:148descriptions=[_('None')]149frame(vbox,_('Keys already approved for "%s"')%domain,'\n'.join(descriptions))150151label=left(translation.ngettext('This key signed the feed:','These keys signed the feed:',len(valid_sigs)))152153label.set_padding(4,4)154vbox.pack_start(label,False,True,0)155156vbox.pack_start(notebook,True,True,0)157158self.add_button(gtk.STOCK_HELP,gtk.RESPONSE_HELP)159self.add_button(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL)160self.add_button(gtk.STOCK_ADD,gtk.RESPONSE_OK)161self.set_default_response(gtk.RESPONSE_OK)162163trust_checkbox={}# Sig -> CheckButton164defok_sensitive():165trust_any=False166fortoggleintrust_checkbox.values():167iftoggle.get_active():168trust_any=True169break170self.set_response_sensitive(gtk.RESPONSE_OK,trust_any)
171172first=True173forsiginvalid_sigs:174ifhasattr(sig,'get_details'):175name='<unknown>'176details=sig.get_details()177foritemindetails:178ifitem[0]=='uid'andlen(item)>9:179name=item[9]180break181else:182name=None183page=gtk.VBox(False,4)184page.set_border_width(8)185186frame(page,_('Fingerprint'),pretty_fp(sig.fingerprint))187188ifnameisnotNone:189frame(page,_('Claimed identity'),name)190191frame(page,_('Unreliable hints database says'),make_hints_area(self.closed,valid_sigs[sig]))192193already_trusted=trust.trust_db.get_trust_domains(sig.fingerprint)194ifalready_trusted:195frame(page,_('You already trust this key for these domains'),196'\n'.join(already_trusted))197198trust_checkbox[sig]=gtk.CheckButton(_('_Trust this key'))199page.pack_start(trust_checkbox[sig],False,True,0)200trust_checkbox[sig].connect('toggled',lambdat:ok_sensitive())201202notebook.append_page(page,gtk.Label(nameor'Signature'))203204iffirst:205trust_checkbox[sig].set_active(True)206first=False207208ok_sensitive()209self.vbox.show_all()210211iflen(valid_sigs)==1:212forboxintrust_checkbox.values():213box.hide()214215defresponse(box,resp):216ifresp==gtk.RESPONSE_HELP:217trust_help.display()218return219ifresp==gtk.RESPONSE_OK:220to_trust=[sigforsigintrust_checkboxiftrust_checkbox[sig].get_active()]221222ifnotself._confirm_unknown_keys(to_trust,valid_sigs):223return224225self.trust_keys(to_trust,domain)226self.destroy()227self.connect('response',response)228
242"""Check the key-info server's results for these keys. If we don't know any of them,243 ask for extra confirmation from the user.244 @param to_trust: the signatures the user wants to trust245 @return: True to continue"""246247defis_unknown(sig):248fornoteinvalid_sigs[sig].info:249ifnote.getAttribute("vote")=="good":250returnFalse251returnTrue
252unknown=[sigforsiginto_trustifis_unknown(sig)]253254ifunknown:255iflen(unknown)==1:256msg=_('WARNING: you are confirming a key which was not known to the key server. Are you sure?')257else:258msg=_('WARNING: you are confirming keys which were not known to the key server. Are you sure?')259260box=gtk.MessageDialog(self,261gtk.DIALOG_DESTROY_WITH_PARENT,262gtk.MESSAGE_QUESTION,gtk.BUTTONS_OK_CANCEL,263msg)264box.set_position(gtk.WIN_POS_CENTER)265response=box.run()266box.destroy()267returnresponse==gtk.RESPONSE_OK268269returnTrue270271trust_help=help_box.HelpBox(_("Trust Help"),272(_('Overview'),'\n'+273_("""When you run a program, it typically has access to all your files and can generally do \274anything that you're allowed to do (delete files, send emails, etc). So it's important \275to make sure that you don't run anything malicious.""")),276277(_('Digital signatures'),'\n'+278_("""Each software author creates a 'key-pair'; a 'public key' and a 'private key'. Without going \279into the maths, only something encrypted with the private key will decrypt with the public key.280281So, when a programmer releases some software, they encrypt it with their private key (which no-one \282else has). When you download it, the injector checks that it decrypts using their public key, thus \283proving that it came from them and hasn't been tampered with.""")),284285(_('Trust'),'\n'+286_("""After the injector has checked that the software hasn't been modified since it was signed with \287the private key, you still have the following problems:2882891. Does the public key you have really belong to the author?2902. Even if the software really did come from that person, do you trust them?""")),291292(_('Key fingerprints'),'\n'+293_("""To confirm (1), you should compare the public key you have with the genuine one. To make this \294easier, the injector displays a 'fingerprint' for the key. Look in mailing list postings or some \295other source to check that the fingerprint is right (a different key will have a different \296fingerprint).297298You're trying to protect against the situation where an attacker breaks into a web site \299and puts up malicious software, signed with the attacker's private key, and puts up the \300attacker's public key too. If you've downloaded this software before, you \301should be suspicious that you're being asked to confirm another key!""")),302303(_('Reputation'),'\n'+304_("""In general, most problems seem to come from malicous and otherwise-unknown people \305replacing software with modified versions, or creating new programs intended only to \306cause damage. So, check your programs are signed by a key with a good reputation!""")))307