[Pkg-privacy-commits] [torbrowser-launcher] 80/476: merged meejah's work, and made sure torproject.pem makes it into /usr/share/torproject-launcher

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository torbrowser-launcher.

commit 6a0128d88d11ea9850bb5593b872a99709302931
Merge: 1a36c24 4294357
Author: Micah Lee <micahflee at riseup.net>
Date:   Thu Feb 28 09:37:34 2013 -0800

    merged meejah's work, and made sure torproject.pem makes it into /usr/share/torproject-launcher

 keys/README         |   3 ++
 keys/torproject.pem |  38 +++++++++++++++++++
 setup.py            |   2 +-
 torbrowser-launcher | 105 ++++++++++++++++++++++++++++++++++++++++++----------
 4 files changed, 127 insertions(+), 21 deletions(-)

diff --cc keys/README
index 2f2777c,2f2777c..bb5ecdf
--- a/keys/README
+++ b/keys/README
@@@ -4,3 -4,3 +4,6 @@@ Please visit the Tor web page about ver
  
  All of the keys in this directory are believed to be verified for
  releasing and signing the TBB releases.
++
++torproject.pem is the https://www.torproject.org cert used for
++certificate pinning.
diff --cc keys/torproject.pem
index 0000000,12cf79b..12cf79b
mode 000000,100644..100644
--- a/keys/torproject.pem
+++ b/keys/torproject.pem
diff --cc setup.py
index cf071c4,cf071c4..0caee77
--- a/setup.py
+++ b/setup.py
@@@ -20,5 -20,5 +20,5 @@@ Tor Browser Launcher will get updated e
        scripts=['torbrowser-launcher'],
        data_files=[('/usr/share/applications', ['torbrowser.desktop']),
                    ('/usr/share/pixmaps', ['img/torbrowser32.xpm', 'img/torbrowser80.xpm']),
--                  ('/usr/share/torbrowser-launcher', ['keys/erinn.asc', 'keys/sebastian.asc', 'verify.sh'])]
++                  ('/usr/share/torbrowser-launcher', ['keys/erinn.asc', 'keys/sebastian.asc', 'keys/torproject.pem', 'verify.sh'])]
        )
diff --cc torbrowser-launcher
index 4d6a2d8,377beaf..2eaa388
--- a/torbrowser-launcher
+++ b/torbrowser-launcher
@@@ -1,82 -1,72 +1,107 @@@
  #!/usr/bin/env python
- .view-twitterator-follow-eff .views-row .views-field-field-tweet {
--
- import os, sys, subprocess, locale, urllib2, gobject, time, pickle, json
+ from twisted.internet import gtk2reactor
+ gtk2reactor.install()
+ from twisted.internet import reactor
  
  import pygtk
  pygtk.require('2.0')
  import gtk
  
 -import os, sys, subprocess, locale, urllib2, gobject, time
++import os, sys, subprocess, locale, urllib2, gobject, time, pickle, json
+ 
+ from twisted.web.client import Agent, ResponseDone
+ from twisted.web.http_headers import Headers
+ from twisted.internet.protocol import Protocol
+ from twisted.internet.ssl import ClientContextFactory
+ 
+ from OpenSSL.SSL import Context, VERIFY_PEER, VERIFY_FAIL_IF_NO_PEER_CERT
+ from OpenSSL.crypto import load_certificate, FILETYPE_PEM
+ 
+ class VerifyTorProjectCert(ClientContextFactory):
+ 
 -    torproject_ca = load_certificate(FILETYPE_PEM, open('torproject.pem', 'r').read())
++    def __init__(self, torproject_pem):
++        self.torproject_ca = load_certificate(FILETYPE_PEM, open(torproject_pem, 'r').read())
+ 
+     def getContext(self, host, port):
+         ctx = ClientContextFactory.getContext(self)
+         ctx.set_verify_depth(0)
+         ctx.set_verify(VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT, self.verifyHostname)
+         return ctx
+ 
+     def verifyHostname(self, connection, cert, errno, depth, preverifyOK):
+         return cert.digest('sha256') == self.torproject_ca.digest('sha256')
+ 
+ 
  class TorBrowserLauncher:
 -  def __init__(self, current_tbb_version):
 +  def __init__(self):
      # initialize the app
 -    self.current_tbb_version = current_tbb_version
      self.discover_arch_lang()
      self.build_paths()
      self.mkdirs()
  
 -    launch_gui = True
 +    # allow buttons to have icons
 +    try:
 +      settings = gtk.settings_get_default()
 +      settings.props.gtk_button_images = True
 +    except:
 +      pass
 +
 +    self.launch_gui = True
 +
 +    # load settings
 +    if self.load_settings():
 +      self.build_paths(self.settings['latest_version'])
 +
 +      # how long was it since the last update check?
 +      # 86400 seconds = 24 hours
 +      current_timestamp = int(time.time())
 +      if current_timestamp - self.settings['last_update_check_timestamp'] >= 86400:
 +        # check for update
 +        print 'Checking for update'
 +        self.set_gui('task', "Checking for Tor Browser update.", 
 +          ['download_update_check', 
 +           'attempt_update'])
 +
 +      else:
 +        # no need to check for update
 +        print 'Checked for update within 24 hours, skipping'
 +        self.start_launcher()
 +
 +    else:
 +      self.set_gui('error', "Error loading settings. Delete ~/.torbrowser and try again.", [])
 +
 +    if self.launch_gui:
 +      # set up the window
 +      self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 +      self.window.set_title("Tor Browser")
 +      self.window.set_position(gtk.WIN_POS_CENTER)
 +      self.window.set_border_width(10)
 +      self.window.connect("delete_event", self.delete_event)
 +      self.window.connect("destroy", self.destroy)
 +
 +      # build the rest of the UI
 +      self.build_ui()
-       gtk.main()
++      reactor.run()
  
 +  # download or run TBB
 +  def start_launcher(self):
      # is TBB already installed?
      if os.path.isfile(self.paths['file']['start']) and os.access(self.paths['file']['start'], os.X_OK):
 -      # does the version file exist?
 -      if os.path.isfile(self.paths['file']['version']):
 -        installed_tbb_version = open(self.paths['file']['version']).read().strip()
 -
 -        if installed_tbb_version == current_tbb_version:
 -          # current version is tbb is installed, launch it
 -          self.run(False)
 -          launch_gui = False
 -        elif installed_tbb_version < self.current_tbb_version:
 -          # there is a tbb upgrade available
 -          self.set_gui('task', "Your Tor Browser is out of date.", 
 -            ['download_tarball', 
 -             'download_tarball_sig', 
 -             'verify', 
 -             'extract', 
 -             'run'])
 -        else:
 -          # for some reason the installed tbb is newer than the current version?
 -          self.set_gui('error', "Something is wrong. The version of Tor Browser Bundle you have installed is newer than the current version?", [])
 -
 +      if self.settings['installed_version'] == self.settings['latest_version']:
 +        # current version of tbb is installed, launch it
 +        self.run(False)
 +        self.launch_gui = False
 +      elif self.settings['installed_version'] < self.settings['latest_version']:
 +        # there is a tbb upgrade available
 +        self.set_gui('task', "Your Tor Browser is out of date.", 
 +          ['download_tarball', 
 +           'download_tarball_sig', 
 +           'verify', 
 +           'extract', 
 +           'run'])
        else:
 -        # if tbb is installed but the version file doesn't exist, something is wrong
 -        self.set_gui('error', "Something is wrong. You have the Tor Browser Bundle installed, but the version file is missing.", [])
 +        # for some reason the installed tbb is newer than the current version?
 +        self.set_gui('error', "Something is wrong. The version of Tor Browser Bundle you have installed is newer than the current version?", [])
  
      # not installed
      else:
@@@ -96,7 -89,11 +121,7 @@@
             'verify', 
             'extract', 
             'run'])
--
 -    if launch_gui:
 -      self.build_ui()
 -      reactor.run()
 -  
++ 
    # discover the architecture and language
    def discover_arch_lang(self):
      # figure out the architecture
@@@ -121,38 -118,33 +146,39 @@@
          self.language = 'en-US'
  
    # build all relevant paths
 -  def build_paths(self):
 +  def build_paths(self, tbb_version = None):
      tbb_data = os.getenv('HOME')+'/.torbrowser'
 -    tarball_filename = 'tor-browser-gnu-linux-'+self.architecture+'-'+self.current_tbb_version+'-dev-'+self.language+'.tar.gz'
 -
 -    self.paths = {
 -      'dir': {
 -        'data': tbb_data,
 -        'download': tbb_data+'/download',
 -        'tbb': tbb_data+'/tbb/'+self.architecture,
 -        'gpg': tbb_data+'/gpgtmp'
 -      },
 -      'file': {
 -        'version': tbb_data+'/version',
 -        'start': tbb_data+'/tbb/'+self.architecture+'/tor-browser_'+self.language+'/start-tor-browser',
 -        'tarball': tbb_data+'/download/'+tarball_filename,
 -        'tarball_sig': tbb_data+'/download/'+tarball_filename+'.asc',
 -        'verify': '/usr/share/torbrowser-launcher/verify.sh'
 -      },
 -      'url': {
 -        'tarball': 'https://www.torproject.org/dist/torbrowser/linux/'+tarball_filename,
 -        'tarball_sig': 'https://www.torproject.org/dist/torbrowser/linux/'+tarball_filename+'.asc'
 -      },
 -      'filename': {
 -        'tarball': tarball_filename,
 -        'tarball_sig': tarball_filename+'.asc'
 +
 +    if tbb_version:
 +      tarball_filename = 'tor-browser-gnu-linux-'+self.architecture+'-'+tbb_version+'-dev-'+self.language+'.tar.gz'
 +      self.paths['file']['tarball'] = tbb_data+'/download/'+tarball_filename
 +      self.paths['file']['tarball_sig'] = tbb_data+'/download/'+tarball_filename+'.asc'
 +      self.paths['url']['tarball'] = 'https://www.torproject.org/dist/torbrowser/linux/'+tarball_filename
 +      self.paths['url']['tarball_sig'] = 'https://www.torproject.org/dist/torbrowser/linux/'+tarball_filename+'.asc'
 +      self.paths['filename']['tarball'] = tarball_filename
 +      self.paths['filename']['tarball_sig'] = tarball_filename+'.asc'
 +
 +    else:
 +      self.paths = {
 +        'dir': {
 +          'data': tbb_data,
 +          'download': tbb_data+'/download',
 +          'tbb': tbb_data+'/tbb/'+self.architecture,
 +          'gpg': tbb_data+'/gpgtmp'
 +        },
 +        'file': {
 +          'settings': tbb_data+'/settings',
 +          'version': tbb_data+'/version',
 +          'start': tbb_data+'/tbb/'+self.architecture+'/tor-browser_'+self.language+'/start-tor-browser',
 +          'update_check': tbb_data+'/download/RecommendedTBBVersions',
-           'verify': '/usr/share/torbrowser-launcher/verify.sh'
++          'verify': '/usr/share/torbrowser-launcher/verify.sh',
++          'torproject_pem': '/usr/share/torbrowser-launcher/torproject.pem'
 +        },
 +        'url': {
 +          'update_check': 'https://check.torproject.org/RecommendedTBBVersions'
 +        },
 +        'filename': {}
        }
 -    }
  
    # create directories that don't exist
    def mkdirs(self):
@@@ -166,29 -158,27 +192,25 @@@
      self.gui = gui
      self.gui_message = message
      self.gui_tasks = tasks
 +    self.gui_task_i = 0
      self.gui_autostart = autostart
  
 -  # build the application's UI
 -  def build_ui(self):
 -    self.timer = False
 -
 -    # allow buttons to have icons
 -    try:
 -      settings = gtk.settings_get_default()
 -      settings.props.gtk_button_images = True
 -    except:
 -      pass
 +  # set all gtk variables to False
 +  def clear_ui(self):
-     if self.timer:
-       gobject.source_remove(self.timer)
-     self.timer = False
- 
 +    if self.box:
 +      self.box.destroy()
 +    self.box = False
  
 -    # set up the window
 -    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 -    self.window.set_title("Tor Browser")
 -    self.window.set_position(gtk.WIN_POS_CENTER)
 -    self.window.set_border_width(10)
 -    self.window.connect("delete_event", self.delete_event)
 -    self.window.connect("destroy", self.destroy)
 +    self.label1 = False
 +    self.label2 = False
 +    self.label = False
 +    self.progressbar = False
 +    self.button_box = False
 +    self.start_button = False
 +    self.exit_button = False
  
 +  # build the application's UI
 +  def build_ui(self):
      self.box = gtk.VBox(False, 20)
      self.window.add(self.box)
  
@@@ -319,17 -347,13 +387,13 @@@
      self.progressbar.show()
      self.refresh_gtk()
  
-     # start the download
-     self.dl_response = urllib2.urlopen(url)
-     self.dl_total_size = self.dl_response.info().getheader('Content-Length').strip()
-     self.dl_total_size = int(self.dl_total_size)
-     self.dl_bytes_so_far = 0
- 
-     # set a timer to download more chunks
-     self.timer = gobject.timeout_add(1, self.download_chunk, name)
 -    agent = Agent(reactor, VerifyTorProjectCert())
++    agent = Agent(reactor, VerifyTorProjectCert(self.paths['file']['torproject_pem']))
+     d = agent.request('GET', url,
+                       Headers({'User-Agent': ['torbrowser-launcher']}),
+                       None)
  
-     # open a file to write to
      self.file_download = open(path, 'w')
+     d.addCallback(self.response_received).addErrback(self.error)
  
    def download_chunk(self, name):
      # download 10kb a time
@@@ -475,14 -440,20 +539,15 @@@
    def delete_event(self, widget, event, data=None):
      return False
    def destroy(self, widget, data=None):
-     gtk.main_quit()
 -    if self.timer:
 -      gobject.source_remove(self.timer)
 -    self.timer = False
 -
+     self.file_download.close()
+     reactor.stop()
  
  if __name__ == "__main__":
 -  current_tbl_version = '0.1'
 -  current_tbb_version = '2.3.25-2'
 +  tor_browser_launcher_version = '0.1'
  
    print 'Tor Browser Launcher'
 -  print 'version %s' % (current_tbl_version)
 +  print 'version %s' % (tor_browser_launcher_version)
    print 'https://github.com/micahflee/torbrowser-launcher'
  
 -  app = TorBrowserLauncher(current_tbb_version)
 +  app = TorBrowserLauncher()
  

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list