summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@leap.se>2013-06-19 21:30:42 -0300
committerTomas Touceda <chiiph@leap.se>2013-06-19 21:30:42 -0300
commit7fa8d1580fd17a248e24350d30dfc3d9a0d7e322 (patch)
treee6d260e40e79a2bbfedd0d5d69ebe42c237a9b8a /src/leap
parent37818048218ede8c32399294dcaf3a2e8467c4c9 (diff)
parentd288330c6294a51cec6fd1dcc35b1b6f4f36932d (diff)
Merge remote-tracking branch 'kali/feature/launch-polkit-agent' into develop
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/services/eip/vpnlaunchers.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py
index 01ec42cf..762b536d 100644
--- a/src/leap/services/eip/vpnlaunchers.py
+++ b/src/leap/services/eip/vpnlaunchers.py
@@ -23,6 +23,7 @@ import logging
import getpass
import os
import platform
+import subprocess
try:
import grp
except ImportError:
@@ -199,11 +200,25 @@ def _is_auth_agent_running():
:return: True if it's running, False if it's not.
:rtype: boolean
"""
- polkit_gnome = 'ps aux | grep polkit-[g]nome-authentication-agent-1'
- polkit_kde = 'ps aux | grep polkit-[k]de-authentication-agent-1'
+ ps = 'ps aux | grep polkit-%s-authentication-agent-1'
+ opts = (ps % case for case in ['[g]nome', '[k]de'])
+ is_running = map(lambda l: commands.getoutput(l), opts)
+ return any(is_running)
- return (len(commands.getoutput(polkit_gnome)) > 0 or
- len(commands.getoutput(polkit_kde)) > 0)
+
+def _try_to_launch_agent():
+ """
+ Tries to launch a polkit daemon.
+ """
+ opts = [
+ "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1&",
+ # XXX add kde thing here
+ ]
+ for cmd in opts:
+ try:
+ subprocess.Popen([cmd], shell=True)
+ except:
+ pass
class LinuxVPNLauncher(VPNLauncher):
@@ -258,6 +273,8 @@ class LinuxVPNLauncher(VPNLauncher):
:rtype: list
"""
if _is_pkexec_in_system():
+ if not _is_auth_agent_running():
+ _try_to_launch_agent()
if _is_auth_agent_running():
pkexec_possibilities = which(kls.PKEXEC_BIN)
leap_assert(len(pkexec_possibilities) > 0,