From 8c9005e665bb7a77f91cf298f49832f663b0df67 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 24 Jul 2014 17:58:56 -0300 Subject: Disable user/pass remembering temporarily. Set the keyring to None in order to simulate an always unavailable keyring, that way we avoid the possibility of the user running into the existing keyring issues. See https://leap.se/code/issues/4190 Update comparisons to do a proper comparison with `None`. Fix login widget 'enabled' changer in order to change the 'remember' widget *only* if we have an usable keyring. --- src/leap/bitmask/util/keyring_helpers.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/keyring_helpers.py b/src/leap/bitmask/util/keyring_helpers.py index ee2d7a1c..0512d988 100644 --- a/src/leap/bitmask/util/keyring_helpers.py +++ b/src/leap/bitmask/util/keyring_helpers.py @@ -34,6 +34,10 @@ except Exception: # dbus socket, or stuff like that. keyring = None +# XXX remember password disabled right now! +# see: https://leap.se/code/issues/4190 +keyring = None + logger = logging.getLogger(__name__) @@ -46,7 +50,7 @@ def _get_keyring_with_fallback(): This is a workaround for the cases in which the keyring module chooses an insecure keyring by default (ie, inside a virtualenv). """ - if not keyring: + if keyring is None: return None kr = keyring.get_keyring() if not canuse(kr): @@ -67,7 +71,7 @@ def has_keyring(): :rtype: bool """ - if not keyring: + if keyring is None: return False kr = _get_keyring_with_fallback() return canuse(kr) @@ -79,7 +83,7 @@ def get_keyring(): :rtype: keyringBackend or None """ - if not keyring: + if keyring is None: return False kr = _get_keyring_with_fallback() return kr if canuse(kr) else None -- cgit v1.2.3 From 28553c41c3d879481923102a1b41ecd71641d0d8 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 25 Jul 2014 11:13:53 -0300 Subject: Add Linux autostart. Closes #4989. --- src/leap/bitmask/util/autostart.py | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/leap/bitmask/util/autostart.py (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py new file mode 100644 index 00000000..b8ac02b1 --- /dev/null +++ b/src/leap/bitmask/util/autostart.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# autostart.py +# Copyright (C) 2013, 2014 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +Helpers to enable/disable bitmask's autostart. +""" +import flags +import logging +import os + +from leap.bitmask.platform_init import IS_LINUX + +logger = logging.getLogger(__name__) + + +DESKTOP_ENTRY = """\ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Type=Application +Name=Bitmask +Comment=Secure Communication +Exec=bitmask --start-hidden +Terminal=false +Icon=bitmask +""" + +DESKTOP_ENTRY_PATH = os.path.expanduser("~/.config/autostart/bitmask.desktop") + + +def set_autostart(enabled): + """ + Set the autostart mode to enabled or disabled depending on the parameter. + If `enabled` is `True`, save the autostart file to its place. Otherwise, + remove that file. + Right now we support only Linux autostart. + + :param enabled: whether the autostart should be enabled or not. + :type enabled: bool + """ + # we don't do autostart for bundle or systems different than Linux + if flags.STANDALONE or not IS_LINUX: + return + + if enabled: + with open(DESKTOP_ENTRY_PATH, 'w') as f: + f.write(DESKTOP_ENTRY) + else: + try: + os.remove(DESKTOP_ENTRY_PATH) + except OSError: # if the file does not exist + pass + except Exception as e: + logger.error("Problem disabling autostart, {0!r}".format(e)) -- cgit v1.2.3 From 89cb09b95f1c45a95c22c9ec99e7ba62fa6dd98b Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 25 Jul 2014 12:21:06 -0300 Subject: Fix misused import. --- src/leap/bitmask/util/autostart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py index b8ac02b1..5f003bd8 100644 --- a/src/leap/bitmask/util/autostart.py +++ b/src/leap/bitmask/util/autostart.py @@ -17,10 +17,10 @@ """ Helpers to enable/disable bitmask's autostart. """ -import flags import logging import os +from leap.bitmask.config import flags from leap.bitmask.platform_init import IS_LINUX logger = logging.getLogger(__name__) -- cgit v1.2.3 From c4df5cff32524bf2fa9e5d43f08210361531d273 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 25 Jul 2014 12:41:25 -0300 Subject: Create the autostart path in case that does not exist. --- src/leap/bitmask/util/autostart.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/autostart.py b/src/leap/bitmask/util/autostart.py index 5f003bd8..d7a8afb8 100644 --- a/src/leap/bitmask/util/autostart.py +++ b/src/leap/bitmask/util/autostart.py @@ -22,6 +22,7 @@ import os from leap.bitmask.config import flags from leap.bitmask.platform_init import IS_LINUX +from leap.common.files import mkdir_p logger = logging.getLogger(__name__) @@ -38,7 +39,8 @@ Terminal=false Icon=bitmask """ -DESKTOP_ENTRY_PATH = os.path.expanduser("~/.config/autostart/bitmask.desktop") +DESKTOP_ENTRY_PATH = os.path.expanduser("~/.config/autostart/") +DESKTOP_ENTRY_FILE = os.path.join(DESKTOP_ENTRY_PATH, 'bitmask.desktop') def set_autostart(enabled): @@ -56,11 +58,12 @@ def set_autostart(enabled): return if enabled: - with open(DESKTOP_ENTRY_PATH, 'w') as f: + mkdir_p(DESKTOP_ENTRY_PATH) + with open(DESKTOP_ENTRY_FILE, 'w') as f: f.write(DESKTOP_ENTRY) else: try: - os.remove(DESKTOP_ENTRY_PATH) + os.remove(DESKTOP_ENTRY_FILE) except OSError: # if the file does not exist pass except Exception as e: -- cgit v1.2.3 From 75eddcf502d23f761cbac26da34fcfd1ab669b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 31 Jul 2014 14:45:43 -0300 Subject: Enable keyring again --- src/leap/bitmask/util/keyring_helpers.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/keyring_helpers.py b/src/leap/bitmask/util/keyring_helpers.py index 0512d988..088e7b3d 100644 --- a/src/leap/bitmask/util/keyring_helpers.py +++ b/src/leap/bitmask/util/keyring_helpers.py @@ -34,10 +34,6 @@ except Exception: # dbus socket, or stuff like that. keyring = None -# XXX remember password disabled right now! -# see: https://leap.se/code/issues/4190 -keyring = None - logger = logging.getLogger(__name__) -- cgit v1.2.3 From d201ee8ff03905e008ce316bae81aa6cfe2caf58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 31 Jul 2014 15:50:28 -0300 Subject: Do not default to SecretService keyring --- src/leap/bitmask/util/keyring_helpers.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/keyring_helpers.py b/src/leap/bitmask/util/keyring_helpers.py index 088e7b3d..2b729b65 100644 --- a/src/leap/bitmask/util/keyring_helpers.py +++ b/src/leap/bitmask/util/keyring_helpers.py @@ -50,11 +50,8 @@ def _get_keyring_with_fallback(): return None kr = keyring.get_keyring() if not canuse(kr): - try: - kr_klass = keyring.backends.SecretService - kr = kr_klass.Keyring() - except AttributeError: - logger.warning("Keyring cannot find SecretService Backend") + logger.debug("No usable keyring found") + return None logger.debug("Selected keyring: %s" % (kr.__class__,)) if not canuse(kr): logger.debug("Not using default keyring since it is obsolete") -- cgit v1.2.3 From e35b7f006b6cb076ff6b982a2f173ab5bc3a41d3 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 13 Aug 2014 17:14:10 -0300 Subject: Use same user/password restrictions as in the webapp. - no uppercase allowed in usernames, - password length min to 8 Closes #5894. --- src/leap/bitmask/util/credentials.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/credentials.py b/src/leap/bitmask/util/credentials.py index 07ded17b..757ce10c 100644 --- a/src/leap/bitmask/util/credentials.py +++ b/src/leap/bitmask/util/credentials.py @@ -21,7 +21,7 @@ Credentials utilities from PySide import QtCore, QtGui WEAK_PASSWORDS = ("123456", "qweasd", "qwerty", "password") -USERNAME_REGEX = r"^[A-Za-z][A-Za-z\d_\-\.]+[A-Za-z\d]$" +USERNAME_REGEX = r"^[a-z][a-z\d_\-\.]+[a-z\d]$" USERNAME_VALIDATOR = QtGui.QRegExpValidator(QtCore.QRegExp(USERNAME_REGEX)) @@ -69,7 +69,7 @@ def password_checks(username, password, password2): if message is None and not password: message = _tr("You can't use an empty password") - if message is None and len(password) < 6: + if message is None and len(password) < 8: message = _tr("Password too short") if message is None and password in WEAK_PASSWORDS: -- cgit v1.2.3