summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-18 11:11:43 +0900
committerkali <kali@leap.se>2012-09-18 19:10:13 +0900
commit0d35f2a82bf15504ace2135af3e0c66ae1c16874 (patch)
tree1915d4f9326ec4f44c553ebad37032f57f6e636a
parent430b6326d06d81c44d534543c8e9684a5c0fcb15 (diff)
do_branding command added to setup
-rw-r--r--.gitignore2
-rw-r--r--MANIFEST.in2
-rw-r--r--data/TODO1
-rw-r--r--data/branding/cacert.pem24
-rw-r--r--pkg/branding/__init__.py15
-rw-r--r--pkg/branding/config.py11
-rwxr-xr-xsetup.py149
-rw-r--r--src/leap/__init__.py5
-rw-r--r--src/leap/app.py2
-rw-r--r--src/leap/base/config.py2
-rw-r--r--src/leap/base/constants.py15
-rw-r--r--src/leap/base/tests/test_config.py2
-rw-r--r--src/leap/baseapp/eip.py19
-rw-r--r--src/leap/certs/__init__.py7
-rw-r--r--src/leap/eip/checks.py14
-rw-r--r--src/leap/eip/eipconnection.py4
-rw-r--r--src/leap/eip/openvpnconnection.py7
-rw-r--r--src/leap/eip/specs.py10
18 files changed, 253 insertions, 38 deletions
diff --git a/.gitignore b/.gitignore
index 1f473a00..a8e2ce6d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,6 @@ man/
share/
src/leap.egg-info/
src/leap_client.egg-info
+src/leap/_branding.py
+src/leap/certs/*.pem
MANIFEST
diff --git a/MANIFEST.in b/MANIFEST.in
index d67d3142..685cee16 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1,5 @@
include pkg/*
+include pkg/branding/*
include docs/*
include versioneer.py
+include src/leap/certs/*.pem
diff --git a/data/TODO b/data/TODO
deleted file mode 100644
index 580227ac..00000000
--- a/data/TODO
+++ /dev/null
@@ -1 +0,0 @@
-icons file and stuff should be moved here at some point!
diff --git a/data/branding/cacert.pem b/data/branding/cacert.pem
new file mode 100644
index 00000000..ed12e159
--- /dev/null
+++ b/data/branding/cacert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Zj29ciwfwrqrtuWZ7km+og0Clcd
+pIB0g+DK0K//NtaDZDK0havQw2AFJKyXlNfI8XZ2jsNmQYR1wtiMci+UfGQr7bjn
+Kw9yyVCf0ohXvnSK4ortz/bDQbcMWkK0m/VCCEK8PSldk+XFzPWFWn5ndKCczcvd
+1BQc392n12ZstEuzm6+d9A0D3kCxralJUXUC+4kThq4Rtjey/gBjyZQnZ+5tIxMF
+5ZFAStEglNxqm6HB17q7owJqTvIg9Cf9GATsvoFFQDJrBXewRX7cWVeSr0zNSQB4
+ydIlSUOkyE3AyfLN+lx8NVS/I7gp4fWDuHrh27NKKDtMxalxPL5pTGO7l4uTybLY
+4aVzQYGvzA5HVS++VAtcTQ6TP9p4HURL2cllEU9u9A==
+-----END CERTIFICATE-----
diff --git a/pkg/branding/__init__.py b/pkg/branding/__init__.py
new file mode 100644
index 00000000..0bd6befb
--- /dev/null
+++ b/pkg/branding/__init__.py
@@ -0,0 +1,15 @@
+from .config import APP_BASE_NAME, APP_PREFIX, BRANDED_BUILD, BRANDED_OPTS
+
+
+def get_name():
+ if BRANDED_BUILD is True:
+ return APP_PREFIX + BRANDED_OPTS.get('short_name', 'name_unknown')
+ else:
+ return APP_BASE_NAME
+
+
+def get_shortname():
+ if BRANDED_BUILD is True:
+ return BRANDED_OPTS.get('short_name', 'name_unknown')
+
+__all__ = ['get_name']
diff --git a/pkg/branding/config.py b/pkg/branding/config.py
new file mode 100644
index 00000000..665cfbda
--- /dev/null
+++ b/pkg/branding/config.py
@@ -0,0 +1,11 @@
+# Configuration file for branding
+
+BRANDED_BUILD = True
+
+APP_BASE_NAME = "leap-client"
+APP_PREFIX = "%s-" % APP_BASE_NAME
+
+BRANDED_OPTS = {
+ 'short_name': "springbok",
+ 'provider_domain': "springbok",
+ 'provider_ca_path': "data/branding/cacert.pem"}
diff --git a/setup.py b/setup.py
index 256d5105..74775dd0 100755
--- a/setup.py
+++ b/setup.py
@@ -12,11 +12,17 @@ except ImportError:
import os
from pkg import utils
+from pkg import branding
import versioneer
versioneer.versionfile_source = 'src/leap/_version.py'
versioneer.versionfile_build = 'leap/_version.py'
versioneer.tag_prefix = '' # tags are like 1.2.0
-versioneer.parentdir_prefix = 'leap_client-'
+#versioneer.parentdir_prefix = 'leap_client-'
+versioneer.parentdir_prefix = branding.APP_PREFIX
+
+branding.brandingfile = 'src/leap/_branding.py'
+branding.brandingfile_build = 'leap/_branding.py'
+branding.cert_path = 'src/leap/certs'
setup_root = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(setup_root, "src"))
@@ -37,11 +43,139 @@ trove_classifiers = [
"Topic :: Utilities"
]
+BRANDING_OPTS = """
+# Do NOT manually edit this file!
+# This file has been written from pkg/branding/config.py data by leap setup.py
+# script.
+
+BRANDING = {
+ 'short_name': "%(short_name)s",
+ 'provider_domain': "%(provider_domain)s",
+ 'provider_ca_file': "%(provider_ca_file)s"}
+"""
+
+
+def write_to_branding_file(filename, branding_dict):
+ f = open(filename, "w")
+ f.write(BRANDING_OPTS % branding_dict)
+ f.close()
+
+
+def copy_pemfile_to_certdir(frompath, topath):
+ with open(frompath, "r") as cert_f:
+ cert_s = cert_f.read()
+ with open(topath, "w") as f:
+ f.write(cert_s)
+
+
+def do_branding(targetfile=branding.brandingfile):
+ if branding.BRANDED_BUILD:
+ opts = branding.BRANDED_OPTS
+ print("DOING BRANDING FOR LEAP")
+ certpath = opts['provider_ca_path']
+ shortname = opts['short_name']
+ tocertfile = shortname + '-cacert.pem'
+ topath = os.path.join(
+ branding.cert_path,
+ tocertfile)
+ copy_pemfile_to_certdir(
+ certpath,
+ topath)
+ opts['provider_ca_file'] = tocertfile
+ write_to_branding_file(
+ targetfile,
+ opts)
+ else:
+ print('not running branding because BRANDED_BUILD set to False')
+
+
+from setuptools import Command
+
+
+class DoBranding(Command):
+ description = "copy the branding info the the top level package"
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ do_branding()
+
+from distutils.command.build import build as _build
+from distutils.command.sdist import sdist as _sdist
+
+
+class cmd_build(_build):
+ def run(self):
+ #versioneer.cmd_build(self)
+ _build.run(self)
+
+ # versioneer
+ versions = versioneer.get_versions(verbose=True)
+ # now locate _version.py in the new build/ directory and replace it
+ # with an updated value
+ target_versionfile = os.path.join(
+ self.build_lib,
+ versioneer.versionfile_build)
+ print("UPDATING %s" % target_versionfile)
+ os.unlink(target_versionfile)
+ f = open(target_versionfile, "w")
+ f.write(versioneer.SHORT_VERSION_PY % versions)
+ f.close()
+
+ # branding
+ target_brandingfile = os.path.join(
+ self.build_lib,
+ branding.brandingfile_build)
+ do_branding(targetfile=target_brandingfile)
+
+
+class cmd_sdist(_sdist):
+ def run(self):
+ # versioneer:
+ versions = versioneer.get_versions(verbose=True)
+ self._versioneer_generated_versions = versions
+ # unless we update this, the command will keep using the old version
+ self.distribution.metadata.version = versions["version"]
+
+ # branding:
+ do_branding()
+ return _sdist.run(self)
+
+ def make_release_tree(self, base_dir, files):
+ _sdist.make_release_tree(self, base_dir, files)
+ # now locate _version.py in the new base_dir directory (remembering
+ # that it may be a hardlink) and replace it with an updated value
+ target_versionfile = os.path.join(
+ base_dir, versioneer.versionfile_source)
+ print("UPDATING %s" % target_versionfile)
+ os.unlink(target_versionfile)
+ f = open(target_versionfile, "w")
+ f.write(
+ versioneer.SHORT_VERSION_PY % self._versioneer_generated_versions)
+ f.close()
+
+
+cmdclass = versioneer.get_cmdclass()
+cmdclass["branding"] = DoBranding
+cmdclass["build"] = cmd_build
+cmdclass["sdist"] = cmd_sdist
+
+launcher_name = branding.get_shortname()
+if launcher_name:
+ leap_launcher = 'leap-%s-client=leap.app:main' % launcher_name
+else:
+ leap_launcher = 'leap=leap.app:main'
+
setup(
- name='leap-client',
+ name=branding.get_name(),
package_dir={"": "src"},
version=versioneer.get_version(),
- cmdclass=versioneer.get_cmdclass(),
+ cmdclass=cmdclass,
description="the internet encryption toolkit",
long_description=(
"Desktop Client for the LEAP Platform."
@@ -79,8 +213,11 @@ setup(
["pkg/linux/polkit/net.openvpn.gui.leap.policy"])
],
platforms="all",
- scripts=["pkg/scripts/leap"],
- entry_points="""
+ #scripts=["pkg/scripts/leap"],
+ entry_points = {
+ 'console_scripts': [leap_launcher]
+ },
+ #entry_points="""
# -*- Entry points: -*-
- """,
+ #""",
)
diff --git a/src/leap/__init__.py b/src/leap/__init__.py
index 75bddd6d..5e003931 100644
--- a/src/leap/__init__.py
+++ b/src/leap/__init__.py
@@ -28,3 +28,8 @@ except ImportError:
pass
__full_version__ = __appname__ + '/' + str(__version__)
+
+try:
+ from leap._branding import BRANDING as __branding
+except ImportError:
+ __branding = {}
diff --git a/src/leap/app.py b/src/leap/app.py
index b721468f..1aebfca2 100644
--- a/src/leap/app.py
+++ b/src/leap/app.py
@@ -44,7 +44,7 @@ def main():
fileh.setFormatter(formatter)
logger.addHandler(fileh)
- logger.debug('args: %s' % opts)
+ #logger.debug('args: %s' % opts)
logger.info('Starting app')
logger.info('Running client version %s', VERSION)
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 5a52637c..e896ffd2 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -239,7 +239,7 @@ def get_config_file(filename, folder=None):
def get_default_provider_path():
default_subpath = os.path.join("providers",
- constants.DEFAULT_TEST_PROVIDER)
+ constants.DEFAULT_PROVIDER)
default_provider_path = get_config_file(
'',
folder=default_subpath)
diff --git a/src/leap/base/constants.py b/src/leap/base/constants.py
index 6266c693..f3e24715 100644
--- a/src/leap/base/constants.py
+++ b/src/leap/base/constants.py
@@ -1,23 +1,26 @@
"""constants to be used in base module"""
-APP_NAME = "leap"
+from leap import __branding
+APP_NAME = __branding.get("short_name", "leap")
# default provider placeholder
# using `example.org` we make sure that this
# is not going to be resolved during the tests phases
# (we expect testers to add it to their /etc/hosts
-DEFAULT_TEST_PROVIDER = "testprovider.example.org"
+DEFAULT_PROVIDER = __branding.get(
+ "provider_domain",
+ "testprovider.example.org")
-DEFINITION_EXPECTED_PATH = "provider-definition.json"
+DEFINITION_EXPECTED_PATH = "definition.json"
DEFAULT_PROVIDER_DEFINITION = {
- u'api_uri': u'https://api.testprovider.example.org/',
+ u'api_uri': u'https://api.%s/' % DEFAULT_PROVIDER,
u'api_version': u'0.1.0',
u'ca_cert': u'8aab80ae4326fd30721689db813733783fe0bd7e',
- u'ca_cert_uri': u'https://testprovider.example.org/cacert.pem',
+ u'ca_cert_uri': u'https://%s/cacert.pem' % DEFAULT_PROVIDER,
u'description': {u'en': u'This is a test provider'},
u'display_name': {u'en': u'Test Provider'},
- u'domain': u'testprovider.example.org',
+ u'domain': u'%s' % DEFAULT_PROVIDER,
u'enrollment_policy': u'open',
u'public_key': u'cb7dbd679f911e85bc2e51bd44afd7308ee19c21',
u'serial': 1,
diff --git a/src/leap/base/tests/test_config.py b/src/leap/base/tests/test_config.py
index 40461b99..74b06119 100644
--- a/src/leap/base/tests/test_config.py
+++ b/src/leap/base/tests/test_config.py
@@ -218,7 +218,7 @@ class ConfigHelperFunctions(BaseLeapTest):
config.get_default_provider_path(),
os.path.expanduser(
'~/.config/leap/providers/%s/' %
- constants.DEFAULT_TEST_PROVIDER)
+ constants.DEFAULT_PROVIDER)
)
# validate ip
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index 515ae58d..ff6a79ac 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -1,5 +1,7 @@
+from __future__ import print_function
import logging
import time
+import sys
from PyQt4 import QtCore
@@ -38,8 +40,9 @@ class EIPConductorAppMixin(object):
debug=self.debugmode,
ovpn_verbosity=opts.openvpn_verb)
- # XXX remove skip download when sample service is ready
- self.conductor.run_checks(skip_download=True)
+ # XXX get skip_download from cli flag
+ skip_download = False
+ self.conductor.run_checks(skip_download=skip_download)
self.error_check()
# XXX should receive "ready" signal
@@ -58,13 +61,11 @@ class EIPConductorAppMixin(object):
"""
logger.debug('error check')
- #####################################
- # XXX refactor in progress (by #504)
-
errq = self.conductor.error_queue
while errq.qsize() != 0:
logger.debug('%s errors left in conductor queue', errq.qsize())
- error = errq.get()
+ # we get exception and original traceback from queue
+ error, tb = errq.get()
# redundant log, debugging the loop.
logger.error('%s: %s', error.__class__.__name__, error.message)
@@ -73,10 +74,8 @@ class EIPConductorAppMixin(object):
self.handle_eip_error(error)
else:
- # This is not quite working. FIXME
- import traceback
- traceback.print_exc()
- raise error
+ # deprecated form of raising exception.
+ raise error, None, tb
if error.failfirst is True:
break
diff --git a/src/leap/certs/__init__.py b/src/leap/certs/__init__.py
new file mode 100644
index 00000000..c4d009b1
--- /dev/null
+++ b/src/leap/certs/__init__.py
@@ -0,0 +1,7 @@
+import os
+
+_where = os.path.split(__file__)[0]
+
+
+def where(filename):
+ return os.path.join(_where, filename)
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index f368c551..aea5a5d7 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -257,7 +257,7 @@ class ProviderCertChecker(object):
return True
def _get_client_cert_uri(self):
- return "https://%s/cert/get" % (baseconstants.DEFAULT_TEST_PROVIDER)
+ return "https://%s/cert/get" % (baseconstants.DEFAULT_PROVIDER)
def _get_client_cert_path(self):
# MVS+ : get provider path
@@ -414,14 +414,18 @@ class EIPConfigChecker(object):
def _get_provider_definition_uri(self, domain=None, path=None):
if domain is None:
- domain = baseconstants.DEFAULT_TEST_PROVIDER
+ domain = baseconstants.DEFAULT_PROVIDER
if path is None:
path = baseconstants.DEFINITION_EXPECTED_PATH
- return "https://%s/%s" % (domain, path)
+ uri = u"https://%s/%s" % (domain, path)
+ logger.debug('getting provider definition from %s' % uri)
+ return uri
def _get_eip_service_uri(self, domain=None, path=None):
if domain is None:
- domain = baseconstants.DEFAULT_TEST_PROVIDER
+ domain = baseconstants.DEFAULT_PROVIDER
if path is None:
path = eipconstants.EIP_SERVICE_EXPECTED_PATH
- return "https://%s/%s" % (domain, path)
+ uri = "https://%s/%s" % (domain, path)
+ logger.debug('getting eip service file from %s', uri)
+ return uri
diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py
index 3a879f01..d1c84b2a 100644
--- a/src/leap/eip/eipconnection.py
+++ b/src/leap/eip/eipconnection.py
@@ -4,6 +4,7 @@ EIP Connection Class
from __future__ import (absolute_import,)
import logging
import Queue
+import sys
from leap.eip.checks import EIPConfigChecker
from leap.eip import config as eipconfig
@@ -48,7 +49,8 @@ class EIPConnection(OpenVPNConnection):
self.config_checker.run_all(skip_download=skip_download)
self.run_openvpn_checks()
except Exception as exc:
- self.error_queue.put(exc)
+ exc_traceback = sys.exc_info()[2]
+ self.error_queue.put((exc, exc_traceback))
def connect(self):
"""
diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py
index c280f70d..65683485 100644
--- a/src/leap/eip/openvpnconnection.py
+++ b/src/leap/eip/openvpnconnection.py
@@ -117,11 +117,10 @@ to be triggered for each one of them.
"""
try:
eip_config.check_vpn_keys()
- except eip_exceptions.EIPInitNoKeyFileError:
- self.missing_vpn_keyfile = True
except eip_exceptions.EIPInitBadKeyFilePermError:
- logger.error('error while checking vpn keys')
- self.bad_keyfile_perms = True
+ logger.error('Bad VPN Keys permission!')
+ # do nothing now
+ # and raise the rest ...
def _launch_openvpn(self):
"""
diff --git a/src/leap/eip/specs.py b/src/leap/eip/specs.py
index e617574c..05aef590 100644
--- a/src/leap/eip/specs.py
+++ b/src/leap/eip/specs.py
@@ -1,15 +1,21 @@
from __future__ import (unicode_literals)
import os
+from leap import __branding
from leap.base import config as baseconfig
+PROVIDER_CA_CERT = __branding.get(
+ 'provider_ca_file',
+ 'testprovider-ca-cert.pem')
provider_ca_path = lambda: unicode(os.path.join(
baseconfig.get_default_provider_path(),
'keys', 'ca',
- 'testprovider-ca-cert.pem'
+ PROVIDER_CA_CERT
))
+PROVIDER_DOMAIN = __branding.get('provider_domain', 'testprovider.example.org')
+
client_cert_path = lambda: unicode(os.path.join(
baseconfig.get_default_provider_path(),
@@ -20,7 +26,7 @@ client_cert_path = lambda: unicode(os.path.join(
eipconfig_spec = {
'provider': {
'type': unicode,
- 'default': u"testprovider.example.org",
+ 'default': u"%s" % PROVIDER_DOMAIN,
'required': True,
},
'transport': {