From 53056ee3f1e1ad07495880ac9f02ed5755ff258f Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Sat, 27 Jul 2013 01:05:16 +0900 Subject: add kext check --- changes/feature_2906_check_kext | 1 + src/leap/gui/mainwindow.py | 16 ++++++++++++---- src/leap/services/eip/vpnlaunchers.py | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 changes/feature_2906_check_kext diff --git a/changes/feature_2906_check_kext b/changes/feature_2906_check_kext new file mode 100644 index 00000000..3b663d55 --- /dev/null +++ b/changes/feature_2906_check_kext @@ -0,0 +1 @@ + o Add check for tuntap kext before launching openvpn. Closes: #2906 diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 1d0d3120..f333d7ec 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -52,10 +52,12 @@ from leap.services.eip.vpnprocess import VPN from leap.services.eip.vpnprocess import OpenVPNAlreadyRunning from leap.services.eip.vpnprocess import AlienOpenVPNAlreadyRunning -from leap.services.eip.vpnlaunchers import (VPNLauncherException, - OpenVPNNotFoundException, - EIPNoPkexecAvailable, - EIPNoPolkitAuthAgentAvailable) +from leap.services.eip.vpnlaunchers import VPNLauncherException +from leap.services.eip.vpnlaunchers import OpenVPNNotFoundException +from leap.services.eip.vpnlaunchers import EIPNoPkexecAvailable +from leap.services.eip.vpnlaunchers import EIPNoPolkitAuthAgentAvailable +from leap.services.eip.vpnlaunchers import EIPNoTunKextLoaded + from leap.util import __version__ as VERSION from leap.util.keyring_helpers import has_keyring @@ -1037,6 +1039,12 @@ class MainWindow(QtGui.QMainWindow): "running and try again."), error=True) self._set_eipstatus_off() + except EIPNoTunKextLoaded: + self._status_panel.set_global_status( + self.tr("Encrypted Internet cannot be started because " + "the tuntap extension is not installed properly " + "in your system.")) + self._set_eipstatus_off() except EIPNoPkexecAvailable: self._status_panel.set_global_status( self.tr("We could not find pkexec " diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py index 81d9b43b..8522d1df 100644 --- a/src/leap/services/eip/vpnlaunchers.py +++ b/src/leap/services/eip/vpnlaunchers.py @@ -58,6 +58,10 @@ class EIPNoPkexecAvailable(VPNLauncherException): pass +class EIPNoTunKextLoaded(VPNLauncherException): + pass + + class VPNLauncher: """ Abstract launcher class @@ -520,6 +524,13 @@ class DarwinVPNLauncher(VPNLauncher): to, frompath, to, to) return cmd + @classmethod + def maybe_kextloaded(kls): + """ + Checks if the needed kext is loaded before launching openvpn. + """ + return bool(commands.getoutput('kextstat | grep "leap.tun"')) + def _get_resource_path(self): """ Returns the absolute path to the app resources directory @@ -600,6 +611,9 @@ class DarwinVPNLauncher(VPNLauncher): leap_assert(socket_host, "We need a socket host!") leap_assert(socket_port, "We need a socket port!") + if not self.maybe_kextloaded(): + raise EIPNoTunKextLoaded + kwargs = {} if ProviderConfig.standalone: kwargs['path_extension'] = os.path.join( -- cgit v1.2.3