From 4d9525be291df0bd5679f9c1247686693161ccf8 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 23 Aug 2013 18:34:04 +0200 Subject: fix up script in linux --- src/leap/bitmask/services/eip/vpnlaunchers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/leap/bitmask/services/eip/vpnlaunchers.py b/src/leap/bitmask/services/eip/vpnlaunchers.py index fb9ac46f..f8c51ad8 100644 --- a/src/leap/bitmask/services/eip/vpnlaunchers.py +++ b/src/leap/bitmask/services/eip/vpnlaunchers.py @@ -343,7 +343,7 @@ class LinuxVPNLauncher(VPNLauncher): abs_path_in_bundle = os.path.join(cwd, rel_path_in_bundle) if os.path.isfile(abs_path_in_bundle): return abs_path_in_bundle - abs_path_in_system = kls.OPENVPN_DOWN_ROOT_FILE + abs_path_in_system = kls.OPENVPN_DOWN_ROOT_PATH if os.path.isfile(abs_path_in_system): return abs_path_in_system -- cgit v1.2.3 From d7635ac49ff1f64e85287b9a3cd8ff61de38a057 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 23 Aug 2013 15:47:44 -0300 Subject: Refactor basic password checks. Closes #3552. --- src/leap/bitmask/gui/preferenceswindow.py | 35 ++----------------- src/leap/bitmask/gui/wizard.py | 41 +++------------------- src/leap/bitmask/util/password.py | 58 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 69 deletions(-) create mode 100644 src/leap/bitmask/util/password.py (limited to 'src') diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py index 67448768..a8220e86 100644 --- a/src/leap/bitmask/gui/preferenceswindow.py +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -26,6 +26,7 @@ from PySide import QtGui from leap.bitmask.gui.ui_preferences import Ui_Preferences from leap.soledad.client import NoStorageSecret from leap.bitmask.crypto.srpauth import SRPAuthBadPassword +from leap.bitmask.util.password import basic_password_checks logger = logging.getLogger(__name__) @@ -59,37 +60,6 @@ class PreferencesWindow(QtGui.QDialog): # Connections self.ui.pbChangePassword.clicked.connect(self._change_password) - def _basic_password_checks(self, username, password, password2): - """ - Performs basic password checks to avoid really easy passwords. - - :param username: username provided at the registrarion form - :type username: str - :param password: password from the registration form - :type password: str - :param password2: second password from the registration form - :type password: str - - :returns: True and empty message if all the checks pass, - False and an error message otherwise - :rtype: tuple(bool, str) - """ - message = None - - if message is None and password != password2: - message = self.tr("Passwords don't match") - - if message is None and len(password) < 6: - message = self.tr("Password too short") - - if message is None and password in self.WEAK_PASSWORDS: - message = self.tr("Password too easy") - - if message is None and username == password: - message = self.tr("Password equal to username") - - return message is None, message - def _set_password_change_status(self, status, error=False, success=False): """ Sets the status label for the password change. @@ -132,8 +102,7 @@ class PreferencesWindow(QtGui.QDialog): new_password = self.ui.leNewPassword.text() new_password2 = self.ui.leNewPassword2.text() - ok, msg = self._basic_password_checks( - username, new_password, new_password2) + ok, msg = basic_password_checks(username, new_password, new_password2) if not ok: self._set_changing_password(False) diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py index ed6c1da0..e3f0085b 100644 --- a/src/leap/bitmask/gui/wizard.py +++ b/src/leap/bitmask/gui/wizard.py @@ -32,6 +32,7 @@ from leap.bitmask.crypto.srpregister import SRPRegister from leap.bitmask.util.privilege_policies import is_missing_policy_permissions from leap.bitmask.util.request_helpers import get_content from leap.bitmask.util.keyring_helpers import has_keyring +from leap.bitmask.util.password import basic_password_checks from leap.bitmask.services.eip.providerbootstrapper import ProviderBootstrapper from leap.bitmask.services import get_supported @@ -199,41 +200,6 @@ class Wizard(QtGui.QWizard): """ self.ui.lblPassword2.setFocus() - def _basic_password_checks(self, username, password, password2): - """ - Performs basic password checks to avoid really easy passwords. - - :param username: username provided at the registrarion form - :type username: str - :param password: password from the registration form - :type password: str - :param password2: second password from the registration form - :type password: str - - :return: returns True if all the checks pass, False otherwise - :rtype: bool - """ - message = None - - if message is None and password != password2: - message = self.tr("Passwords don't match") - - if message is None and len(password) < 6: - message = self.tr("Password too short") - - if message is None and password in self.WEAK_PASSWORDS: - message = self.tr("Password too easy") - - if message is None and username == password: - message = self.tr("Password equal to username") - - if message is not None: - self._set_register_status(message, error=True) - self._focus_password() - return False - - return True - def _register(self): """ Performs the registration based on the values provided in the form @@ -244,7 +210,8 @@ class Wizard(QtGui.QWizard): password = self.ui.lblPassword.text() password2 = self.ui.lblPassword2.text() - if self._basic_password_checks(username, password, password2): + ok, msg = basic_password_checks(username, password, password2) + if ok: register = SRPRegister(provider_config=self._provider_config) register.registration_finished.connect( self._registration_finished) @@ -258,6 +225,8 @@ class Wizard(QtGui.QWizard): self._password = password self._set_register_status(self.tr("Starting registration...")) else: + self._set_register_status(msg, error=True) + self._focus_password() self.ui.btnRegister.setEnabled(True) def _set_registration_fields_visibility(self, visible): diff --git a/src/leap/bitmask/util/password.py b/src/leap/bitmask/util/password.py new file mode 100644 index 00000000..73659f0d --- /dev/null +++ b/src/leap/bitmask/util/password.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# password.py +# Copyright (C) 2013 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 . + +""" +Password utilities +""" +from PySide import QtCore + +WEAK_PASSWORDS = ("123456", "qweasd", "qwerty", "password") + + +def basic_password_checks(username, password, password2): + """ + Performs basic password checks to avoid really easy passwords. + + :param username: username provided at the registrarion form + :type username: str + :param password: password from the registration form + :type password: str + :param password2: second password from the registration form + :type password: str + + :returns: True and empty message if all the checks pass, + False and an error message otherwise + :rtype: tuple(bool, str) + """ + # translation helper + _tr = QtCore.QObject().tr + + message = None + + if message is None and password != password2: + message = _tr("Passwords don't match") + + if message is None and len(password) < 6: + message = _tr("Password too short") + + if message is None and password in WEAK_PASSWORDS: + message = _tr("Password too easy") + + if message is None and username == password: + message = _tr("Password equal to username") + + return message is None, message -- cgit v1.2.3 From 721aa952da943cf3e1ffd3a2a4d1d9a92ee51312 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 27 Aug 2013 17:11:38 +0200 Subject: more naming changes --- src/leap/bitmask/platform_init/locks.py | 4 ++-- src/leap/bitmask/util/requirement_checker.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/leap/bitmask/platform_init/locks.py b/src/leap/bitmask/platform_init/locks.py index ecfe3b1f..34f884dc 100644 --- a/src/leap/bitmask/platform_init/locks.py +++ b/src/leap/bitmask/platform_init/locks.py @@ -185,7 +185,7 @@ if platform_init.IS_WIN: Creates a lock based on the atomic nature of mkdir on Windows system calls. """ - LOCKBASE = os.path.join(gettempdir(), "leap-client-lock") + LOCKBASE = os.path.join(gettempdir(), "bitmask-lock") def __init__(self): """ @@ -353,7 +353,7 @@ def we_are_the_one_and_only(): _sys = platform.system() if _sys in ("Linux", "Darwin"): - locker = UnixLock('/tmp/leap-client.lock') + locker = UnixLock('/tmp/bitmask.lock') locker.get_lock() we_are_the_one = locker.locked_by_us if not we_are_the_one: diff --git a/src/leap/bitmask/util/requirement_checker.py b/src/leap/bitmask/util/requirement_checker.py index 1d9b9923..bd3c1412 100644 --- a/src/leap/bitmask/util/requirement_checker.py +++ b/src/leap/bitmask/util/requirement_checker.py @@ -51,8 +51,9 @@ def get_requirements(): # if we are running from the package if not develop: - requires_file_name = os.path.join('leap', 'util', 'reqs.txt') - dist_name = Requirement.parse('leap-client') + requires_file_name = os.path.join( + 'leap', 'bitmask', 'util', 'reqs.txt') + dist_name = Requirement.parse('bitmask') try: with resource_stream(dist_name, requires_file_name) as stream: -- cgit v1.2.3