summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2014-05-30 11:12:19 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2014-05-30 11:12:19 -0300
commit014b10ffae521f3abbf7d38c6700bbacf2712134 (patch)
tree57c0dc366cb3e426bf6d13166a4f7b68a7c8d042 /src/leap
parent3477cc811fab50268ab6b9427e632253c3e7e1d1 (diff)
parentd4d6b0c5476b45629d632debe4527f9d6cb3cb0e (diff)
Merge remote-tracking branch 'chiiph/bug/openvpn_not_found' into develop
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/backend.py74
-rw-r--r--src/leap/bitmask/gui/eip_status.py36
-rw-r--r--src/leap/bitmask/gui/mainwindow.py5
-rw-r--r--src/leap/bitmask/gui/statemachines.py4
-rw-r--r--src/leap/bitmask/platform_init/initializers.py1
-rw-r--r--src/leap/bitmask/services/eip/conductor.py1
6 files changed, 87 insertions, 34 deletions
diff --git a/src/leap/bitmask/backend.py b/src/leap/bitmask/backend.py
index 1ab5b40d..e67bee1b 100644
--- a/src/leap/bitmask/backend.py
+++ b/src/leap/bitmask/backend.py
@@ -45,7 +45,7 @@ from leap.bitmask.services.eip.eipbootstrapper import EIPBootstrapper
from leap.bitmask.services.eip import vpnlauncher, vpnprocess
from leap.bitmask.services.eip import linuxvpnlauncher, darwinvpnlauncher
-
+from leap.bitmask.services.eip import get_vpn_launcher
from leap.bitmask.services.mail.imapcontroller import IMAPController
from leap.bitmask.services.mail.smtpbootstrapper import SMTPBootstrapper
@@ -389,6 +389,11 @@ class EIP(object):
loaded = eipconfig.load_eipconfig_if_needed(
provider_config, eip_config, domain)
+ if not self._can_start(domain):
+ if self._signaler is not None:
+ self._signaler.signal(self._signaler.EIP_CONNECTION_ABORTED)
+ return
+
if not loaded:
if self._signaler is not None:
self._signaler.signal(self._signaler.EIP_CONNECTION_ABORTED)
@@ -572,44 +577,61 @@ class EIP(object):
self._signaler.signal(
self._signaler.EIP_GET_GATEWAYS_LIST, gateways)
- def can_start(self, domain):
+ def _can_start(self, domain):
"""
- Signal whether it has everything that is needed to run EIP or not
+ Returns True if it has everything that is needed to run EIP,
+ False otherwise
:param domain: the domain for the provider to check
:type domain: str
-
- Signals:
- eip_can_start
- eip_cannot_start
"""
- try:
- eip_config = eipconfig.EIPConfig()
- provider_config = ProviderConfig.get_provider_config(domain)
+ eip_config = eipconfig.EIPConfig()
+ provider_config = ProviderConfig.get_provider_config(domain)
+
+ api_version = provider_config.get_api_version()
+ eip_config.set_api_version(api_version)
+ eip_loaded = eip_config.load(eipconfig.get_eipconfig_path(domain))
+
+ launcher = get_vpn_launcher()
+ if not os.path.isfile(launcher.OPENVPN_BIN_PATH):
+ logger.error("Cannot start OpenVPN, binary not found")
+ return False
+
+ # check for other problems
+ if not eip_loaded or provider_config is None:
+ logger.error("Cannot load provider and eip config, cannot "
+ "autostart")
+ return False
- api_version = provider_config.get_api_version()
- eip_config.set_api_version(api_version)
- eip_loaded = eip_config.load(eipconfig.get_eipconfig_path(domain))
+ client_cert_path = eip_config.\
+ get_client_cert_path(provider_config, about_to_download=False)
- # check for other problems
- if not eip_loaded or provider_config is None:
- raise Exception("Cannot load provider and eip config, cannot "
- "autostart")
+ if leap_certs.should_redownload(client_cert_path):
+ logger.error("The client should redownload the certificate,"
+ " cannot autostart")
+ return False
- client_cert_path = eip_config.\
- get_client_cert_path(provider_config, about_to_download=False)
+ if not os.path.isfile(client_cert_path):
+ logger.error("Can't find the certificate, cannot autostart")
+ return False
- if leap_certs.should_redownload(client_cert_path):
- raise Exception("The client should redownload the certificate,"
- " cannot autostart")
+ return True
- if not os.path.isfile(client_cert_path):
- raise Exception("Can't find the certificate, cannot autostart")
+ def can_start(self, domain):
+ """
+ Signal whether it has everything that is needed to run EIP or not
+ :param domain: the domain for the provider to check
+ :type domain: str
+
+ Signals:
+ eip_can_start
+ eip_cannot_start
+ """
+ if self._can_start(domain):
if self._signaler is not None:
self._signaler.signal(self._signaler.EIP_CAN_START)
- except Exception as e:
- logger.exception(e)
+ else:
if self._signaler is not None:
self._signaler.signal(self._signaler.EIP_CANNOT_START)
diff --git a/src/leap/bitmask/gui/eip_status.py b/src/leap/bitmask/gui/eip_status.py
index 04acc167..ba041968 100644
--- a/src/leap/bitmask/gui/eip_status.py
+++ b/src/leap/bitmask/gui/eip_status.py
@@ -102,6 +102,8 @@ class EIPStatusWidget(QtGui.QWidget):
self._on_eip_vpn_launcher_exception)
signaler.eip_no_polkit_agent_error.connect(
self._on_eip_no_polkit_agent_error)
+ signaler.eip_connection_aborted.connect(
+ self._on_eip_connection_aborted)
signaler.eip_no_pkexec_error.connect(self._on_eip_no_pkexec_error)
signaler.eip_no_tun_kext_error.connect(self._on_eip_no_tun_kext_error)
@@ -539,11 +541,11 @@ class EIPStatusWidget(QtGui.QWidget):
eip_status_label = self.tr("Could not load {0} configuration.")
eip_status_label = eip_status_label.format(
- self._eip_conductor.eip_name)
+ self.eip_conductor.eip_name)
self.set_eip_status(eip_status_label, error=True)
# signal connection_aborted to state machine:
- qtsigs = self._eipconnection.qtsigs
+ qtsigs = self.eipconnection.qtsigs
qtsigs.connection_aborted_signal.emit()
def _on_eip_openvpn_already_running(self):
@@ -553,6 +555,10 @@ class EIPStatusWidget(QtGui.QWidget):
error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_alien_openvpn_already_running(self):
self.set_eip_status(
self.tr("Another openvpn instance is already running, and "
@@ -561,18 +567,30 @@ class EIPStatusWidget(QtGui.QWidget):
error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_openvpn_not_found_error(self):
self.set_eip_status(
self.tr("We could not find openvpn binary."),
error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_vpn_launcher_exception(self):
# XXX We should implement again translatable exceptions so
# we can pass a translatable string to the panel (usermessage attr)
self.set_eip_status("VPN Launcher error.", error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_no_polkit_agent_error(self):
self.set_eip_status(
# XXX this should change to polkit-kde where
@@ -584,19 +602,31 @@ class EIPStatusWidget(QtGui.QWidget):
error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_no_pkexec_error(self):
self.set_eip_status(
self.tr("We could not find <b>pkexec</b> in your system."),
error=True)
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
def _on_eip_no_tun_kext_error(self):
self.set_eip_status(
self.tr("{0} cannot be started because the tuntap extension is "
"not installed properly in your "
- "system.").format(self._eip_conductor.eip_name))
+ "system.").format(self.eip_conductor.eip_name))
self.set_eipstatus_off()
+ # signal connection_aborted to state machine:
+ qtsigs = self.eipconnection.qtsigs
+ qtsigs.connection_aborted_signal.emit()
+
@QtCore.Slot()
def _on_eip_network_unreachable(self):
"""
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 1d467e60..a0eb84a2 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -597,7 +597,7 @@ class MainWindow(QtGui.QMainWindow):
default_provider = settings.get_defaultprovider()
if default_provider is None:
- logger.warning("Trying toupdate eip enabled status but there's no"
+ logger.warning("Trying to update eip enabled status but there's no"
" default provider. Disabling EIP for the time"
" being...")
self._backend_cannot_start_eip()
@@ -637,7 +637,6 @@ class MainWindow(QtGui.QMainWindow):
# so the user needs to log in first
self._eip_status.disable_eip_start()
else:
- self._stop_eip()
self._eip_status.disable_eip_start()
self._eip_status.set_eip_status(self.tr("Disabled"))
@@ -664,7 +663,6 @@ class MainWindow(QtGui.QMainWindow):
# so the user needs to log in first
self._eip_status.disable_eip_start()
else:
- self._stop_eip()
self._eip_status.disable_eip_start()
self._eip_status.set_eip_status(self.tr("Disabled"))
@@ -1566,6 +1564,7 @@ class MainWindow(QtGui.QMainWindow):
# XXX this should be handled by the state machine.
self._eip_status.set_eip_status(
self.tr("Starting..."))
+ self._eip_status.eip_button.setEnabled(False)
domain = self._login_widget.get_selected_provider()
self._backend.eip_setup(domain)
diff --git a/src/leap/bitmask/gui/statemachines.py b/src/leap/bitmask/gui/statemachines.py
index f8e5479d..00a1387e 100644
--- a/src/leap/bitmask/gui/statemachines.py
+++ b/src/leap/bitmask/gui/statemachines.py
@@ -565,11 +565,15 @@ class ConnectionMachineBuilder(object):
button, 'text', off_label)
off.assignProperty(
button, 'enabled', True)
+ off.assignProperty(
+ button, 'visible', True)
if action:
off.assignProperty(
action, 'text', off_label)
off.assignProperty(
action, 'enabled', True)
+ off.assignProperty(
+ action, 'visible', True)
off.setObjectName(_OFF)
states[_OFF] = off
diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py
index f2710c58..14d96c9b 100644
--- a/src/leap/bitmask/platform_init/initializers.py
+++ b/src/leap/bitmask/platform_init/initializers.py
@@ -33,7 +33,6 @@ from leap.bitmask.services.eip import get_vpn_launcher
from leap.bitmask.services.eip.linuxvpnlauncher import LinuxVPNLauncher
from leap.bitmask.services.eip.darwinvpnlauncher import DarwinVPNLauncher
from leap.bitmask.util import first
-from leap.bitmask.util import privilege_policies
logger = logging.getLogger(__name__)
diff --git a/src/leap/bitmask/services/eip/conductor.py b/src/leap/bitmask/services/eip/conductor.py
index 0cd4c95c..53b1fde9 100644
--- a/src/leap/bitmask/services/eip/conductor.py
+++ b/src/leap/bitmask/services/eip/conductor.py
@@ -26,7 +26,6 @@ from leap.bitmask.services import EIP_SERVICE
from leap.bitmask.services import get_service_display_name
from leap.bitmask.services.eip.connection import EIPConnection
from leap.bitmask.platform_init import IS_MAC
-from leap.bitmask.util import make_address
QtDelayedCall = QtCore.QTimer.singleShot
logger = logging.getLogger(__name__)