From 65bbc9ac87092053a8079d4d7d88cac4df5fbc36 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Thu, 10 Apr 2014 16:59:07 -0300 Subject: Add flag to start the app hidden in the tray. Closes #4990. --- src/leap/bitmask/util/leap_argparse.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py index 88267ff8..8aacc85d 100644 --- a/src/leap/bitmask/util/leap_argparse.py +++ b/src/leap/bitmask/util/leap_argparse.py @@ -59,6 +59,9 @@ def build_parser(): action="store_false", dest="api_version_check", help='Skip the api version compatibility check with ' 'the provider.') + parser.add_argument('-H', '--start-hidden', default=False, + action="store_true", dest="start_hidden", + help='Starts the application just in the taskbar.') # openvpn options parser.add_argument('--openvpn-verbosity', nargs='?', -- cgit v1.2.3 From da22a4ced468432d4a5c58bd34c74f3e445dfce5 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Fri, 11 Apr 2014 12:17:17 -0300 Subject: Add post limit exception and remove legacy code. --- src/leap/bitmask/util/pastebin.py | 105 +++++--------------------------------- 1 file changed, 13 insertions(+), 92 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/pastebin.py b/src/leap/bitmask/util/pastebin.py index 21b8a0b7..a3bdba02 100755 --- a/src/leap/bitmask/util/pastebin.py +++ b/src/leap/bitmask/util/pastebin.py @@ -27,8 +27,8 @@ __ALL__ = ['delete_paste', 'user_details', 'trending', 'pastes_by_user', - 'generate_user_key', 'legacy_paste', 'paste', 'Pastebin', - 'PastebinError'] + 'generate_user_key', 'paste', 'Pastebin', 'PastebinError', + 'PostLimitError'] import urllib @@ -40,6 +40,12 @@ class PastebinError(RuntimeError): exception message.""" +class PostLimitError(PastebinError): + """The user reached the limit of posts that can do in a day. + For more information look at: http://pastebin.com/faq#11a + """ + + class PastebinAPI(object): """Pastebin API interaction object. @@ -67,6 +73,9 @@ class PastebinAPI(object): # String to determine bad API requests _bad_request = 'Bad API request' + # String to determine if we reached the max post limit per day + _post_limit = 'Post limit, maximum pastes per 24h reached' + # Base domain name _base_domain = 'pastebin.com' @@ -708,95 +717,8 @@ class PastebinAPI(object): # errors we are likely to encounter if response.startswith(self._bad_request): raise PastebinError(response) - elif not response.startswith(self._prefix_url): - raise PastebinError(response) - - return response - - def legacy_paste(self, paste_code, - paste_name=None, paste_private=None, - paste_expire_date=None, paste_format=None): - """Unofficial python interface to the Pastebin legacy API. - - Unlike the official API, this one doesn't require an API key, so it's - virtually anonymous. - - - Usage Example:: - from pastebin import PastebinAPI - x = PastebinAPI() - url = x.legacy_paste('Snippet of code to paste goes here', - paste_name = 'title of paste', - paste_private = 'unlisted', - paste_expire_date = '10M', - paste_format = 'python') - print url - http://pastebin.com/tawPUgqY - - - @type paste_code: string - @param paste_code: The file or string to paste to body of the - U{http://pastebin.com} paste. - - @type paste_name: string - @param paste_name: (Optional) Title of the paste. - Default is to paste with no title. - - @type paste_private: string - @param paste_private: (Optional) C{'public'} if the paste is public - (visible by everyone), C{'unlisted'} if it's public but not - searchable. C{'private'} if the paste is private and not - searchable or indexed. - The Pastebin FAQ (U{http://pastebin.com/faq}) claims - private pastes are not indexed by search engines (aka Google). - - @type paste_expire_date: string - @param paste_expire_date: (Optional) Expiration date for the paste. - Once past this date the paste is deleted automatically. Valid - values are found in the L{PastebinAPI.paste_expire_date} class - member. - If not provided, the paste never expires. - - @type paste_format: string - @param paste_format: (Optional) Programming language of the code being - pasted. This enables syntax highlighting when reading the code in - U{http://pastebin.com}. Default is no syntax highlighting (text is - just text and not source code). - - @rtype: string - @return: Returns the URL to the newly created paste. - """ - - # Code snippet to submit - argv = {'paste_code': str(paste_code)} - - # Name of the poster - if paste_name is not None: - argv['paste_name'] = str(paste_name) - - # Is the snippet private? - if paste_private is not None: - argv['paste_private'] = int(bool(int(paste_private))) - - # Expiration for the snippet - if paste_expire_date is not None: - paste_expire_date = str(paste_expire_date).strip().upper() - argv['paste_expire_date'] = paste_expire_date - - # Syntax highlighting - if paste_format is not None: - paste_format = str(paste_format).strip().lower() - argv['paste_format'] = paste_format - - # lets try to read the URL that we've just built. - data = urllib.urlencode(argv) - request_string = urllib.urlopen(self._legacy_api_url, data) - response = request_string.read() - - # do some basic error checking here so we can gracefully handle any - # errors we are likely to encounter - if response.startswith(self._bad_request): - raise PastebinError(response) + elif response.startswith(self._post_limit): + raise PostLimitError(response) elif not response.startswith(self._prefix_url): raise PastebinError(response) @@ -810,5 +732,4 @@ user_details = PastebinAPI.user_details trending = PastebinAPI.trending pastes_by_user = PastebinAPI.pastes_by_user generate_user_key = PastebinAPI.generate_user_key -legacy_paste = PastebinAPI.legacy_paste paste = PastebinAPI.paste -- cgit v1.2.3 From bcf3c5d5928585e06c058bf1754100d078919bbd Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 22 Apr 2014 17:06:46 -0300 Subject: Add flag to skip provider checks in wizard. --- src/leap/bitmask/util/leap_argparse.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/leap_argparse.py b/src/leap/bitmask/util/leap_argparse.py index 8aacc85d..84af4e8d 100644 --- a/src/leap/bitmask/util/leap_argparse.py +++ b/src/leap/bitmask/util/leap_argparse.py @@ -62,6 +62,10 @@ def build_parser(): parser.add_argument('-H', '--start-hidden', default=False, action="store_true", dest="start_hidden", help='Starts the application just in the taskbar.') + parser.add_argument('-S', '--skip-wizard-checks', default=False, + action="store_true", dest="skip_wizard_checks", + help='Skips the provider checks in the wizard (use ' + 'for testing purposes only).') # openvpn options parser.add_argument('--openvpn-verbosity', nargs='?', -- cgit v1.2.3 From 745ae7f55836ff331d9176b52cc98df451a3c2ef Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 8 May 2014 10:41:55 -0500 Subject: change paths for installing the latest helpers --- src/leap/bitmask/util/privilege_policies.py | 82 ++--------------------------- 1 file changed, 3 insertions(+), 79 deletions(-) (limited to 'src/leap/bitmask/util') diff --git a/src/leap/bitmask/util/privilege_policies.py b/src/leap/bitmask/util/privilege_policies.py index 72442553..9d1e2c9a 100644 --- a/src/leap/bitmask/util/privilege_policies.py +++ b/src/leap/bitmask/util/privilege_policies.py @@ -27,35 +27,6 @@ from abc import ABCMeta, abstractmethod logger = logging.getLogger(__name__) -POLICY_TEMPLATE = """ - - - - LEAP Project - https://leap.se/ - - - Runs the openvpn binary - Ejecuta el binario openvpn - OpenVPN needs that you authenticate to start - - OpenVPN necesita autorizacion para comenzar - - package-x-generic - - yes - yes - yes - - {path} - true - - -""" - - def is_missing_policy_permissions(): """ Returns True if we do not have implemented a policy checker for this @@ -76,36 +47,6 @@ def is_missing_policy_permissions(): return policy_checker().is_missing_policy_permissions() -def get_policy_contents(openvpn_path): - """ - Returns the contents that the policy file should have. - - :param openvpn_path: the openvpn path to use in the polkit file - :type openvpn_path: str - :rtype: str - """ - return POLICY_TEMPLATE.format(path=openvpn_path) - - -def is_policy_outdated(path): - """ - Returns if the existing polkit file is outdated, comparing if the path - is correct. - - :param path: the path that should have the polkit file. - :type path: str. - :rtype: bool - """ - _system = platform.system() - platform_checker = _system + "PolicyChecker" - policy_checker = globals().get(platform_checker, None) - if policy_checker is None: - logger.debug("we could not find a policy checker implementation " - "for %s" % (_system,)) - return False - return policy_checker().is_outdated(path) - - class PolicyChecker: """ Abstract PolicyChecker class @@ -129,7 +70,7 @@ class LinuxPolicyChecker(PolicyChecker): PolicyChecker for Linux """ LINUX_POLKIT_FILE = ("/usr/share/polkit-1/actions/" - "net.openvpn.gui.leap.policy") + "se.leap.bitmask.policy") @classmethod def get_polkit_path(self): @@ -141,6 +82,8 @@ class LinuxPolicyChecker(PolicyChecker): return self.LINUX_POLKIT_FILE def is_missing_policy_permissions(self): + # FIXME this name is quite confusing, it does not have anything to do with + # file permissions. """ Returns True if we could not find the appropriate policykit file in place @@ -148,22 +91,3 @@ class LinuxPolicyChecker(PolicyChecker): :rtype: bool """ return not os.path.isfile(self.LINUX_POLKIT_FILE) - - def is_outdated(self, path): - """ - Returns if the existing polkit file is outdated, comparing if the path - is correct. - - :param path: the path that should have the polkit file. - :type path: str. - :rtype: bool - """ - polkit = None - try: - with open(self.LINUX_POLKIT_FILE) as f: - polkit = f.read() - except IOError, e: - logger.error("Error reading polkit file(%s): %r" % ( - self.LINUX_POLKIT_FILE, e)) - - return get_policy_contents(path) != polkit -- cgit v1.2.3