diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-03-12 09:02:08 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-03-12 09:02:08 -0300 |
commit | cf83b3ffe300058a4ed30d255481f0c781b0b942 (patch) | |
tree | 406400f83e9cd2a5542a3dff0eb63a5c9fd3e780 | |
parent | 908a726f0f10722ff8a875f24325ea1be6f293a1 (diff) |
Extend path to sbin by default
-rw-r--r-- | src/leap/services/eip/vpnlaunchers.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py index 9f2967aa..6f277481 100644 --- a/src/leap/services/eip/vpnlaunchers.py +++ b/src/leap/services/eip/vpnlaunchers.py @@ -76,7 +76,7 @@ def get_platform_launcher(): # Twisted implementation of which -def which(name, flags=os.X_OK): +def which(name, flags=os.X_OK, path_extension="/usr/sbin:/sbin"): """ Search PATH for executable files with the given name. @@ -99,14 +99,14 @@ def which(name, flags=os.X_OK): order in which they were found. """ - # TODO: make sure sbin is in path - result = [] exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep)) path = os.environ.get('PATH', None) + path += ":" + path_extension if path is None: return [] - for p in os.environ.get('PATH', '').split(os.pathsep): + parts = path.split(os.pathsep) + for p in parts: p = os.path.join(p, name) if os.access(p, flags): result.append(p) |