From 459024de9e36aea0813aa01a570b68db7e9c1a26 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 6 Oct 2015 14:41:18 -0300 Subject: [bug] consider STANDALONE for the paths Since we need to write a file we have to consider whether we are running in 'standalone' mode or not to use the right path prefix. - Related: #7512 --- src/leap/common/config/flags.py | 28 ++++++++++++++++++++++++++++ src/leap/common/events/client.py | 5 ++--- src/leap/common/events/txclient.py | 2 +- src/leap/common/events/zmq_components.py | 4 ++-- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/leap/common/config/flags.py (limited to 'src/leap/common') diff --git a/src/leap/common/config/flags.py b/src/leap/common/config/flags.py new file mode 100644 index 0000000..6fd43f6 --- /dev/null +++ b/src/leap/common/config/flags.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# flags.py +# Copyright (C) 2015 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 . +""" +This file is meant to be used to store global flags that affect the +application. + +WARNING: You should NOT use this kind of flags unless you're sure of what + you're doing, and someone else tells you that you're right. + Most of the times there is a better and safer alternative. +""" + +# The STANDALONE flag is used to: +# - use a relative or system wide path to find the configuration files. +STANDALONE = False diff --git a/src/leap/common/events/client.py b/src/leap/common/events/client.py index e38e9d3..60d24bc 100644 --- a/src/leap/common/events/client.py +++ b/src/leap/common/events/client.py @@ -47,7 +47,7 @@ try: except ImportError: pass -from leap.common.config import get_path_prefix +from leap.common.config import flags, get_path_prefix from leap.common.zmq_utils import zmq_has_curve from leap.common.zmq_utils import maybe_create_and_get_certificates from leap.common.zmq_utils import PUBLIC_KEYS_PREFIX @@ -55,7 +55,6 @@ from leap.common.zmq_utils import PUBLIC_KEYS_PREFIX from leap.common.events.errors import CallbackAlreadyRegisteredError from leap.common.events.server import EMIT_ADDR from leap.common.events.server import REG_ADDR -from leap.common.events import flags from leap.common.events import catalog @@ -280,7 +279,7 @@ class EventsClientThread(threading.Thread, EventsClient): self._lock = threading.Lock() self._initialized = threading.Event() self._config_prefix = os.path.join( - get_path_prefix(), "leap", "events") + get_path_prefix(flags.STANDALONE), "leap", "events") self._loop = None self._context = None self._push = None diff --git a/src/leap/common/events/txclient.py b/src/leap/common/events/txclient.py index f3c183e..dfd0533 100644 --- a/src/leap/common/events/txclient.py +++ b/src/leap/common/events/txclient.py @@ -35,7 +35,7 @@ from leap.common.events.client import EventsClient from leap.common.events.client import configure_client from leap.common.events.server import EMIT_ADDR from leap.common.events.server import REG_ADDR -from leap.common.events import catalog, flags +from leap.common.events import catalog logger = logging.getLogger(__name__) diff --git a/src/leap/common/events/zmq_components.py b/src/leap/common/events/zmq_components.py index f99c754..729ca90 100644 --- a/src/leap/common/events/zmq_components.py +++ b/src/leap/common/events/zmq_components.py @@ -36,7 +36,7 @@ try: except ImportError: pass -from leap.common.config import get_path_prefix +from leap.common.config import flags, get_path_prefix from leap.common.zmq_utils import zmq_has_curve from leap.common.zmq_utils import maybe_create_and_get_certificates from leap.common.zmq_utils import PUBLIC_KEYS_PREFIX @@ -64,7 +64,7 @@ class TxZmqComponent(object): self._factory = txzmq.ZmqFactory() self._factory.registerForShutdown() if path_prefix is None: - path_prefix = get_path_prefix() + path_prefix = get_path_prefix(flags.STANDALONE) self._config_prefix = os.path.join(path_prefix, "leap", "events") self._connections = [] -- cgit v1.2.3 From c1781d87a76f941c588709405cd5b2634dc6b1e8 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 9 Oct 2015 15:01:13 -0400 Subject: [bug] fix wrong ca_cert path inside bundle -Resolves: #7524 --- src/leap/common/ca_bundle.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/leap/common') diff --git a/src/leap/common/ca_bundle.py b/src/leap/common/ca_bundle.py index 2c41d18..c0ce35f 100644 --- a/src/leap/common/ca_bundle.py +++ b/src/leap/common/ca_bundle.py @@ -21,8 +21,9 @@ If you are packaging Requests, e.g., for a Linux distribution or a managed environment, you can change the definition of where() to return a separately packaged CA bundle. """ -import platform import os.path +import platform +import sys _system = platform.system() @@ -34,12 +35,11 @@ def where(): Return the preferred certificate bundle. :rtype: str """ - # vendored bundle inside Requests, plus some additions of ours - if IS_MAC: - return os.path.join("/Applications", "Bitmask.app", - "Contents", "Resources", - "cacert.pem") - return os.path.join(os.path.dirname(__file__), 'cacert.pem') + if getattr(sys, 'frozen', False): + # we are running in a |PyInstaller| bundle + path = sys._MEIPASS + return os.path.join(path, 'cacert.pem') + return os.path.join(os.path, dirname(__file__), 'cacert.pem') if __name__ == '__main__': print(where()) -- cgit v1.2.3 From c105a8d3b016cc907a908de1a31b445b32b42ca9 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 13 Oct 2015 13:09:45 -0300 Subject: [bug] fix typo on dirname usage --- src/leap/common/ca_bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/common') diff --git a/src/leap/common/ca_bundle.py b/src/leap/common/ca_bundle.py index c0ce35f..e2a624d 100644 --- a/src/leap/common/ca_bundle.py +++ b/src/leap/common/ca_bundle.py @@ -39,7 +39,7 @@ def where(): # we are running in a |PyInstaller| bundle path = sys._MEIPASS return os.path.join(path, 'cacert.pem') - return os.path.join(os.path, dirname(__file__), 'cacert.pem') + return os.path.join(os.path.dirname(__file__), 'cacert.pem') if __name__ == '__main__': print(where()) -- cgit v1.2.3 From 5af395a5662c63a09cc6db2bacbb495090488d78 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Wed, 21 Oct 2015 10:07:06 +0200 Subject: Workaround for deadlock problem in zmq auth - See https://leap.se/code/issues/7536 - Actual root cause not identified yet --- src/leap/common/events/zmq_components.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/leap/common') diff --git a/src/leap/common/events/zmq_components.py b/src/leap/common/events/zmq_components.py index 729ca90..51de02c 100644 --- a/src/leap/common/events/zmq_components.py +++ b/src/leap/common/events/zmq_components.py @@ -25,6 +25,7 @@ import os import logging import txzmq import re +import time from abc import ABCMeta @@ -154,6 +155,11 @@ class TxZmqComponent(object): :type socket: zmq.Socket """ authenticator = ThreadAuthenticator(self._factory.context) + + # Temporary fix until we understand what the problem is + # See https://leap.se/code/issues/7536 + time.sleep(0.5) + authenticator.start() # XXX do not hardcode this here. authenticator.allow('127.0.0.1') -- cgit v1.2.3