diff options
author | Kali Kaneko <kali@leap.se> | 2014-07-01 01:48:50 -0500 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-07-01 01:48:50 -0500 |
commit | 44a3896a86c33cbca4d239c8bd0fe65c0e83b9d0 (patch) | |
tree | a2e0c6b0163c6c54e518c8e620e431d3784d8b6c /src/leap/bitmask/util | |
parent | b2a00d0ce2db905fe79cf9e7c33411f4f37bb943 (diff) | |
parent | 1e456b0fff46001641a736bc5932314e9d00b1bc (diff) |
Merge branch 'develop' into deb-0.5.3
Diffstat (limited to 'src/leap/bitmask/util')
-rw-r--r-- | src/leap/bitmask/util/__init__.py | 19 | ||||
-rw-r--r-- | src/leap/bitmask/util/leap_argparse.py | 15 | ||||
-rw-r--r--[-rwxr-xr-x] | src/leap/bitmask/util/pastebin.py | 0 | ||||
-rw-r--r-- | src/leap/bitmask/util/privilege_policies.py | 10 |
4 files changed, 40 insertions, 4 deletions
diff --git a/src/leap/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py index c35be99e..25b86874 100644 --- a/src/leap/bitmask/util/__init__.py +++ b/src/leap/bitmask/util/__init__.py @@ -110,3 +110,22 @@ def make_address(user, provider): :type provider: basestring """ return "%s@%s" % (user, provider) + + +def force_eval(items): + """ + Return a sequence that evaluates any callable in the sequence, + instantiating it beforehand if the item is a class, and + leaves the non-callable items without change. + """ + def do_eval(thing): + if isinstance(thing, type): + return thing()() + if callable(thing): + return thing() + return thing + + if isinstance(items, (list, tuple)): + return map(do_eval, items) + else: + return do_eval(items) diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py index 84af4e8d..c7fed0a3 100644 --- a/src/leap/bitmask/util/leap_argparse.py +++ b/src/leap/bitmask/util/leap_argparse.py @@ -123,7 +123,18 @@ def build_parser(): return parser -def init_leapc_args(): +def get_options(): + """ + Get the command line options used when the app was started. + + :return: the command options + :rtype: argparse.Namespace + """ parser = build_parser() opts, unknown = parser.parse_known_args() - return parser, opts + + # we add this option manually since it's not defined for 'release version' + if IS_RELEASE_VERSION: + opts.danger = False + + return opts diff --git a/src/leap/bitmask/util/pastebin.py b/src/leap/bitmask/util/pastebin.py index a3bdba02..a3bdba02 100755..100644 --- a/src/leap/bitmask/util/pastebin.py +++ b/src/leap/bitmask/util/pastebin.py diff --git a/src/leap/bitmask/util/privilege_policies.py b/src/leap/bitmask/util/privilege_policies.py index 9d1e2c9a..adc3503f 100644 --- a/src/leap/bitmask/util/privilege_policies.py +++ b/src/leap/bitmask/util/privilege_policies.py @@ -24,6 +24,8 @@ import platform from abc import ABCMeta, abstractmethod +from leap.bitmask.config import flags + logger = logging.getLogger(__name__) @@ -71,6 +73,8 @@ class LinuxPolicyChecker(PolicyChecker): """ LINUX_POLKIT_FILE = ("/usr/share/polkit-1/actions/" "se.leap.bitmask.policy") + LINUX_POLKIT_FILE_BUNDLE = ("/usr/share/polkit-1/actions/" + "se.leap.bitmask.bundle.policy") @classmethod def get_polkit_path(self): @@ -79,7 +83,8 @@ class LinuxPolicyChecker(PolicyChecker): :rtype: str """ - return self.LINUX_POLKIT_FILE + return (self.LINUX_POLKIT_FILE_BUNDLE if flags.STANDALONE + else self.LINUX_POLKIT_FILE) def is_missing_policy_permissions(self): # FIXME this name is quite confusing, it does not have anything to do with @@ -90,4 +95,5 @@ class LinuxPolicyChecker(PolicyChecker): :rtype: bool """ - return not os.path.isfile(self.LINUX_POLKIT_FILE) + path = self.get_polkit_path() + return not os.path.isfile(path) |