summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/util')
-rw-r--r--src/leap/bitmask/util/leap_argparse.py7
-rw-r--r--src/leap/bitmask/util/polkit_agent.py46
-rw-r--r--src/leap/bitmask/util/privilege_policies.py7
3 files changed, 49 insertions, 11 deletions
diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py
index cbd6d8a5..346caed5 100644
--- a/src/leap/bitmask/util/leap_argparse.py
+++ b/src/leap/bitmask/util/leap_argparse.py
@@ -74,9 +74,10 @@ def build_parser():
help='Verbosity level for openvpn logs [1-6]')
# mail stuff
- parser.add_argument('-o', '--offline', action="store_true",
- help='Starts Bitmask in offline mode: will not '
- 'try to sync with remote replicas for email.')
+ # XXX Disabled right now since it's not tested after login refactor
+ # parser.add_argument('-o', '--offline', action="store_true",
+ # help='Starts Bitmask in offline mode: will not '
+ # 'try to sync with remote replicas for email.')
parser.add_argument('--acct', metavar="user@provider",
nargs='?',
diff --git a/src/leap/bitmask/util/polkit_agent.py b/src/leap/bitmask/util/polkit_agent.py
index 7764f571..af5e431c 100644
--- a/src/leap/bitmask/util/polkit_agent.py
+++ b/src/leap/bitmask/util/polkit_agent.py
@@ -18,6 +18,7 @@
Daemonizes polkit authentication agent.
"""
import logging
+import os
import subprocess
import daemon
@@ -30,21 +31,52 @@ BASE_PATH_KDE = "/usr/lib/kde4/libexec/"
GNO_PATH = BASE_PATH_GNO + AUTH_FILE % ("gnome",)
KDE_PATH = BASE_PATH_KDE + AUTH_FILE % ("kde",)
+POLKIT_PATHS = {
+ '/usr/lib/lxpolkit/lxpolkit',
+ '/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1',
+ '/usr/lib/mate-polkit/polkit-mate-authentication-agent-1',
+ '/usr/lib/kde4/libexec/polkit-kde-authentication-agent-1',
+}
+
+
+def _get_polkit_agent():
+ """
+ Return a valid polkit agent to use.
+
+ :rtype: str or None
+ """
+ # TODO: in caso of having more than one polkit agent we may want to
+ # stablish priorities. E.g.: lxpolkit over gnome-polkit for minimalistic
+ # desktops.
+ for polkit in POLKIT_PATHS:
+ if os.path.isfile(polkit):
+ return polkit
+
+ return None
+
def _launch_agent():
+ """
+ Launch a polkit authentication agent on a subprocess.
+ """
+ polkit_agent = _get_polkit_agent()
+
+ if polkit_agent is None:
+ logger.erro("No usable polkit was found.")
+ return
+
logger.debug('Launching polkit auth agent')
try:
- subprocess.call(GNO_PATH)
- except Exception as exc:
- logger.error('Exception while running polkit authentication agent '
- '%s' % (exc,))
# XXX fix KDE launch. See: #3755
- # try:
- # subprocess.call(KDE_PATH)
- # except Exception as exc:
+ subprocess.call(polkit_agent)
+ except Exception as e:
+ logger.error('Error launching polkit authentication agent %r' % (e, ))
def launch():
+ """
+ Launch a polkit authentication agent as a daemon.
+ """
with daemon.DaemonContext():
_launch_agent()
diff --git a/src/leap/bitmask/util/privilege_policies.py b/src/leap/bitmask/util/privilege_policies.py
index 68a1af28..65132133 100644
--- a/src/leap/bitmask/util/privilege_policies.py
+++ b/src/leap/bitmask/util/privilege_policies.py
@@ -149,7 +149,12 @@ class LinuxPolicyChecker(PolicyChecker):
"""
env = None
if flags.STANDALONE:
- env = {"PYTHONPATH": os.path.abspath('../../../../lib/')}
+ # This allows us to send to subprocess the environment configs that
+ # works for the standalone bundle (like the PYTHONPATH)
+ env = dict(os.environ)
+ # The LD_LIBRARY_PATH is set on the launcher but not forwarded to
+ # subprocess unless we do so explicitly.
+ env["LD_LIBRARY_PATH"] = os.path.abspath("./lib/")
try:
# We need to quote the command because subprocess call
# will do "sh -c 'foo'", so if we do not quoute it we'll end