From 875eb57d3528e9029ecc1ea85dd9bbcd8dac5022 Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Fri, 15 Nov 2013 14:28:47 +0100 Subject: [PATCH 1/6] Change for more useful documentation --- README.txt | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/README.txt b/README.txt index 2861c89..32c73e0 100644 --- a/README.txt +++ b/README.txt @@ -1,20 +1,11 @@ -This file is for you to describe the ddportfolioservice -application. Typically you would include information such as the -information below: -Installation and Setup -====================== +This is the source code for the Debian Member Portfolio Service +application [0]. -Install ``ddportfolioservice`` using easy_install:: +Cf. https://debian-member-portfolio-service.readthedocs.org/ for more +documentation (or its source in docs/source/devdocs.rst), including +how to configure a development environment. - easy_install ddportfolioservice -Make a config file as follows:: +[0] http://wiki.debian.org/DDPortfolio - paster make-config ddportfolioservice config.ini - -Tweak the config file as appropriate and then setup the application:: - - paster setup-app config.ini - -Then you are ready to go. From 2752c2e98d6d0ab7c6420ddd7a0275f0dabad342 Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Fri, 15 Nov 2013 14:31:46 +0100 Subject: [PATCH 2/6] Adopt the way which is described in /usr/share/doc/gnupg/DETAILS.gz which expands first line, and use email.utils.parseaddr() --- ddportfolioservice/model/keyringanalyzer.py | 27 ++++++--------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/ddportfolioservice/model/keyringanalyzer.py b/ddportfolioservice/model/keyringanalyzer.py index cc501c6..b3304a7 100644 --- a/ddportfolioservice/model/keyringanalyzer.py +++ b/ddportfolioservice/model/keyringanalyzer.py @@ -35,6 +35,7 @@ import os.path import logging import subprocess import sys +import email.utils def _get_keyrings(): @@ -58,22 +59,8 @@ def _parse_uid(uid): Parse a uid of the form 'Real Name ' into email and realname parts. """ - uid = uid.strip() - # First, strip comment - s = uid.find('(') - e = uid.find(')') - if s >= 0 and e >= 0: - uid = uid[:s] + uid[e + 1:] - s = uid.find('<') - e = uid.find('>') - email = None - if s >= 0 and e >= 0: - email = uid[s + 1:e] - uid = uid[:s] + uid[e + 1:] - uid = uid.strip() - if not email and uid.find('@') >= 0: - email, uid = uid, email - return (uid, email) + (uid, mail) = email.utils.parseaddr(uid) + return (uid, mail) resultdict = {} @@ -85,6 +72,7 @@ def _get_canonical(key): def _add_to_result(key, newvalue): + logging.debug("adding %s: %s", key, newvalue) thekey = _get_canonical(key) if newvalue not in resultdict[thekey]: resultdict[thekey].append(newvalue) @@ -95,10 +83,10 @@ def process_keyrings(): file.""" for keyring in _get_keyrings(): logging.debug("get data from %s", keyring) - proc = subprocess.Popen(["gpg", "--no-default-keyring", + proc = subprocess.Popen(["gpg", "--no-options", "--no-default-keyring", "--no-expensive-trust-checks", "--keyring", keyring, "--list-keys", - "--with-colons", "--fingerprint"], + "--with-colons", "--fixed-list-mode", "--with-fingerprint", "--with-fingerprint"], stdout=subprocess.PIPE) fpr = None entry = None @@ -108,11 +96,10 @@ def process_keyrings(): uid = None if items[0] == 'pub': fpr = entry = None - lastpub = items[9].strip() + lastpub = items[4].strip() continue elif items[0] == 'fpr': fpr = items[9].strip() - uid = lastpub elif items[0] == 'uid': uid = items[9].strip() else: From 8ebe8bfede929882cc0ab3fc3b5de7f1e9f68605 Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Fri, 15 Nov 2013 14:32:24 +0100 Subject: [PATCH 3/6] Exclude revoked ids : can't trust them, IMHO --- ddportfolioservice/model/keyringanalyzer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ddportfolioservice/model/keyringanalyzer.py b/ddportfolioservice/model/keyringanalyzer.py index b3304a7..9f3aa69 100644 --- a/ddportfolioservice/model/keyringanalyzer.py +++ b/ddportfolioservice/model/keyringanalyzer.py @@ -101,6 +101,8 @@ def process_keyrings(): elif items[0] == 'fpr': fpr = items[9].strip() elif items[0] == 'uid': + if items[1] == 'r': + continue uid = items[9].strip() else: continue From d12111b4009801e6a401c98304791fa66662fcce Mon Sep 17 00:00:00 2001 From: Olivier Berger Date: Fri, 15 Nov 2013 14:34:23 +0100 Subject: [PATCH 4/6] Add some test code to dump contents of the cache --- ddportfolioservice/model/keyfinder.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ddportfolioservice/model/keyfinder.py b/ddportfolioservice/model/keyfinder.py index d857f4d..71f584a 100644 --- a/ddportfolioservice/model/keyfinder.py +++ b/ddportfolioservice/model/keyfinder.py @@ -26,6 +26,7 @@ given keyring. """ import logging import time +import sys db = None cachetimestamp = 0 @@ -84,3 +85,25 @@ def getLoginByFingerprint(fpr): Gets the login associated with the given fingerprint if available. """ return _get_cached('login:fpr:%s' % fpr) + +def _dump_cache(): + cache = _get_keyring_cache() + fprs = [] + for key in cache.keys(): + if key.startswith('email:fpr:'): + fpr = key.replace('email:fpr:', '') + if not fpr in fprs: + fprs.append(fpr) + + for fpr in fprs: + login = getLoginByFingerprint(fpr) + email = _get_cached('email:fpr:%s' % fpr) + name = _get_cached('name:fpr:%s' % fpr) + + print fpr, login, ':' + print ' ', name, email + + +if __name__ == '__main__': + logging.basicConfig(stream=sys.stderr, level=logging.WARNING) + _dump_cache() From a9bde6350aedec2b3a7492aa80bdc91629602e7d Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 15 Nov 2013 21:41:22 +0100 Subject: [PATCH 5/6] give credits to Olivier Berger --- docs/source/credits.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/credits.rst b/docs/source/credits.rst index 74e2dd2..2744e27 100644 --- a/docs/source/credits.rst +++ b/docs/source/credits.rst @@ -8,6 +8,7 @@ Code * Jan Dittberner * Paul Wise + * Olivier Berger Translations ------------ From ecb9689ca5b597e7d3b9966eef13b261651f4f2c Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 15 Nov 2013 21:44:20 +0100 Subject: [PATCH 6/6] bump version to 0.2.19 --- docs/source/conf.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 54103d2..f00d642 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -50,9 +50,9 @@ copyright = u'2009-2013, Jan Dittberner' # built documents. # # The short X.Y version. -version = '0.2.18.1' +version = '0.2.19' # The full version, including alpha/beta/rc tags. -release = '0.2.18' +release = '0.2.19' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 2640725..1396e1e 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ except ImportError: setup( name='ddportfolioservice', - version='0.2.18.1', + version='0.2.19', description='service to create DDPortfolio URLs', long_description="""This is a service implementation that returns a set of personalized URLs as outlined in