From ac83b8900bb8d31e6f1f1fa983435659625ff91f Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 22 Aug 2014 17:25:52 -0300 Subject: Hide button / improve message on missing helpers. * Emit the `eip_missing_helpers` signal when the user chooses "Don't ask me again". * We emit that signal when some helper file is missing, even if the user doesn't want a warning. * Do the update of the eip enabled status with some delay to give some time the eip machine to start and do what it needs with the buttons/labels and avoid the 'hide turn on button if missing files' being overridden. Closes #5945. --- src/leap/bitmask/platform_init/initializers.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/leap/bitmask/platform_init') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index f56b9330..6c62734c 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -164,6 +164,7 @@ def check_missing(): logger.debug( "Setting alert_missing_scripts to False, we will not " "ask again") + init_signals.eip_missing_helpers.emit() config.set_alert_missing_scripts(False) if complain_missing and missing_some: @@ -171,6 +172,12 @@ def check_missing(): msg = _get_missing_complain_dialog(missing) ret = msg.exec_() + # If there is some missing file and we don't want to complain, we emit the + # 'missing helpers' signal so the eip status can show that some files are + # missing. + if missing_some and not alert_missing and not complain_missing: + init_signals.eip_missing_helpers.emit() + # # windows initializers # -- cgit v1.2.3 From ad85a375eb74609c8a1d7a7a3a0a11b7489a2483 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 28 Aug 2014 10:42:53 -0300 Subject: Remove /tmp/bitmask.lock on quit. Closes #5866. Add a platform independent release_lock helper, so all the SO dependent code goes inside the locks file. Also, do some code cleanup. --- src/leap/bitmask/platform_init/locks.py | 59 ++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 20 deletions(-) (limited to 'src/leap/bitmask/platform_init') diff --git a/src/leap/bitmask/platform_init/locks.py b/src/leap/bitmask/platform_init/locks.py index 78ebf4cd..ac45a5ce 100644 --- a/src/leap/bitmask/platform_init/locks.py +++ b/src/leap/bitmask/platform_init/locks.py @@ -22,11 +22,11 @@ import errno import os import platform -from leap.bitmask import platform_init +from leap.bitmask.platform_init import IS_WIN, IS_UNIX from leap.common.events import signal as signal_event from leap.common.events import events_pb2 as proto -if platform_init.IS_UNIX: +if IS_UNIX: from fcntl import flock, LOCK_EX, LOCK_NB else: # WINDOWS import datetime @@ -40,7 +40,7 @@ else: # WINDOWS logger = logging.getLogger(__name__) -if platform_init.IS_UNIX: +if IS_UNIX: class UnixLock(object): """ @@ -48,14 +48,13 @@ if platform_init.IS_UNIX: See man 2 flock """ - def __init__(self, path): + _LOCK_FILE = '/tmp/bitmask.lock' + + def __init__(self): """ - iniializes t he UnixLock with the path of the - desired lockfile + Initialize the UnixLock. """ - self._fd = None - self.path = path def get_lock(self): """ @@ -77,7 +76,7 @@ if platform_init.IS_UNIX: :rtype: bool """ - self._fd = os.open(self.path, os.O_CREAT | os.O_RDWR) + self._fd = os.open(self._LOCK_FILE, os.O_CREAT | os.O_RDWR) try: flock(self._fd, LOCK_EX | LOCK_NB) @@ -102,6 +101,21 @@ if platform_init.IS_UNIX: gotit, pid = self._get_lock_and_pid() return pid == os.getpid() + @classmethod + def release_lock(self): + """ + Release the lock. + + :return: True if the lock was released, False otherwise + :rtype: bool + """ + try: + os.remove(self._LOCK_FILE) + return True + except Exception as e: + logger.debug("Problem removing lock, {0!r}".format(e)) + return False + def _get_lock_and_pid(self): """ Tries to get a lock over the file. @@ -109,7 +123,6 @@ if platform_init.IS_UNIX: :rtype: tuple """ - if self._get_lock(): self._write_to_pidfile() return True, None @@ -121,9 +134,7 @@ if platform_init.IS_UNIX: Tries to read pid from the pidfile, returns False if no content found. """ - - pidfile = os.read( - self._fd, 16) + pidfile = os.read(self._fd, 16) if not pidfile: return False @@ -144,7 +155,7 @@ if platform_init.IS_UNIX: os.fsync(fd) -if platform_init.IS_WIN: +if IS_WIN: # Time to wait (in secs) before assuming a raise window signal has not been # ack-ed. @@ -348,17 +359,15 @@ def we_are_the_one_and_only(): :rtype: bool """ - _sys = platform.system() - - if _sys in ("Linux", "Darwin"): - locker = UnixLock('/tmp/bitmask.lock') + if IS_UNIX: + locker = UnixLock() locker.get_lock() we_are_the_one = locker.locked_by_us if not we_are_the_one: signal_event(proto.RAISE_WINDOW) return we_are_the_one - elif _sys == "Windows": + elif IS_WIN: locker = WindowsLock() locker.get_lock() we_are_the_one = locker.locked_by_us @@ -398,6 +407,16 @@ def we_are_the_one_and_only(): else: logger.warning("Multi-instance checker " - "not implemented for %s" % (_sys)) + "not implemented for %s" % (platform.system())) # lies, lies, lies... return True + + +def release_lock(): + """ + Release the acquired lock. + """ + if IS_WIN: + WindowsLock.release_all_locks() + elif IS_UNIX: + UnixLock.release_lock() -- cgit v1.2.3 From de2f0e13a5a48e86b75eb54a56fe9f88b720193f Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 3 Sep 2014 14:50:46 -0300 Subject: Better logging output for missing files and error. --- src/leap/bitmask/platform_init/initializers.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/leap/bitmask/platform_init') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index 6c62734c..70d787dd 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -127,12 +127,15 @@ def check_missing(): complain_missing = True launcher = get_vpn_launcher() - missing_scripts = launcher.missing_updown_scripts - missing_other = launcher.missing_other_files + missing_scripts = launcher.missing_updown_scripts() + missing_other = launcher.missing_other_files() - logger.debug("MISSING OTHER: %s" % (str(missing_other()))) + if missing_scripts: + logger.warning("Missing scripts: %s" % (missing_scripts)) + if missing_other: + logger.warning("Missing other files: %s" % (missing_other)) - missing_some = missing_scripts() or missing_other() + missing_some = missing_scripts or missing_other if alert_missing and missing_some: msg = get_missing_helpers_dialog() ret = msg.exec_() @@ -168,7 +171,7 @@ def check_missing(): config.set_alert_missing_scripts(False) if complain_missing and missing_some: - missing = missing_scripts() + missing_other() + missing = missing_scripts + missing_other msg = _get_missing_complain_dialog(missing) ret = msg.exec_() -- cgit v1.2.3 From f9ed736e41aa63b60925802fad021fc387dbc303 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Fri, 12 Sep 2014 13:30:42 -0500 Subject: Initializers needs to use PolicyChecker to get pkexec in linux --- src/leap/bitmask/platform_init/initializers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/leap/bitmask/platform_init') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index 70d787dd..1d6bb1d0 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -29,9 +29,9 @@ from PySide import QtGui, QtCore from leap.bitmask.config import flags from leap.bitmask.config.leapsettings import LeapSettings from leap.bitmask.services.eip import get_vpn_launcher -from leap.bitmask.services.eip.linuxvpnlauncher import LinuxVPNLauncher from leap.bitmask.services.eip.darwinvpnlauncher import DarwinVPNLauncher from leap.bitmask.util import first +from leap.bitmask.util.privilege_policies import LinuxPolicyChecker logger = logging.getLogger(__name__) @@ -445,7 +445,6 @@ def _linux_install_missing_scripts(badexec, notfound): success = False installer_path = os.path.abspath( os.path.join(os.getcwd(), "apps", "eip", "files")) - launcher = LinuxVPNLauncher install_helper = "leap-install-helper.sh" install_helper_path = os.path.join(installer_path, install_helper) @@ -456,7 +455,8 @@ def _linux_install_missing_scripts(badexec, notfound): if os.path.isdir(installer_path): try: - pkexec = first(launcher.maybe_pkexec()) + policyChecker = LinuxPolicyChecker() + pkexec = first(policyChecker.maybe_pkexec()) cmdline = ["%s %s %s" % ( pkexec, install_helper_path, install_opts)] -- cgit v1.2.3