summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/util
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-08-31 14:54:52 -0400
committerKali Kaneko <kali@leap.se>2015-08-31 14:54:52 -0400
commitf4547479fc050f338845f4f546d8dd7c0e4512eb (patch)
tree0f737c7f102674230f5467ecaf17720e1d28f6eb /src/leap/bitmask/util
parentdd43dad4b150adb66e571a56a8a5c053dec858d0 (diff)
parentfd27f48a35736d8ba186c423a7de15ffee5143dd (diff)
Merge tag '0.9.0rc2' into debian/experimental
Tag leap.bitmask version 0.9.0rc2
Diffstat (limited to 'src/leap/bitmask/util')
-rw-r--r--src/leap/bitmask/util/__init__.py12
-rw-r--r--src/leap/bitmask/util/autostart.py4
-rw-r--r--src/leap/bitmask/util/keyring_helpers.py5
-rw-r--r--src/leap/bitmask/util/leap_argparse.py61
-rw-r--r--src/leap/bitmask/util/polkit_agent.py4
-rw-r--r--src/leap/bitmask/util/privilege_policies.py5
-rw-r--r--src/leap/bitmask/util/requirement_checker.py6
7 files changed, 50 insertions, 47 deletions
diff --git a/src/leap/bitmask/util/__init__.py b/src/leap/bitmask/util/__init__.py
index e8eddd64..9853803a 100644
--- a/src/leap/bitmask/util/__init__.py
+++ b/src/leap/bitmask/util/__init__.py
@@ -20,6 +20,7 @@ Some small and handy functions.
import datetime
import itertools
import os
+import sys
from leap.bitmask.config import flags
from leap.common.config import get_path_prefix as common_get_path_prefix
@@ -154,3 +155,14 @@ def flags_to_dict():
values = dict((i, getattr(flags, i)) for i in items)
return values
+
+def here(module=None):
+ if getattr(sys, 'frozen', False):
+ # we are running in a |PyInstaller| bundle
+ return sys._MEIPASS
+ else:
+ dirname = os.path.dirname
+ if module:
+ return dirname(module.__file__)
+ else:
+ return dirname(__file__)
diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py
index d7a8afb8..2000b9f5 100644
--- a/src/leap/bitmask/util/autostart.py
+++ b/src/leap/bitmask/util/autostart.py
@@ -17,14 +17,14 @@
"""
Helpers to enable/disable bitmask's autostart.
"""
-import logging
import os
from leap.bitmask.config import flags
+from leap.bitmask.logs.utils import get_logger
from leap.bitmask.platform_init import IS_LINUX
from leap.common.files import mkdir_p
-logger = logging.getLogger(__name__)
+logger = get_logger()
DESKTOP_ENTRY = """\
diff --git a/src/leap/bitmask/util/keyring_helpers.py b/src/leap/bitmask/util/keyring_helpers.py
index 2b729b65..d81f39b1 100644
--- a/src/leap/bitmask/util/keyring_helpers.py
+++ b/src/leap/bitmask/util/keyring_helpers.py
@@ -17,8 +17,6 @@
"""
Keyring helpers.
"""
-import logging
-
try:
import keyring
from keyring.backends.file import EncryptedKeyring, PlaintextKeyring
@@ -35,7 +33,8 @@ except Exception:
keyring = None
-logger = logging.getLogger(__name__)
+from leap.bitmask.logs.utils import get_logger
+logger = get_logger()
def _get_keyring_with_fallback():
diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py
index 346caed5..bfff503e 100644
--- a/src/leap/bitmask/util/leap_argparse.py
+++ b/src/leap/bitmask/util/leap_argparse.py
@@ -19,8 +19,6 @@ Parses the command line arguments passed to the application.
"""
import argparse
-from leap.bitmask import IS_RELEASE_VERSION
-
def build_parser():
"""
@@ -38,9 +36,6 @@ def build_parser():
help='Displays Bitmask version and exits.')
# files
- parser.add_argument('-l', '--logfile', metavar="LOG FILE", nargs='?',
- action="store", dest="log_file",
- help='Optional log file.')
parser.add_argument('-m', '--mail-logfile',
metavar="MAIL LOG FILE", nargs='?',
action="store", dest="mail_log_file",
@@ -74,32 +69,32 @@ def build_parser():
help='Verbosity level for openvpn logs [1-6]')
# mail stuff
- # 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='?',
- action="store", dest="acct",
- help='Manipulate mailboxes for this account')
- parser.add_argument('-r', '--repair-mailboxes', default=False,
- action="store_true", dest="repair",
- help='Repair mailboxes for a given account. '
- 'Use when upgrading versions after a schema '
- 'change. Use with --acct')
- parser.add_argument('--import-maildir', metavar="/path/to/Maildir",
- nargs='?',
- action="store", dest="import_maildir",
- help='Import the given maildir. Use with the '
- '--to-mbox flag to import to folders other '
- 'than INBOX. Use with --acct')
-
- if not IS_RELEASE_VERSION:
- help_text = ("Bypasses the certificate check during provider "
- "bootstraping, for debugging development servers. "
- "Use at your own risk!")
- parser.add_argument('--danger', action="store_true", help=help_text)
+ 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 not yet updated to new mail api for mail 0.4.0
+
+ # parser.add_argument('--acct', metavar="user@provider",
+ # nargs='?',
+ # action="store", dest="acct",
+ # help='Manipulate mailboxes for this account')
+ # parser.add_argument('-r', '--repair-mailboxes', default=False,
+ # action="store_true", dest="repair",
+ # help='Repair mailboxes for a given account. '
+ # 'Use when upgrading versions after a schema '
+ # 'change. Use with --acct')
+ # parser.add_argument('--import-maildir', metavar="/path/to/Maildir",
+ # nargs='?',
+ # action="store", dest="import_maildir",
+ # help='Import the given maildir. Use with the '
+ # '--to-mbox flag to import to folders other '
+ # 'than INBOX. Use with --acct')
+
+ help_text = ("INSECURE: Bypasses the certificate check during provider "
+ "bootstraping, for debugging development servers. "
+ "USE AT YOUR OWN RISK!")
+ parser.add_argument('--danger', action="store_true", help=help_text)
# optional cert file used to check domains with self signed certs.
parser.add_argument('--ca-cert-file', metavar="/path/to/cacert.pem",
@@ -134,8 +129,4 @@ def get_options():
parser = build_parser()
opts, unknown = parser.parse_known_args()
- # 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/polkit_agent.py b/src/leap/bitmask/util/polkit_agent.py
index e512bffa..f6c7b4ca 100644
--- a/src/leap/bitmask/util/polkit_agent.py
+++ b/src/leap/bitmask/util/polkit_agent.py
@@ -17,14 +17,14 @@
"""
Daemonizes polkit authentication agent.
"""
-import logging
import os
import subprocess
import daemon
# TODO --- logger won't work when daemoninzed. Log to syslog instead?
-logger = logging.getLogger(__name__)
+from leap.bitmask.logs.utils import get_logger
+logger = get_logger()
POLKIT_PATHS = (
'/usr/lib/lxpolkit/lxpolkit',
diff --git a/src/leap/bitmask/util/privilege_policies.py b/src/leap/bitmask/util/privilege_policies.py
index 65132133..fd8c7c8e 100644
--- a/src/leap/bitmask/util/privilege_policies.py
+++ b/src/leap/bitmask/util/privilege_policies.py
@@ -19,7 +19,6 @@ Helpers to determine if the needed policies for privilege escalation
are operative under this client run.
"""
import commands
-import logging
import os
import subprocess
import platform
@@ -28,10 +27,11 @@ import time
from abc import ABCMeta, abstractmethod
from leap.bitmask.config import flags
+from leap.bitmask.logs.utils import get_logger
from leap.common.check import leap_assert
from leap.common.files import which
-logger = logging.getLogger(__name__)
+logger = get_logger()
class NoPolkitAuthAgentAvailable(Exception):
@@ -187,6 +187,7 @@ class LinuxPolicyChecker(PolicyChecker):
'ps aux | grep "[l]xsession"',
'ps aux | grep "[g]nome-shell"',
'ps aux | grep "[f]ingerprint-polkit-agent"',
+ 'ps aux | grep "[x]fce-polkit"',
]
is_running = [commands.getoutput(cmd) for cmd in polkit_options]
diff --git a/src/leap/bitmask/util/requirement_checker.py b/src/leap/bitmask/util/requirement_checker.py
index 37e8e693..99ef81b4 100644
--- a/src/leap/bitmask/util/requirement_checker.py
+++ b/src/leap/bitmask/util/requirement_checker.py
@@ -18,9 +18,7 @@
"""
Utility to check the needed requirements.
"""
-
import os
-import logging
from pkg_resources import (DistributionNotFound,
get_distribution,
@@ -28,7 +26,9 @@ from pkg_resources import (DistributionNotFound,
resource_stream,
VersionConflict)
-logger = logging.getLogger(__name__)
+from leap.bitmask.logs.utils import get_logger
+
+logger = get_logger()
def get_requirements():