summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/app.py16
-rw-r--r--src/leap/bitmask/config/flags.py32
-rw-r--r--src/leap/bitmask/config/leapsettings.py15
-rw-r--r--src/leap/bitmask/config/providerconfig.py11
-rw-r--r--src/leap/bitmask/crypto/srpauth.py7
-rw-r--r--src/leap/bitmask/gui/mainwindow.py18
-rw-r--r--src/leap/bitmask/gui/preferenceswindow.py16
-rw-r--r--src/leap/bitmask/gui/wizard.py20
-rw-r--r--src/leap/bitmask/services/__init__.py14
-rw-r--r--src/leap/bitmask/services/eip/eipbootstrapper.py1
-rw-r--r--src/leap/bitmask/services/eip/eipconfig.py10
-rw-r--r--src/leap/bitmask/services/eip/providerbootstrapper.py6
-rw-r--r--src/leap/bitmask/services/eip/vpnlaunchers.py68
-rw-r--r--src/leap/bitmask/services/eip/vpnprocess.py2
-rw-r--r--src/leap/bitmask/services/mail/smtpconfig.py10
-rw-r--r--src/leap/bitmask/services/soledad/soledadbootstrapper.py24
-rw-r--r--src/leap/bitmask/util/__init__.py7
-rw-r--r--src/leap/bitmask/util/log_silencer.py9
18 files changed, 126 insertions, 160 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py
index dae6b357..02b1693d 100644
--- a/src/leap/bitmask/app.py
+++ b/src/leap/bitmask/app.py
@@ -78,7 +78,7 @@ def install_qtreactor(logger):
logger.debug("Qt4 reactor installed")
-def add_logger_handlers(debug=False, logfile=None, standalone=False):
+def add_logger_handlers(debug=False, logfile=None):
"""
Create the logger and attach the handlers.
@@ -107,7 +107,7 @@ def add_logger_handlers(debug=False, logfile=None, standalone=False):
console.setLevel(level)
console.setFormatter(formatter)
- silencer = log_silencer.SelectiveSilencerFilter(standalone=standalone)
+ silencer = log_silencer.SelectiveSilencerFilter()
console.addFilter(silencer)
logger.addHandler(console)
logger.debug('Console handler plugged!')
@@ -174,12 +174,10 @@ def main():
# Given how paths and bundling works, we need to delay the imports
# of certain parts that depend on this path settings.
# So first we set all the places where standalone might be queried.
- from leap.bitmask.config.providerconfig import ProviderConfig
+ from leap.bitmask.config import flags
from leap.common.config.baseconfig import BaseConfig
- from leap.bitmask.services.eip.eipconfig import EIPConfig
+ flags.STANDALONE = standalone
BaseConfig.standalone = standalone
- ProviderConfig.standalone = standalone
- EIPConfig.standalone = standalone
# And then we import all the other stuff
from leap.bitmask.gui import locale_rc
@@ -192,7 +190,7 @@ def main():
# pylint: avoid unused import
assert(locale_rc)
- logger = add_logger_handlers(debug, logfile, standalone)
+ logger = add_logger_handlers(debug, logfile)
replace_stdout_stderr_with_logging(logger)
if not we_are_the_one_and_only():
@@ -210,9 +208,6 @@ def main():
logger.info('Starting app')
- ProviderConfig.standalone = standalone
- EIPConfig.standalone = standalone
-
# We force the style if on KDE so that it doesn't load all the kde
# libs, which causes a compatibility issue in some systems.
# For more info, see issue #3194
@@ -253,7 +248,6 @@ def main():
window = MainWindow(
lambda: twisted_main.quit(app),
- standalone=standalone,
openvpn_verb=openvpn_verb,
bypass_checks=bypass_checks)
diff --git a/src/leap/bitmask/config/flags.py b/src/leap/bitmask/config/flags.py
new file mode 100644
index 00000000..98395def
--- /dev/null
+++ b/src/leap/bitmask/config/flags.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+# flags.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/>.
+"""
+This file is meant to be used to store global flags that affect the
+application.
+
+WARNING: You should NOT use this kind of flags unless you're sure of what
+ you're doing, and someone else tells you that you're right.
+ Most of the times there is a better and safer alternative.
+"""
+
+# The STANDALONE flag is used to:
+# - define a different set of messages for the application when is running
+# inside of a bundle or installed system wide.
+# - use a relative or system wide path to find the configuration files.
+# - search for binaries inside the bundled app instead of the system ones.
+# e.g.: openvpn, gpg
+STANDALONE = False
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index 7d8b5977..338fa475 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -24,7 +24,7 @@ import logging
from PySide import QtCore
from leap.common.check import leap_assert, leap_assert_type
-from leap.common.config import get_path_prefix
+from leap.bitmask.util import get_path_prefix
logger = logging.getLogger(__name__)
@@ -71,15 +71,8 @@ class LeapSettings(object):
# values
GATEWAY_AUTOMATIC = "Automatic"
- def __init__(self, standalone=False):
- """
- Constructor
-
- :param standalone: parameter used to define the location of the config.
- :type standalone: bool
- """
- self._path_prefix = get_path_prefix(standalone=standalone)
- settings_path = os.path.join(self._path_prefix,
+ def __init__(self):
+ settings_path = os.path.join(get_path_prefix(),
"leap", self.CONFIG_NAME)
self._settings = QtCore.QSettings(settings_path,
@@ -132,7 +125,7 @@ class LeapSettings(object):
# other things, not just the directories
providers = []
try:
- providers_path = os.path.join(self._path_prefix,
+ providers_path = os.path.join(get_path_prefix(),
"leap", "providers")
providers = os.listdir(providers_path)
except Exception as e:
diff --git a/src/leap/bitmask/config/providerconfig.py b/src/leap/bitmask/config/providerconfig.py
index a7808399..c8c8a59e 100644
--- a/src/leap/bitmask/config/providerconfig.py
+++ b/src/leap/bitmask/config/providerconfig.py
@@ -21,10 +21,11 @@ Provider configuration
import logging
import os
-from leap.bitmask.config.provider_spec import leap_provider_spec
from leap.common.check import leap_check
from leap.common.config.baseconfig import BaseConfig, LocalizedKey
+from leap.bitmask.config.provider_spec import leap_provider_spec
from leap.bitmask.services import get_service_display_name
+from leap.bitmask.util import get_path_prefix
logger = logging.getLogger(__name__)
@@ -151,13 +152,9 @@ class ProviderConfig(BaseConfig):
:type about_to_download: bool
"""
- cert_path = os.path.join(self.get_path_prefix(),
- "leap",
- "providers",
+ cert_path = os.path.join(get_path_prefix(), "leap", "providers",
self.get_domain(),
- "keys",
- "ca",
- "cacert.pem")
+ "keys", "ca", "cacert.pem")
if not about_to_download:
cert_exists = os.path.exists(cert_path)
diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py
index 776fb2cc..8477ea9e 100644
--- a/src/leap/bitmask/crypto/srpauth.py
+++ b/src/leap/bitmask/crypto/srpauth.py
@@ -171,6 +171,9 @@ class SRPAuth(QtCore.QObject):
self._srp_user = None
self._srp_a = None
+ # Error msg displayed if the username or the password is invalid
+ self._WRONG_USER_PASS = self.tr("Invalid username or password.")
+
# User credentials stored for password changing checks
self._username = None
self._password = None
@@ -265,7 +268,7 @@ class SRPAuth(QtCore.QObject):
"Status code = %r. Content: %r" %
(init_session.status_code, content))
if init_session.status_code == 422:
- raise SRPAuthUnknownUser(self.tr("Unknown user"))
+ raise SRPAuthUnknownUser(self._WRONG_USER_PASS)
raise SRPAuthBadStatusCode(self.tr("There was a problem with"
" authentication"))
@@ -354,7 +357,7 @@ class SRPAuth(QtCore.QObject):
"received: %s", (content,))
logger.error("[%s] Wrong password (HAMK): [%s]" %
(auth_result.status_code, error))
- raise SRPAuthBadPassword(self.tr("Wrong password"))
+ raise SRPAuthBadPassword(self._WRONG_USER_PASS)
if auth_result.status_code not in (200,):
logger.error("No valid response (HAMK): "
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 37bbf1c4..69e36328 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -28,6 +28,7 @@ import keyring
from PySide import QtCore, QtGui
from twisted.internet import threads
+from leap.bitmask.config import flags
from leap.bitmask.config.leapsettings import LeapSettings
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpauth import SRPAuth
@@ -107,7 +108,6 @@ class MainWindow(QtGui.QMainWindow):
user_stopped_eip = False
def __init__(self, quit_callback,
- standalone=False,
openvpn_verb=1,
bypass_checks=False):
"""
@@ -117,10 +117,6 @@ class MainWindow(QtGui.QMainWindow):
the application.
:type quit_callback: callable
- :param standalone: Set to true if the app should use configs
- inside its pwd
- :type standalone: bool
-
:param bypass_checks: Set to true if the app should bypass
first round of checks for CA
certificates at bootstrap
@@ -147,7 +143,7 @@ class MainWindow(QtGui.QMainWindow):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
- self._settings = LeapSettings(standalone)
+ self._settings = LeapSettings()
self._login_widget = LoginWidget(
self._settings,
@@ -176,7 +172,6 @@ class MainWindow(QtGui.QMainWindow):
# This is loaded only once, there's a bug when doing that more
# than once
- self._standalone = standalone
self._provider_config = ProviderConfig()
# Used for automatic start of EIP
self._provisional_provider_config = ProviderConfig()
@@ -306,8 +301,7 @@ class MainWindow(QtGui.QMainWindow):
if self._first_run():
self._wizard_firstrun = True
- self._wizard = Wizard(standalone=standalone,
- bypass_checks=bypass_checks)
+ self._wizard = Wizard(bypass_checks=bypass_checks)
# Give this window time to finish init and then show the wizard
QtCore.QTimer.singleShot(1, self._launch_wizard)
self._wizard.accepted.connect(self._finish_init)
@@ -412,8 +406,7 @@ class MainWindow(QtGui.QMainWindow):
Displays the preferences window.
"""
- preferences_window = PreferencesWindow(
- self, self._srp_auth, self._settings, self._standalone)
+ preferences_window = PreferencesWindow(self, self._srp_auth)
if self._soledad_ready:
preferences_window.set_soledad_ready(self._soledad)
@@ -965,8 +958,7 @@ class MainWindow(QtGui.QMainWindow):
self._provider_config,
self._login_widget.get_user(),
self._login_widget.get_password(),
- download_if_needed=True,
- standalone=self._standalone)
+ download_if_needed=True)
self._download_eip_config()
diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py
index 1becfb18..2d17f6c2 100644
--- a/src/leap/bitmask/gui/preferenceswindow.py
+++ b/src/leap/bitmask/gui/preferenceswindow.py
@@ -24,6 +24,7 @@ import logging
from functools import partial
from PySide import QtCore, QtGui
+from leap.bitmask.config.leapsettings import LeapSettings
from leap.bitmask.gui.ui_preferences import Ui_Preferences
from leap.soledad.client import NoStorageSecret
from leap.bitmask.crypto.srpauth import SRPAuthBadPassword
@@ -40,26 +41,18 @@ class PreferencesWindow(QtGui.QDialog):
"""
Window that displays the preferences.
"""
-
- WEAK_PASSWORDS = ("123456", "qweasd", "qwerty", "password")
-
- def __init__(self, parent, srp_auth, leap_settings, standalone):
+ def __init__(self, parent, srp_auth):
"""
:param parent: parent object of the PreferencesWindow.
:parent type: QWidget
:param srp_auth: SRPAuth object configured in the main app.
:type srp_auth: SRPAuth
- :param standalone: If True, the application is running as standalone
- and the preferences dialog should display some
- messages according to this.
- :type standalone: bool
"""
QtGui.QDialog.__init__(self, parent)
self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")
self._srp_auth = srp_auth
- self._settings = leap_settings
- self._standalone = standalone
+ self._settings = LeapSettings()
self._soledad = None
# Load UI
@@ -325,8 +318,7 @@ class PreferencesWindow(QtGui.QDialog):
for service in services:
try:
checkbox = QtGui.QCheckBox(self)
- service_label = get_service_display_name(
- service, self._standalone)
+ service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.vlServices.addWidget(checkbox)
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index e004e6cf..45734b81 100644
--- a/src/leap/bitmask/gui/wizard.py
+++ b/src/leap/bitmask/gui/wizard.py
@@ -27,6 +27,7 @@ from functools import partial
from PySide import QtCore, QtGui
from twisted.internet import threads
+from leap.bitmask.config import flags
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpregister import SRPRegister
from leap.bitmask.util.privilege_policies import is_missing_policy_permissions
@@ -58,21 +59,16 @@ class Wizard(QtGui.QWizard):
BARE_USERNAME_REGEX = r"^[A-Za-z\d_]+$"
- def __init__(self, standalone=False, bypass_checks=False):
+ def __init__(self, bypass_checks=False):
"""
Constructor for the main Wizard.
- :param standalone: If True, the application is running as standalone
- and the wizard should display some messages according to this.
- :type standalone: bool
:param bypass_checks: Set to true if the app should bypass
first round of checks for CA certificates at bootstrap
:type bypass_checks: bool
"""
QtGui.QWizard.__init__(self)
- self.standalone = standalone
-
self.ui = Ui_Wizard()
self.ui.setupUi(self)
@@ -489,8 +485,7 @@ class Wizard(QtGui.QWizard):
try:
if service not in self._shown_services:
checkbox = QtGui.QCheckBox(self)
- service_label = get_service_display_name(
- service, self.standalone)
+ service_label = get_service_display_name(service)
checkbox.setText(service_label)
self.ui.serviceListLayout.addWidget(checkbox)
@@ -555,15 +550,6 @@ class Wizard(QtGui.QWizard):
if pageId == self.SERVICES_PAGE:
self._populate_services()
- def _is_need_eip_password_warning(self):
- """
- Returns True if we need to add a warning about eip needing
- administrative permissions to start. That can be either
- because we are running in standalone mode, or because we could
- not find the needed privilege escalation mechanisms being operative.
- """
- return self.standalone or is_missing_policy_permissions()
-
def nextId(self):
"""
Sets the next page id for the wizard based on wether the user
diff --git a/src/leap/bitmask/services/__init__.py b/src/leap/bitmask/services/__init__.py
index 2646235d..afce72f6 100644
--- a/src/leap/bitmask/services/__init__.py
+++ b/src/leap/bitmask/services/__init__.py
@@ -22,10 +22,12 @@ import os
from PySide import QtCore
+from leap.bitmask.config import flags
from leap.bitmask.crypto.srpauth import SRPAuth
from leap.bitmask.util.constants import REQUEST_TIMEOUT
from leap.bitmask.util.privilege_policies import is_missing_policy_permissions
from leap.bitmask.util.request_helpers import get_content
+from leap.bitmask.util import get_path_prefix
from leap.common.check import leap_assert
from leap.common.config.baseconfig import BaseConfig
@@ -37,7 +39,7 @@ logger = logging.getLogger(__name__)
DEPLOYED = ["openvpn", "mx"]
-def get_service_display_name(service, standalone=False):
+def get_service_display_name(service):
"""
Returns the name to display of the given service.
If there is no configured name for that service, then returns the same
@@ -45,9 +47,6 @@ def get_service_display_name(service, standalone=False):
:param service: the 'machine' service name
:type service: str
- :param standalone: True if the app is running in a standalone mode, used
- to display messages according that.
- :type standalone: bool
:rtype: str
"""
@@ -67,7 +66,7 @@ def get_service_display_name(service, standalone=False):
# administrative permissions to start. That can be either
# because we are running in standalone mode, or because we could
# not find the needed privilege escalation mechanisms being operative.
- if standalone or is_missing_policy_permissions():
+ if flags.STANDALONE or is_missing_policy_permissions():
EIP_LABEL += " " + _tr("(will need admin password to start)")
return service_display.get(service, service)
@@ -106,9 +105,8 @@ def download_service_config(provider_config, service_config,
service_name = service_config.name
service_json = "{0}-service.json".format(service_name)
headers = {}
- mtime = get_mtime(os.path.join(service_config.get_path_prefix(),
- "leap",
- "providers",
+ mtime = get_mtime(os.path.join(get_path_prefix(),
+ "leap", "providers",
provider_config.get_domain(),
service_json))
if download_if_needed and mtime:
diff --git a/src/leap/bitmask/services/eip/eipbootstrapper.py b/src/leap/bitmask/services/eip/eipbootstrapper.py
index 5a238a1c..885c4420 100644
--- a/src/leap/bitmask/services/eip/eipbootstrapper.py
+++ b/src/leap/bitmask/services/eip/eipbootstrapper.py
@@ -28,6 +28,7 @@ from leap.bitmask.services import download_service_config
from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper
from leap.bitmask.services.eip.eipconfig import EIPConfig
from leap.common import certs as leap_certs
+from leap.bitmask.util import get_path_prefix
from leap.common.check import leap_assert, leap_assert_type
from leap.common.files import check_and_fix_urw_only
diff --git a/src/leap/bitmask/services/eip/eipconfig.py b/src/leap/bitmask/services/eip/eipconfig.py
index 2241290b..466a644c 100644
--- a/src/leap/bitmask/services/eip/eipconfig.py
+++ b/src/leap/bitmask/services/eip/eipconfig.py
@@ -28,6 +28,7 @@ import ipaddr
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.services import ServiceConfig
from leap.bitmask.services.eip.eipspec import get_schema
+from leap.bitmask.util import get_path_prefix
from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
@@ -238,13 +239,10 @@ class EIPConfig(ServiceConfig):
leap_assert(providerconfig, "We need a provider")
leap_assert_type(providerconfig, ProviderConfig)
- cert_path = os.path.join(self.get_path_prefix(),
- "leap",
- "providers",
+ cert_path = os.path.join(get_path_prefix(),
+ "leap", "providers",
providerconfig.get_domain(),
- "keys",
- "client",
- "openvpn.pem")
+ "keys", "client", "openvpn.pem")
if not about_to_download:
leap_assert(os.path.exists(cert_path),
diff --git a/src/leap/bitmask/services/eip/providerbootstrapper.py b/src/leap/bitmask/services/eip/providerbootstrapper.py
index ac3a44db..3b7c9899 100644
--- a/src/leap/bitmask/services/eip/providerbootstrapper.py
+++ b/src/leap/bitmask/services/eip/providerbootstrapper.py
@@ -28,6 +28,7 @@ from PySide import QtCore
from leap.bitmask.config.providerconfig import ProviderConfig, MissingCACert
from leap.bitmask.util.request_helpers import get_content
+from leap.bitmask.util import get_path_prefix
from leap.bitmask.util.constants import REQUEST_TIMEOUT
from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper
from leap.bitmask.provider.supportedapis import SupportedAPIs
@@ -133,9 +134,8 @@ class ProviderBootstrapper(AbstractBootstrapper):
headers = {}
- provider_json = os.path.join(
- ProviderConfig().get_path_prefix(), "leap", "providers",
- self._domain, "provider.json")
+ provider_json = os.path.join(get_path_prefix(), "leap", "providers",
+ self._domain, "provider.json")
mtime = get_mtime(provider_json)
if self._download_if_needed and mtime:
diff --git a/src/leap/bitmask/services/eip/vpnlaunchers.py b/src/leap/bitmask/services/eip/vpnlaunchers.py
index a50da8b9..daa0d81f 100644
--- a/src/leap/bitmask/services/eip/vpnlaunchers.py
+++ b/src/leap/bitmask/services/eip/vpnlaunchers.py
@@ -34,16 +34,19 @@ from abc import ABCMeta, abstractmethod
from functools import partial
from time import sleep
+from leap.bitmask.config import flags
from leap.bitmask.config.leapsettings import LeapSettings
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.services.eip.eipconfig import EIPConfig, VPNGatewaySelector
from leap.bitmask.util import first
+from leap.bitmask.util import get_path_prefix
from leap.bitmask.util.privilege_policies import LinuxPolicyChecker
from leap.bitmask.util import privilege_policies
from leap.common.check import leap_assert, leap_assert_type
from leap.common.files import which
+
logger = logging.getLogger(__name__)
@@ -98,15 +101,12 @@ class VPNLauncher(object):
return []
@abstractmethod
- def get_vpn_env(self, providerconfig):
+ def get_vpn_env(self):
"""
Returns a dictionary with the custom env for the platform.
This is mainly used for setting LD_LIBRARY_PATH to the correct
path when distributing a standalone client
- :param providerconfig: provider specific configuration
- :type providerconfig: ProviderConfig
-
:rtype: dict
"""
return {}
@@ -220,14 +220,13 @@ def _is_auth_agent_running():
return any(is_running)
-def _try_to_launch_agent(standalone=False):
+def _try_to_launch_agent():
"""
Tries to launch a polkit daemon.
"""
env = None
- if standalone is True:
- env = {
- "PYTHONPATH": os.path.abspath('../../../../lib/')}
+ if flags.STANDALONE is True:
+ env = {"PYTHONPATH": os.path.abspath('../../../../lib/')}
try:
# We need to quote the command because subprocess call
# will do "sh -c 'foo'", so if we do not quoute it we'll end
@@ -247,8 +246,7 @@ class LinuxVPNLauncher(VPNLauncher):
PKEXEC_BIN = 'pkexec'
OPENVPN_BIN = 'openvpn'
OPENVPN_BIN_PATH = os.path.join(
- ProviderConfig().get_path_prefix(),
- "..", "apps", "eip", OPENVPN_BIN)
+ get_path_prefix(), "..", "apps", "eip", OPENVPN_BIN)
SYSTEM_CONFIG = "/etc/leap"
UP_DOWN_FILE = "resolv-update"
@@ -320,7 +318,7 @@ class LinuxVPNLauncher(VPNLauncher):
"""
if _is_pkexec_in_system():
if not _is_auth_agent_running():
- _try_to_launch_agent(ProviderConfig.standalone)
+ _try_to_launch_agent()
sleep(0.5)
if _is_auth_agent_running():
pkexec_possibilities = which(kls.PKEXEC_BIN)
@@ -397,10 +395,9 @@ class LinuxVPNLauncher(VPNLauncher):
leap_assert(socket_port, "We need a socket port!")
kwargs = {}
- if ProviderConfig.standalone:
+ if flags.STANDALONE:
kwargs['path_extension'] = os.path.join(
- providerconfig.get_path_prefix(),
- "..", "apps", "eip")
+ get_path_prefix(), "..", "apps", "eip")
openvpn_possibilities = which(self.OPENVPN_BIN, **kwargs)
@@ -423,7 +420,7 @@ class LinuxVPNLauncher(VPNLauncher):
args += ['--verb', '%d' % (openvpn_verb,)]
gateways = []
- leap_settings = LeapSettings(ProviderConfig.standalone)
+ leap_settings = LeapSettings()
domain = providerconfig.get_domain()
gateway_conf = leap_settings.get_selected_gateway(domain)
@@ -513,23 +510,17 @@ class LinuxVPNLauncher(VPNLauncher):
return [openvpn] + args
- def get_vpn_env(self, providerconfig):
+ def get_vpn_env(self):
"""
Returns a dictionary with the custom env for the platform.
This is mainly used for setting LD_LIBRARY_PATH to the correct
path when distributing a standalone client
- :param providerconfig: provider specific configuration
- :type providerconfig: ProviderConfig
-
:rtype: dict
"""
- leap_assert(providerconfig, "We need a provider config")
- leap_assert_type(providerconfig, ProviderConfig)
-
- return {"LD_LIBRARY_PATH": os.path.join(
- providerconfig.get_path_prefix(),
- "..", "lib")}
+ return {
+ "LD_LIBRARY_PATH": os.path.join(get_path_prefix(), "..", "lib")
+ }
class DarwinVPNLauncher(VPNLauncher):
@@ -664,10 +655,9 @@ class DarwinVPNLauncher(VPNLauncher):
raise EIPNoTunKextLoaded
kwargs = {}
- if ProviderConfig.standalone:
+ if flags.STANDALONE:
kwargs['path_extension'] = os.path.join(
- providerconfig.get_path_prefix(),
- "..", "apps", "eip")
+ get_path_prefix(), "..", "apps", "eip")
openvpn_possibilities = which(
self.OPENVPN_BIN,
@@ -686,7 +676,7 @@ class DarwinVPNLauncher(VPNLauncher):
args += ['--verb', '%d' % (openvpn_verb,)]
gateways = []
- leap_settings = LeapSettings(ProviderConfig.standalone)
+ leap_settings = LeapSettings()
domain = providerconfig.get_domain()
gateway_conf = leap_settings.get_selected_gateway(domain)
@@ -787,20 +777,17 @@ class DarwinVPNLauncher(VPNLauncher):
return [command] + cmd_args
- def get_vpn_env(self, providerconfig):
+ def get_vpn_env(self):
"""
Returns a dictionary with the custom env for the platform.
This is mainly used for setting LD_LIBRARY_PATH to the correct
path when distributing a standalone client
- :param providerconfig: provider specific configuration
- :type providerconfig: ProviderConfig
-
:rtype: dict
"""
- return {"DYLD_LIBRARY_PATH": os.path.join(
- providerconfig.get_path_prefix(),
- "..", "lib")}
+ return {
+ "DYLD_LIBRARY_PATH": os.path.join(get_path_prefix(), "..", "lib")
+ }
class WindowsVPNLauncher(VPNLauncher):
@@ -852,7 +839,7 @@ class WindowsVPNLauncher(VPNLauncher):
openvpn_possibilities = which(
self.OPENVPN_BIN,
- path_extension=os.path.join(providerconfig.get_path_prefix(),
+ path_extension=os.path.join(get_path_prefix(),
"..", "apps", "eip"))
if len(openvpn_possibilities) == 0:
@@ -869,7 +856,7 @@ class WindowsVPNLauncher(VPNLauncher):
args += ['--verb', '%d' % (openvpn_verb,)]
gateways = []
- leap_settings = LeapSettings(ProviderConfig.standalone)
+ leap_settings = LeapSettings()
domain = providerconfig.get_domain()
gateway_conf = leap_settings.get_selected_gateway(domain)
@@ -936,15 +923,12 @@ class WindowsVPNLauncher(VPNLauncher):
return [openvpn] + args
- def get_vpn_env(self, providerconfig):
+ def get_vpn_env(self):
"""
Returns a dictionary with the custom env for the platform.
This is mainly used for setting LD_LIBRARY_PATH to the correct
path when distributing a standalone client
- :param providerconfig: provider specific configuration
- :type providerconfig: ProviderConfig
-
:rtype: dict
"""
return {}
diff --git a/src/leap/bitmask/services/eip/vpnprocess.py b/src/leap/bitmask/services/eip/vpnprocess.py
index a896b60c..c01da372 100644
--- a/src/leap/bitmask/services/eip/vpnprocess.py
+++ b/src/leap/bitmask/services/eip/vpnprocess.py
@@ -536,7 +536,7 @@ class VPNManager(object):
"""
Return a dict containing the vpn environment to be used.
"""
- return self._launcher.get_vpn_env(self._providerconfig)
+ return self._launcher.get_vpn_env()
def terminate_openvpn(self, shutdown=False):
"""
diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py
index 74c9bc94..09f90314 100644
--- a/src/leap/bitmask/services/mail/smtpconfig.py
+++ b/src/leap/bitmask/services/mail/smtpconfig.py
@@ -23,6 +23,7 @@ import os
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.services import ServiceConfig
from leap.bitmask.services.mail.smtpspec import get_schema
+from leap.bitmask.util import get_path_prefix
from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
@@ -61,13 +62,10 @@ class SMTPConfig(ServiceConfig):
leap_assert(providerconfig, "We need a provider")
leap_assert_type(providerconfig, ProviderConfig)
- cert_path = os.path.join(self.get_path_prefix(),
- "leap",
- "providers",
+ cert_path = os.path.join(get_path_prefix(),
+ "leap", "providers",
providerconfig.get_domain(),
- "keys",
- "client",
- "smtp.pem")
+ "keys", "client", "smtp.pem")
if not about_to_download:
leap_assert(os.path.exists(cert_path),
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index 3bbfea85..cac91440 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -26,11 +26,13 @@ import socket
from PySide import QtCore
from u1db import errors as u1db_errors
+from leap.bitmask.config import flags
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpauth import SRPAuth
from leap.bitmask.services.abstractbootstrapper import AbstractBootstrapper
from leap.bitmask.services.soledad.soledadconfig import SoledadConfig
from leap.bitmask.util.request_helpers import get_content
+from leap.bitmask.util import get_path_prefix
from leap.common.check import leap_assert, leap_assert_type
from leap.common.files import get_mtime
from leap.keymanager import KeyManager, openpgp
@@ -120,8 +122,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
srp_auth = self.srpauth
uuid = srp_auth.get_uid()
- prefix = os.path.join(self._soledad_config.get_path_prefix(),
- "leap", "soledad")
+ prefix = os.path.join(get_path_prefix(), "leap", "soledad")
secrets_path = "%s/%s.secret" % (prefix, uuid)
local_db_path = "%s/%s.db" % (prefix, uuid)
@@ -186,11 +187,9 @@ class SoledadBootstrapper(AbstractBootstrapper):
headers = {}
mtime = get_mtime(
- os.path.join(
- self._soledad_config.get_path_prefix(),
- "leap", "providers",
- self._provider_config.get_domain(),
- "soledad-service.json"))
+ os.path.join(get_path_prefix(), "leap", "providers",
+ self._provider_config.get_domain(),
+ "soledad-service.json"))
if self._download_if_needed and mtime:
headers['if-modified-since'] = mtime
@@ -256,8 +255,8 @@ class SoledadBootstrapper(AbstractBootstrapper):
# TODO: Fix for Windows
gpgbin = "/usr/bin/gpg"
- if self._standalone:
- gpgbin = os.path.join(self._provider_config.get_path_prefix(),
+ if flags.STANDALONE:
+ gpgbin = os.path.join(get_path_prefix(),
"..", "apps", "mail", "gpg")
self._keymanager = KeyManager(
@@ -284,8 +283,7 @@ class SoledadBootstrapper(AbstractBootstrapper):
provider_config,
user,
password,
- download_if_needed=False,
- standalone=False):
+ download_if_needed=False):
"""
Starts the checks needed for a new soledad setup
@@ -299,9 +297,6 @@ class SoledadBootstrapper(AbstractBootstrapper):
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)
@@ -310,7 +305,6 @@ 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/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py
index 78efcb6e..f762a350 100644
--- a/src/leap/bitmask/util/__init__.py
+++ b/src/leap/bitmask/util/__init__.py
@@ -20,6 +20,13 @@ Some small and handy functions.
import datetime
import os
+from leap.bitmask.config import flags
+from leap.common.config import get_path_prefix as common_get_path_prefix
+
+
+def get_path_prefix():
+ return common_get_path_prefix(flags.STANDALONE)
+
def first(things):
"""
diff --git a/src/leap/bitmask/util/log_silencer.py b/src/leap/bitmask/util/log_silencer.py
index 09aa2cff..b9f69ad2 100644
--- a/src/leap/bitmask/util/log_silencer.py
+++ b/src/leap/bitmask/util/log_silencer.py
@@ -21,7 +21,7 @@ import logging
import os
import re
-from leap.common.config import get_path_prefix
+from leap.bitmask.util import get_path_prefix
class SelectiveSilencerFilter(logging.Filter):
@@ -48,12 +48,11 @@ class SelectiveSilencerFilter(logging.Filter):
'leap.common.events',
)
- def __init__(self, standalone=False):
+ def __init__(self):
"""
Tries to load silencer rules from the default path,
or load from the SILENCER_RULES tuple if not found.
"""
- self.standalone = standalone
self.rules = None
if os.path.isfile(self._rules_path):
self.rules = self._load_rules()
@@ -65,9 +64,7 @@ class SelectiveSilencerFilter(logging.Filter):
"""
The configuration file for custom ignore rules.
"""
- return os.path.join(
- get_path_prefix(standalone=self.standalone),
- "leap", self.CONFIG_NAME)
+ return os.path.join(get_path_prefix(), "leap", self.CONFIG_NAME)
def _load_rules(self):
"""