summaryrefslogtreecommitdiff
path: root/src/leap/platform_init/initializers.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-04-03 00:42:29 +0900
committerkali <kali@leap.se>2013-04-03 01:02:13 +0900
commit91a60870e89e565a6136bf6d21b155dc055f4827 (patch)
tree946ec8aae60c3e8a54046255959eb5bfd8bac02c /src/leap/platform_init/initializers.py
parent399b80dbc2a48806fe54fa4d84d513dc83269c3d (diff)
fix tuntaposx invocation
Diffstat (limited to 'src/leap/platform_init/initializers.py')
-rw-r--r--src/leap/platform_init/initializers.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/leap/platform_init/initializers.py b/src/leap/platform_init/initializers.py
index 6392a3c5..3cb19fc6 100644
--- a/src/leap/platform_init/initializers.py
+++ b/src/leap/platform_init/initializers.py
@@ -85,7 +85,8 @@ def WindowsInitializer():
"proceed?"))
msg.setInformativeText(msg.tr("Encrypted Internet uses VPN, which "
"needs a TAP device installed and none "
- "has been found"))
+ "has been found. This will ask for "
+ "administrative privileges."))
msg.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
msg.setDefaultButton(QtGui.QMessageBox.Yes)
ret = msg.exec_()
@@ -102,6 +103,7 @@ def WindowsInitializer():
inf_path = os.path.join(driver_path,
"OemWin2k.inf")
cmd = [dev_installer, "install", inf_path, "tap0901"]
+ # XXX should avoid shell expansion.
ret = subprocess.call(cmd, stdout=subprocess.PIPE, shell=True)
else:
logger.error("Tried to install TAP driver, but the installer "
@@ -114,15 +116,23 @@ def _darwin_has_tun_kext():
containing a kext named tun.kext, AND we found a startup item named 'tun'
"""
# XXX we should be smarter here and use kextstats output.
+
has_kext = lambda: os.path.isdir("/System/Library/Extensions/tun.kext")
has_startup = lambda: os.path.isdir("/System/Library/StartupItems/tun")
- return has_kext() and has_startup()
+ has_tun_and_startup = has_kext() and has_startup()
+ logger.debug('platform initializer check: has tun_and_startup = %s' %
+ (has_tun_and_startup,))
+ return has_tun_and_startup
def DarwinInitializer():
"""
Raises a dialog in case that the osx tuntap driver has not been found
in the registry, asking the user for permission to install the driver
"""
+ NOTFOUND_MSG = ("Tried to install tuntaposx kext, but the installer "
+ "is not found inside this bundle.")
+ BADEXEC_MSG = ("Tried to install tuntaposx kext, but the installer "
+ "failed to be launched.")
if not _darwin_has_tun_kext():
msg = QtGui.QMessageBox()
msg.setWindowTitle(msg.tr("TUN Driver"))
@@ -131,8 +141,9 @@ def DarwinInitializer():
"proceed?"))
msg.setInformativeText(msg.tr("Encrypted Internet uses VPN, which "
"needs a kernel extension for a TUN "
- "device installed and none "
- "has been found"))
+ "device installed, and none "
+ "has been found. This will ask for "
+ "administrative privileges."))
msg.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
msg.setDefaultButton(QtGui.QMessageBox.Yes)
ret = msg.exec_()
@@ -142,10 +153,14 @@ def DarwinInitializer():
"..",
"Resources",
"tuntap-installer.app")
- if os.path.isfile(installer_path) and \
- os.access(installer_path, os.X_OK):
- cmd = ["open", installer_path]
- ret = subprocess.call(cmd, stdout=subprocess.PIPE, shell=True)
+ if os.path.isdir(installer_path):
+ cmd = ["open %s" % (installer_path,)]
+ try:
+ # XXX should avoid shell expansion
+ ret = subprocess.call(
+ cmd, stdout=subprocess.PIPE,
+ shell=True)
+ except:
+ logger.error(BADEXEC_MSG)
else:
- logger.error("Tried to install tuntaposx kext, but the installer "
- "is not found inside this bundle, or it is not executable")
+ logger.error(NOTFOUND_MSG)