diff options
author | Kali Kaneko <kali@leap.se> | 2013-08-09 18:18:00 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-08-09 18:18:00 +0200 |
commit | e3758f91f58d3a17032860bb17e1643c331c3b0f (patch) | |
tree | 7fb9d8e5a675a093443a4224b0fd70c26d437b0c /src | |
parent | 275109e17f53c2fceb21d6f87626762800f53e22 (diff) | |
parent | b942468aac94be2bf4bb9bc1849391e72c366697 (diff) |
Merge remote-tracking branch 'chiiph/feature/relnotes' into develop
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/_version.py | 9 | ||||
-rw-r--r-- | src/leap/app.py | 14 | ||||
-rw-r--r-- | src/leap/config/providerconfig.py | 17 | ||||
-rw-r--r-- | src/leap/gui/login.py | 6 | ||||
-rw-r--r-- | src/leap/gui/mainwindow.py | 184 | ||||
-rw-r--r-- | src/leap/gui/ui/loggerwindow.ui | 2 | ||||
-rw-r--r-- | src/leap/gui/ui/mainwindow.ui | 8 | ||||
-rw-r--r-- | src/leap/gui/ui/wizard.ui | 8 | ||||
-rw-r--r-- | src/leap/platform_init/initializers.py | 6 | ||||
-rw-r--r-- | src/leap/services/eip/eipconfig.py | 20 | ||||
-rw-r--r-- | src/leap/services/eip/vpnlaunchers.py | 33 | ||||
-rw-r--r-- | src/leap/services/eip/vpnprocess.py | 27 | ||||
-rw-r--r-- | src/leap/services/mail/imap.py | 42 | ||||
-rw-r--r-- | src/leap/services/mail/smtpbootstrapper.py | 8 | ||||
-rw-r--r-- | src/leap/services/mail/smtpconfig.py | 10 | ||||
-rw-r--r-- | src/leap/services/mail/smtpspec.py | 21 | ||||
-rw-r--r-- | src/leap/services/soledad/soledadbootstrapper.py | 50 | ||||
-rw-r--r-- | src/leap/services/soledad/soledadconfig.py | 10 | ||||
-rw-r--r-- | src/leap/services/soledad/soledadspec.py | 21 | ||||
-rw-r--r-- | src/leap/services/tx.py | 2 | ||||
-rw-r--r-- | src/leap/util/leap_argparse.py | 6 |
21 files changed, 350 insertions, 154 deletions
diff --git a/src/leap/_version.py b/src/leap/_version.py index 6f7e3d05..05542975 100644 --- a/src/leap/_version.py +++ b/src/leap/_version.py @@ -16,6 +16,8 @@ git_full = "$Format:%H$" import subprocess import sys +import re +import os.path def run_command(args, cwd=None, verbose=False): @@ -38,11 +40,6 @@ def run_command(args, cwd=None, verbose=False): return stdout -import sys -import re -import os.path - - def get_expanded_variables(versionfile_source): # the code embedded in _version.py can just fetch the value of these # variables. When used from setup.py, we don't want to import @@ -187,7 +184,7 @@ def versions_from_parentdir(parentdir_prefix, versionfile_source, return {"version": dirname[len(parentdir_prefix):], "full": ""} tag_prefix = "" -parentdir_prefix = "leap_client-" +parentdir_prefix = "bitmask-" versionfile_source = "src/leap/_version.py" diff --git a/src/leap/app.py b/src/leap/app.py index 6ba27813..22340d4d 100644 --- a/src/leap/app.py +++ b/src/leap/app.py @@ -142,21 +142,22 @@ def main(): bypass_checks = getattr(opts, 'danger', False) debug = opts.debug logfile = opts.log_file + openvpn_verb = opts.openvpn_verb logger = add_logger_handlers(debug, logfile) replace_stdout_stderr_with_logging(logger) if not we_are_the_one_and_only(): - # leap-client is already running + # Bitmask is already running logger.warning("Tried to launch more than one instance " - "of leap-client. Raising the existing " + "of Bitmask. Raising the existing " "one instead.") sys.exit(1) check_requirements() logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') - logger.info('LEAP client version %s', VERSION) + logger.info('Bitmask version %s', VERSION) logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') logger.info('Starting app') @@ -202,6 +203,7 @@ def main(): window = MainWindow( lambda: twisted_main.quit(app), standalone=standalone, + openvpn_verb=openvpn_verb, bypass_checks=bypass_checks) sigint_window = partial(sigint_handler, window, logger=logger) @@ -210,8 +212,10 @@ def main(): if IS_MAC: window.raise_() - tx_app = leap_services() - assert(tx_app) + # This was a good idea, but for this to work as intended we + # should centralize the start of all services in there. + #tx_app = leap_services() + #assert(tx_app) # Run main loop twisted_main.start(app) diff --git a/src/leap/config/providerconfig.py b/src/leap/config/providerconfig.py index eb097034..f899b17c 100644 --- a/src/leap/config/providerconfig.py +++ b/src/leap/config/providerconfig.py @@ -42,12 +42,25 @@ class ProviderConfig(BaseConfig): def __init__(self): BaseConfig.__init__(self) - def _get_spec(self): + def _get_schema(self): """ - Returns the spec object for the specific configuration + Returns the schema corresponding to the version given. + + :rtype: dict or None if the version is not supported. """ return leap_provider_spec + def _get_spec(self): + """ + Returns the spec object for the specific configuration. + + Override the BaseConfig one because we do not support multiple schemas + for the provider yet. + + :rtype: dict or None if the version is not supported. + """ + return self._get_schema() + def get_api_uri(self): return self._safe_get_value("api_uri") diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py index 3c994597..de0b2d50 100644 --- a/src/leap/gui/login.py +++ b/src/leap/gui/login.py @@ -197,18 +197,18 @@ class LoginWidget(QtGui.QWidget): """ self.ui.lnUser.setEnabled(enabled) self.ui.lnPassword.setEnabled(enabled) - self.ui.btnLogin.setEnabled(enabled) self.ui.chkRemember.setEnabled(enabled) self.ui.cmbProviders.setEnabled(enabled) - def set_cancel(self, enabled=False): + self._set_cancel(not enabled) + + def _set_cancel(self, enabled=False): """ Enables or disables the cancel action in the "log in" process. :param enabled: wether it should be enabled or not :type enabled: bool """ - self.ui.btnLogin.setEnabled(enabled) text = self.tr("Cancel") login_or_cancel = self.cancel_login diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index a1ba4df4..5ace1043 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -45,6 +45,7 @@ from leap.services.eip.providerbootstrapper import ProviderBootstrapper # XXX: Soledad might not work out of the box in Windows, issue #2932 from leap.services.soledad.soledadbootstrapper import SoledadBootstrapper from leap.services.mail.smtpbootstrapper import SMTPBootstrapper +from leap.services.mail import imap from leap.platform_init import IS_WIN, IS_MAC from leap.platform_init.initializers import init_platform @@ -82,7 +83,7 @@ class MainWindow(QtGui.QMainWindow): EIP_STATUS_INDEX = 1 # Keyring - KEYRING_KEY = "leap_client" + KEYRING_KEY = "bitmask" # SMTP PORT_KEY = "port" @@ -94,12 +95,15 @@ class MainWindow(QtGui.QMainWindow): # Signals new_updates = QtCore.Signal(object) raise_window = QtCore.Signal([]) + soledad_ready = QtCore.Signal([]) # We use this flag to detect abnormal terminations user_stopped_eip = False def __init__(self, quit_callback, - standalone=False, bypass_checks=False): + standalone=False, + openvpn_verb=1, + bypass_checks=False): """ Constructor for the client main window @@ -140,6 +144,9 @@ class MainWindow(QtGui.QMainWindow): self.ui.stackedWidget.widget(self.LOGIN_INDEX)) self.ui.loginLayout.addWidget(self._login_widget) + # Signals + # TODO separate logic from ui signals. + self._login_widget.login.connect(self._login) self._login_widget.cancel_login.connect(self._cancel_login) self._login_widget.show_wizard.connect( @@ -210,7 +217,7 @@ class MainWindow(QtGui.QMainWindow): self._smtp_bootstrapper.download_config.connect( self._smtp_bootstrapped_stage) - self._vpn = VPN() + self._vpn = VPN(openvpn_verb=openvpn_verb) self._vpn.qtsigs.state_changed.connect( self._status_panel.update_vpn_state) self._vpn.qtsigs.status_changed.connect( @@ -260,7 +267,9 @@ class MainWindow(QtGui.QMainWindow): self.ui.lblNewUpdates.setVisible(False) self.ui.btnMore.setVisible(False) self.ui.btnMore.clicked.connect(self._updates_details) + self.new_updates.connect(self._react_to_new_updates) + self.soledad_ready.connect(self._start_imap_service) init_platform() @@ -273,6 +282,7 @@ class MainWindow(QtGui.QMainWindow): self._soledad = None self._keymanager = None + self._imap_service = None self._login_defer = None self._download_provider_defer = None @@ -413,11 +423,11 @@ class MainWindow(QtGui.QMainWindow): Parses and displays the updates details """ - msg = self.tr("The LEAPClient app is ready to update, please" + msg = self.tr("The Bitmask app is ready to update, please" " restart the application.") # We assume that if there is nothing in the contents, then - # the LEAPClient bundle is what needs updating. + # the Bitmask bundle is what needs updating. if len(self._updates_content) > 0: files = self._updates_content.split(", ") files_str = "" @@ -645,17 +655,23 @@ class MainWindow(QtGui.QMainWindow): SLOT TRIGGERS: self.ui.action_about_leap.triggered - Display the About LEAP dialog + Display the About Bitmask dialog """ QtGui.QMessageBox.about( - self, self.tr("About LEAP - %s") % (VERSION,), - self.tr("version: <b>%s</b><br>" + self, self.tr("About Bitmask - %s") % (VERSION,), + self.tr("Version: <b>%s</b><br>" + "<br>" + "Bitmask is the Desktop client application for " + "the LEAP platform, supporting encrypted internet " + "proxy, secure email, and secure chat (coming soon).<br>" + "<br>" "LEAP is a non-profit dedicated to giving " "all internet users access to secure " "communication. Our focus is on adapting " "encryption technology to make it easy to use " - "and widely available. " - "<a href=\"https://leap.se\">More about LEAP" + "and widely available. <br>" + "<br>" + "<a href='https://leap.se'>More about LEAP" "</a>") % (VERSION,)) def changeEvent(self, e): @@ -804,7 +820,6 @@ class MainWindow(QtGui.QMainWindow): self._login_widget.set_status(self.tr("Logging in..."), error=False) self._login_widget.set_enabled(False) - self._login_widget.set_cancel(True) if self._login_widget.get_remember() and has_keyring(): # in the keyring and in the settings @@ -832,7 +847,6 @@ class MainWindow(QtGui.QMainWindow): Stops the login sequence. """ logger.debug("Cancelling log in.") - self._login_widget.set_cancel(False) if self._download_provider_defer: logger.debug("Cancelling download provider defer.") @@ -913,7 +927,8 @@ class MainWindow(QtGui.QMainWindow): self._provider_config, self._login_widget.get_user(), self._login_widget.get_password(), - download_if_needed=True) + download_if_needed=True, + standalone=self._standalone) self._download_eip_config() @@ -951,29 +966,41 @@ class MainWindow(QtGui.QMainWindow): passed = data[self._soledad_bootstrapper.PASSED_KEY] if not passed: logger.error(data[self._soledad_bootstrapper.ERROR_KEY]) - else: - logger.debug("Done bootstrapping Soledad") + return - self._soledad = self._soledad_bootstrapper.soledad - self._keymanager = self._soledad_bootstrapper.keymanager + logger.debug("Done bootstrapping Soledad") - if self._provider_config.provides_mx() and \ - self._enabled_services.count(self.MX_SERVICE) > 0: - self._smtp_bootstrapper.run_smtp_setup_checks( - self._provider_config, - self._smtp_config, - True) + self._soledad = self._soledad_bootstrapper.soledad + self._keymanager = self._soledad_bootstrapper.keymanager + + # Ok, now soledad is ready, so we can allow other things that + # depend on soledad to start. + + # this will trigger start_imap_service + self.soledad_ready.emit() + + # TODO connect all these activations to the soledad_ready + # signal so the logic is clearer to follow. + + if self._provider_config.provides_mx() and \ + self._enabled_services.count(self.MX_SERVICE) > 0: + self._smtp_bootstrapper.run_smtp_setup_checks( + self._provider_config, + self._smtp_config, + True) + else: + if self._enabled_services.count(self.MX_SERVICE) > 0: + pass # TODO: show MX status + #self._status_panel.set_eip_status( + # self.tr("%s does not support MX") % + # (self._provider_config.get_domain(),), + # error=True) else: - if self._enabled_services.count(self.MX_SERVICE) > 0: - pass # TODO: show MX status - #self._status_panel.set_eip_status( - # self.tr("%s does not support MX") % - # (self._provider_config.get_domain(),), - # error=True) - else: - pass # TODO: show MX status - #self._status_panel.set_eip_status( - # self.tr("MX is disabled")) + pass # TODO: show MX status + #self._status_panel.set_eip_status( + # self.tr("MX is disabled")) + + # Service control methods: smtp def _smtp_bootstrapped_stage(self, data): """ @@ -991,29 +1018,41 @@ class MainWindow(QtGui.QMainWindow): passed = data[self._smtp_bootstrapper.PASSED_KEY] if not passed: logger.error(data[self._smtp_bootstrapper.ERROR_KEY]) - else: - logger.debug("Done bootstrapping SMTP") - - hosts = self._smtp_config.get_hosts() - # TODO: handle more than one host and define how to choose - if len(hosts) > 0: - hostname = hosts.keys()[0] - logger.debug("Using hostname %s for SMTP" % (hostname,)) - host = hosts[hostname][self.IP_KEY].encode("utf-8") - port = hosts[hostname][self.PORT_KEY] - # TODO: pick local smtp port in a better way - # TODO: Make the encrypted_only configurable - - from leap.mail.smtp import setup_smtp_relay - client_cert = self._eip_config.get_client_cert_path( - self._provider_config) - setup_smtp_relay(port=1234, - keymanager=self._keymanager, - smtp_host=host, - smtp_port=port, - smtp_cert=client_cert, - smtp_key=client_cert, - encrypted_only=False) + return + logger.debug("Done bootstrapping SMTP") + + hosts = self._smtp_config.get_hosts() + # TODO: handle more than one host and define how to choose + if len(hosts) > 0: + hostname = hosts.keys()[0] + logger.debug("Using hostname %s for SMTP" % (hostname,)) + host = hosts[hostname][self.IP_KEY].encode("utf-8") + port = hosts[hostname][self.PORT_KEY] + # TODO: pick local smtp port in a better way + # TODO: Make the encrypted_only configurable + + from leap.mail.smtp import setup_smtp_relay + client_cert = self._eip_config.get_client_cert_path( + self._provider_config) + setup_smtp_relay(port=2013, + keymanager=self._keymanager, + smtp_host=host, + smtp_port=port, + smtp_cert=client_cert, + smtp_key=client_cert, + encrypted_only=False) + + def _start_imap_service(self): + """ + SLOT + TRIGGERS: + soledad_ready + """ + logger.debug('Starting imap service') + + self._imap_service = imap.start_imap_service( + self._soledad, + self._keymanager) def _get_socket_host(self): """ @@ -1068,6 +1107,7 @@ class MainWindow(QtGui.QMainWindow): self._status_panel.eip_started() + # XXX refactor into status_panel method? self._action_eip_startstop.setText(self.tr("Turn OFF")) self._action_eip_startstop.disconnect(self) self._action_eip_startstop.triggered.connect( @@ -1112,7 +1152,7 @@ class MainWindow(QtGui.QMainWindow): self._status_panel.set_global_status( self.tr("Another openvpn instance is already running, and " "could not be stopped because it was not launched by " - "LEAP. Please stop it and try again."), + "Bitmask. Please stop it and try again."), error=True) self._set_eipstatus_off() except VPNLauncherException as e: @@ -1301,7 +1341,6 @@ class MainWindow(QtGui.QMainWindow): """ passed = data[self._provider_bootstrapper.PASSED_KEY] if not passed: - self._login_widget.set_cancel(False) self._login_widget.set_enabled(True) self._login_widget.set_status( self.tr("Unable to connect: Problem with provider")) @@ -1409,6 +1448,9 @@ class MainWindow(QtGui.QMainWindow): """ logger.debug('About to quit, doing cleanup...') + if self._imap_service is not None: + self._imap_service.stop() + if self._srp_auth is not None: if self._srp_auth.get_session_id() is not None or \ self._srp_auth.get_token() is not None: @@ -1421,16 +1463,28 @@ class MainWindow(QtGui.QMainWindow): else: logger.error("No instance of soledad was found.") - logger.debug('Cleaning pidfiles') - self._cleanup_pidfiles() - logger.debug('Terminating vpn') self._vpn.terminate(shutdown=True) + if self._login_defer: + logger.debug("Cancelling login defer.") + self._login_defer.cancel() + + if self._download_provider_defer: + logger.debug("Cancelling download provider defer.") + self._download_provider_defer.cancel() + + # TODO missing any more cancels? + + logger.debug('Cleaning pidfiles') + self._cleanup_pidfiles() + def quit(self): """ Cleanup and tidely close the main window before quitting. """ + # TODO: separate the shutting down of services from the + # UI stuff. self._cleanup_and_quit() self._really_quit = True @@ -1441,14 +1495,6 @@ class MainWindow(QtGui.QMainWindow): if self._logger_window: self._logger_window.close() - if self._login_defer: - logger.debug("Cancelling login defer.") - self._login_defer.cancel() - - if self._download_provider_defer: - logger.debug("Cancelling download provider defer.") - self._download_provider_defer.cancel() - self.close() if self._quit_callback: diff --git a/src/leap/gui/ui/loggerwindow.ui b/src/leap/gui/ui/loggerwindow.ui index 28325cdf..b08428a9 100644 --- a/src/leap/gui/ui/loggerwindow.ui +++ b/src/leap/gui/ui/loggerwindow.ui @@ -15,7 +15,7 @@ </property> <property name="windowIcon"> <iconset resource="../../../../data/resources/mainwindow.qrc"> - <normaloff>:/images/leap-color-big.png</normaloff>:/images/leap-color-big.png</iconset> + <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <layout class="QGridLayout" name="gridLayout"> <item row="2" column="0" colspan="2"> diff --git a/src/leap/gui/ui/mainwindow.ui b/src/leap/gui/ui/mainwindow.ui index 67d78736..ecd3cbe9 100644 --- a/src/leap/gui/ui/mainwindow.ui +++ b/src/leap/gui/ui/mainwindow.ui @@ -11,11 +11,11 @@ </rect> </property> <property name="windowTitle"> - <string>LEAP</string> + <string>Bitmask</string> </property> <property name="windowIcon"> <iconset resource="../../../../data/resources/mainwindow.qrc"> - <normaloff>:/images/leap-color-big.png</normaloff>:/images/leap-color-big.png</iconset> + <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <property name="inputMethodHints"> <set>Qt::ImhHiddenText</set> @@ -166,7 +166,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/leap-color-big.png</pixmap> + <pixmap resource="../../../../data/resources/mainwindow.qrc">:/images/mask-launcher.png</pixmap> </property> <property name="alignment"> <set>Qt::AlignCenter</set> @@ -288,7 +288,7 @@ </action> <action name="action_about_leap"> <property name="text"> - <string>About &LEAP</string> + <string>About &Bitmask</string> </property> </action> <action name="action_help"> diff --git a/src/leap/gui/ui/wizard.ui b/src/leap/gui/ui/wizard.ui index d8acd69a..a8f66bbc 100644 --- a/src/leap/gui/ui/wizard.ui +++ b/src/leap/gui/ui/wizard.ui @@ -11,11 +11,11 @@ </rect> </property> <property name="windowTitle"> - <string>LEAP First run</string> + <string>Bitmask first run</string> </property> <property name="windowIcon"> <iconset resource="../../../../data/resources/mainwindow.qrc"> - <normaloff>:/images/leap-color-big.png</normaloff>:/images/leap-color-big.png</iconset> + <normaloff>:/images/mask-icon.png</normaloff>:/images/mask-icon.png</iconset> </property> <property name="modal"> <bool>true</bool> @@ -31,7 +31,7 @@ <string>Welcome</string> </property> <property name="subTitle"> - <string>This is the LEAP Client first run wizard</string> + <string>This is the Bitmask first run wizard</string> </property> <attribute name="pageId"> <string notr="true">0</string> @@ -733,7 +733,7 @@ <string>Congratulations!</string> </property> <property name="subTitle"> - <string>You have successfully configured the LEAP Client.</string> + <string>You have successfully configured Bitmask.</string> </property> <attribute name="pageId"> <string notr="true">6</string> diff --git a/src/leap/platform_init/initializers.py b/src/leap/platform_init/initializers.py index cc5f6e87..46488250 100644 --- a/src/leap/platform_init/initializers.py +++ b/src/leap/platform_init/initializers.py @@ -84,7 +84,7 @@ def get_missing_updown_dialog(): :rtype: QtGui.QMessageBox instance """ WE_NEED_POWERS = ("To better protect your privacy, " - "LEAP needs administrative privileges " + "Bitmask needs administrative privileges " "to install helper files. " "Do you want to proceed?") msg = QtGui.QMessageBox() @@ -180,7 +180,7 @@ def WindowsInitializer(): if not _windows_has_tap_device(): msg = QtGui.QMessageBox() msg.setWindowTitle(msg.tr("TAP Driver")) - msg.setText(msg.tr("LEAPClient needs to install the necessary drivers " + msg.setText(msg.tr("Bitmask needs to install the necessary drivers " "for Encrypted Internet to work. Would you like to " "proceed?")) msg.setInformativeText(msg.tr("Encrypted Internet uses VPN, which " @@ -306,7 +306,7 @@ def DarwinInitializer(): if not _darwin_has_tun_kext(): msg = QtGui.QMessageBox() msg.setWindowTitle(msg.tr("TUN Driver")) - msg.setText(msg.tr("LEAPClient needs to install the necessary drivers " + msg.setText(msg.tr("Bitmask needs to install the necessary drivers " "for Encrypted Internet to work. Would you like to " "proceed?")) msg.setInformativeText(msg.tr("Encrypted Internet uses VPN, which " diff --git a/src/leap/services/eip/eipconfig.py b/src/leap/services/eip/eipconfig.py index 2f2f6e7c..d69e1fd8 100644 --- a/src/leap/services/eip/eipconfig.py +++ b/src/leap/services/eip/eipconfig.py @@ -138,25 +138,13 @@ class EIPConfig(BaseConfig): BaseConfig.__init__(self) self._api_version = None - def _get_spec(self): + def _get_schema(self): """ - Returns the spec object for the specific configuration - """ - leap_assert(self._api_version is not None, - "You should set the API version.") - - return get_schema(self._api_version) + Returns the schema corresponding to the version given. - def set_api_version(self, version): + :rtype: dict or None if the version is not supported. """ - Sets the supported api version. - - :param api_version: the version of the api supported by the provider. - :type api_version: str - """ - self._api_version = version - leap_assert(get_schema(self._api_version) is not None, - "Version %s is not supported." % (version, )) + return get_schema(self._api_version) def get_clusters(self): # TODO: create an abstraction for clusters diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py index 526f1ba4..17950a25 100644 --- a/src/leap/services/eip/vpnlaunchers.py +++ b/src/leap/services/eip/vpnlaunchers.py @@ -352,7 +352,7 @@ class LinuxVPNLauncher(VPNLauncher): return None def get_vpn_command(self, eipconfig=None, providerconfig=None, - socket_host=None, socket_port="unix"): + socket_host=None, socket_port="unix", openvpn_verb=1): """ Returns the platform dependant vpn launching command. It will look for openvpn in the regular paths and algo in @@ -375,6 +375,9 @@ class LinuxVPNLauncher(VPNLauncher): socket, or port otherwise :type socket_port: str + :param openvpn_verb: openvpn verbosity wanted + :type openvpn_verb: int + :return: A VPN command ready to be launched :rtype: list """ @@ -404,7 +407,8 @@ class LinuxVPNLauncher(VPNLauncher): args.append(openvpn) openvpn = first(pkexec) - # TODO: handle verbosity + if openvpn_verb is not None: + args += ['--verb', '%d' % (openvpn_verb,)] gateway_selector = VPNGatewaySelector(eipconfig) gateways = gateway_selector.get_gateways() @@ -516,9 +520,9 @@ class DarwinVPNLauncher(VPNLauncher): COCOASUDO = "cocoasudo" # XXX need the good old magic translate for these strings # (look for magic in 0.2.0 release) - SUDO_MSG = ("LEAP needs administrative privileges to run " + SUDO_MSG = ("Bitmask needs administrative privileges to run " "Encrypted Internet.") - INSTALL_MSG = ("\"LEAP needs administrative privileges to install " + INSTALL_MSG = ("\"Bitmask needs administrative privileges to install " "missing scripts and fix permissions.\"") INSTALL_PATH = os.path.realpath(os.getcwd() + "/../../") @@ -604,7 +608,7 @@ class DarwinVPNLauncher(VPNLauncher): return self.COCOASUDO, args def get_vpn_command(self, eipconfig=None, providerconfig=None, - socket_host=None, socket_port="unix"): + socket_host=None, socket_port="unix", openvpn_verb=1): """ Returns the platform dependant vpn launching command @@ -623,6 +627,9 @@ class DarwinVPNLauncher(VPNLauncher): socket, or port otherwise :type socket_port: str + :param openvpn_verb: openvpn verbosity wanted + :type openvpn_verb: int + :return: A VPN command ready to be launched :rtype: list """ @@ -651,7 +658,8 @@ class DarwinVPNLauncher(VPNLauncher): openvpn = first(openvpn_possibilities) args = [openvpn] - # TODO: handle verbosity + if openvpn_verb is not None: + args += ['--verb', '%d' % (openvpn_verb,)] gateway_selector = VPNGatewaySelector(eipconfig) gateways = gateway_selector.get_gateways() @@ -768,9 +776,10 @@ class WindowsVPNLauncher(VPNLauncher): OPENVPN_BIN = 'openvpn_leap.exe' # XXX UPDOWN_FILES ... we do not have updown files defined yet! + # (and maybe we won't) def get_vpn_command(self, eipconfig=None, providerconfig=None, - socket_host=None, socket_port="9876"): + socket_host=None, socket_port="9876", openvpn_verb=1): """ Returns the platform dependant vpn launching command. It will look for openvpn in the regular paths and algo in @@ -780,14 +789,20 @@ class WindowsVPNLauncher(VPNLauncher): :param eipconfig: eip configuration object :type eipconfig: EIPConfig + :param providerconfig: provider specific configuration :type providerconfig: ProviderConfig + :param socket_host: either socket path (unix) or socket IP :type socket_host: str + :param socket_port: either string "unix" if it's a unix socket, or port otherwise :type socket_port: str + :param openvpn_verb: the openvpn verbosity wanted + :type openvpn_verb: int + :return: A VPN command ready to be launched :rtype: list """ @@ -810,8 +825,8 @@ class WindowsVPNLauncher(VPNLauncher): openvpn = first(openvpn_possibilities) args = [] - - # TODO: handle verbosity + if openvpn_verb is not None: + args += ['--verb', '%d' % (openvpn_verb,)] gateway_selector = VPNGatewaySelector(eipconfig) gateways = gateway_selector.get_gateways() diff --git a/src/leap/services/eip/vpnprocess.py b/src/leap/services/eip/vpnprocess.py index c4bdb30c..5b07a3cf 100644 --- a/src/leap/services/eip/vpnprocess.py +++ b/src/leap/services/eip/vpnprocess.py @@ -80,7 +80,9 @@ class VPN(object): TERMINATE_MAXTRIES = 10 TERMINATE_WAIT = 1 # secs - def __init__(self): + OPENVPN_VERB = "openvpn_verb" + + def __init__(self, **kwargs): """ Instantiate empty attributes and get a copy of a QObject containing the QSignals that we will pass along @@ -92,6 +94,8 @@ class VPN(object): self._reactor = reactor self._qtsigs = VPNSignals() + self._openvpn_verb = kwargs.get(self.OPENVPN_VERB, None) + @property def qtsigs(self): return self._qtsigs @@ -108,9 +112,12 @@ class VPN(object): """ self._stop_pollers() kwargs['qtsigs'] = self.qtsigs + kwargs['openvpn_verb'] = self._openvpn_verb # start the main vpn subprocess vpnproc = VPNProcess(*args, **kwargs) + #qtsigs=self.qtsigs, + #openvpn_verb=self._openvpn_verb) if vpnproc.get_openvpn_process(): logger.info("Another vpn process is running. Will try to stop it.") @@ -566,7 +573,12 @@ class VPNManager(object): # we should check that cmdline BEGINS # with openvpn or with our wrapper # (pkexec / osascript / whatever) - if "openvpn" in ' '.join(p.cmdline): + + # This needs more work, see #3268, but for the moment + # we need to be able to filter out arguments in the form + # --openvpn-foo, since otherwise we are shooting ourselves + # in the feet. + if any(map(lambda s: s.startswith("openvpn"), p.cmdline)): openvpn_process = p break except psutil.error.AccessDenied: @@ -645,7 +657,7 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager): """ def __init__(self, eipconfig, providerconfig, socket_host, socket_port, - qtsigs): + qtsigs, openvpn_verb): """ :param eipconfig: eip configuration object :type eipconfig: EIPConfig @@ -663,6 +675,10 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager): :param qtsigs: a QObject containing the Qt signals used to notify the UI. :type qtsigs: QObject + + :param openvpn_verb: the desired level of verbosity in the + openvpn invocation + :type openvpn_verb: int """ VPNManager.__init__(self, qtsigs=qtsigs) leap_assert_type(eipconfig, EIPConfig) @@ -682,6 +698,8 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager): self._last_status = None self._alive = False + self._openvpn_verb = openvpn_verb + # processProtocol methods def connectionMade(self): @@ -757,7 +775,8 @@ class VPNProcess(protocol.ProcessProtocol, VPNManager): eipconfig=self._eipconfig, providerconfig=self._providerconfig, socket_host=self._socket_host, - socket_port=self._socket_port) + socket_port=self._socket_port, + openvpn_verb=self._openvpn_verb) return map(str, cmd) # shutdown diff --git a/src/leap/services/mail/imap.py b/src/leap/services/mail/imap.py new file mode 100644 index 00000000..4dceb2ad --- /dev/null +++ b/src/leap/services/mail/imap.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# imap.py +# Copyright (C) 2013 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +""" +Initialization of imap service +""" +import logging +import sys + +from leap.mail.imap.service import imap +from twisted.python import log + +logger = logging.getLogger(__name__) + + +def start_imap_service(*args, **kwargs): + """ + Initializes and run imap service. + + :returns: twisted.internet.task.LoopingCall instance + """ + logger.debug('Launching imap service') + + # Uncomment the next two lines to get a separate debugging log + # TODO handle this by a separate flag. + #log.startLogging(open('/tmp/leap-imap.log', 'w')) + #log.startLogging(sys.stdout) + + return imap.run_service(*args, **kwargs) diff --git a/src/leap/services/mail/smtpbootstrapper.py b/src/leap/services/mail/smtpbootstrapper.py index e8af5349..48040035 100644 --- a/src/leap/services/mail/smtpbootstrapper.py +++ b/src/leap/services/mail/smtpbootstrapper.py @@ -72,10 +72,12 @@ class SMTPBootstrapper(AbstractBootstrapper): if self._download_if_needed and mtime: headers['if-modified-since'] = mtime + api_version = self._provider_config.get_api_version() + # there is some confusion with this uri, config_uri = "%s/%s/config/smtp-service.json" % ( - self._provider_config.get_api_uri(), - self._provider_config.get_api_version()) + self._provider_config.get_api_uri(), api_version) + logger.debug('Downloading SMTP config from: %s' % config_uri) srp_auth = SRPAuth(self._provider_config) @@ -91,6 +93,8 @@ class SMTPBootstrapper(AbstractBootstrapper): cookies=cookies) res.raise_for_status() + self._smtp_config.set_api_version(api_version) + # Not modified if res.status_code == 304: logger.debug("SMTP definition has not been modified") diff --git a/src/leap/services/mail/smtpconfig.py b/src/leap/services/mail/smtpconfig.py index 30371005..ea0f9c37 100644 --- a/src/leap/services/mail/smtpconfig.py +++ b/src/leap/services/mail/smtpconfig.py @@ -21,7 +21,7 @@ SMTP configuration import logging from leap.common.config.baseconfig import BaseConfig -from leap.services.mail.smtpspec import smtp_config_spec +from leap.services.mail.smtpspec import get_schema logger = logging.getLogger(__name__) @@ -34,11 +34,13 @@ class SMTPConfig(BaseConfig): def __init__(self): BaseConfig.__init__(self) - def _get_spec(self): + def _get_schema(self): """ - Returns the spec object for the specific configuration + Returns the schema corresponding to the version given. + + :rtype: dict or None if the version is not supported. """ - return smtp_config_spec + return get_schema(self._api_version) def get_hosts(self): return self._safe_get_value("hosts") diff --git a/src/leap/services/mail/smtpspec.py b/src/leap/services/mail/smtpspec.py index 270dfb76..ff9d1bf8 100644 --- a/src/leap/services/mail/smtpspec.py +++ b/src/leap/services/mail/smtpspec.py @@ -15,7 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -smtp_config_spec = { +# Schemas dict +# To add a schema for a version you should follow the form: +# { '1': schema_v1, '2': schema_v2, ... etc } +# so for instance, to add the '2' version, you should do: +# smtp_config_spec['2'] = schema_v2 +smtp_config_spec = {} + +smtp_config_spec['1'] = { 'description': 'sample smtp service config', 'type': 'object', 'properties': { @@ -49,3 +56,15 @@ smtp_config_spec = { } } } + + +def get_schema(version): + """ + Returns the schema corresponding to the version given. + + :param version: the version of the schema to get. + :type version: str + :rtype: dict or None if the version is not supported. + """ + schema = smtp_config_spec.get(version, None) + return schema diff --git a/src/leap/services/soledad/soledadbootstrapper.py b/src/leap/services/soledad/soledadbootstrapper.py index ac3243c1..c67bc004 100644 --- a/src/leap/services/soledad/soledadbootstrapper.py +++ b/src/leap/services/soledad/soledadbootstrapper.py @@ -23,6 +23,7 @@ import logging import os from PySide import QtCore +from u1db import errors as u1db_errors from leap.common.check import leap_assert, leap_assert_type from leap.common.files import get_mtime @@ -103,15 +104,18 @@ class SoledadBootstrapper(AbstractBootstrapper): # TODO: If selected server fails, retry with another host # (issue #3309) - self._soledad = Soledad(uuid, - self._password.encode("utf-8"), - secrets_path=secrets_path, - local_db_path=local_db_path, - server_url=server_url, - cert_file=cert_file, - auth_token=srp_auth.get_token()) - - self._soledad.sync() + try: + self._soledad = Soledad( + uuid, + self._password.encode("utf-8"), + secrets_path=secrets_path, + local_db_path=local_db_path, + server_url=server_url, + cert_file=cert_file, + auth_token=srp_auth.get_token()) + self._soledad.sync() + except u1db_errors.Unauthorized: + logger.error("Error while initializing soledad.") else: raise Exception("No soledad server found") @@ -139,10 +143,12 @@ class SoledadBootstrapper(AbstractBootstrapper): if self._download_if_needed and mtime: headers['if-modified-since'] = mtime + api_version = self._provider_config.get_api_version() + # there is some confusion with this uri, config_uri = "%s/%s/config/soledad-service.json" % ( self._provider_config.get_api_uri(), - self._provider_config.get_api_version()) + api_version) logger.debug('Downloading soledad config from: %s' % config_uri) srp_auth = SRPAuth(self._provider_config) @@ -158,6 +164,8 @@ class SoledadBootstrapper(AbstractBootstrapper): cookies=cookies) res.raise_for_status() + self._soledad_config.set_api_version(api_version) + # Not modified if res.status_code == 304: logger.debug("Soledad definition has not been modified") @@ -190,6 +198,14 @@ class SoledadBootstrapper(AbstractBootstrapper): logger.debug("Retrieving key for %s" % (address,)) srp_auth = SRPAuth(self._provider_config) + + # TODO: Fix for Windows + gpgbin = "/usr/bin/gpg" + + if self._standalone: + gpgbin = os.path.join(self._provider_config.get_path_prefix(), + "..", "apps", "mail", "gpg") + self._keymanager = KeyManager( address, "https://nicknym.%s:6425" % (self._provider_config.get_domain(),), @@ -199,7 +215,8 @@ class SoledadBootstrapper(AbstractBootstrapper): ca_cert_path=self._provider_config.get_ca_cert_path(), api_uri=self._provider_config.get_api_uri(), api_version=self._provider_config.get_api_version(), - uid=srp_auth.get_uid()) + uid=srp_auth.get_uid(), + gpgbinary=gpgbin) try: self._keymanager.get_key(address, openpgp.OpenPGPKey, private=True, fetch_remote=False) @@ -213,7 +230,8 @@ class SoledadBootstrapper(AbstractBootstrapper): provider_config, user, password, - download_if_needed=False): + download_if_needed=False, + standalone=False): """ Starts the checks needed for a new soledad setup @@ -223,6 +241,13 @@ class SoledadBootstrapper(AbstractBootstrapper): :type user: str :param password: User's password :type password: str + :param download_if_needed: If True, it will only download + files if the have changed since the + time it was previously downloaded. + :type download_if_needed: bool + :param standalone: If True, it'll look for paths inside the + bundle (like for gpg) + :type standalone: bool """ leap_assert_type(provider_config, ProviderConfig) @@ -230,6 +255,7 @@ class SoledadBootstrapper(AbstractBootstrapper): self._download_if_needed = download_if_needed self._user = user self._password = password + self._standalone = standalone cb_chain = [ (self._download_config, self.download_config), diff --git a/src/leap/services/soledad/soledadconfig.py b/src/leap/services/soledad/soledadconfig.py index 80a82d11..a2367692 100644 --- a/src/leap/services/soledad/soledadconfig.py +++ b/src/leap/services/soledad/soledadconfig.py @@ -21,7 +21,7 @@ Soledad configuration import logging from leap.common.config.baseconfig import BaseConfig -from leap.services.soledad.soledadspec import soledad_config_spec +from leap.services.soledad.soledadspec import get_schema logger = logging.getLogger(__name__) @@ -34,11 +34,13 @@ class SoledadConfig(BaseConfig): def __init__(self): BaseConfig.__init__(self) - def _get_spec(self): + def _get_schema(self): """ - Returns the spec object for the specific configuration + Returns the schema corresponding to the version given. + + :rtype: dict or None if the version is not supported. """ - return soledad_config_spec + return get_schema(self._api_version) def get_hosts(self): return self._safe_get_value("hosts") diff --git a/src/leap/services/soledad/soledadspec.py b/src/leap/services/soledad/soledadspec.py index 8233d6a0..111175dd 100644 --- a/src/leap/services/soledad/soledadspec.py +++ b/src/leap/services/soledad/soledadspec.py @@ -15,7 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -soledad_config_spec = { +# Schemas dict +# To add a schema for a version you should follow the form: +# { '1': schema_v1, '2': schema_v2, ... etc } +# so for instance, to add the '2' version, you should do: +# soledad_config_spec['2'] = schema_v2 +soledad_config_spec = {} + +soledad_config_spec['1'] = { 'description': 'sample soledad service config', 'type': 'object', 'properties': { @@ -55,3 +62,15 @@ soledad_config_spec = { } } } + + +def get_schema(version): + """ + Returns the schema corresponding to the version given. + + :param version: the version of the schema to get. + :type version: str + :rtype: dict or None if the version is not supported. + """ + schema = soledad_config_spec.get(version, None) + return schema diff --git a/src/leap/services/tx.py b/src/leap/services/tx.py index ef08fcc6..7da1cb01 100644 --- a/src/leap/services/tx.py +++ b/src/leap/services/tx.py @@ -40,7 +40,7 @@ def leap_services(): register them. """ logger.debug('starting leap services') - application = Application("LEAP Client Local Services") + application = Application("Bitmask Local Services") #lc = LoopingCall(task) #lc.start(5) return application diff --git a/src/leap/util/leap_argparse.py b/src/leap/util/leap_argparse.py index bdf80401..f60c4e10 100644 --- a/src/leap/util/leap_argparse.py +++ b/src/leap/util/leap_argparse.py @@ -27,9 +27,9 @@ def build_parser(): """ epilog = "Copyright 2012 The LEAP Encryption Access Project" parser = argparse.ArgumentParser(description=""" -Launches the LEAP Client""", epilog=epilog) +Launches Bitmask""", epilog=epilog) parser.add_argument('-d', '--debug', action="store_true", - help=("Launches client in debug mode, writing debug" + help=("Launches Bitmask in debug mode, writing debug" "info to stdout")) # TODO: when we are ready to disable the --danger flag remove 'True or ' if True or not IS_RELEASE_VERSION: @@ -45,7 +45,7 @@ Launches the LEAP Client""", epilog=epilog) action="store", dest="openvpn_verb", help='verbosity level for openvpn logs [1-6]') parser.add_argument('-s', '--standalone', action="store_true", - help='Makes the client use standalone' + help='Makes Bitmask use standalone' 'directories for configuration and binary' 'searching') |