[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: ac6e01e5646d5f6fdd14d65f43a785368e1d8b80 Author: Brian Dolbec dolsen gentoo org> AuthorDate: Wed Aug 15 16:00:32 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Aug 15 16:13:53 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=ac6e01e5 gkeys actions.py: Add unique devs pass/fail tracking to spec-check This adds numbers tracking to identify which devs have passing keys and which have only failing keys. gkeys/gkeys/actions.py | 54 +++--- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 539ff26..78faa9a 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -452,6 +452,8 @@ class Actions(ActionBase): catdir, keyresults = self.keyhandler.determine_keys(args) self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir) results = {} +unique_pass = {} +unique_fail = {} failed = defaultdict(list) self.output('', '\n Checking keys...') '''Login email''' @@ -552,9 +554,20 @@ class Actions(ActionBase): pub_pass['final'] = False break if pub_pass['final']: +if gkey.name in unique_fail: +unique_fail.pop(gkey.name) +if gkey.name not in unique_pass: +unique_pass[gkey.name] = [] +if spec not in unique_pass[gkey.name]: +unique_pass[gkey.name].append(spec) if spec not in failed['spec-approved']: failed['spec-approved'].append(spec) else: +if gkey.name not in unique_pass: +if gkey.name not in unique_fail: +unique_fail[gkey.name] = [] +if spec not in unique_fail[gkey.name]: +unique_fail[gkey.name].append(spec) if spec not in failed['spec']: failed['spec'].append(spec) sdata = convert_pf(pub_pass, ['pub', 'sign', 'final']) @@ -601,21 +614,38 @@ class Actions(ActionBase): self.output([sorted(set(failed['spec']))], '\n Failed to pass SPEC requirements:') if failed['spec-approved']: self.output([sorted(set(failed['spec-approved']))], '\n SPEC Approved:') +fkeys = [] +pkeys = [] +if unique_fail: +fkeys = sorted(unique_fail) +failed['unique-fail'] = [] +for k in fkeys: +failed['unique-fail'].extend(unique_fail[k]) +self.output([failed['unique-fail']], '\n Unique SPEC Failed by name:') +if unique_pass: +pkeys = sorted(unique_pass) +#failed['unique-pass'] = [] +#for k in pkeys: +#failed['unique-pass'].extend(unique_pass[k]) +#self.output([failed['unique-pass']], '\n Unique SPEC Passed:') + return (len(failed) <1, ['\nFound Failures:\n---', -'Revoked: %d' % len(set(failed['revoked'])), -'Invalid: %d' % len(set(failed['invalid'])), -'No Signing subkey..: %d' % len(set(failed['sign'])), -'No Encryption subkey...: %d' % len(set(failed['encrypt'])), -'Algorithm..: %d' % len(set(failed['algo'])), -'Bit length.: %d' % len(set(failed['bits'])), -'Qualified IDs..: %d' % len(set(failed['qualified_id'])), -'Expiry.: %d' % len(set(failed['expired'])), -'Expiry Warnings: %d' % len(set(failed['warn'])), -'SPEC requirements..: %d' % len(set(failed['spec'])), -'=', -'SPEC Approved..: %d' % len(set(failed['spec-approved'])), +'Revoked..: %d' % len(set(failed['revoked'])), +'Invalid..: %d' % len(set(failed['invalid'])), +'No Signing subkey: %d' % len(set(failed['sign'])), +'No Encryption subkey.: %d' % len(set(failed['encrypt'])), +'Algorithm: %d' % len(set(failed['algo'])), +'Bit length...: %d' % len(set(failed['bits'])), +'Qualified IDs: %d' % len(set(failed['qualified_id'])), +'Expiry...: %d' % len(set(failed['expired'])), +'Expiry Warnings..: %d' % len(set(failed['warn'])), +'SPEC requirements: %d' % len(set(failed['spec'])), +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 2bdf8c0c827cf024c4e26f9167ed4a6573625601 Author: Brian Dolbec dolsen gentoo org> AuthorDate: Wed Aug 15 01:47:19 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Aug 15 01:47:19 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=2bdf8c0c gkeys checks.py: Remove missed DSA algorithm entries Move bitlength calc within the primary if, gkeys/gkeys/checks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py index 8119395..8da6414 100644 --- a/gkeys/gkeys/checks.py +++ b/gkeys/gkeys/checks.py @@ -64,7 +64,7 @@ TEST_SPEC = { 'expire': 900, }, }, -'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'], +'algorithms': ['RSA', '1', '2', '3'], 'versions': ['4'], 'qualified_id': '@gentoo.org', } @@ -302,8 +302,8 @@ class KeyChecks(object): def _test_bits(self, data, stats): -bits = int(data.keylength) if data.pubkey_algo in TEST_SPEC['algorithms']: +bits = int(data.keylength) if bits >= TEST_SPEC['bits'][ALGORITHM_CODES[data.pubkey_algo]]: stats[SPEC_INDEX['bits']] = True else:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 0b2edc8ff515b404efd8284b3b961b9ffdb4223e Author: Brian Dolbec dolsen gentoo org> AuthorDate: Wed Aug 15 01:04:22 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Aug 15 01:04:22 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0b2edc8f gkeys checks.py: Update glep 63 specs gkeys/gkeys/checks.py | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py index 7610d70..8119395 100644 --- a/gkeys/gkeys/checks.py +++ b/gkeys/gkeys/checks.py @@ -51,18 +51,17 @@ SPEC_STAT = ['', '','', False, False, False, False, False, False, False, False, # and approved options, limits TEST_SPEC = { 'bits': { -'DSA': 2048, 'RSA': 2048, }, -'expire': 5 * 365, # in days +'expire': 900, # in days 'subkeys': {# warning/error mode 'encrypt': { 'mode': 'notice', -'expire': 5 * 365, +'expire': 900, }, 'sign': { 'mode': 'error', -'expire': 5 * 365, +'expire': 900, }, }, 'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c311c0ad71c73b0af69c6a0e130d92b824d98322 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 7 15:08:28 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 15:08:28 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c311c0ad gkeys/lock.py: Fix missed import namespace edit Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/lock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/lock.py b/gkeys/gkeys/lock.py index 5614335..3e37103 100644 --- a/gkeys/gkeys/lock.py +++ b/gkeys/gkeys/lock.py @@ -3,7 +3,7 @@ import os from snakeoil import fileutils from snakeoil import osutils -from catalyst.fileops import ensure_dirs +from gkeys.fileops import ensure_dirs LockInUse = osutils.LockException
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: dd966401553f4632f60cb673327b9446fb326654 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 7 14:47:46 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 14:47:46 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dd966401 gkeys/base.py: Fix args.email test for gkeys-ldap gkeys-ldap does not use the email arg. Prevents: File "/var/lib/gkeys/gentoo-keys/gkeys/gkeys/base.py", line 330, in setup if args.email: AttributeError: 'Namespace' object has no attribute 'email' Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 8aff933..48c8a4d 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -327,7 +327,7 @@ class CliBase(object): if args.config: self.config.defaults['config'] = args.config self.config.defaults['configdir'] = os.path.dirname(args.config) -if args.email: +if getattr(args, 'email', False): configs = [self.config.defaults['config'], os.path.abspath(os.path.join(self.config.defaults['configdir'], "email.conf"))] self.config.read_config(configs) else:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c63848f59c5f960c3e7cd82ed1f5ff1efe2870ba Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 15:25:13 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:12 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c63848f5 gkeys actionbase.py: Update _set_category for the new keyrings config All keyings locations can be set individually now Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actionbase.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index 23b7161..737c9d6 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -80,13 +80,12 @@ class ActionBase(object): def _set_category(self, cat): -keyring = self.config.get_key('keyring') -if not keyring: +catdir = self.config.get_key('keyrings', cat) +if not catdir: raise Exception("No keyring set.") if not cat: raise Exception("No category set.") self.category = cat -catdir = os.path.join(keyring, cat) self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir) self._set_trust(cat) return catdir
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 9aae3603e6785ac216e97c867c09980eefedd7b6 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 20:02:29 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:14 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9aae3603 gkeys: Update version and authors Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py index a1e901c..dc19604 100644 --- a/gkeys/gkeys/__init__.py +++ b/gkeys/gkeys/__init__.py @@ -9,7 +9,7 @@ from collections import OrderedDict from gkeys.action_map import Action_Map, Available_Actions -__version__ = '0.2' +__version__ = '0.3' __license__ = 'GPLv2' if sys.version_info[0] >= 3: @@ -32,5 +32,5 @@ the GPG keys used for validation on users and Gentoo's infrastracutre servers. Gentoo Keys is able to verify GPG keys used for Gentoo's release media, such as installation CD's, Live DVD's, packages and other GPG signed documents.''', 'sub-cmds': subdata, -'authors': ['Brian Dolbec ', 'Pavlos Ratis '], +'authors': ['Brian Dolbec ', 'Pavlos Ratis ', 'aeroniero33 '], }
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 57fc6696d44df48c6a72fd0c1e08741e11f048e8 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 15:28:24 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=57fc6696 gkeys keyhandler: Additional debug logging Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/keyhandler.py | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/keyhandler.py b/gkeys/gkeys/keyhandler.py index 0a02c22..06f4b86 100644 --- a/gkeys/gkeys/keyhandler.py +++ b/gkeys/gkeys/keyhandler.py @@ -75,10 +75,11 @@ class KeyHandler(object): def determine_keys(self, args, default_cat=None): +self.logger.debug(_unicode("KeyHandler: determine_keys; args.category = %s"), args.category or default_cat) seeds = self.seedhandler.load_category(args.category or default_cat) keyring = self.config.get_key('keyring') catdir = os.path.join(keyring, args.category) -self.logger.debug(_unicode("KeyHandler: determine_keys; catdir = %s") % catdir) +self.logger.debug(_unicode("KeyHandler: determine_keys; catdir = %s"), catdir) kwargs = self.seedhandler.build_gkeydict(args) return (catdir, seeds.list(**kwargs)) @@ -88,10 +89,12 @@ class KeyHandler(object): results = {} search_args = [x for x in KEY_OPTIONS if getattr(args, x)] if args.category: +self.logger.debug(_unicode("KeyHandler: key_search; args.category = %s"), args.category) self.seedhandler.load_category(args.category) results[args.category] = self.seedhandler.key_search(args, search_args) else: for cat in sorted(self.config.get_key('seeds')): +self.logger.debug(_unicode("KeyHandler: key_search; cat = %s"), cat) self.seedhandler.load_category(cat) found = self.seedhandler.key_search(args, search_args) if found:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 8482e689c5000493655cfbdfc38d90b389319dc2 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 15:25:56 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:12 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8482e689 gkeys actions.py: Additional debug logging Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actions.py | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index f9bba7a..e480613 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -284,6 +284,7 @@ class Actions(ActionBase): kwargs = self.seedhandler.build_gkeydict(args) keyresults = seeds.list(**kwargs) for key in sorted(keyresults): +self.logger.debug("ACTIONS: listkey; key/keydir:" + str(key.keydir)) if args.fingerprint: result = self.gpg.list_keys(key.keydir, kwargs['fingerprint']) else: @@ -775,6 +776,7 @@ class Actions(ActionBase): self.logger.debug(_unicode( "ACTIONS: verify; keyring category not specified, using default: %s") % args.category) +self.logger.debug(_unicode("ACTIONS: verify; keyring category: %s"), args.category) keys = self.seedhandler.load_category(args.category) if not keys: return (False, ['No installed keys found, try installkey action.']) @@ -788,6 +790,7 @@ class Actions(ActionBase): args.nick = self.config.get_key('verify-nick') messages.append(_unicode("Using config defaults..: %s %s") % (args.category, args.nick)) +self.logger.debug(_unicode("ACTIONS: verify; going recursive... %s, %s"), args.category, args.nick) self.verify_recursion = True return self.verify(args, messages) elif self.verify_recursion: @@ -808,6 +811,7 @@ class Actions(ActionBase): timestamp_path = None isurl = success = verified = False if filepath.startswith('http'): +self.logger.debug(_unicode("ACTIONS: _verify; supplied url, using current directory ./%s"), filepath) isurl = True url = filepath filepath = args.destination @@ -824,6 +828,8 @@ class Actions(ActionBase): else: climit = 0 sig_path = None +get_sig = signature is not None +self.logger.debug(_unicode("ACTIONS: _verify; supplied signature %s"), signature) if isurl: fetcher = Fetch(self.logger) success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path, @@ -851,7 +857,7 @@ class Actions(ActionBase): sig_path = None elif signature: sig_path = os.path.abspath(signature) -self.logger.info("Verifying file...") +self.logger.info("Verifying file... %s, %s, %s", key, sig_path, filepath) verified = False results = self.gpg.verify_file(key, sig_path, filepath) keyid = key.keyid[0]
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 8c0866aa69f3b0c600d1f2f9ad7942f563409f4a Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 18:50:41 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:14 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8c0866aa gkeys actions.py: Exit smoothly if fetch failed to get a new file Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actions.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index fd92a77..539ff26 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -834,6 +834,9 @@ class Actions(ActionBase): climit=climit) sig_path = fetcher.sig_path messages.extend(msgs) +if not success: +self.logger.debug(_unicode("ACTIONS: _verify; File not downloaded, exiting... %s"), filepath) +return (False, messages) elif signature is not None and os.path.exists(signature): sig_path = signature else:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 653d1b0c231ee789a294d040a67cef141bb11cc0 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 17:51:36 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=653d1b0c gkeys seedhandler.py: Simplify code, let verify() handle fetching Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/seedhandler.py | 68 -- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index cb082ef..a7bfbaa 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -24,6 +24,7 @@ demandload( "json:load", "gkeys.exception:UpdateDbError", "gkeys.fileops:ensure_dirs", +"gkeys.fileops:updateseeds", "gkeys.fetch:Fetch", "sslfetch.connections:get_timestamp", ) @@ -170,9 +171,10 @@ class SeedHandler(object): if category == 'sign': catdir = self.config.get_key('sign-keydir') else: -keyrings = self.config.get_key('keyring') -catdir = os.path.join(keyrings, category) -self.logger.debug("SeedHandler: load_category; catdir = %s" % catdir) +#keyrings = self.config.get_key('keyring') +#catdir = os.path.join(keyrings, category) +catdir = self.config.get_key('keyrings', category) +self.logger.debug("SeedHandler: load_category; catdir = %s", catdir) try: if not nicks: nicks = os.listdir(catdir) @@ -185,11 +187,14 @@ class SeedHandler(object): try: with open(gkey_path, 'r') as fileseed: seed = load(fileseed) +self.logger.debug("SeedHandler: load_category; loaded seed file %s.", + gkey_path) except IOError as error: -self.logger.debug("SeedHandler: load_category; IOError loading seed file %s." - % gkey_path) +self.logger.debug("SeedHandler: load_category; IOError loading seed file %s.", + gkey_path) self.logger.debug("Error was: %s" % str(error)) if seed: +self.logger.debug("SeedHandler: load_category; processing seeds: %s", seed) for nick in sorted(seed): key = seed[nick] # GKEY class change auto-update @@ -206,6 +211,7 @@ class SeedHandler(object): self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir) self.logger.exception("Error was: %s" % str(error)) self.seeds = seeds +self.logger.debug("SeedHandler: load_category; seeds loaded: %s", seeds) return seeds def fetch_seeds(self, seeds, args, verified_dl=None): @@ -231,44 +237,40 @@ class SeedHandler(object): except KeyError: pass succeeded = [] -seedsdir = os.path.join(self.config.get_key('seedsdir')) +seedsdir = os.path.dirname(self.config.get_key('seeds', seeds)) updatedir = os.path.join(seedsdir, "__updates__") mode = int(self.config.get_key('permissions', 'directories'),0) ensure_dirs(updatedir, mode=mode) self.update_lock = LockDir(updatedir) self.update_lock.write_lock() -fetcher = Fetch(self.logger) for (seed, url, filepath) in urls: tmppath = os.path.join(updatedir, os.path.split(filepath)[-1]) # use the real timestamp file for the dl timestamp tpath = filepath + ".timestamp" -# verify the re-fetch cycle timer -if fetcher.verify_cycle(tpath, climit=60): -timestamp = get_timestamp(filepath + ".timestamp") -success, msgs = fetcher.fetch_url(url, tmppath, timestamp=timestamp) -messages.extend(msgs) -if success: -verify_info = self.config.get_key('verify-seeds', seed).split() -args.category = verify_info[0] -args.nick = verify_info[1] -args.filename = url -args.signature = tmppath + ".timestamp" -#args.timestamp = True -args.destination = tmppath -verified, messages_ = verified_dl(args) -messages.append(messages_) -if verified and not args.fetchonly: -self.seedsdir_lock = LockDir(seedsdir) -if updateseeds(tmppath, filepath) and updateseeds(args.signature, tpath): -self.logger.info("Updated seed file...: %s ... OK" % (filepath)) -succeeded.append(verified) -else: -
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 5ac5f27889115cd48e89e910a3d12380367cccb6 Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 24 09:11:08 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:10 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5ac5f278 gkeys base.py: Remove the auto-update code from run() This code was causing the fetch-seed action to fail with empty urls to connect to. This code should also not be running directly from the CliBase class. I'll move this code to the actions or lib class, to be determined later. gkeys/gkeys/base.py | 58 - 1 file changed, 58 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 3ecbd1b..a67b330 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -358,7 +358,6 @@ class CliBase(object): return False return True - def run(self, args): '''Run the action selected @@ -366,63 +365,6 @@ class CliBase(object): ''' # establish our actions instance self.actions = self.cli_config['Actions'](self.config, self.output_results, self.logger) -# check for seed update -from sslfetch.connections import Connector -connector_output = { - 'info': self.logger.info, - 'debug': self.logger.debug, - 'error': self.logger.error, - 'exception': self.logger.exception, - 'warning': self.warning_output, - 'kwargs-info': {}, - 'kwargs-debug': {}, - 'kwargs-error': {}, - 'kwargs-exception': {}, - 'kwargs-warning': {}, -} -fetcher = Connector(connector_output, None, "Gentoo Keys") -successes = [] -up_to_date = True -categories = list(self.config.defaults['seeds']) -'''Attemp to download seed and seed.sig files for each available category''' -for category in categories: -filepath = self.config.defaults['seedsdir'] + "/" + category + ".seeds" -timestamp_path = filepath + ".timestamp" -url = self.config.defaults['seedurls'][category] -success, signedfile, timestamp = fetcher.fetch_file( -url, filepath, timestamp_path) -if timestamp != "": -up_to_date = False -successes.append(success) -url += ".sig" -filepath += ".sig" -success, signedfile, timestamp = fetcher.fetch_file( -url, filepath, timestamp_path) -if timestamp != "": -up_to_date = False -successes.append(success) -if False not in successes and not up_to_date: -print("Seeds need to be updated") -ack = None -while ack not in ("y", "yes", "n", "no"): -ack = py_input("Would you like to update the seeds now? (y/n) ").lower() -if ack in ("y", "yes"): -custom_args = copy.copy(args) -for attr in GKEY._fields: -if attr != "debug": -custom_args.attr = None -custom_args.category = None -custom_args.action = "update-seed" -print("Updating seeds") -self.run(custom_args) -elif False not in successes: -print("Seeds are up to date") -else: -<<< HEAD -print("Seed update check failed, check your internet connection.") -=== -print("Seed update check failed, check your internet connection.") ->>> b9e64a9... gkeys actions: Added automatic seeds,keys update capability # run the action func = getattr(self.actions, '%s' % self.cli_config['Action_Map'][args.action]['func'])
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: a7e1d29148a3e2a2718db101797383b79f2adda6 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 15:29:01 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=a7e1d291 gkeys log.py: Reduce the frequency of new log files, add a timestamp message Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/log.py b/gkeys/gkeys/log.py index 4ea5cb1..6916d97 100644 --- a/gkeys/gkeys/log.py +++ b/gkeys/gkeys/log.py @@ -51,7 +51,7 @@ def set_logger(namespace=None, logpath='', level=None, ensure_dirs(logpath, mode=dirmode, fatal=True) os.umask(filemask) logname = os.path.join(logpath, -'%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H:%M'))) +'%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H'))) file_handler = logging.FileHandler(logname) if level: file_handler.setLevel(log_levels[level]) @@ -66,7 +66,7 @@ def set_logger(namespace=None, logpath='', level=None, #Console_handler.setFormatter(formatter) logger.addHandler(Console_handler) #print "File logger suppose to be initialized", logger, Console_handler -logger.debug("Loggers initialized") +logger.debug(" Loggers initialized time: %s", time.strftime('%Y%m%d-%H:%M:%S') ) return logger
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d2b30942d665fd5a79cef5a933904824273928e7 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 17:49:59 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d2b30942 gkeys actions.py: Assign sig_path from fetcher Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 2fe29fb..fd92a77 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -832,6 +832,7 @@ class Actions(ActionBase): fetcher = Fetch(self.logger) success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path, climit=climit) +sig_path = fetcher.sig_path messages.extend(msgs) elif signature is not None and os.path.exists(signature): sig_path = signature
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:40:21 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:11 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0a745d03 gkeys/utils.py: Add get_ack function Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/utils.py | 9 + 1 file changed, 9 insertions(+) diff --git a/gkeys/gkeys/utils.py b/gkeys/gkeys/utils.py index 64f11aa..f08acc1 100644 --- a/gkeys/gkeys/utils.py +++ b/gkeys/gkeys/utils.py @@ -39,6 +39,8 @@ try: except AttributeError: StringTypes = [str] +Y_N = ("y", "yes", "n", "no") + def encoder(text, _encoding_): return codecs.encode(text, _encoding_, 'replace') @@ -161,6 +163,13 @@ def path(path_elements): return pathname +def get_ack(prompt_msg, accepted=Y_N): +ack = None +while ack not in accepted: +ack = py_input(prompt_msg).lower() +return ack + + if __name__ == '__main__': import doctest doctest.testmod(sys.modules[__name__])
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 691285b64caf4497d693462751d81a74934b36a1 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:52:17 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:11 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=691285b6 gkeys/fetch.py: New Fetch class Add sig_path assignment, makes the sig_path available to class instance holders like _verify() Use the lack of a returned timestamp to abort the process If the main file is not downloaded, then don't bother looking for a signature. This allows a verify action to exit smoothly. There is a message about the reason for not downloading, so is not hidden. Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/fetch.py | 63 1 file changed, 63 insertions(+) diff --git a/gkeys/gkeys/fetch.py b/gkeys/gkeys/fetch.py new file mode 100644 index 000..365124a --- /dev/null +++ b/gkeys/gkeys/fetch.py @@ -0,0 +1,63 @@ + +from sslfetch.connections import Connector, get_timestamp +from gkeys import _unicode + +EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig'] + + +class Fetch(object): + +def __init__(self, logger): +self.logger = logger +connector_output = { + 'info': self.logger.info, + 'debug': self.logger.debug, + 'error': self.logger.error, + 'exception': self.logger.exception, + # we want any warnings to be printed to the terminal + # so assign it to logging.error + 'warning': self.logger.error, + 'kwargs-info': {}, + 'kwargs-debug': {}, + 'kwargs-error': {}, + 'kwargs-exception': {}, + 'kwargs-warning': {}, +} +self.fetcher = Connector(connector_output, None, "Gentoo Keys") +self.sig_path = None + +def fetch_url(self, url, filepath, signature=True, timestamp=None, timestamp_path=None, climit=60): +if not timestamp_path: +timestamp_path = filepath + ".timestamp" +messages = [] +self.logger.debug( +_unicode("FETCH: fetching %s signed file ") % filepath) +self.logger.debug( +_unicode("FETCH: timestamp path: %s") % timestamp_path) +success, signedfile, timestamp = self.fetcher.fetch_file( +url, filepath, timestamp_path, climit=climit, timestamp=timestamp) +if timestamp is '': +self.logger.debug("Fetch.fetch_url; file not downloaded") +return (False, messages) +elif not success: +messages.append(_unicode("File %s cannot be retrieved.") % filepath) +elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS: +self.logger.debug("File %s successfully retrieved.", filepath) +if signature: +success_fetch = False +for ext in EXTENSIONS: +sig_path = filepath + ext +signature = url + ext +self.logger.debug( +_unicode("FETCH: fetching %s signature ") +% signature) +success_fetch, sig, timestamp = self.fetcher.fetch_file(signature, sig_path) +if success_fetch: +self.sig_path = sig_path +break +else: +signature = None +return (success, messages) + +def verify_cycle(self, tpath, climit=60): +return self.fetcher.verify_cycle(tpath, climit=60)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: eed71e755fca18ebc271b3a3b72e70c0822f55d2 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:57:23 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:12 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=eed71e75 gkeys: Implement use of the new Fetch class Signed-off-by: Brian Dolbec gentoo.org> Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actions.py | 51 +--- gkeys/gkeys/base.py| 6 + gkeys/gkeys/seedhandler.py | 64 ++ 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 64d6123..0f03880 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -29,6 +29,7 @@ from snakeoil.demandload import demandload demandload( "gkeys.base:Args", +"gkeys.fetch:Fetch", "json:load", ) @@ -718,9 +719,7 @@ class Actions(ActionBase): def installed(self, args): '''Lists the installed key directories''' -if args.category: -keyring = self.config.get_key('keyring') -else: +if not args.category: return (False, ["Please specify a category."]) catdir = self._set_category(args.category) self.logger.debug("ACTIONS: installed; catdir = %s" % catdir) @@ -818,45 +817,10 @@ class Actions(ActionBase): climit = 0 sig_path = None if isurl: -from sslfetch.connections import Connector -connector_output = { - 'info': self.logger.info, - 'debug': self.logger.debug, - 'error': self.logger.error, - 'exception': self.logger.exception, - # we want any warnings to be printed to the terminal - # so assign it to logging.error - 'warning': self.logger.error, - 'kwargs-info': {}, - 'kwargs-debug': {}, - 'kwargs-error': {}, - 'kwargs-exception': {}, - 'kwargs-warning': {}, -} -fetcher = Connector(connector_output, None, "Gentoo Keys") -self.logger.debug( -_unicode("ACTIONS: verify; fetching %s signed file ") % filepath) -self.logger.debug( -_unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path) -success, signedfile, timestamp = fetcher.fetch_file( -url, filepath, timestamp_path, climit=climit) -if not success: -messages.append(_unicode("File %s cannot be retrieved.") % filepath) -elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS: -if not signature: -success_fetch = False -for ext in EXTENSIONS: -sig_path = filepath + ext -if isurl: -signature = url + ext -self.logger.debug( -_unicode("ACTIONS: verify; fetching %s signature ") -% signature) -success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path) -if success_fetch: -break -else: -signature = None +fetcher = Fetch(self.logger) +success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path, + climit=climit) +messages.extend(msgs) elif signature is not None and os.path.exists(signature): sig_path = signature else: @@ -864,9 +828,8 @@ class Actions(ActionBase): self.logger.debug( _unicode("ACTIONS: verify; local file %s") % filepath) success = os.path.isfile(filepath) -if (not signature +if (success and not signature and '.' + filepath.rsplit('.', 1)[-1] not in EXTENSIONS): -success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext sig_path = os.path.abspath(sig_path) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index a67b330..2de1493 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -130,6 +130,12 @@ class CliBase(object): action='store_true', default=False, help='Use CASE matching in searches') +@staticmethod +def _option_fetcthonly(parser=None): +parser.add_argument('--fetchonly', +dest='fetchonly', default=False, +help="Only fetch the seed file if there is an update or doesn't exist locally") + @staticmethod def _option_file(parser=None):
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 33625064ee63796b6b02ca9f200d3d4ff1707ff9 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 15:31:20 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=33625064 gkeys lib.py: Additional debug logging Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actions.py | 2 -- gkeys/gkeys/lib.py | 7 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index e480613..2fe29fb 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -827,8 +827,6 @@ class Actions(ActionBase): climit = 60 else: climit = 0 -sig_path = None -get_sig = signature is not None self.logger.debug(_unicode("ACTIONS: _verify; supplied signature %s"), signature) if isurl: fetcher = Fetch(self.logger) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index a8529f4..7928347 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -88,8 +88,8 @@ class GkeysGPG(GPG): def set_keydir(self, keydir, task, fingerprint=True, reset=True): -self.logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir)) self.keydir = pjoin(self.basedir, keydir) +self.logger.debug("GkeysGPG.set_keydir; keydir: %s, task: %s, self.keydir: %s" % (keydir, task, self.keydir)) self.task = task if reset: self.config.options['tasks'][task] = self.config.defaults['tasks'][task][:] @@ -98,7 +98,7 @@ class GkeysGPG(GPG): task_value.append('--fingerprint') task_value.extend(['--homedir', self.keydir]) self.config.options['tasks'][task].extend(task_value) -self.logger.debug("set_keydir: New task options: %s" %str(self.config.options['tasks'][task])) +self.logger.debug("GkeysGPG.set_keydir; New task options: %s" %str(self.config.options['tasks'][task])) return @@ -147,6 +147,8 @@ class GkeysGPG(GPG): fingerprint, gkey.name)) result = self.runGPG(task='recv-keys', inputfile=fingerprint) self.logger.info('GPG return code: ' + str(result.returncode)) +self.logger.debug("LIB: add_key; fingerprint: %s. type: %s", fingerprint, type(fingerprint)) +self.logger.debug("LIB: add_key; gkey.keys: %s. type: %s", gkey.keys, [type(key) for key in gkey.keys]) if result.fingerprint in gkey.keys: result.failed = False message = "Fingerprints match... Import successful: " @@ -254,6 +256,7 @@ class GkeysGPG(GPG): self.logger.debug("LIB: list_keys(), invalid keydir parameter: %s" % str(keydir)) return [] +self.logger.debug("LIB: list_keys(), keydir parameter: %s"% str(keydir)) if fingerprint: task = 'list-key' target = fingerprint
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: a297c693402827cec3c5c1740b4559b040903030 Author: Brian Dolbec gentoo org> AuthorDate: Thu Jul 5 17:00:59 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:13 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=a297c693 gkeys base.py: Fix fetchonly typo and add to Args class Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 2de1493..8aff933 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -63,6 +63,7 @@ class Args(object): self.status = False self.timestamp = None self.uid = None +self.fetchonly = None class CliBase(object): @@ -131,7 +132,7 @@ class CliBase(object): help='Use CASE matching in searches') @staticmethod -def _option_fetcthonly(parser=None): +def _option_fetchonly(parser=None): parser.add_argument('--fetchonly', dest='fetchonly', default=False, help="Only fetch the seed file if there is an update or doesn't exist locally") @@ -375,6 +376,7 @@ class CliBase(object): func = getattr(self.actions, '%s' % self.cli_config['Action_Map'][args.action]['func']) self.logger.debug('Main: run; Found action: %s' % args.action) +self.logger.debug('Main: run; args: %s' % str(args.__dict__)) success, results = func(args) if not results: print("No results found. Check your configuration and that the",
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 80a59eed95c17a8702da10f54f9b6fdf8e90a880 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:52:53 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:11 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=80a59eed gkeys/lock.py: New LockDir class Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/lock.py | 31 +++ 1 file changed, 31 insertions(+) diff --git a/gkeys/gkeys/lock.py b/gkeys/gkeys/lock.py new file mode 100644 index 000..5614335 --- /dev/null +++ b/gkeys/gkeys/lock.py @@ -0,0 +1,31 @@ + +import os + +from snakeoil import fileutils +from snakeoil import osutils +from catalyst.fileops import ensure_dirs + + +LockInUse = osutils.LockException + + +class LockDir(object): +"""An object that creates locks inside dirs""" + +def __init__(self, lockdir): +#self.gid = 250 +self.lockfile = os.path.join(lockdir, '.gkeys_lock') +ensure_dirs(lockdir) +fileutils.touch(self.lockfile, mode=0o664) +#os.chown(self.lockfile, -1, self.gid) +self.lock = osutils.FsLock(self.lockfile) + +def read_lock(self): +self.lock.acquire_read_lock() + +def write_lock(self): +self.lock.acquire_write_lock() + +def unlock(self): +# Releasing a write lock is the same as a read lock. +self.lock.release_write_lock()
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: dfdfd7ccde868f2069de44bb5c3331482177b88d Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:50:32 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:11 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dfdfd7cc gkeys/fileops.py: Add new updateseeds function Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/fileops.py | 28 1 file changed, 28 insertions(+) diff --git a/gkeys/gkeys/fileops.py b/gkeys/gkeys/fileops.py index 5b89ea8..f6341ca 100644 --- a/gkeys/gkeys/fileops.py +++ b/gkeys/gkeys/fileops.py @@ -1,4 +1,6 @@ import os +import shutil + from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs) @@ -61,3 +63,29 @@ def updatefiles(config, logger, category=None, filename = None): raise return False return True + + +def updateseeds(config, logger, src, dst): +if not src or not dst: +logger.error("MAIN: updateseeds(); source and/or destination not supplied") +return False +try: +if os.path.exists(dst): +logger.debug( +"MAIN: updateseeds(); Removing 'old' seed file: %s" +% dst) +os.unlink(dst) +if os.path.exists(src): +logger.debug( +"MAIN: updateseeds(); Moving new seed file to: " +"%s" % dst) +shutil.move(src, dst) +except IOError: +raise +return False +return True + + +def rm_files(config, logger, files, lock=None): +pass +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: f048645778033bed905ca391c93234dc9c880067 Author: Brian Dolbec gentoo org> AuthorDate: Mon Jul 2 21:33:38 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:11 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=f0486457 gkeys/actions/py: Move the py_input & _unicode import to __init__.py This way it is done once and can be re-used anywhere in the code. Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/__init__.py | 8 gkeys/gkeys/actions.py | 9 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py index 05fc730..a1e901c 100644 --- a/gkeys/gkeys/__init__.py +++ b/gkeys/gkeys/__init__.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- +import sys from collections import OrderedDict @@ -11,6 +12,13 @@ from gkeys.action_map import Action_Map, Available_Actions __version__ = '0.2' __license__ = 'GPLv2' +if sys.version_info[0] >= 3: +py_input = input +_unicode = str +else: +py_input = raw_input +_unicode = unicode + subdata = OrderedDict() for cmd in Available_Actions: diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 71ed081..64d6123 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -15,18 +15,11 @@ from __future__ import print_function import itertools import os -import sys - -if sys.version_info[0] >= 3: -py_input = input -_unicode = str -else: -py_input = raw_input -_unicode = unicode from collections import defaultdict +from gkeys import _unicode, py_input from gkeys.actionbase import ActionBase from gkeys.gkey import GKEY from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 6a3a033243058a2724bc6c8d8cb2b2bd6cf73109 Author: Brian Dolbec gentoo org> AuthorDate: Wed Jul 4 23:02:12 2018 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 7 05:22:12 2018 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=6a3a0332 gkeys actions.py: Add verify() recursion detection and exit Handles the case of incorrect configuration or keyring problems. Reported by irc user "puchu" in #gentoo-keys. Signed-off-by: Brian Dolbec gentoo.org> gkeys/gkeys/actionbase.py | 1 + gkeys/gkeys/actions.py| 10 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index 3993be4..23b7161 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -43,6 +43,7 @@ class ActionBase(object): self._keyhandler = None self._gpg = None self.category = None +self.verify_recursion = False @property diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 0f03880..f9bba7a 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -779,7 +779,7 @@ class Actions(ActionBase): if not keys: return (False, ['No installed keys found, try installkey action.']) key = self.seedhandler.seeds.nick_search(args.nick) -if not key: +if not key and not self.verify_recursion: if args.nick: messages.append(_unicode( "Failed to find.: %s in category: %s") @@ -788,7 +788,15 @@ class Actions(ActionBase): args.nick = self.config.get_key('verify-nick') messages.append(_unicode("Using config defaults..: %s %s") % (args.category, args.nick)) +self.verify_recursion = True return self.verify(args, messages) +elif self.verify_recursion: +messages.append(_unicode( +"Failed to find.: %s in category: %s") +% (args.category, args.nick)) +messages.append("...giving up") +self.verify_recursion = False +return (False, ['No installed verification keys found, try installkey action.']) return self._verify(args, key, messages)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c1cf82a2f2f651da4749065be050154f23e07469 Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 24 04:51:55 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Dec 24 04:51:55 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c1cf82a2 gkeys actions: Migrate self.category setting to _set_category() gkeys/gkeys/actions.py | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 07dba7a..a9d2b69 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -108,6 +108,7 @@ class Actions(ActionBase): if args.uid is None: args.uid = [] gkey = self.seedhandler.new(args, checkgkey=True) +self._set_category(args.category) if not gkey: return (False, ["Failed to create a valid GKEY instance.", "Check for invalid data entries"]) @@ -198,7 +199,7 @@ class Actions(ActionBase): # fill in code here if not args.category: args.category = 'gentoo' -self.category = args.category +self._set_category(args.category) if args.keydir: self.gpg.set_keydir(args.keydir, "list-keys") self.gpg.set_keyseedfile() @@ -267,7 +268,7 @@ class Actions(ActionBase): return (False, ["Search failed for search term"]) # get confirmation # fill in code here -self.category = args.category +self._set_category(args.category) for gkey in gkeys: self.gpg.set_keydir(gkey.keydir, "recv-keys") self.gpg.set_keyseedfile() @@ -325,7 +326,7 @@ class Actions(ActionBase): return (False, [_unicode("Please specify seeds category.")]) self.logger.debug(_unicode("ACTIONS: checkkey; args: %s") % _unicode(args)) seeds = self.seedhandler.load_category(args.category) -self.category = args.category +self._set_category(args.category) results = {} failed = defaultdict(list) kwargs = self.seedhandler.build_gkeydict(args) @@ -375,7 +376,7 @@ class Actions(ActionBase): return (False, ["Please specify seeds category."]) self.logger.debug(_unicode("ACTIONS: speccheck; args: %s") % _unicode(args)) -self.category = args.category +self._set_category(args.category) catdir, keyresults = self.keyhandler.determine_keys(args) self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir) results = {} @@ -524,6 +525,7 @@ class Actions(ActionBase): self.logger.debug(_unicode("ACTIONS: removekey; kwargs: %s") % _unicode(kwargs)) seeds = self.seedhandler.load_category(args.category) +self._set_category(args.category) messages = [] if args.nick == '*': self.output([''],_unicode('Remove All keys in category: %s') @@ -620,9 +622,9 @@ class Actions(ActionBase): '''Lists the installed key directories''' if args.category: keyring = self.config.get_key('keyring') -catdir = os.path.join(keyring, args.category) else: return (False, ["Please specify a category."]) +catdir = self._set_category(args.category) self.logger.debug("ACTIONS: installed; catdir = %s" % catdir) installed_keys = [] try: @@ -697,7 +699,7 @@ class Actions(ActionBase): def _verify(self, args, key, messages=None): if messages == None: messages = [] -self.category = args.category +self._set_category(args.category) filepath, signature = args.filename, args.signature timestamp_path = None isurl = success = verified = False @@ -831,9 +833,9 @@ class Actions(ActionBase): else: nicks = args.nick args.category = 'sign' +self._set_category(args.category) # load our installed signing keys db self.seeds = self.seedhandler.load_category('sign', nicks) -self.category = args.category if not self.seeds.seeds: return (False, ['No installed keys, try installkey action.', '']) keydir = self.config.get_key("sign", "keydir") @@ -877,7 +879,7 @@ class Actions(ActionBase): self.logger.debug(_unicode("ACTIONS: refreshkey; args: %s") % _unicode(args)) seeds = self.seedhandler.load_category(args.category, refresh=True) -self.category = args.category +self._set_category(args.category) results = {} kwargs = self.seedhandler.build_gkeydict(args) keyresults = seeds.list(**kwargs)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 93c87f84c607819b8b544705f2b50d6721911bd3 Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 24 00:36:55 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Dec 24 00:36:55 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=93c87f84 gkeys actionbase: Fix trust model detection & setting in _set_trust() gkeys/gkeys/actionbase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index 67d3520..3993be4 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -95,8 +95,8 @@ class ActionBase(object): trust = self.config.get_key('trust-model', cat) if trust in [None]: trust = 'auto' -if 'trust-model' in self.config.defaults['gpg_defaults']: -index = self.config.defaults['gpg_defaults'].index('trust-model') +if '--trust-model' in self.config.defaults['gpg_defaults']: +index = self.config.defaults['gpg_defaults'].index('--trust-model') self.config.defaults['gpg_defaults'][index+1] = trust else: self.config.defaults['gpg_defaults'].extend(['--trust-model', trust])
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: db9c5818bdf1623bdb96a2656e9f2d7d3985eed3 Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 24 00:35:11 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Dec 24 00:35:11 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=db9c5818 gkeys actions: Fix missing category errors for sign action gkeys/gkeys/actions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index b38db19..07dba7a 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -830,8 +830,10 @@ class Actions(ActionBase): nicks = [args.nick] else: nicks = args.nick +args.category = 'sign' # load our installed signing keys db self.seeds = self.seedhandler.load_category('sign', nicks) +self.category = args.category if not self.seeds.seeds: return (False, ['No installed keys, try installkey action.', '']) keydir = self.config.get_key("sign", "keydir")
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: cc14fb9350cbfea5d07564bee963d9dc60b94239 Author: Zac Medico gentoo org> AuthorDate: Thu Oct 27 21:48:07 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Oct 27 21:49:01 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=cc14fb93 Actions._verify: support --signature path argument If the --signature argument refers to an existing file path, use it. This fixes an issue where signature verification would fail because the sig_path variable referred to None. gkeys/gkeys/actions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index d51fb3f..b38db19 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -758,6 +758,8 @@ class Actions(ActionBase): break else: signature = None +elif signature is not None and os.path.exists(signature): +sig_path = signature else: filepath = os.path.abspath(filepath) self.logger.debug(
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 961f66af2d741386bc917de569153863e086732a Author: Zac Medico gentoo org> AuthorDate: Mon Oct 24 05:45:59 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Mon Oct 24 05:58:34 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=961f66af Actions.checkkey: fix success returncode The failed dictionary contains lists for each type of failure, so return success if all of those lists are emtpy. gkeys/gkeys/actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 1b27605..d51fb3f 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -13,6 +13,7 @@ from __future__ import print_function +import itertools import os import sys @@ -360,7 +361,7 @@ class Actions(ActionBase): self.output([failed['invalid']], '\n Invalid keys:\n') if failed['sign']: self.output([failed['sign']], '\n No signing capable subkeys:\n') -return (len(failed) <1, +return (not any(itertools.chain.from_iterable(failed.values())), ['\nFound:\n---', 'Expired: %d' % len(failed['expired']), 'Revoked: %d' % len(failed['revoked']), 'Invalid: %d' % len(failed['invalid']),
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: bacec7da1e7ff446f232d48dcf34b71966df7068 Author: aeroniero33 gmail com> AuthorDate: Tue Apr 12 23:49:05 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Jun 1 15:13:48 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=bacec7da Count Incorrect Qualified IDs and present them in the speccheck summary. Changed the names of Qualified_IDs Changed Qualified_Id position gkeys/gkeys/actions.py | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index d61b415..ef8a30e 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -407,6 +407,8 @@ class Actions(ActionBase): 'encrypts': [], 'authens': [], 'final': False, +'qualified_id_checks': [], +'qualified_id_passed': False } if key.key is "SUB": if key.sign_capable and key.passed_spec: @@ -419,6 +421,9 @@ class Actions(ActionBase): pub_pass['authens'].append(key.passed_spec) if key.passed_spec: pub_pass['auth'] = True +if key.id: +pub_pass['qualified_id_checks'].append(key.id) +pub_pass['qualified_id_passed'] = True validity = key.validity.split(',')[0] if not key.expire and not 'r' in validity: failed['expired'].append(_unicode("%s <%s>: %s") @@ -446,6 +451,9 @@ class Actions(ActionBase): if not pub_pass['sign']: failed['sign'].append(_unicode("%s <%s>: %s") % (gkey.name, gkey.nick, pub_pass['key'].fingerprint)) +if not pub_pass['qualified_id_passed']: +failed['qualified_id'].append(_unicode("%s <%s>: %s") +% (gkey.name, gkey.nick, pub_pass['key'].fingerprint)) if not pub_pass['encrypt']: failed['encrypt'].append(_unicode("%s <%s>: %s") % (gkey.name, gkey.nick, pub_pass['key'].fingerprint)) @@ -483,6 +491,8 @@ class Actions(ActionBase): self.output([sorted(set(failed['expired']))], '\n Expiry keys:') if failed['warn']: self.output([sorted(set(failed['warn']))], '\n Expiry Warnings:') +if failed['qualified_id']: +self.output([sorted(set(failed['qualified_id']))], '\n Qualified IDs:') if failed['spec']: self.output([sorted(set(failed['spec']))], '\n Failed to pass SPEC requirements:') if failed['spec-approved']: @@ -496,6 +506,7 @@ class Actions(ActionBase): 'No Encryption subkey...: %d' % len(set(failed['encrypt'])), 'Algorithm..: %d' % len(set(failed['algo'])), 'Bit length.: %d' % len(set(failed['bits'])), +'Qualified IDs..: %d' % len(set(failed['qualified_id'])), 'Expiry.: %d' % len(set(failed['expired'])), 'Expiry Warnings: %d' % len(set(failed['warn'])), 'SPEC requirements..: %d' % len(set(failed['spec'])), @@ -889,4 +900,3 @@ class Actions(ActionBase): msgs.append(keys[cat]) del keys return (True, msgs) -
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 423c3bf0b3ae993e15886858aede0a94372b55fd Author: aeroniero33 gmail com> AuthorDate: Fri May 27 13:28:38 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Jun 1 15:14:55 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=423c3bf0 Fixed move-seed function gkeys/gkeys/action_map.py | 4 +--- gkeys/gkeys/actions.py | 4 ++-- gkeys/gkeys/seedhandler.py | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index d7eac63..80c59fe 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -15,7 +15,7 @@ from collections import OrderedDict Seed_Actions = ['seeds', 'add-seed', 'fetch-seed', -'list-seed', 'list-seedfiles', 'remove-seed'] +'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed'] Key_Actions = ['keys-', 'check-key', 'installed', 'install-key', 'list-key', 'refresh-key', 'remove-key', @@ -430,5 +430,3 @@ Found Failures: ''', }), ]) - - diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index ef8a30e..1b27605 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -153,10 +153,10 @@ class Actions(ActionBase): self.logger.debug(_unicode("ACTIONS: moveseed; gkey: %s") % _unicode(searchkey)) if not self.seeds: -self.seeds = self.load_seeds(args.category) +self.seeds = self.seedhandler.load_seeds(args.category) kwargs = self.seedhandler.build_gkeydict(args) sourcekeys = self.seeds.list(**kwargs) -dest = self.load_seeds(args.destination) +dest = self.seedhandler.load_seeds(args.destination) destkeys = dest.list(**kwargs) messages = [] if len(sourcekeys) == 1 and destkeys == []: diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 248b7b6..de2a6ad 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -67,7 +67,8 @@ class SeedHandler(object): else: keyinfo[attr] = value except AttributeError: -pass +if attr in GKEY._fields: +keyinfo[attr] = None return keyinfo def load_seeds(self, seedfile=None, filepath=None, refresh=False):
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 8843c85e7b579e80db80b327dbbee159746b87e9 Author: Brian Dolbec gentoo org> AuthorDate: Wed Jan 20 15:58:41 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Jan 20 15:58:41 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8843c85e actions.py: Update ssl-fetch Connector call, add climit Update for an ssl-fetch API change gkeys/gkeys/actions.py | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 01255eb..d3e403d 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -702,6 +702,9 @@ class Actions(ActionBase): "not supplied, using current directory ./%s") % filepath) if args.timestamp: timestamp_path = filepath + ".timestamp" +climit = 60 +else: +climit = 0 sig_path = None if isurl: from sslfetch.connections import Connector @@ -719,7 +722,7 @@ class Actions(ActionBase): self.logger.debug( _unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path) success, signedfile, timestamp = fetcher.fetch_file( -url, filepath, timestamp_path) +url, filepath, timestamp_path, climit=climit) if not success: messages.append(_unicode("File %s cannot be retrieved.") % filepath) elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: fd8b642afb7ec732f2407553788fe49aed27cdec Author: Brian Dolbec gentoo org> AuthorDate: Sat Jan 23 23:31:07 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 23 23:31:07 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=fd8b642a actions.py: Update for ssl-fetch API changes gkeys/gkeys/actions.py | 6 ++ 1 file changed, 6 insertions(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index d3e403d..d61b415 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -712,9 +712,15 @@ class Actions(ActionBase): 'info': self.logger.info, 'debug': self.logger.debug, 'error': self.logger.error, + 'exception': self.logger.exception, + # we want any warnings to be printed to the terminal + # so assign it to logging.error + 'warning': self.logger.error, 'kwargs-info': {}, 'kwargs-debug': {}, 'kwargs-error': {}, + 'kwargs-exception': {}, + 'kwargs-warning': {}, } fetcher = Connector(connector_output, None, "Gentoo Keys") self.logger.debug(
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: dc793f99c4b68e025bf4415d6162288bcaa971eb Author: Brian Dolbec gentoo org> AuthorDate: Sat Jan 23 23:32:31 2016 + Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 23 23:32:31 2016 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dc793f99 gkeys: Increase a few logger.error messages to logger.exception This will include a full traceback for debugging. gkeys/gkeys/seed.py| 4 ++-- gkeys/gkeys/seedhandler.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index f1bf7db..96bd8b2 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -246,10 +246,10 @@ class Seeds(object): '''Class error logging function''' if debug: self.logger.debug("Seed: Error processing seed file %s" % self.filename) -self.logger.debug("Seed: Error was: %s" % str(err)) +self.logger.exception("Seed: Error was: %s" % str(err)) else: self.logger.error("Seed: Error processing seed file %s" % self.filename) -self.logger.error("Seed: Error was: %s" % str(err)) +self.logger.exception("Seed: Error was: %s" % str(err)) def _seeds2json(self, seeds): diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 5c3e8aa..248b7b6 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -137,7 +137,7 @@ class SeedHandler(object): seeds.add(nick, GKEY(**key)) except OSError as error: self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir) -self.logger.debug("Error was: %s" % str(error)) +self.logger.exception("Error was: %s" % str(error)) self.seeds = seeds return seeds
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d30a4c052be16bc01f82c2893ab26114f9ac54a5 Author: Brian Dolbec gentoo org> AuthorDate: Sun Dec 13 02:22:25 2015 + Commit: Brian Dolbec gentoo org> CommitDate: Sun Dec 13 02:22:25 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d30a4c05 gkeys/actionbase.py: Add an exception to the raise statements There were no active exceptions at this point which in itself caused an exception. gkeys/gkeys/actionbase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index c53bfdb..67d3520 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -81,9 +81,9 @@ class ActionBase(object): def _set_category(self, cat): keyring = self.config.get_key('keyring') if not keyring: -raise +raise Exception("No keyring set.") if not cat: -raise +raise Exception("No category set.") self.category = cat catdir = os.path.join(keyring, cat) self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 0ea1407c73ade111e1459099be1bf5ebf585b517 Author: Brian Dolbec gentoo org> AuthorDate: Sun Dec 13 00:48:13 2015 + Commit: Brian Dolbec gentoo org> CommitDate: Sun Dec 13 00:48:13 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0ea1407c gkeys/log.py: Remove a couple commented out debug prints gkeys/gkeys/log.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/gkeys/gkeys/log.py b/gkeys/gkeys/log.py index f9b7963..4ea5cb1 100644 --- a/gkeys/gkeys/log.py +++ b/gkeys/gkeys/log.py @@ -54,10 +54,8 @@ def set_logger(namespace=None, logpath='', level=None, '%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H:%M'))) file_handler = logging.FileHandler(logname) if level: -#print "Setting cli log level", level, log_levels[level] file_handler.setLevel(log_levels[level]) else: -#print "Create file handler which logs even debug messages" file_handler.setLevel(log_levels['DEBUG']) file_handler.setFormatter(formatter) logger.addHandler(file_handler)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 54c1719b1701ce9f4b5853b029a2e9bc9412db8e Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Aug 25 14:05:26 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Aug 25 14:05:26 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=54c1719b actionbase.py: Fix sanity check in _set_category pyGPG changed, it now returns None for a key/subkey that it fails to find. Add a cat check as well. gkeys/gkeys/actionbase.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index e8d5ba4..c53bfdb 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -80,7 +80,9 @@ class ActionBase(object): def _set_category(self, cat): keyring = self.config.get_key('keyring') -if foo-bar'd in keyring: +if not keyring: +raise +if not cat: raise self.category = cat catdir = os.path.join(keyring, cat)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 1a9629201a102f2a173116a9e9ce368315501c0e Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Aug 25 14:09:09 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Aug 25 14:09:09 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=1a962920 gkeys: Set default verify-keyring, add verify-nick default Fix verify-keyring typo in verify action. Add missed self.category setting in verify(). gkeys/gkeys/actions.py | 3 ++- gkeys/gkeys/config.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 69d05b6..01255eb 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -660,7 +660,7 @@ class Actions(ActionBase): if not args.filename: return (False, ['Please provide a signed file.']) if not args.category: -args.category = self.config.get_key('verify_keyring') +args.category = self.config.get_key('verify-keyring') self.logger.debug(_unicode( ACTIONS: verify; keyring category not specified, using default: %s) % args.category) @@ -685,6 +685,7 @@ class Actions(ActionBase): def _verify(self, args, key, messages=None): if messages == None: messages = [] +self.category = args.category filepath, signature = args.filename, args.signature timestamp_path = None isurl = success = verified = False diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index 592aad6..ee667ec 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -82,7 +82,8 @@ class GKeysConfig(GPGConfig): 'keyring': None, 'type': 'clearsign', } -self.defaults['verify-keyring'] = '' +self.defaults['verify-keyring'] = 'gentoo' +self.defaults['verify-nick'] = 'gkeys' self.defaults['verify-seeds'] = {}
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 396d5c5afab583fc1873d4a211c856d9df0b8074 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sun Aug 9 22:29:46 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sun Aug 9 22:29:46 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=396d5c5a gkeys/seedhandler.py: Add an isdir check to load_category This prevents trying to look into a file like it does a keyring directory. (I accidentlly added garbage to a keyring using gpg directly) gkeys/gkeys/seedhandler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 3e51bb2..5c3e8aa 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -112,6 +112,8 @@ class SeedHandler(object): nicks = os.listdir(catdir) for nick in nicks: seed_path = os.path.join(catdir, nick) +if not os.path.isdir(seed_path): +continue gkey_path = os.path.join(seed_path, 'gkey.seeds') seed = None try:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/, gkeys/etc/
commit: 38d2b1fed19ac636346ab1e7a456bbac5bc69cec Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sun Aug 9 22:43:31 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sun Aug 9 22:52:05 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=38d2b1fe gkeys: Add settable trust-model for the keyrings The --trust-model option is needed for git verification and many other gkeys operations. gkeys/etc/gkeys.conf | 14 +- gkeys/gkeys/actionbase.py | 10 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gkeys/etc/gkeys.conf b/gkeys/etc/gkeys.conf index e7a363f..e9eb820 100644 --- a/gkeys/etc/gkeys.conf +++ b/gkeys/etc/gkeys.conf @@ -67,9 +67,12 @@ files: 0o022 # file is a json text file of: nick, name, keydir, fingerprint # one file per line # category = category or seedfile name -# these categories/seedfile nmaes are used for the +# these categories/seedfile names are used for the # -C, --category input value validations # eg: category: filepath +# +# If adding additional seed files, +# remember to set an appropriate [trust-model] for them below gentoo: %(seedsdir)s/gentoo.seeds gentoo-devs: %(seedsdir)s/gentoo-devs.seeds @@ -92,6 +95,15 @@ gentoo-devs: https://api.gentoo.org/gentoo-keys/seeds/gentoo-devs.seeds #sign: +# Set the trust levels +# one of {pgp|classic|direct|always|auto} +# default is auto +# for the gentoo and gentoo-devs keyrings set to always +[trust-model] +gentoo: always +gentoo-devs: always + + [verify-seeds] # mapping of the seedfile category name diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py index 77748c5..e8d5ba4 100644 --- a/gkeys/gkeys/actionbase.py +++ b/gkeys/gkeys/actionbase.py @@ -85,6 +85,16 @@ class ActionBase(object): self.category = cat catdir = os.path.join(keyring, cat) self.logger.debug(_unicode(ACTIONS: _set_category; catdir = %s) % catdir) +self._set_trust(cat) return catdir +def _set_trust(self, cat): +trust = self.config.get_key('trust-model', cat) +if trust in [None]: +trust = 'auto' +if 'trust-model' in self.config.defaults['gpg_defaults']: +index = self.config.defaults['gpg_defaults'].index('trust-model') +self.config.defaults['gpg_defaults'][index+1] = trust +else: +self.config.defaults['gpg_defaults'].extend(['--trust-model', trust])
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 79b95d1d05ed9ce82b94167074b068e63cfa2cb8 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 04:39:37 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Aug 3 03:59:36 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=79b95d1d gkeys: Fix the user config location and operation Move the config to ~/.config/gkeys/ along with the logs. Fix the improper ensure_dirs() call in base.py. gkeys/gkeys/base.py | 5 +++-- gkeys/gkeys/config.py | 10 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 7fd9908..970ad7c 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -299,8 +299,8 @@ class CliBase(object): if not self.config.defaults['homedir']: self.config.defaults['homedir'] = os.path.expanduser('~') if not os.access(self.config['logdir'], os.W_OK): -self.config['logdir'] = ensure_dirs( -os.path.join(self.config['user-dir'], 'logs')) +self.config.options['logdir'] = os.path.join(self.config['userconfigdir'], 'logs') +ensure_dirs(self.config.options['logdir']) # establish our logger and update it in the imported files self.logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug, dirmode=int(self.config.get_key('permissions', 'directories'),0), @@ -314,6 +314,7 @@ class CliBase(object): if args.config: self.logger.debug(Main: run; Found alternate config request: %s % args.config) +self.logger.debug(Main: run; Using config: %s % self.config['config']) # check if a -C, --category was input # if it was, check if the category is listed in the [seeds] diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index 7cd856a..592aad6 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -54,10 +54,11 @@ class GKeysConfig(GPGConfig): def _set_default_config(self): self.defaults['homedir'] = os.path.expanduser('~') -self.defaults['configdir'] = os.path.join( -self.defaults['homedir'], '.gkeys') +self.defaults['userconfigdir'] = os.path.join( +self.defaults['homedir'], '.config', 'gkeys') +self.defaults['configdir'] = self.defaults['userconfigdir'] self.defaults['config']= os.path.join( -self.defaults['configdir'], 'gkeys.conf') +self.defaults['userconfigdir'], 'gkeys.conf') if not os.path.exists(self.defaults['config']): self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gkeys']) self.defaults['config'] = '%(configdir)s/gkeys.conf' @@ -101,6 +102,9 @@ class GKeysConfig(GPGConfig): defaults[key] = self.defaults[key] if filename == None: filename = self.defaults['config'] +if foo-bar'd in filename: +print(Config: read_config(); Configuration ERROR: filename: %s, access: %s +% (filename, os.access(filename, os.R_OK))) self.configparser = SaneConfigParser(defaults) self.configparser.read(filename) if self.configparser.has_section('base'):
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c8aaf3c1f7137f10bba74308d4067b3584a59985 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:57:56 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Aug 3 04:00:55 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c8aaf3c1 gkeys/lib.py: Whitespace cleanup, remove an unused variable assignment gkeys/gkeys/lib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 838ebf0..96a57f2 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -20,6 +20,7 @@ with gentoo-keys specific convienience functions. from __future__ import print_function import os + from os.path import abspath, pardir from os.path import join as pjoin from shutil import rmtree @@ -29,6 +30,7 @@ from gkeys.checks import KeyChecks from gkeys.fileops import ensure_dirs from gkeys.seed import Seeds + class GkeysGPG(GPG): '''Gentoo-keys primary gpg class''' @@ -357,7 +359,6 @@ class GkeysGPG(GPG): @param fingerprint: string of the fingerprint to sign with @param filepath: string with the path of the file to sign ''' -keyid = gkey.keyid[0] self.set_keydir(gkey.keydir, mode, reset=True) self.logger.debug(** Calling runGPG with Running 'gpg %s --%s %s %s' % (' '.join(self.config['tasks'][mode]), mode, fingerprint, filepath))
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 317de4981cc9208f5ff4595f048fb17f522283f6 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:18:41 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:40 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=317de498 gkeys: [1 of 2] Creation of a new ActionBase class This class is to hold non-action functions/methods Restructure external handlers. Creation of @property decorated keyhandler, seedhandler, gpg functions to initialize and return.the classwide instances of their code. gkeys/gkeys/actionbase.py | 90 +++ gkeys/gkeys/actions.py| 10 ++ 2 files changed, 93 insertions(+), 7 deletions(-) diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py new file mode 100644 index 000..77748c5 --- /dev/null +++ b/gkeys/gkeys/actionbase.py @@ -0,0 +1,90 @@ +# +#-*- coding:utf-8 -*- + + +Gentoo-keys - actionbase.py + +Base api interface module + +@copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org +@license: GNU GPL2, see COPYING for details. + + +from __future__ import print_function + +import os +import sys + +if sys.version_info[0] = 3: +_unicode = str +else: +_unicode = unicode + + +from snakeoil.demandload import demandload + +demandload( +json:load, +gkeys.lib:GkeysGPG, +gkeys.keyhandler:KeyHandler, +) + + + +class ActionBase(object): +'''Base actions class holding comon functions and init''' + +def __init__(self, config, output=None, logger=None): +self.config = config +self.output = output +self.logger = logger +self.seeds = None +self._seedhandler = None +self._keyhandler = None +self._gpg = None +self.category = None + + +@property +def gpg(self): +'''Holds the classwide GkeysGPG instance''' +if not self._gpg: +self._gpg = GkeysGPG(self.config, +self._set_category(self.category), self.logger) +else: +self._gpg.basedir = self._set_category(self.category) +return self._gpg + + +@property +def keyhandler(self): +'''Holds the classwide KeyHandler instance''' +if not self._keyhandler: +self._init_keyhandler() +return self._keyhandler + + +def _init_keyhandler(self): +self._keyhandler = KeyHandler(self.config, self.logger) +self._seedhandler = self._keyhandler.seedhandler + + +@property +def seedhandler(self): +'''Holds the classwide SeedHandler instance +which is a convienience variable for the keyhandler's instance of it''' +if not self._seedhandler: +self._init_keyhandler() +return self._seedhandler + + +def _set_category(self, cat): +keyring = self.config.get_key('keyring') +if foo-bar'd in keyring: +raise +self.category = cat +catdir = os.path.join(keyring, cat) +self.logger.debug(_unicode(ACTIONS: _set_category; catdir = %s) % catdir) +return catdir + + diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index e24d24d..11f1ca8 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -27,7 +27,7 @@ else: from collections import defaultdict from snakeoil.demandload import demandload - +from gkeys.actionbase import ActionBase from gkeys.gkey import GKEY from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn @@ -41,14 +41,11 @@ demandload( EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig'] -class Actions(object): +class Actions(ActionBase): '''Primary API actions''' def __init__(self, config, output=None, logger=None): -self.config = config -self.output = output -self.logger = logger -self.seeds = None +ActionBase.__init__(self, config, output, logger) @staticmethod @@ -68,7 +65,6 @@ class Actions(object): '''- general actions --''' pass - def listseed(self, args): '''Pretty-print the selected seed file''' handler = SeedHandler(self.logger, self.config)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: fd5717c14ae65678f268ac9802d597b237f43a3a Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:06:18 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:39 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=fd5717c1 gkeys/base.py: Fix typo in action initialization gkeys/gkeys/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 970ad7c..7253b7b 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -34,7 +34,7 @@ class Args(object): def __init__(self): -self.ation = None +self.action = None self.all = False self.category = None self.cleankey = False
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 3fd82a0c97b291da10ca116fb80f24c0d3bcef90 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 05:59:39 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Aug 3 03:59:36 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=3fd82a0c gkeys/lib.py: Split out _log_result() Split out common code to be used for all veritf_* functions. gkeys/gkeys/lib.py | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index bce4e55..838ebf0 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -338,14 +338,7 @@ class GkeysGPG(GPG): self.logger.debug(** Calling runGPG with Running 'gpg %s --decrypt %s' % (' '.join(self.config['tasks']['decrypt']), filepath)) results = self.runGPG(task='decrypt', inputfile=filepath) -keyid = gkey.keyid[0] -if results.verified[0]: -self.logger.info(GPG verification succeeded. Name: %s / Key: %s % (gkey.name, keyid)) -self.logger.info(\tSignature result: + str(results.verified)) -else: -self.logger.debug(GPG verification failed. Name: %s / Key: %s % (gkey.name, keyid)) -self.logger.debug(\t Signature result:+ str(results.verified)) -self.logger.debug(LIB: verify; stderr_out: + str(results.stderr_out)) +self._log_result('verification', gkey, results) return results @@ -369,12 +362,20 @@ class GkeysGPG(GPG): self.logger.debug(** Calling runGPG with Running 'gpg %s --%s %s %s' % (' '.join(self.config['tasks'][mode]), mode, fingerprint, filepath)) results = self.runGPG(task=mode, inputfile=filepath) +self._log_result('signing', gkey, results) +return results + +def _log_result(self, mode, gkey, results): if results.verified[0]: -self.logger.info(GPG signing succeeded. Name: %s / Key: %s % (str(gkey.name), str(keyid))) +self.logger.info(GPG %s succeeded. Name: %s / Key: %s +% (mode, gkey.name, gkey.keyid[0])) self.logger.info(\tSignature result: + str(results.verified)) else: -self.logger.debug(GPG signing failed. Name: %s / Key: %s % (str(gkey.name), str(keyid))) +self.logger.debug(GPG %s failed. Name: %s / Key: %s +% (mode, gkey.name, gkey.keyid[0])) self.logger.debug(\t Signature result:+ str(results.verified)) -self.logger.debug(LIB: sign; stderr_out: + str(results.stderr_out)) -return results +self.logger.debug(LIB: verify; stderr_out: + +str(results.stderr_out)) + +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 7f42bd9d867372b75b4e1657ebc6552e9ef062e1 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Jul 25 20:55:18 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Aug 3 03:59:35 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=7f42bd9d gkeys/actions.py: Fix a traceback when a filename does not have an extension This will instead get the filename itself back. gkeys/gkeys/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 6610480..a4081c9 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -779,7 +779,7 @@ class Actions(object): _unicode(ACTIONS: verify; local file %s) % filepath) success = os.path.isfile(filepath) if (not signature -and '.' + filepath.rsplit('.', 1)[1] not in EXTENSIONS): +and '.' + filepath.rsplit('.', 1)[-1] not in EXTENSIONS): success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 534fac884f2ce1a45cf6a73d0491884e1bfe0d0a Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Jul 25 20:56:30 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Aug 3 03:59:36 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=534fac88 gkeys/base.py: Add missing action and timestamp attributes Sort the staus attribute. gkeys/gkeys/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index b422caf..7fd9908 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -34,7 +34,7 @@ class Args(object): def __init__(self): -self.status = False +self.ation = None self.all = False self.category = None self.cleankey = False @@ -50,6 +50,8 @@ class Args(object): self.keydir = None self.seedfile = None self.signature = None +self.status = False +self.timestamp = None self.uid = None
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 918a9e0e3375b394979dc13c95176f9e333a5c7a Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:03:23 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:15 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=918a9e0e gkeys/seedhandler.py: Add an addtional debug log message Re-arrange the sorting of search_args for a better debug message. gkeys/gkeys/seedhandler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 18725b9..01abf78 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -223,10 +223,11 @@ class SeedHandler(object): def key_search(self, args, search_args): '''Performs a search for all listed args in the seeds''' -results = [] +search_args.sort() self.logger.debug(SeedHandler.key_search() search_args: %s % str(search_args)) +self.logger.debug(SeedHandler.key_search() search_args values: %s % str(args)) +results = [] found = {} -search_args.sort() if isinstance(args, dict): exact = args.get('exact', False) _all = args.get('all', False)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 9e7539d68b75a37626cc4a2b6c59a8d21208b57c Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:35:53 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:40 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9e7539d6 gkeys: [2 of 2] Move common key handling to it's own class Creation of a new KeyHandler class. Move primary seed handling intialization and control to the new KeyHandler class. This unifies key handling and removes suplicated code throughout Actions class. Break out a KEY_OPTIONS list. Cleans up a long line and makes it available for import use to ensure the correct options are added to the cli (gkeys-gpg) for correct key_search() operation. gkeys/gkeys/actions.py| 156 +++--- gkeys/gkeys/keyhandler.py | 110 2 files changed, 148 insertions(+), 118 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 11f1ca8..69d05b6 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -26,18 +26,17 @@ else: from collections import defaultdict -from snakeoil.demandload import demandload from gkeys.actionbase import ActionBase from gkeys.gkey import GKEY from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn +from snakeoil.demandload import demandload + demandload( +gkeys.base:Args, json:load, -gkeys.lib:GkeysGPG, -gkeys.seedhandler:SeedHandler, ) - EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig'] @@ -67,13 +66,12 @@ class Actions(ActionBase): def listseed(self, args): '''Pretty-print the selected seed file''' -handler = SeedHandler(self.logger, self.config) -kwargs = handler.build_gkeydict(args) +kwargs = self.seedhandler.build_gkeydict(args) self.logger.debug(_unicode(ACTIONS: listseed; kwargs: %s) % _unicode(kwargs)) if not self.seeds: try: -self.seeds = handler.load_seeds(args.category, args.nick) +self.seeds = self.seedhandler.load_seeds(args.category, args.nick) except ValueError: return (False, ['', Failed to load seed file. Consider fetching seedfiles.]) if self.seeds: @@ -89,8 +87,10 @@ class Actions(ActionBase): % _unicode(args)) if not args.category: return (False, [Please specify seeds category.]) -handler = SeedHandler(self.logger, self.config) -success, messages = handler.fetch_seeds(args.category, args, self.verify) +self._set_category(self.config.get_key('verify-keyring')) +verifyargs = Args() +verifyargs.category=args.category +success, messages = self.seedhandler.fetch_seeds(args.category, verifyargs, self.verify) messages.append() messages.append(Fetch operation completed) return (False not in success, messages) @@ -98,7 +98,6 @@ class Actions(ActionBase): def addseed(self, args): '''Add or replace a key in the selected seed file''' -handler = SeedHandler(self.logger, self.config) success, data = self.listseed(args) gkeys = data[1] if not args.nick or not args.name or not args.keys or not args.keydir: @@ -107,7 +106,7 @@ class Actions(ActionBase): args.fingerprint = args.keys if args.uid is None: args.uid = [] -gkey = handler.new(args, checkgkey=True) +gkey = self.seedhandler.new(args, checkgkey=True) if not gkey: return (False, [Failed to create a valid GKEY instance., Check for invalid data entries]) @@ -150,13 +149,12 @@ class Actions(ActionBase): def moveseed(self, args): '''Move keys between seed files''' -handler = SeedHandler(self.logger, self.config) -searchkey = handler.new(args, checkgkey=False) +searchkey = self.seedhandler.new(args, checkgkey=False) self.logger.debug(_unicode(ACTIONS: moveseed; gkey: %s) % _unicode(searchkey)) if not self.seeds: self.seeds = self.load_seeds(args.category) -kwargs = handler.build_gkeydict(args) +kwargs = self.seedhandler.build_gkeydict(args) sourcekeys = self.seeds.list(**kwargs) dest = self.load_seeds(args.destination) destkeys = dest.list(**kwargs) @@ -199,21 +197,17 @@ class Actions(ActionBase): # fill in code here if not args.category: args.category = 'gentoo' -keyring = self.config.get_key('keyring') -catdir = os.path.join(keyring, args.category) -self.logger.debug(_unicode(ACTIONS: listkey; catdir = %s) % catdir) -self.gpg = GkeysGPG(self.config, catdir, self.logger) -handler = SeedHandler(self.logger, self.config) +self.category = args.category if args.keydir:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 4aac84d4a8e95d1cac079036a61c2f61df4a7608 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:55:37 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:39 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=4aac84d4 gkeys: Update copyrights, Add Pavlos to several files gkeys/gkeys/actions.py | 3 ++- gkeys/gkeys/base.py| 2 +- gkeys/gkeys/checks.py | 3 ++- gkeys/gkeys/cli.py | 2 +- gkeys/gkeys/lib.py | 7 --- gkeys/gkeys/seed.py| 8 +--- gkeys/gkeys/seedhandler.py | 3 ++- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index a4081c9..e24d24d 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -6,7 +6,8 @@ Primary api interface module -@copyright: 2012 by Brian Dolbec dol-...@gentoo.org +@copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org +@copyright: 2014-2015 by Pavlos Ratis daster...@gentoo.org @license: GNU GPL2, see COPYING for details. diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 7253b7b..4cee27d 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -7,7 +7,7 @@ Command line interface argsparse options module and common functions -@copyright: 2012 by Brian Dolbec dol-...@gentoo.org +@copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org @license: GNU GPL2, see COPYING for details. diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py index 7e40720..7610d70 100644 --- a/gkeys/gkeys/checks.py +++ b/gkeys/gkeys/checks.py @@ -5,7 +5,8 @@ Gentoo-Keys - gkeygen/checks.py Primary key checks module -@copyright: 2014 by Brian Dolbec dol...@gentoo.org +@copyright: 2014-2015 by Brian Dolbec dol...@gentoo.org +@copyright: 2014-2015 by Pavlos Ratis daster...@gentoo.org @license: GNU GPL2, see COPYING for details diff --git a/gkeys/gkeys/cli.py b/gkeys/gkeys/cli.py index 194afd2..532c03e 100644 --- a/gkeys/gkeys/cli.py +++ b/gkeys/gkeys/cli.py @@ -6,7 +6,7 @@ Command line interface module -@copyright: 2012 by Brian Dolbec dol-...@gentoo.org +@copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org @license: GNU GPL2, see COPYING for details. diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 96a57f2..528464b 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -8,11 +8,12 @@ with gentoo-keys specific convienience functions. Distributed under the terms of the GNU General Public License v2 Copyright: - (c) 2011 Brian Dolbec - Distributed under the terms of the GNU General Public License v2 +@copyright: 2011-2015 by Brian Dolbec dol-...@gentoo.org +@copyright: 2014-2015 by Pavlos Ratis daster...@gentoo.org +Distributed under the terms of the GNU General Public License v2 Author(s): - Brian Dolbec dol...@gentoo.org +Brian Dolbec dol...@gentoo.org ''' diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index 01ca5a5..f1bf7db 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -8,11 +8,13 @@ with gentoo-keys specific convienience functions. Distributed under the terms of the GNU General Public License v2 Copyright: - (c) 2011 Brian Dolbec - Distributed under the terms of the GNU General Public License v2 +@copyright: 2011-2015 by Brian Dolbec dol-...@gentoo.org +@copyright: 2014-2015 by Pavlos Ratis daster...@gentoo.org +Distributed under the terms of the GNU General Public License v2 Author(s): - Brian Dolbec dol...@gentoo.org +Brian Dolbec dol...@gentoo.org +Pavlos Ratis daster...@gentoo.org ''' diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 01abf78..3e51bb2 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -6,7 +6,8 @@ Seed handling interface module -@copyright: 2012 by Brian Dolbec dol-...@gentoo.org +@copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org +@copyright: 2014-2015 by Pavlos Ratis daster...@gentoo.org @license: GNU GPL2, see COPYING for details.
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 24aa5eb9f92883fb0fb3e7222b78eeddf33b9bf6 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jul 29 06:39:47 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Aug 8 15:51:40 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=24aa5eb9 gkeys/lib.py: Creation of the code for the verify_text() gkeys/gkeys/lib.py | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 528464b..5ad1aab 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -318,10 +318,19 @@ class GkeysGPG(GPG): pass -def verify_text(self, text): +def verify_text(self, gkey, text, filepath=None): '''Verify a text block in memory + +@param gkey: GKEY instance of the gpg key used to verify it +@param text: string of the of the text to verify +@param filepath: optional string with the path or url of the signed file ''' -pass +self.set_keydir(gkey.keydir, 'verify', fingerprint=False, reset=True) +self.logger.debug(** Calling runGPG with Running 'gpg %s --verify %s' +% (' '.join(self.config['tasks']['verify']), filepath)) +results = self.runGPG(task='verify', inputfile=filepath, inputtxt=text) +self._log_result('verification', gkey, results) +return results def verify_file(self, gkey, signature, filepath):
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: afee05b427446ffdc12b3d138a1f1d712a757b2d Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:56:49 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jul 25 16:43:21 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=afee05b4 gkeys/gkeysinterface.py: Initial commit of an api consumer interface First use was for creating a gpg signed Manifest verification in portage. Use snakeoil's demandload for imports gkeys/gkeys/gkeysinterface.py | 120 ++ 1 file changed, 120 insertions(+) diff --git a/gkeys/gkeys/gkeysinterface.py b/gkeys/gkeys/gkeysinterface.py new file mode 100644 index 000..8618268 --- /dev/null +++ b/gkeys/gkeys/gkeysinterface.py @@ -0,0 +1,120 @@ +'''Gkeys comsumer app API interface''' + + +import os + +from snakeoil.demandload import demandload + +from gkeys.config import GKeysConfig +from gkeys.gkey import GKEY + +demandload( +gkeys:log, +gkeys.lib:GkeysGPG, +gkeys.seedhandler:SeedHandler, +) + + +class GkeysInterface(object): +'''High level class to hold and operate our gkeys GkeysGPG instance''' + +def __init__(self, namespace, root='/', config=None, +logger=None, loglevel='DEBUG'): +'''GkeysInterface init + +@param namespace: string of the logging namespace setting to use +@param root: string of the root path to initialize with, default is '/' +@param logger: optional logging instance, if undefiined, it +will use it's gkeys logger. +@param loglevel: string one of {'CRITICAL', 'DEBUG', 'ERROR', 'FATAL', +'INFO', 'NOTSET', 'WARN', 'WARNING'} +''' +self.root = root +self.namespace = namespace +self.config = config or GKeysConfig(root=root, read_configfile=True) +self.logger = logger or log.logger or log.set_logger( +namespace=namespace, +logpath=self.config.get_key('logdir'), +level=loglevel) +self.gpg = None +self.handler = None + + +def keyid_search(self, keyid): +'''Searches for a keyid in the installed keyrings + +@param keyid: string of the longkeyid to search for +@returns dictionary of {category: [GKEY, ...]} +''' +results = {} +for cat in list(self.config.get_key('seeds')): +self.handler.load_category(cat) +found = self.handler.key_search({'keyid': keyid,}, ['keyid']) +if found: +if cat in results: +results[cat].extend(found) +else: +results[cat] = found +return results + + +def verify_file(self, filepath, category='gentoo', nick='snapshot', +strict=False): +'''One stop action to verify a file. + +If the first gpg verification fails, it will auto-search +for the correct key to validate against. +@param filepath: path of the file to verify +@param category: string, optional keyring category, default is 'gentoo' +@param nick: string, optional keyring nick, default is 'snapshot' +@param strict: boolean toggles off the auto-search if the category/nick +supplied fail +@return (bool, bool) (verification pass/fail, file had a signature) +''' +if not self.handler: +self.handler = SeedHandler(self.logger, self.config) +keys = self.handler.load_category(category) +if not keys: +self.logger.warn('No installed keys found, try installing keys.') +return False +key = self.handler.seeds.nick_search(nick) +if not key: +self.logger.debug(Failed to find.: %s in category: %s +% (category, nick)) +category = self.config.get_key('verify-keyring') +nick = self.config.get_key('verify-nick') +self.logger.debug(Using config defaults..: %s %s +% (category, nick)) +return self.verify_file(filepath, category, nick) + +keyrings = self.config.get_key('keyring') +catdir = os.path.join(keyrings, category) +self.logger.debug(ACTIONS: verify; catdir = %s % catdir) +self.gpg = GkeysGPG(self.config, catdir, self.logger) +results = self.gpg.verify_file(key, None, filepath) + +(valid, trust) = results.verified +if valid: +return True, True +self.logger.debug(Verification failed: %s % (filepath)) +self.logger.debug(Key info...: %s %s, %s +% ( key.name, key.nick, key.keyid)) +has_no_pubkey, s_keyid = results.no_pubkey +if has_no_pubkey and s_keyid and not strict: +self.logger.debug(Auto-searching for key.: 0x%s % s_keyid) +elif not s_keyid or strict: +return False, has_no_pubkey +keys =
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 734aed55964979017863639edfc9ca9036a629c0 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Mar 23 15:40:21 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jul 25 16:43:13 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=734aed55 gkeys/base.py: Add an alternate args class for compatibility use for Action as an API Rough draft, so it can be used for the args arguments in Actions functions. An alternate to having an argsparser innstance. gkeys/gkeys/base.py | 27 +++ 1 file changed, 27 insertions(+) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index fba1976..b422caf 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -26,6 +26,33 @@ if sys.version_info[0] = 3: unicode = str +class Args(object): +'''Basic argsparser replacement for using gkeys Actions via an API + +Holds the full spectrum of possible options supported. +Not all options used by all actions.''' + + +def __init__(self): +self.status = False +self.all = False +self.category = None +self.cleankey = False +self.destination = None +self.exact = False +self.filename = None +self.fingerprint = None +self.keyid = None +self.keyring = None +self.keys = None +self.nick = None +self.name = None +self.keydir = None +self.seedfile = None +self.signature = None +self.uid = None + + class CliBase(object): '''Common cli and argsparse options class'''
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 7c2b40ebb75a5b7d86fa8f2657e673ac8e0285b5 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 20:49:54 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jul 25 16:43:05 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=7c2b40eb gkeys: Re-enable remove-key action gkeys/gkeys/action_map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index 3b1b9d0..d7eac63 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -18,7 +18,7 @@ Seed_Actions = ['seeds', 'add-seed', 'fetch-seed', 'list-seed', 'list-seedfiles', 'remove-seed'] Key_Actions = ['keys-', 'check-key', 'installed', -'install-key', 'list-key', 'refresh-key', +'install-key', 'list-key', 'refresh-key', 'remove-key', 'search-key', 'spec-check'] General_Actions = ['---general---', 'list-cats', 'sign','verify']
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d996f4c306e6ca366b288f8ba329f77b54768d51 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Jun 22 13:41:29 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Jun 22 13:41:29 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d996f4c3 gkeys/actions.py: Add filename extension check exclusion gkeys/gkeys/actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 7275739..6610480 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -778,7 +778,8 @@ class Actions(object): self.logger.debug( _unicode(ACTIONS: verify; local file %s) % filepath) success = os.path.isfile(filepath) -if not signature: +if (not signature +and '.' + filepath.rsplit('.', 1)[1] not in EXTENSIONS): success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: b0402fd5d51b95ca32705936444ae082f4b3a5c4 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Jun 1 01:56:24 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Jun 1 01:56:24 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=b0402fd5 gkeys/actions.py: verify url was not smart about being passed a sig url and would fail to verify Move EXTENSIONS out as a constant instead of being defined twice. gkeys/gkeys/actions.py | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 24c323e..7275739 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -36,6 +36,10 @@ demandload( gkeys.seedhandler:SeedHandler, ) + +EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig'] + + class Actions(object): '''Primary API actions''' @@ -754,9 +758,8 @@ class Actions(object): url, filepath, timestamp_path) if not success: messages.append(_unicode(File %s cannot be retrieved.) % filepath) -else: +elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS: if not signature: -EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig'] success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext @@ -776,7 +779,6 @@ class Actions(object): _unicode(ACTIONS: verify; local file %s) % filepath) success = os.path.isfile(filepath) if not signature: -EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig'] success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 25e13adf18f29529287868abe32ee522b898c66e Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:10:36 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=25e13adf gkeys/actions.py: Remove unused keyring_dir assignment gkeys/gkeys/actions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index edbea0d..8e078f0 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -572,7 +572,6 @@ class Actions(object): if args.category: keyring = self.config.get_key('keyring') catdir = os.path.join(keyring, args.category) -keyring_dir = self.config.get_key(keyring) self.logger.debug(_unicode(ACTIONS: importkey; catdir = %s) % catdir) self.gpg = GkeysGPG(self.config, catdir, self.logger)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 2573d49b85fabcb871d067c67f92fe75cfd4 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 20:42:30 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=2573d49b gkeys/seedhandler.py: Add space removal for fingerprints in build_gkeydict() gkeys/gkeys/seedhandler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index adf9507..a905051 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -53,6 +53,8 @@ class SeedHandler(object): value = getattr(args, attr) if attr == 'name' and isinstance(value, list): value = .join(value) +if attr == 'fingerprint' and value: +value = [x.replace( , ) for x in value] if value is not None: keyinfo[attr] = decoder(value) except AttributeError:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 8c6da8152ca04b3a1d706abc2bbd57b1cd982e82 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:12:22 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:51 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8c6da815 gkeys/actions.py: Refactor installkey to refresh keys that are already installed and unchanged gkeys/gkeys/actions.py | 78 +- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 8e078f0..7b834a4 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -245,11 +245,11 @@ class Actions(object): def installkey(self, args): '''Install a key from the seed(s)''' self.logger.debug(ACTIONS: installkey; args: %s % str(args)) -success, gkey = self.listseed(args)[1] -if gkey: -if gkey and not args.nick == '*' and self.output: -self.output(['', gkey], \n Found GKEY seeds:) -elif gkey and self.output: +success, gkeys = self.listseed(args)[1] +if gkeys: +if gkeys and not args.nick == '*' and self.output: +self.output(['', gkeys], \n Found GKEY seeds:) +elif gkeys and self.output: self.output(['all'], \n Installing seeds:) else: self.logger.info(ACTIONS: installkey; @@ -269,33 +269,47 @@ class Actions(object): self.logger.debug(_unicode(ACTIONS: installkey; catdir = %s) % catdir) self.gpg = GkeysGPG(self.config, catdir, self.logger) -results = {} -failed = [] -for key in gkey: -self.logger.debug(ACTIONS: installkey; adding key:) -self.logger.debug(ACTIONS: + str(key)) -results[key.name] = self.gpg.add_key(key) -for result in results[key.name]: -self.logger.debug(ACTIONS: installkey; result.failed = + - str(result.failed)) -if self.config.options['print_results']: -msg = _unicode(key desired: %(name)s, key added: %(key)s, succeeded: +\ - %(success)s, fingerprint: %(fpr)s) -for result in results[key.name]: -umsg = msg % ({'name': key.name, 'key': result.username, -'success': str(not result.failed), -'fpr': result.fingerprint}) -try: -print(umsg) -except UnicodeDecodeError: -print(_unicode(UnicodeDecodeError printing results for:), key.name) -self.logger.debug(_unicode(installkey(); UnicodeDecodeError for:) + key.name) -self.logger.debug(_unicode( result.username...:) + result.username) -self.logger.debug(_unicode( result.failed.:) + result.failed) -self.logger.debug(_unicode( result.fingerprint:) + result.fingerprint) -self.logger.debug(stderr_out: + str(result.stderr_out)) -if result.failed: -failed.append(key) +for gkey in gkeys: +self.gpg.set_keydir(gkey.keydir, recv-keys) +self.gpg.set_keyseedfile() +seeds = self.gpg.seedfile.seeds +#print(seeds) +if seeds: +self.logger.debug(ACTIONS: installkey; found installed seeds: +\n %s % seeds) +results = {} +failed = [] +if gkey.nick in seeds and gkey.keys == seeds[gkey.nick].keys: +self.logger.debug(ACTIONS: installkey; refreshing key:) +if self.config.options['print_results']: +print(_unicode(Refreshing already installed key: %s, %s +%(gkey.nick, gkey.keys))) +self.gpg.refresh_key(gkey) +else: +self.logger.debug(ACTIONS: installkey; adding key:) +self.logger.debug(ACTIONS: + str(gkey)) +results[gkey.name] = self.gpg.add_key(gkey) +for result in results[gkey.name]: +self.logger.debug(ACTIONS: installkey; result.failed = + + str(result.failed)) +if self.config.options['print_results']: +msg = _unicode(key desired: %(name)s, key added: %(key)s, succeeded: +\ + %(success)s, fingerprint: %(fpr)s) +for result in results[gkey.name]: +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 666b8a6c00251b0034d5e57ee338a44aa6b0a997 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat May 30 23:13:46 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sun May 31 04:46:31 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=666b8a6c gkeys/actions.py: Fix an UnboundLocalError File /usr/lib64/python2.7/site-packages/gkeys/actions.py, line 798, in _verify results = self.gpg.verify_file(key, sig_path, filepath) UnboundLocalError: local variable 'sig_path' referenced before assignment Reported by: Johannes Huber johu AT gentoo.org gkeys/gkeys/actions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index d467500..24c323e 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -734,6 +734,7 @@ class Actions(object): not supplied, using current directory ./%s) % filepath) if args.timestamp: timestamp_path = filepath + .timestamp +sig_path = None if isurl: from sslfetch.connections import Connector connector_output = {
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 328359a9c6d7fb5192b2e4fc3e0a458563cfcdfd Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:07:06 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=328359a9 gkeys/config.py: Correctly set default keyring dir name to keyrings gkeys/gkeys/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index 6abec96..7cd856a 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -64,7 +64,7 @@ class GKeysConfig(GPGConfig): def _add_gkey_defaults(self): self.defaults['gkeysdir'] = path([self.root, EPREFIX, '/var/lib/gentoo/gkeys']) -self.defaults['keyring'] = '%(gkeysdir)s/keyring' +self.defaults['keyring'] = '%(gkeysdir)s/keyrings' self.defaults['sign-keydir'] = '%(gkeysdir)s/sign', self.defaults['logdir'] = '/var/log/gkeys' # local directory to scan for seed files installed via ebuild, layman
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 695631f23ad2bddff1f3efda698a90a23d38db1c Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Apr 20 17:46:59 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:32:17 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=695631f2 gkeys/seedhandler.py: Fix build_gkeydict() gkeys/gkeys/seedhandler.py | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 86cab25..18725b9 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -58,10 +58,13 @@ class SeedHandler(object): value = getattr(args, attr) if attr == 'name' and isinstance(value, list): value = .join(value) -if attr == 'fingerprint' and value: +if attr in ['fingerprint', 'keys'] and value: value = [x.replace( , ) for x in value] -if value is not None: +keyinfo[attr] = value +if value is not None and attr in ['keydir', 'name', 'nick']: keyinfo[attr] = decoder(value) +else: +keyinfo[attr] = value except AttributeError: pass return keyinfo
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 35ecad248a81436dcad7e6b9928ed3eeb098c9af Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Apr 20 17:44:59 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:29:06 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=35ecad24 gkeys/seed.py: Replace codecs usage with unicode() Add a noop for an empty kwargs[key]. jgjhgj gkeys/gkeys/seed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index 985f6a1..01ca5a5 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -36,7 +36,7 @@ if sys.version_info[0] = 3: return text else: def decoder(text, enc='utf_8'): -return codecs.decode(text, enc) +return unicode(text) class Seeds(object): @@ -155,6 +155,8 @@ class Seeds(object): keys = kwargs result = self.seeds for key in keys: +if not kwargs[key]: +continue if key in ['fingerprint', 'keys', 'keyid']: kwargs[key] = [x.replace(' ', '').upper() for x in kwargs[key]] if key in ['fingerprint', 'keys', 'uid']:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 37c128e77c7d9e3220561b5ca7bb5ff9bae51f32 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 20:50:57 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=37c128e7 gkeys/actionspy: Fix grammar in the confirmation input message gkeys/gkeys/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 6975c38..efab4fa 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -542,7 +542,7 @@ class Actions(object): if args.nick == '*': self.output([''],_unicode('Remove All keys in category: %s') % _unicode(args.category)) -ans = py_input (Do you really want to remove ALL of keys?[y/n]: ) +ans = py_input (Do you really want to remove ALL of the keys?[y/n]: ) while ans not in [yes, y, no, n]: ans = py_input (Do you really want to remove ALL keys?[y/n]: ) if ans in [no, n]:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 5b11872bd684d0bac674b65832c737280d001e11 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sun Mar 22 15:54:59 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:51 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5b11872b gkeys/gkey.py: Fix typo in @license gkeys/gkeys/gkey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py index a305804..ab62f5b 100644 --- a/gkeys/gkeys/gkey.py +++ b/gkeys/gkeys/gkey.py @@ -7,7 +7,7 @@ Holds GKEY class and related values @copyright: 2012-2015 by Brian Dolbec dol-...@gentoo.org -@license: GNU GNU GPL2, see COPYING for details. +@license: GNU GPL2, see COPYING for details.
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c3b217c2c8e0402a71e75407e7d37f9639f045f2 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:09:03 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c3b217c2 gkeys/seedhandler.py: Make key_search accept args as a dictionary or argsparse object gkeys/gkeys/seedhandler.py | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index a905051..8b787d1 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -216,17 +216,27 @@ class SeedHandler(object): def key_search(self, args, search_args): '''Performs a search for all listed args in the seeds''' results = [] -self.logger.debug(_field_search search_args: %s % str(search_args)) +self.logger.debug(SeedHandler.key_search() search_args: %s % str(search_args)) found = {} search_args.sort() +if isinstance(args, dict): +exact = args.get('exact', False) +_all = args.get('all', False) +else: +exact = getattr(args, 'exact', False) +_all = getattr(args, 'all', False) for arg in search_args: -seeds = self.seeds.field_search(arg, getattr(args, arg), args.exact) +if isinstance(args, dict): +value = args.get(arg, '') +else: +value = getattr(args, arg) +seeds = self.seeds.field_search(arg, value, exact) for seed in seeds: if seed.nick in found: found[seed.nick]['args'].append(arg) else: found[seed.nick] = {'args': [arg], 'seed': seed} -if args.all: +if _all: for possible in sorted(found): if search_args == found[possible]['args']: results.append(found[possible]['seed'])
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c05d6a6e622d14a6dc9d3b72b34e7d040efe7a37 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 20:49:18 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c05d6a6e gkeys: Fix list-key action to list all keys found in the keydir unless -f is passed in This now ignores the keys listed in the db's seed file and lists all keys seen by gpg. Except when -f, --fingerprint is an argument, then it lists only that key. gkeys/gkeys/actions.py | 5 - gkeys/gkeys/lib.py | 9 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 22d660f..6975c38 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -237,7 +237,10 @@ class Actions(object): kwargs = handler.build_gkeydict(args) keyresults = seeds.list(**kwargs) for key in sorted(keyresults): -result = self.gpg.list_keys(key.keydir, key.fingerprint) +if args.fingerprint: +result = self.gpg.list_keys(key.keydir, kwargs['fingerprint']) +else: +result = self.gpg.list_keys(key.keydir) ls, lr = self._list_it(key, result.output) success.append(ls) results[key.name] = lr diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index a740dd9..bce4e55 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -254,16 +254,17 @@ class GkeysGPG(GPG): if fingerprint: task = 'list-key' target = fingerprint +self.set_keydir(keydir, task, fingerprint=True) else: task = 'list-keys' -target = keydir -self.set_keydir(keydir, task, fingerprint=True) -self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint', '--fingerprint']) +target = '' +self.set_keydir(keydir, task, fingerprint=False) +self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint']) if colons: task_value = ['--with-colons'] self.config.options['tasks'][task].extend(task_value) self.logger.debug(** Calling runGPG with Running 'gpg %s --%s %s' -% (' '.join(self.config['tasks'][task]), task, keydir) +% (' '.join(self.config['tasks'][task]), task, target) ) result = self.runGPG(task=task, inputfile=target) self.logger.info('GPG return code: ' + str(result.returncode))
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d1abd2a51a3712a5c9f8c55a8d1baa3bdae4907f Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 21 19:06:01 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d1abd2a5 gkeys/config.py: Remove no longer used MAPSEEDS constant gkeys/gkeys/config.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index 1cac0b0..6abec96 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -30,9 +30,6 @@ if GENTOO_PORTAGE_EPREFIX in EPREFIX: EPREFIX = '' -MAPSEEDS = { 'dev' : 'gentoodevs.seeds', 'rel': 'gentoo.seeds' } - - class GKeysConfig(GPGConfig): Configuration superclass which holds our gentoo-keys config settings for pygpg
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: ffe53b207532d165f3e6019e10ee27f23e0b3e84 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 23:18:13 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=ffe53b20 gkeys: Remove gpgsearch option from list-key action The default action for list-key is to now list all keys found in the keydir. Regardless if they are in the db's seed file for that keydir. gkeys/gkeys/action_map.py | 2 +- gkeys/gkeys/actions.py| 48 ++- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index d547ab3..3b1b9d0 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -157,7 +157,7 @@ Found: ('list-key', { 'func': 'listkey', 'options': ['category', 'nick', 'name', 'fingerprint', 'keyid', 'keys', -'keydir', 'keyring', 'gpgsearch'], +'keydir', 'keyring'], 'desc': '''Pretty-print the selected gpg key''', 'long_desc': '''Pretty-print the selected gpg key''', 'example': '''gkeys list-key -C gentoo -n gkeys diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index efab4fa..edbea0d 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -206,45 +206,17 @@ class Actions(object): results = {} success = [] messages = [] -if args.gpgsearch: -keyresults = seeds.seeds -# pick any key -key = keyresults[sorted(keyresults)[0]] -result = self.gpg.list_keys(key.keydir, args.gpgsearch) -# now split the results and reverse lookup the gkey -lines = result.output.split('\n') -while lines: -# determine the end of the first key listing -index = lines.index('') -keyinfo = lines[:index] -# trim off the first keys info -lines = lines[index + 1:] -# make sure it is a key listing -if len(keyinfo) 2: -break -# get the fingerprint from the line -fpr = keyinfo[1].split('= ')[1] -# search for the matching gkey -kwargs = {'keydir': args.keydir, 'fingerprint': [fpr]} -keyresults = seeds.list(**kwargs) -# list the results -for key in sorted(keyresults): -ls, lr = self._list_it(key, '\n'.join(keyinfo)) -success.append(ls) -results[key.name] = lr +kwargs = handler.build_gkeydict(args) +keyresults = seeds.list(**kwargs) +for key in sorted(keyresults): +if args.fingerprint: +result = self.gpg.list_keys(key.keydir, kwargs['fingerprint']) +else: +result = self.gpg.list_keys(key.keydir) +ls, lr = self._list_it(key, result.output) +success.append(ls) +results[key.name] = lr messages = [Done.] -else: -kwargs = handler.build_gkeydict(args) -keyresults = seeds.list(**kwargs) -for key in sorted(keyresults): -if args.fingerprint: -result = self.gpg.list_keys(key.keydir, kwargs['fingerprint']) -else: -result = self.gpg.list_keys(key.keydir) -ls, lr = self._list_it(key, result.output) -success.append(ls) -results[key.name] = lr -messages = [Done.] if not messages: messages = ['No results found meeting criteria', Did you specify -n foo or -n '*']
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 46bbcbc3cc1b11577eceb9291fc469f4aad8469f Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 20:44:58 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:50 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=46bbcbc3 gkeys/lib.py: Fix logger message to show the correct function gkeys/gkeys/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 3eb267c..a740dd9 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -234,7 +234,7 @@ class GkeysGPG(GPG): lresults.append(self.list_keys(gkey.keydir, fpr, colons=True)) self.seedfile.update(gkey.update(lresults)) if save and not self.seedfile.save(): -self.logger.error(GkeysGPG.refresh_key(); failed to save seed: + gkey.nick) +self.logger.error(GkeysGPG.update_gkey(); failed to save seed: + gkey.nick) return False return True
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 8afad8720eea5e69c9247fe207c9cd8e20a2a0e6 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Fri Jan 9 21:04:04 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Mon Apr 20 17:49:44 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8afad872 gkeys: remove-key refactoring Update the remove-key action to use the proper installed db. Populate the del_key, del_keydir functions in lib.py gkeys/gkeys/actions.py | 27 +-- gkeys/gkeys/lib.py | 35 +-- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index cfe69ee..22d660f 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -25,7 +25,6 @@ else: from collections import defaultdict from json import load -from shutil import rmtree from gkeys.lib import GkeysGPG from gkeys.seedhandler import SeedHandler @@ -551,7 +550,7 @@ class Actions(object): keyresults = seeds.list(**kwargs) self.output('', '\n Removing keys...') success = True -print(keyresults) +#print(keyresults) for gkey in sorted(keyresults): if kwargs['nick'] != '*' and kwargs['nick'] not in gkey.nick: messages.append(_unicode(%s does not seem to be a valid key.) @@ -569,22 +568,22 @@ class Actions(object): if ans in [no, n]: messages.append(Key removal aborted... Nothing to be done.) else: -## This next code is total crap now -## re-write it from scratch -## there could be multiple keys installed in one keyring -## this code just rm's everything. keyring = self.config.get_key('keyring') catdir = os.path.join(keyring, args.category) -rm_candidate = os.path.join(catdir, gkey.nick) self.logger.debug(_unicode(ACTIONS: removekey; catdir = %s) % catdir) -if args.category: -try: -rmtree(rm_candidate) -messages.append(_unicode(Done removing %s key.) % kwargs['nick']) -except OSError: -messages.append(_unicode(%s directory does not exist.) % rm_candidate) -success = False +self.gpg = GkeysGPG(self.config, catdir, self.logger) +if len(gkey.keys) == 1 or args.keys == gkey.keys: +success, msgs = self.gpg.del_keydir(gkey) +messages.extend(msgs) +elif args.keys: +for key in args.keys: +success, msgs = self.gpg.del_key(gkey, key) +msgs.extend(msgs) +else: +for key in gkey.keys: +success, msgs = self.gpg.del_key(gkey, key) +msgs.extend(msgs) return (success, messages) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 9687c24..3eb267c 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -19,9 +19,10 @@ with gentoo-keys specific convienience functions. # for py 2.6 compatibility from __future__ import print_function - +import os from os.path import abspath, pardir from os.path import join as pjoin +from shutil import rmtree from pyGPG.gpg import GPG from gkeys.checks import KeyChecks @@ -165,18 +166,40 @@ class GkeysGPG(GPG): return results -def del_key(self, gkey, keydir): -'''Delete the specified key in the specified keydir +def del_key(self, gkey, key): +'''Delete the specified key @param gkey: GKEY namedtuple with (name, nick, keydir, fingerprint) +@param key: Fingerprint of the primary key to delete ''' -return [] +self.set_keydir(gkey.keydir, 'del-key', reset=True) +self.set_keyring('pubring.gpg', 'del-key', reset=False) +self.set_keyseedfile(refresh=True) +self.logger.debug(LIB: del_key, gkey: %s % str(gkey)) +self.logger.debug(LIB: del_key, key: %s % key) +self.logger.debug(** Calling runGPG with: 'gpg %s --delete-keys' for: %s +% (' '.join(self.config.get_key('tasks', 'delete-keys')), str(gkey))) +result = self.runGPG(task='delete-keys', inputfile=key) +self.logger.info('GPG return code: ' + str(result.returncode)) +self.update_gkey(gkey, save=True) +return (False, []) -def del_keydir(self, keydir): +def del_keydir(self, gkey): '''Delete the specified keydir + +@param gkey: GKEY namedtuple with (name, nick, keydir, fingerprint) ''' -return [] +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 75cd2f50c181c78863e71ebbef17c70da90bfe6c Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Mar 23 15:37:24 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat May 30 23:18:51 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=75cd2f50 gkeys: Use snakeoil's demandload where appropriate gkeys/gkeys/actions.py | 10 +++--- gkeys/gkeys/seed.py| 10 +++--- gkeys/gkeys/seedhandler.py | 11 --- gkeys/gkeys/utils.py | 13 + 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 7b834a4..80c3c72 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -24,13 +24,17 @@ else: from collections import defaultdict -from json import load -from gkeys.lib import GkeysGPG -from gkeys.seedhandler import SeedHandler +from snakeoil.demandload import demandload + from gkeys.gkey import GKEY from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn +demandload( +json:load, +gkeys.lib:GkeysGPG, +gkeys.seedhandler:SeedHandler, +) class Actions(object): '''Primary API actions''' diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index ca5e2d2..985f6a1 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -21,11 +21,15 @@ import json import os import sys -from gkeys.exception import UpdateDbError -from gkeys.log import logger +from snakeoil.demandload import demandload + from gkeys.gkey import GKEY -from gkeys.fileops import ensure_dirs +demandload( +gkeys.log:logger, +gkeys.exception:UpdateDbError, +gkeys.fileops:ensure_dirs, +) if sys.version_info[0] = 3: def decoder(text, enc='utf_8'): diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 8b787d1..86cab25 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -12,12 +12,17 @@ import os import re -from json import load -from gkeys.exception import UpdateDbError +from snakeoil.demandload import demandload + from gkeys.gkey import GKEY from gkeys.seed import Seeds, decoder -from gkeys.fileops import ensure_dirs + +demandload( +json:load, +gkeys.exception:UpdateDbError, +gkeys.fileops:ensure_dirs, +) class SeedHandler(object): diff --git a/gkeys/gkeys/utils.py b/gkeys/gkeys/utils.py index 92abc50..64f11aa 100644 --- a/gkeys/gkeys/utils.py +++ b/gkeys/gkeys/utils.py @@ -24,10 +24,15 @@ Utility functions''' import types import re -import os -import sys -import locale -import codecs + +from snakeoil.demandload import demandload + +demandload( +os, +sys, +locale, +codecs, +) try: StringTypes = types.StringTypes
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 9f19528a9d61517cb262081b2cf28a3c2d5ee95b Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Mon Apr 20 17:48:15 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sun May 31 04:45:22 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9f19528a gkeys/actions.py: Seed handling fixes Update for newer listseed() data returned. gkeys/gkeys/actions.py | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 80c3c72..d467500 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -98,7 +98,8 @@ class Actions(object): def addseed(self, args): '''Add or replace a key in the selected seed file''' handler = SeedHandler(self.logger, self.config) -success, gkeys = self.listseed(args)[1] +success, data = self.listseed(args) +gkeys = data[1] if not args.nick or not args.name or not args.keys or not args.keydir: return (False, [Provide a nickname, a name and a public key fingerprint (-K, --keys).]) if not args.fingerprint: @@ -126,7 +127,8 @@ class Actions(object): def removeseed(self, args): '''Remove a seed from the selected seed file''' -success, gkeys = self.listseed(args)[1] +success, data = self.listseed(args) +gkeys = data[1] if not gkeys: return (False, [Failed to remove seed: No gkeys returned from listseed(), []]) @@ -249,7 +251,8 @@ class Actions(object): def installkey(self, args): '''Install a key from the seed(s)''' self.logger.debug(ACTIONS: installkey; args: %s % str(args)) -success, gkeys = self.listseed(args)[1] +success, data = self.listseed(args) +gkeys = data[1] if gkeys: if gkeys and not args.nick == '*' and self.output: self.output(['', gkeys], \n Found GKEY seeds:) @@ -593,7 +596,8 @@ class Actions(object): self.logger.debug(_unicode(ACTIONS: importkey; catdir = %s) % catdir) self.gpg = GkeysGPG(self.config, catdir, self.logger) -success, gkeys = self.listseed(args)[1] +success, data = self.listseed(args) +gkeys = data[1] results = {} failed = [] print(Importing specified keys to keyring.)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 1f8fc87469153591e4cefeb93bdff0ba995c5190 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Mar 18 15:32:17 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Mar 18 15:32:17 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=1f8fc874 gkeys/checks.py: Downgrade the logging to warn from error logging.error also prints to the screen which we don't want in this case. The logging.warn is fine for these errors since they are already shown in a formatted output. gkeys/gkeys/checks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py index a3af3ab..7e40720 100644 --- a/gkeys/gkeys/checks.py +++ b/gkeys/gkeys/checks.py @@ -369,10 +369,10 @@ class KeyChecks(object): stats[SPEC_INDEX['expire']] = True elif days delta_t and not ('i' in data.validity or 'r' in data.validity): stats[SPEC_INDEX['expire_reason']] = '== Exceeds specification' -self.logger.error(ERROR in key %s : gpg key expire date: %s EXCEEDS specification +self.logger.warn(ERROR in key %s : gpg key expire date: %s EXCEEDS specification % (data.long_keyid, data.expiredate)) else: -self.logger.error(ERROR in key %s : invalid gpg key expire date: %s +self.logger.warn(ERROR in key %s : invalid gpg key expire date: %s % (data.long_keyid, data.expiredate)) if 0 days 30 and not ('i' in data.validity or 'r' in data.validity): stats[SPEC_INDEX['expire_reason']] = '== WARNING 30 days' @@ -398,7 +398,7 @@ class KeyChecks(object): stats[SPEC_INDEX['encrypt_capable']] = True elif cap not in CAPABILITY_MAP: stats[SPEC_INDEX['caps']] = False -self.logger.error(ERROR in key %s : unknown gpg key capability: %s +self.logger.warn(ERROR in key %s : unknown gpg key capability: %s % (data.long_keyid, cap)) stats[SPEC_INDEX['long_caps']] = ', '.join(kcaps) return stats
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: f12dcd69d558b3b5f58ecd21ee20e347a06a3405 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Mar 17 19:50:53 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Mar 17 19:50:53 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=f12dcd69 gkeys/checks.py: Fix the expiry warning summary not detecting any Add logger messages for expiry errors/warnings gkeys/gkeys/actions.py | 2 +- gkeys/gkeys/checks.py | 9 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index b2b8cf3..cfe69ee 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -459,7 +459,7 @@ class Actions(object): if not key.bits: failed['bits'].append(_unicode(%s %s: %s) % (gkey.name, gkey.nick, key.fingerprint)) -if Warning in key.expire_reason: +if warning in key.expire_reason.lower(): failed['warn'].append(_unicode(%s %s: %s ) % (gkey.name, gkey.nick, key.fingerprint)) if True in pub_pass['signs']: diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py index bddad5f..a3af3ab 100644 --- a/gkeys/gkeys/checks.py +++ b/gkeys/gkeys/checks.py @@ -369,12 +369,15 @@ class KeyChecks(object): stats[SPEC_INDEX['expire']] = True elif days delta_t and not ('i' in data.validity or 'r' in data.validity): stats[SPEC_INDEX['expire_reason']] = '== Exceeds specification' +self.logger.error(ERROR in key %s : gpg key expire date: %s EXCEEDS specification +% (data.long_keyid, data.expiredate)) else: -self.logger.debug(ERROR in key %s : invalid gpg key expire date: %s +self.logger.error(ERROR in key %s : invalid gpg key expire date: %s % (data.long_keyid, data.expiredate)) if 0 days 30 and not ('i' in data.validity or 'r' in data.validity): stats[SPEC_INDEX['expire_reason']] = '== WARNING 30 days' - +self.logger.warn(WARNING in key %s : gpg key expire date: %s WARNING 30 days +% (data.long_keyid, data.expiredate)) return stats @@ -395,7 +398,7 @@ class KeyChecks(object): stats[SPEC_INDEX['encrypt_capable']] = True elif cap not in CAPABILITY_MAP: stats[SPEC_INDEX['caps']] = False -self.logger.debug(ERROR in key %s : unknown gpg key capability: %s +self.logger.error(ERROR in key %s : unknown gpg key capability: %s % (data.long_keyid, cap)) stats[SPEC_INDEX['long_caps']] = ', '.join(kcaps) return stats
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/, gkeys/etc/
commit: dfe6fd48a50d5753127a3720259f10312822a39b Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Mar 10 14:14:27 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Mar 10 14:14:27 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dfe6fd48 gkeys: Fix setting deafault location of homedir Pass in the os.expanduser('~') setting to the config parser. Comment out the gkeys.conf homedir setting so it can use the passed in default. gkeys/etc/gkeys.conf | 4 +++- gkeys/gkeys/config.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gkeys/etc/gkeys.conf b/gkeys/etc/gkeys.conf index 3f15051..e7a363f 100644 --- a/gkeys/etc/gkeys.conf +++ b/gkeys/etc/gkeys.conf @@ -16,7 +16,9 @@ gkeysdir: /var/lib/gentoo/gkeys # default user home directory -homedir: +# normally set by expanding ~ +# uncomment and edit for a custom location +#homedir: # user gkey directory diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index 96e85e6..1cac0b0 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -99,8 +99,8 @@ class GKeysConfig(GPGConfig): self.defaults[key] = self._sub_(self.defaults[key]) defaults = OrderedDict() # Add only the defaults we want in the configparser -for key in ['gkeysdir', 'keyring', 'sign-keydir', 'logdir', 'seedsdir', -'keyserver']: +for key in ['gkeysdir', 'homedir', 'keyring', 'sign-keydir', 'logdir', +'seedsdir', 'keyserver']: defaults[key] = self.defaults[key] if filename == None: filename = self.defaults['config']
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 5a12b768465c9e68f2c46354d8f77316c40f9ef6 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Mar 7 18:04:52 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Mar 7 18:04:52 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5a12b768 gkeys/base.py: Fix expanduser error reported by K_F gkeys/gkeys/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 08bfe5f..fba1976 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -267,8 +267,8 @@ class CliBase(object): self.config.read_config(configs) # check for permissions and adjust configs accordngly -if not self.config['homedir']: -self.config['homedir'] = os.path.expanduser('~') +if not self.config.defaults['homedir']: +self.config.defaults['homedir'] = os.path.expanduser('~') if not os.access(self.config['logdir'], os.W_OK): self.config['logdir'] = ensure_dirs( os.path.join(self.config['user-dir'], 'logs'))
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 104269d7a6bf20cc0a618ba9194c2be6e2970abe Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Fri Mar 6 21:03:46 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Fri Mar 6 21:03:46 2015 + URL:https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=104269d7 gkeys/seed.py: Revert the use of codecs to open the seed file It was causing tracebacks in python-2.7 running in vulture.gentoo.org gkeys/gkeys/seed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index 262ba57..ca5e2d2 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -61,7 +61,7 @@ class Seeds(object): seedlines = None self.seeds = {} try: -with codecs.open(self.filename, r+, encoding='utf_8') as seedfile: +with open(self.filename, r+) as seedfile: seedlines = json.load(seedfile) except IOError as err: self.logger.debug(Seed: load; IOError occurred while loading file) @@ -104,7 +104,7 @@ class Seeds(object): fatal=True) os.umask(int(self.config.get_key(permissions, files),0)) try: -with codecs.open(self.filename, 'w', encoding='utf_8') as seedfile: +with open(self.filename, 'w') as seedfile: seedfile.write(self._seeds2json(self.seeds)) seedfile.write(\n) except IOError as err:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 80fbd3d7da1720844103a202809b7583a3f11c7b Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 20 05:58:00 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 04:40:29 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=80fbd3d7 gkeys: Wrap all strings which have %s with _unicode() to prevent decode errors Hopefully this will stop the intermittent python-2.7 UnicodeDecodeError that some people get during string substitution. --- gkeys/gkeys/actions.py | 278 ++--- gkeys/gkeys/base.py| 2 +- 2 files changed, 172 insertions(+), 108 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index ad03038..16dbb26 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -17,8 +17,10 @@ import sys if sys.version_info[0] = 3: py_input = input +_unicode = str else: py_input = raw_input +_unicode = unicode from collections import defaultdict @@ -63,7 +65,8 @@ class Actions(object): '''Pretty-print the selected seed file''' handler = SeedHandler(self.logger, self.config) kwargs = handler.build_gkeydict(args) -self.logger.debug(ACTIONS: listseed; kwargs: %s % str(kwargs)) +self.logger.debug(_unicode(ACTIONS: listseed; kwargs: %s) +% _unicode(kwargs)) if not self.seeds: try: self.seeds = handler.load_seeds(args.category, args.nick) @@ -78,7 +81,8 @@ class Actions(object): def fetchseed(self, args): '''Download the selected seed file(s)''' -self.logger.debug(ACTIONS: fetchseed; args: %s % str(args)) +self.logger.debug(_unicode(ACTIONS: fetchseed; args: %s) +% _unicode(args)) if not args.category: return (False, [Please specify seeds category.]) handler = SeedHandler(self.logger, self.config) @@ -103,7 +107,9 @@ class Actions(object): return (False, [Failed to create a valid GKEY instance., Check for invalid data entries]) if len(gkeys) == 0: -self.logger.debug(ACTIONS: installkey; now adding gkey: %s % str(gkey)) +self.logger.debug( +_unicode(ACTIONS: installkey; now adding gkey: %s) +% _unicode(gkey)) success = self.seeds.add(getattr(gkey, 'nick'), gkey) if success: success = self.seeds.save() @@ -122,12 +128,14 @@ class Actions(object): return (False, [Failed to remove seed: No gkeys returned from listseed(), []]) if len(gkeys) == 1: -self.logger.debug(ACTIONS: removeseed; now deleting gkey: %s % str(gkeys)) +self.logger.debug( +_unicode(ACTIONS: removeseed; now deleting gkey: %s) +% _unicode(gkeys)) success = self.seeds.delete(gkeys[0]) if success: success = self.seeds.save() -return (success, [Successfully removed seed: %s % str(success), -gkeys]) +return (success, [_unicode(Successfully removed seed: %s) +% _unicode(success), gkeys]) elif len(gkeys): return (False, [Too many seeds found to remove, gkeys]) return (False, [Failed to remove seed:, args, @@ -138,7 +146,8 @@ class Actions(object): '''Move keys between seed files''' handler = SeedHandler(self.logger, self.config) searchkey = handler.new(args, checkgkey=False) -self.logger.debug(ACTIONS: moveseed; gkey: %s % str(searchkey)) +self.logger.debug(_unicode(ACTIONS: moveseed; gkey: %s) +% _unicode(searchkey)) if not self.seeds: self.seeds = self.load_seeds(args.category) kwargs = handler.build_gkeydict(args) @@ -147,17 +156,21 @@ class Actions(object): destkeys = dest.list(**kwargs) messages = [] if len(sourcekeys) == 1 and destkeys == []: -self.logger.debug(ACTIONS: moveseed; now adding destination gkey: %s -% str(sourcekeys[0])) +self.logger.debug( +_unicode(ACTIONS: moveseed; now adding destination gkey: %s) +% _unicode(sourcekeys[0])) success = dest.add(sourcekeys[0]) -self.logger.debug(ACTIONS: moveseed; success: %s %str(success)) -self.logger.debug(ACTIONS: moveseed; now deleting sourcekey: %s % str(sourcekeys[0])) +self.logger.debug(ACTIONS: moveseed; success: %s % str(success)) +self.logger.debug( +_unicode(ACTIONS: moveseed; now deleting sourcekey: %s) +% _unicode(sourcekeys[0])) success = self.seeds.delete(sourcekeys[0]) if success: success = dest.save() -self.logger.debug(ACTIONS:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 22173b6b70d6c1ba88249cf948801365cb1f64e1 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Sat Jan 31 03:33:59 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 04:40:29 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=22173b6b gkeys/actions.py: separate the message info substitution It is usually the result.username that gives the error. This tries to trap it and keep going. --- gkeys/gkeys/actions.py | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index dfc9f09..3852372 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -308,10 +308,11 @@ class Actions(object): msg = _unicode(key desired: %(name)s, key added: %(key)s, succeeded: +\ %(success)s, fingerprint: %(fpr)s) for result in results[key.name]: -try: -print(msg % ({'name': key.name, 'key': result.username, +umsg = msg % ({'name': key.name, 'key': result.username, 'success': str(not result.failed), -'fpr': result.fingerprint})) +'fpr': result.fingerprint}) +try: +print(umsg) except UnicodeDecodeError: print(_unicode(UnicodeDecodeError printing results for:), key.name) self.logger.debug(_unicode(installkey(); UnicodeDecodeError for:) + key.name)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d3446934815ba262e479cea7272a524b65d3f041 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 13 05:58:59 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 03:43:47 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d3446934 gkeys/actions.py: Trap UnicodeDecodeError for installkey() Add debug logging for the error. --- gkeys/gkeys/actions.py | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 23c71fc..ad03038 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -292,9 +292,16 @@ class Actions(object): msg = key desired: %(name)s, key added: %(key)s, succeeded: +\ %(success)s, fingerprint: %(fpr)s for result in results[key.name]: -print(msg % ({'name': key.name, 'key': result.username, -'success': not result.failed, -'fpr': result.fingerprint})) +try: +print(msg % ({'name': key.name, 'key': result.username, +'success': str(not result.failed), +'fpr': result.fingerprint})) +except UnicodeDecodeError: +print(UnicodeDecodeError printing results for:, key.name) +self.logger.debug(installkey(); UnicodeDecodeError for: + key.name) +self.logger.debug(result.username...: + result.username) +self.logger.debug(result.failed.: + result.failed) +self.logger.debug(result.fingerprint: + result.fingerprint) self.logger.debug(stderr_out: + str(result.stderr_out)) if result.failed: failed.append(key) @@ -564,7 +571,7 @@ class Actions(object): succeeded: %(success)s, fingerprint: %(fpr)s for result in results[gkey.name]: print(msg % ({'name': gkey.name, 'key': result.username, -'success': not result.failed, +'success': str(not result.failed), 'fpr': result.fingerprint})) self.logger.debug(stderr_out: + str(result.stderr_out)) if result.failed:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: f67614b04b13ba636d4b95be353d165bf85f9078 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 13 05:10:32 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 03:43:47 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f67614b0 gkeys/base.py: Remove no longer used code --- gkeys/gkeys/base.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index cfd3702..8308df8 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -219,8 +219,6 @@ class CliBase(object): description='Valid subcommands', help='Additional help') for name in self.cli_config['Available_Actions']: -action_method = getattr(self.cli_config['Actions'], -self.cli_config['Action_Map'][name]['func']) actiondoc = self.cli_config['Action_Map'][name]['desc'] try: text = actiondoc.splitlines()[0]
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/, gkeys/etc/
commit: 0ffd0b9353a42251f6ca4c5292dcd1078a7b22e9 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 13 05:08:24 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 03:43:47 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=0ffd0b93 logger location refactor bug 536314 --- gkeys/etc/gkeys.conf | 2 +- gkeys/gkeys/base.py | 10 -- gkeys/gkeys/config.py | 8 +--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gkeys/etc/gkeys.conf b/gkeys/etc/gkeys.conf index 7a774be..3f15051 100644 --- a/gkeys/etc/gkeys.conf +++ b/gkeys/etc/gkeys.conf @@ -16,7 +16,7 @@ gkeysdir: /var/lib/gentoo/gkeys # default user home directory -homedir: ~ +homedir: # user gkey directory diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 7e28b90..cfd3702 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -15,9 +15,10 @@ from __future__ import print_function import argparse +import os import sys -from gkeys import fileops +from gkeys.fileops import ensure_dirs from gkeys.log import log_levels, set_logger @@ -267,12 +268,17 @@ class CliBase(object): else: self.config.read_config(configs) +# check for permissions and adjust configs accordngly +if not self.config['homedir']: +self.config['homedir'] = os.path.expanduser('~') +if not os.access(self.config['logdir'], os.W_OK): +self.config['logdir'] = ensure_dirs( +os.path.join(self.config['user-dir'], 'logs')) # establish our logger and update it in the imported files self.logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug, dirmode=int(self.config.get_key('permissions', 'directories'),0), filemask=int(self.config.get_key('permissions', 'files'),0)) self.config.logger = self.logger -fileops.logger = self.logger if message: self.logger.error(message) diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py index fdc1cee..96e85e6 100644 --- a/gkeys/gkeys/config.py +++ b/gkeys/gkeys/config.py @@ -56,9 +56,11 @@ class GKeysConfig(GPGConfig): def _set_default_config(self): -self.defaults['homedir'] = os.path.join(os.path.expanduser('~'), '.gkeys') -self.defaults['configdir'] = self.defaults['homedir'] -self.defaults['config']= os.path.join(self.defaults['homedir'], 'gkeys.conf') +self.defaults['homedir'] = os.path.expanduser('~') +self.defaults['configdir'] = os.path.join( +self.defaults['homedir'], '.gkeys') +self.defaults['config']= os.path.join( +self.defaults['configdir'], 'gkeys.conf') if not os.path.exists(self.defaults['config']): self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gkeys']) self.defaults['config'] = '%(configdir)s/gkeys.conf'
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 50670d9212b29b27192f3e951d680391e0fbd70a Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Feb 11 17:21:35 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Feb 11 17:30:27 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=50670d92 gkeys/actions.py: Remove result from del list, it's not always defined --- gkeys/gkeys/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 3852372..0a30679 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -953,7 +953,7 @@ class Actions(object): if isinstance(result, GKEY): keys[cat].append(result) if data_only: -del found, cat, result, handler +del found, cat, handler return keys msgs = [] for cat in list(keys):
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 0b5e90a96d8434177c7ef8f5cfc34129a879baf3 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Feb 11 17:20:24 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Feb 11 17:30:27 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=0b5e90a9 gkeys/action_map.py: Add uid to possible options --- gkeys/gkeys/action_map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index 2a11146..d547ab3 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -58,7 +58,7 @@ Action_Map = OrderedDict([ ('verify', { 'func': 'verify', 'options': ['category', 'nick', 'name', 'fingerprint', 'keydir', 'keys', -'1file', 'signature', 'timestamp', 'dest'], +'1file', 'signature', 'timestamp', 'dest', 'uid'], 'desc': '''File automatic download and/or verification action.''', 'long_desc': '''File automatic download and/or verification action. Note: If the specified key/keyring to verify against does not contain
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 9ecc173ca9dfa1b22af86ba9412c6f6777cbb54b Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jan 28 21:30:04 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Sat Jan 31 04:40:29 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9ecc173c gkeys: Fix verify -F logic for inline sigs --- gkeys/gkeys/actions.py | 115 ++--- gkeys/gkeys/lib.py | 2 +- 2 files changed, 62 insertions(+), 55 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 16dbb26..dfc9f09 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -755,71 +755,78 @@ class Actions(object): _unicode(ACTIONS: verify; timestamp path: %s) % timestamp_path) success, signedfile, timestamp = fetcher.fetch_file( url, filepath, timestamp_path) +if not success: +messages.append(_unicode(File %s cannot be retrieved.) % filepath) +else: +if not signature: +EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig'] +success_fetch = False +for ext in EXTENSIONS: +sig_path = filepath + ext +if isurl: +signature = url + ext +self.logger.debug( +_unicode(ACTIONS: verify; fetching %s signature ) +% signature) +success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path) +if success_fetch: +break +else: +signature = None else: filepath = os.path.abspath(filepath) self.logger.debug( _unicode(ACTIONS: verify; local file %s) % filepath) success = os.path.isfile(filepath) -if not success: -messages.append(_unicode(File %s cannot be retrieved.) % filepath) -else: if not signature: EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig'] success_fetch = False for ext in EXTENSIONS: sig_path = filepath + ext -if isurl: -signature = url + ext -self.logger.debug( -_unicode(ACTIONS: verify; fetching %s signature ) -% signature) -success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path) -else: -signature = filepath + ext -signature = os.path.abspath(signature) -self.logger.debug( -_unicode(ACTIONS: verify; checking %s signature ) -% signature) -success_fetch = os.path.isfile(signature) -if success_fetch: +sig_path = os.path.abspath(sig_path) +self.logger.debug( +_unicode(ACTIONS: verify; checking %s signature ) +% sig_path) +success_sig = os.path.isfile(sig_path) +if success_sig: break -else: -sig_path = signature -self.logger.info(Verifying file...) -verified = False -results = self.gpg.verify_file(key, sig_path, filepath) -keyid = key.keyid[0] -(valid, trust) = results.verified -if valid: -verified = True -messages.extend( -[_unicode(Verification succeeded.: %s) % (filepath), -_unicode(Key info...: %s %s, %s) -% ( key.name, key.nick, keyid), -_unicode(category, nick.: %s %s) -% (args.category, args.nick)]) -else: -messages.extend( -[_unicode(Verification failed: %s) % (filepath), -_unicode(Key info...: %s %s, %s) -% ( key.name, key.nick, keyid)]) -has_no_pubkey, s_keyid = results.no_pubkey -if has_no_pubkey: -messages.append( -_unicode(Auto-searching for key.: 0x%s) % s_keyid) -# reset all but keyid and pass thru data -args.keyid = s_keyid -args.keydir = None -args.fingerprint = None -args.exact = False -args.category = None -args.nick = None -args.name = None -args.all =
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 7243efa95b7f2da8f1d61af8a2ad643d9f10a8fa Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Feb 11 17:22:34 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Feb 11 17:30:28 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7243efa9 gkeys/actions.py: _verify() Properly report a failed search --- gkeys/gkeys/actions.py | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 0a30679..b2b8cf3 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -825,9 +825,11 @@ class Actions(object): args.name = None args.all = False keys = self.key_search(args, data_only=True) -args.category = list(keys)[0] -args.nick = keys[args.category][0].nick -return self.verify(args, messages) +if keys: +args.category = list(keys)[0] +args.nick = keys[args.category][0].nick +return self.verify(args, messages) +messages.append(_unicode(Failed to find gpg key.: 0x%s) % s_keyid) return (verified, messages)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 4db4657c83e471e65ec60ee4a26a9b2d8eda2838 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Fri Jan 9 03:03:32 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Fri Jan 9 06:07:44 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4db4657c gkeys/seed.py: Rename search() to regex_search() --- gkeys/gkeys/seed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index f92d910..262ba57 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -173,7 +173,7 @@ class Seeds(object): return sorted(result.values()) -def search(self, pattern): +def regex_search(self, pattern): '''Search for the keys matching the regular expression pattern''' pass
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: c4dfd5ac664f6afec52a77ab911c2130e028e402 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Thu Jan 8 21:51:52 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Fri Jan 9 06:07:29 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c4dfd5ac gkeys: Fix seed file loading, saving unicode issues Fix unicode cli args issues. --- gkeys/gkeys/actions.py | 36 +--- gkeys/gkeys/seed.py| 28 +--- gkeys/gkeys/seedhandler.py | 6 +++--- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 9d57870..59929cd 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -241,15 +241,15 @@ class Actions(object): if self.config.options['print_results']: if print_key: print() -print(Nick.:, key.nick) -print(Name.:, key.name) -print(Keydir...:, key.keydir) +print(Nick.: %s % key.nick) +print(Name.: %s % key.name) +print(Keydir...: %s % key.keydir) c = 0 for line in result.split('\n'): if c == 0: -print(Gpg info.:, line) +print(Gpg info.: %s % line) else: -print( , line) +print( %s % line) c += 1 self.logger.debug(data output:\n + str(result)) return (True, result) @@ -289,10 +289,12 @@ class Actions(object): self.logger.debug(ACTIONS: installkey; result.failed = + str(result.failed)) if self.config.options['print_results']: +msg = key desired: %(name)s, key added: %(key)s, succeeded: +\ + %(success)s, fingerprint: %(fpr)s for result in results[key.name]: -print(key desired:, key.name, , key added:, -result.username, , succeeded:, -not result.failed, , fingerprint:, result.fingerprint) +print(msg % ({'name': key.name, 'key': result.username, +'success': not result.failed, +'fpr': result.fingerprint})) self.logger.debug(stderr_out: + str(result.stderr_out)) if result.failed: failed.append(key) @@ -488,7 +490,7 @@ class Actions(object): return (False, [Please provide a nickname or -n *]) handler = SeedHandler(self.logger, self.config) kwargs = handler.build_gkeydict(args) -self.logger.debug(ACTIONS: addkey; kwargs: %s % str(kwargs)) +self.logger.debug(ACTIONS: removekey; kwargs: %s % str(kwargs)) success, installed_keys = self.installed(args)[1] for gkey in installed_keys: if kwargs['nick'] not in gkey.nick: @@ -539,17 +541,21 @@ class Actions(object): self.logger.debug(ACTIONS: importkey; adding key: %s, gkey.name) results[gkey.name] = self.gpg.add_key(gkey) if self.config.options['print_results']: +msg = key desired: %(name)s, key added: %(key)s, + \ +succeeded: %(success)s, fingerprint: %(fpr)s for result in results[gkey.name]: -print(key desired:, gkey.name, , key added:, -result.username, , succeeded:, -not result.failed, , fingerprint:, result.fingerprint) +print(msg % ({'name': gkey.name, 'key': result.username, +'success': not result.failed, +'fpr': result.fingerprint})) self.logger.debug(stderr_out: + str(result.stderr_out)) if result.failed: -self.logger.debug(ACTIONS: importkey; result.failed = + str(result.failed)) +self.logger.debug(ACTIONS: importkey; result.failed = ++ str(result.failed)) failed.append(gkey) if not results[gkey.name][0].failed: -print(Importing: , gkey.name) -self.logger.debug(ACTIONS: importkey; importing key: %s, gkey.name) +print(Importing: %s % gkey.name) +self.logger.debug(ACTIONS: importkey; importing key: %s +% gkey.name) _keyring = os.path.join(catdir, args.keyring + '.gpg') self.gpg.add_to_keyring(gkey, catdir, _keyring) if failed and
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: aa3b192bfc5cf981fde0cc1476367cba556796ec Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Fri Jan 9 03:02:58 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Fri Jan 9 06:07:44 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=aa3b192b gkeys/seed.py: Update field_search() docstring --- gkeys/gkeys/seed.py | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py index 2f6e72a..f92d910 100644 --- a/gkeys/gkeys/seed.py +++ b/gkeys/gkeys/seed.py @@ -191,9 +191,11 @@ class Seeds(object): def field_search(self, field, value, exact=False): -'''Searches the seeds for a matching nick +'''Searches the seeds for a matching value -@param keyid: string +@param field: string +@param value: string +@param exact: Boolean @returns GKEY instance or None ''' results = []
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 622f59e420f92062cc093b6ba540a15f03e56358 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Fri Jan 9 05:57:34 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Fri Jan 9 06:07:44 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=622f59e4 gkeys/actions.py: Partially update removekey() The removal code is completely wrong if there are multiple keys installed in one keyring. Everything below my comments needs a complete re-do. Disabling the remove-key action until refactored. --- gkeys/gkeys/action_map.py | 2 +- gkeys/gkeys/actions.py| 37 - 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index fc5bfb0..b9224ea 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -18,7 +18,7 @@ Seed_Actions = ['seeds', 'add-seed', 'fetch-seed', 'list-seed', 'list-seedfiles', 'remove-seed'] Key_Actions = ['keys-', 'check-key', 'installed', -'install-key', 'list-key', 'refresh-key', 'remove-key', +'install-key', 'list-key', 'refresh-key', 'search-key', 'spec-check'] General_Actions = ['---general---', 'list-cats', 'sign','verify'] diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 59929cd..23c71fc 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -491,21 +491,40 @@ class Actions(object): handler = SeedHandler(self.logger, self.config) kwargs = handler.build_gkeydict(args) self.logger.debug(ACTIONS: removekey; kwargs: %s % str(kwargs)) -success, installed_keys = self.installed(args)[1] -for gkey in installed_keys: -if kwargs['nick'] not in gkey.nick: -messages = [%s does not seem to be a valid key. % kwargs['nick']] +seeds = handler.load_category(args.category) +messages = [] +if args.nick == '*': +self.output([''],'Remove All keys in category: %s' % args.category) +ans = py_input (Do you really want to remove ALL of keys?[y/n]: ) +while ans not in [yes, y, no, n]: +ans = py_input (Do you really want to remove ALL keys?[y/n]: ) +if ans in [no, n]: +messages.append(Key removal aborted... Nothing to be done.) +return (True, messages) +keyresults = seeds.seeds +else: +keyresults = seeds.list(**kwargs) +self.output('', '\n Removing keys...') +success = True +print(keyresults) +for gkey in sorted(keyresults): +if kwargs['nick'] != '*' and kwargs['nick'] not in gkey.nick: +messages.append(%s does not seem to be a valid key. % kwargs['nick']) success = False else: self.output(['', [gkey]], '\n Found GKEY seed:') ans = py_input (Do you really want to remove %s?[y/n]: -% kwargs['nick']).lower() +% kwargs['nick'].lower()) while ans not in [yes, y, no, n]: ans = py_input (Do you really want to remove %s?[y/n]: -% kwargs['nick']).lower() +% kwargs['nick'].lower()) if ans in [no, n]: -messages = [Key removal aborted... Nothing to be done.] +messages.append(Key removal aborted... Nothing to be done.) else: +## This next code is total crap now +## re-write it from scratch +## there could be multiple keys installed in one keyring +## this code just rm's everything. keyring = self.config.get_key('keyring') catdir = os.path.join(keyring, args.category) rm_candidate = os.path.join(catdir, gkey.nick) @@ -513,9 +532,9 @@ class Actions(object): if args.category: try: rmtree(rm_candidate) -messages = [Done removing %s key. % kwargs['nick']] +messages.append(Done removing %s key. % kwargs['nick']) except OSError: -messages = [%s directory does not exist. % rm_candidate] +messages.append(%s directory does not exist. % rm_candidate) success = False return (success, messages)
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: b547e16c7e047d9fd9ac7d9536678cf9102c2b16 Author: Pavlos Ratis dastergon AT gentoo DOT org AuthorDate: Thu Jan 8 20:42:20 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Thu Jan 8 21:05:22 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b547e16c Revert gkeys: Finally fix all the unicode printing errors This reverts commit b7f9364cb0952f2e06f94299400d2f23b629553d. It totally broke py-3 comaptibility! --- gkeys/gkeys/actions.py | 20 +--- gkeys/gkeys/base.py| 10 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 4db3757..9d57870 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -25,8 +25,6 @@ from collections import defaultdict from json import load from shutil import rmtree -from pyGPG.status import _unicode_encode - from gkeys.lib import GkeysGPG from gkeys.seedhandler import SeedHandler from gkeys.gkey import GKEY @@ -243,15 +241,15 @@ class Actions(object): if self.config.options['print_results']: if print_key: print() -print(Nick.:, _unicode_encode(key.nick)) -print(Name.:, _unicode_encode(key.name)) -print(Keydir...:, _unicode_encode(key.keydir)) +print(Nick.:, key.nick) +print(Name.:, key.name) +print(Keydir...:, key.keydir) c = 0 for line in result.split('\n'): if c == 0: -print(Gpg info.:, _unicode_encode(line)) +print(Gpg info.:, line) else: -print( , _unicode_encode(line)) +print( , line) c += 1 self.logger.debug(data output:\n + str(result)) return (True, result) @@ -292,7 +290,7 @@ class Actions(object): str(result.failed)) if self.config.options['print_results']: for result in results[key.name]: -print(key desired:, _unicode_encode(key.name), , key added:, +print(key desired:, key.name, , key added:, result.username, , succeeded:, not result.failed, , fingerprint:, result.fingerprint) self.logger.debug(stderr_out: + str(result.stderr_out)) @@ -383,7 +381,7 @@ class Actions(object): for g in results: pub_pass = {} for key in results[g]: -self.output('', _unicode_encode(key.pretty_print())) +self.output('', key.pretty_print()) if key.key is PUB: pub_pass = { @@ -542,7 +540,7 @@ class Actions(object): results[gkey.name] = self.gpg.add_key(gkey) if self.config.options['print_results']: for result in results[gkey.name]: -print(key desired:, _unicode_encode(gkey.name), , key added:, +print(key desired:, gkey.name, , key added:, result.username, , succeeded:, not result.failed, , fingerprint:, result.fingerprint) self.logger.debug(stderr_out: + str(result.stderr_out)) @@ -550,7 +548,7 @@ class Actions(object): self.logger.debug(ACTIONS: importkey; result.failed = + str(result.failed)) failed.append(gkey) if not results[gkey.name][0].failed: -print(Importing: , _unicode_encode(gkey.name)) +print(Importing: , gkey.name) self.logger.debug(ACTIONS: importkey; importing key: %s, gkey.name) _keyring = os.path.join(catdir, args.keyring + '.gpg') self.gpg.add_to_keyring(gkey, catdir, _keyring) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 1a80a03..46f8f2f 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -17,7 +17,7 @@ from __future__ import print_function import argparse import sys -from pyGPG.status import _unicode_encode +from pyGPG.status import _unicode_decode from gkeys import fileops from gkeys.log import log_levels, set_logger @@ -315,16 +315,16 @@ class CliBase(object): def output_results(results, header=None): # super simple output for the time being if header: -print(_unicode_encode(header)) +print(_unicode_decode(header)) for msg in results: if type(msg) in [str, unicode]: -print(' ', _unicode_encode(msg)) +print(' ', _unicode_decode(msg)) else:
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: e493576420d6396481cd5e74ddfc29d20946df32 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Thu Jan 8 21:07:47 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Thu Jan 8 21:07:47 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e4935764 Revert gkeys/base.py: Wrap all output with _unicode_decode() This reverts commit d947f8fc4b5d91f1655e1f7770a0f94cbb6a52a9. --- gkeys/gkeys/base.py | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 46f8f2f..7e28b90 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -17,7 +17,6 @@ from __future__ import print_function import argparse import sys -from pyGPG.status import _unicode_decode from gkeys import fileops from gkeys.log import log_levels, set_logger @@ -315,16 +314,16 @@ class CliBase(object): def output_results(results, header=None): # super simple output for the time being if header: -print(_unicode_decode(header)) +print(header) for msg in results: if type(msg) in [str, unicode]: -print(' ', _unicode_decode(msg)) +print(' ', msg) else: try: -print(\n.join([_unicode_decode(x.pretty_print) for x in msg])) +print(\n.join([x.pretty_print for x in msg])) except AttributeError: for x in msg: -print('', _unicode_decode(x)) +print('', x) print()
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: 5c4b8d7eceee333f803941f40d2cc757ecf5f80b Author: Pavlos Ratis dastergon AT gentoo DOT org AuthorDate: Thu Jan 8 17:08:51 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Thu Jan 8 17:08:51 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5c4b8d7e add checks to fetch-seed in case of missing category Added a check about categories in fetch-seed action because it failed when the command ran without a category --- gkeys/gkeys/actions.py | 3 ++- gkeys/gkeys/seedhandler.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index eef338e..4db3757 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -81,9 +81,10 @@ class Actions(object): def fetchseed(self, args): '''Download the selected seed file(s)''' self.logger.debug(ACTIONS: fetchseed; args: %s % str(args)) +if not args.category: +return (False, [Please specify seeds category.]) handler = SeedHandler(self.logger, self.config) success, messages = handler.fetch_seeds(args.category, args, self.verify) - messages.append() messages.append(Fetch operation completed) return (False not in success, messages) diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index 600ac35..5f15222 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -142,10 +142,10 @@ class SeedHandler(object): for seed in [seeds]: seedurl = self.config.get_key('seedurls', seed) seedpath = self.config.get_key('seeds', seed) -if http_check.match(seedurl): +if seedurl and seedpath and http_check.match(seedurl): urls.extend([(seed, seedurl, seedpath)]) else: -self.logger.info(Wrong seed file URLs... Skipping: %s % seed) +self.logger.info(Wrong seed file URLs/seed path... Skipping: %s % seed) except KeyError: pass succeeded = []
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: b7f9364cb0952f2e06f94299400d2f23b629553d Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Thu Jan 8 03:43:10 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Thu Jan 8 03:43:10 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b7f9364c gkeys: Finally fix all the unicode printing errors --- gkeys/gkeys/actions.py | 20 +++- gkeys/gkeys/base.py| 10 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index de72000..eef338e 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -25,6 +25,8 @@ from collections import defaultdict from json import load from shutil import rmtree +from pyGPG.status import _unicode_encode + from gkeys.lib import GkeysGPG from gkeys.seedhandler import SeedHandler from gkeys.gkey import GKEY @@ -240,15 +242,15 @@ class Actions(object): if self.config.options['print_results']: if print_key: print() -print(Nick.:, key.nick) -print(Name.:, key.name) -print(Keydir...:, key.keydir) +print(Nick.:, _unicode_encode(key.nick)) +print(Name.:, _unicode_encode(key.name)) +print(Keydir...:, _unicode_encode(key.keydir)) c = 0 for line in result.split('\n'): if c == 0: -print(Gpg info.:, line) +print(Gpg info.:, _unicode_encode(line)) else: -print( , line) +print( , _unicode_encode(line)) c += 1 self.logger.debug(data output:\n + str(result)) return (True, result) @@ -289,7 +291,7 @@ class Actions(object): str(result.failed)) if self.config.options['print_results']: for result in results[key.name]: -print(key desired:, key.name, , key added:, +print(key desired:, _unicode_encode(key.name), , key added:, result.username, , succeeded:, not result.failed, , fingerprint:, result.fingerprint) self.logger.debug(stderr_out: + str(result.stderr_out)) @@ -380,7 +382,7 @@ class Actions(object): for g in results: pub_pass = {} for key in results[g]: -self.output('', key.pretty_print()) +self.output('', _unicode_encode(key.pretty_print())) if key.key is PUB: pub_pass = { @@ -539,7 +541,7 @@ class Actions(object): results[gkey.name] = self.gpg.add_key(gkey) if self.config.options['print_results']: for result in results[gkey.name]: -print(key desired:, gkey.name, , key added:, +print(key desired:, _unicode_encode(gkey.name), , key added:, result.username, , succeeded:, not result.failed, , fingerprint:, result.fingerprint) self.logger.debug(stderr_out: + str(result.stderr_out)) @@ -547,7 +549,7 @@ class Actions(object): self.logger.debug(ACTIONS: importkey; result.failed = + str(result.failed)) failed.append(gkey) if not results[gkey.name][0].failed: -print(Importing: , gkey.name) +print(Importing: , _unicode_encode(gkey.name)) self.logger.debug(ACTIONS: importkey; importing key: %s, gkey.name) _keyring = os.path.join(catdir, args.keyring + '.gpg') self.gpg.add_to_keyring(gkey, catdir, _keyring) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 46f8f2f..1a80a03 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -17,7 +17,7 @@ from __future__ import print_function import argparse import sys -from pyGPG.status import _unicode_decode +from pyGPG.status import _unicode_encode from gkeys import fileops from gkeys.log import log_levels, set_logger @@ -315,16 +315,16 @@ class CliBase(object): def output_results(results, header=None): # super simple output for the time being if header: -print(_unicode_decode(header)) +print(_unicode_encode(header)) for msg in results: if type(msg) in [str, unicode]: -print(' ', _unicode_decode(msg)) +print(' ', _unicode_encode(msg)) else: try: -print(\n.join([_unicode_decode(x.pretty_print) for x in msg])) +
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/, gkeys-gen/gkeygen/, py2man/
commit: 807bb140b51eb75ac25474ff76577b09be04b1d1 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Thu Jan 8 03:42:26 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Thu Jan 8 03:42:26 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=807bb140 gkeys, gkeys-gen: Add --version option --- gkeys-gen/gkeygen/__init__.py | 2 +- gkeys-gen/gkeygen/cli.py | 2 ++ gkeys/gkeys/__init__.py | 2 +- gkeys/gkeys/base.py | 3 +++ gkeys/gkeys/cli.py| 2 ++ py2man/command.template | 2 +- py2man/options.py | 2 ++ 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gkeys-gen/gkeygen/__init__.py b/gkeys-gen/gkeygen/__init__.py index e990779..ea87b6a 100644 --- a/gkeys-gen/gkeygen/__init__.py +++ b/gkeys-gen/gkeygen/__init__.py @@ -15,7 +15,7 @@ for cmd in Available_Actions: subdata[cmd] = Action_Map[cmd]['desc'] Gkeys_Map = { -'options': ['help', 'config', 'debug'], +'options': ['help', 'config', 'debug', 'version'], 'desc': 'OpenPGP/GPG key generator tool', 'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to manage the GPG keys used for validation on users and Gentoo's infrastracutre servers. diff --git a/gkeys-gen/gkeygen/cli.py b/gkeys-gen/gkeygen/cli.py index 561bf9f..f522814 100644 --- a/gkeys-gen/gkeygen/cli.py +++ b/gkeys-gen/gkeygen/cli.py @@ -7,6 +7,7 @@ from __future__ import print_function import os import sys +from gkeys import __version__ from gkeys.config import GKeysConfig from gkeys.base import CliBase from gkeygen.actions import Actions, Available_Actions, Action_Map @@ -35,6 +36,7 @@ class Main(CliBase): 'description': 'Gentoo Keys GPG key generator program', 'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to your system!''' } +self.version = __version__ def __call__(self, args=None): diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py index 503d359..d148872 100644 --- a/gkeys/gkeys/__init__.py +++ b/gkeys/gkeys/__init__.py @@ -17,7 +17,7 @@ for cmd in Available_Actions: subdata[cmd] = Action_Map[cmd]['desc'] Gkeys_Map = { -'options': ['help', 'config', 'debug'], +'options': ['help', 'config', 'debug', 'version'], 'desc': 'OpenPGP/GPG key management tool', 'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to manage the GPG keys used for validation on users and Gentoo's infrastracutre servers. diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 65ad9cc..46f8f2f 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -44,6 +44,7 @@ class CliBase(object): self.seeds = None self.actions = None self.logger = None +self.version = None @staticmethod @@ -209,6 +210,8 @@ class CliBase(object): parser.add_argument('-D', '--debug', default='DEBUG', choices=list(log_levels), help='The logging level to set for the logfile') +parser.add_argument('-V', '--version', action = 'version', + version = self.version) subparsers = parser.add_subparsers( diff --git a/gkeys/gkeys/cli.py b/gkeys/gkeys/cli.py index 8ec45f9..194afd2 100644 --- a/gkeys/gkeys/cli.py +++ b/gkeys/gkeys/cli.py @@ -16,6 +16,7 @@ from __future__ import print_function import os import sys +from gkeys import __version__ from gkeys.base import CliBase from gkeys.actions import Actions from gkeys.action_map import Available_Actions, Action_Map @@ -44,6 +45,7 @@ class Main(CliBase): 'description': 'Gentoo-keys manager program', 'epilog': '''CAUTION: adding UNTRUSTED keys can be HAZARDOUS to your system!''' } +self.version = __version__ def __call__(self, args=None): diff --git a/py2man/command.template b/py2man/command.template index 975a4bf..7b44506 100644 --- a/py2man/command.template +++ b/py2man/command.template @@ -4,7 +4,7 @@ .SH SYNOPSIS .B %(prog)s -[\fB\-h\fR] [\fB\-c\fR \fICONFIG\fR] [\fB\-D\fR \fI{WARNING,INFO,FATAL,NOTSET,WARN,DEBUG,ERROR,CRITICAL}\fR] [\fBSUBCOMMAND] [\fBSUBCOMMAND-OPTION] ... +[\fB\-h\fR] [\fB\-c\fR \fICONFIG\fR] [\fB\-D\fR \fI{WARNING,INFO,FATAL,NOTSET,WARN,DEBUG,ERROR,CRITICAL}\fR] [\fB\-V\fR][\fBSUBCOMMAND] [\fBSUBCOMMAND-OPTION] ... .SH DESCRIPTION .PP diff --git a/py2man/options.py b/py2man/options.py index 87d19bf..61a6230 100644 --- a/py2man/options.py +++ b/py2man/options.py @@ -64,6 +64,8 @@ The spec file to use from the gkeys-gen.conf file.''', Turn on timestamp use.''', 'uid': '''.IP -u \\fIUID\\fR, --uid \\fIUID The user id(s) (and email) of the key(s) being added (optional)''', +'version': '''.IP -V, --version +The program version''', }) SHORT_OPTS = OrderedDict({
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
commit: d947f8fc4b5d91f1655e1f7770a0f94cbb6a52a9 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jan 7 23:33:54 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Jan 7 23:33:54 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d947f8fc gkeys/base.py: Wrap all output with _unicode_decode() Kristian was still getting py-2.7 errors for some devs due to unicode. --- gkeys/gkeys/base.py | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py index 05946c2..65ad9cc 100644 --- a/gkeys/gkeys/base.py +++ b/gkeys/gkeys/base.py @@ -17,6 +17,7 @@ from __future__ import print_function import argparse import sys +from pyGPG.status import _unicode_decode from gkeys import fileops from gkeys.log import log_levels, set_logger @@ -311,16 +312,16 @@ class CliBase(object): def output_results(results, header=None): # super simple output for the time being if header: -print(header) +print(_unicode_decode(header)) for msg in results: if type(msg) in [str, unicode]: -print(' ', msg) +print(' ', _unicode_decode(msg)) else: try: -print(\n.join([x.pretty_print for x in msg])) +print(\n.join([_unicode_decode(x.pretty_print) for x in msg])) except AttributeError: for x in msg: -print('', x) +print('', _unicode_decode(x)) print()
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/, gkeys-gen/
commit: 512495d435ddd0714d0780faf4c03117dc1ce989 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jan 7 21:01:29 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Jan 7 21:01:29 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=512495d4 gkeys, gkeys-gen: Make sdist do .bz2 compression --- gkeys-gen/setup.py | 12 gkeys/setup.py | 12 2 files changed, 24 insertions(+) diff --git a/gkeys-gen/setup.py b/gkeys-gen/setup.py index 1512219..5fae8f4 100755 --- a/gkeys-gen/setup.py +++ b/gkeys-gen/setup.py @@ -6,6 +6,7 @@ import sys from distutils.core import setup, Command from distutils.command.build import build +from distutils.command.sdist import sdist from glob import glob from gkeygen import __version__, __license__ @@ -62,6 +63,16 @@ class build_man(Command): man.make_subpages(Action_Map, Available_Actions) +class x_sdist(sdist): + sdist defaulting to .tar.bz2 format + +def finalize_options(self): +if self.formats is None: +self.formats = ['bztar'] + +sdist.finalize_options(self) + + setup( name='gkeys-gen', version=__version__, @@ -84,6 +95,7 @@ setup( cmdclass = { 'build': x_build, 'build_man': build_man, +'sdist': x_sdist, }, classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/gkeys/setup.py b/gkeys/setup.py index 5a20738..12a3632 100755 --- a/gkeys/setup.py +++ b/gkeys/setup.py @@ -6,6 +6,7 @@ import sys from distutils.core import setup, Command from distutils.command.build import build +from distutils.command.sdist import sdist from glob import glob from gkeys import __version__, __license__ @@ -62,6 +63,16 @@ class build_man(Command): man.make_subpages(Action_Map, Available_Actions) +class x_sdist(sdist): + sdist defaulting to .tar.bz2 format + +def finalize_options(self): +if self.formats is None: +self.formats = ['bztar'] + +sdist.finalize_options(self) + + setup( name='gkeys', version=__version__, @@ -85,6 +96,7 @@ setup( cmdclass = { 'build': x_build, 'build_man': build_man, +'sdist': x_sdist, }, classifiers=[ 'Development Status :: 3 - Alpha',
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/, gkeys-gen/
commit: 41d9a206204150d6901eb1b74304eac08d1f96d0 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Wed Jan 7 19:39:26 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Wed Jan 7 19:39:26 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=41d9a206 gkeys, gkeys-gen: Include py2man for sdist tarball creation --- gkeys-gen/MANIFEST.in | 1 + gkeys/MANIFEST.in | 1 + 2 files changed, 2 insertions(+) diff --git a/gkeys-gen/MANIFEST.in b/gkeys-gen/MANIFEST.in index c1a7121..c0d51c9 100644 --- a/gkeys-gen/MANIFEST.in +++ b/gkeys-gen/MANIFEST.in @@ -1,2 +1,3 @@ include LICENSE include README.md +include py2man/* diff --git a/gkeys/MANIFEST.in b/gkeys/MANIFEST.in index c1a7121..c0d51c9 100644 --- a/gkeys/MANIFEST.in +++ b/gkeys/MANIFEST.in @@ -1,2 +1,3 @@ include LICENSE include README.md +include py2man/*
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/, gkeys-gen/gkeygen/
commit: 3b8f2bad274be6c6f55a19d715fb87c4ad2898bd Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 6 21:16:29 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Jan 6 21:19:40 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3b8f2bad gkeys, gkeys-gen: set version to 0.1 --- gkeys-gen/gkeygen/__init__.py | 2 +- gkeys/gkeys/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gkeys-gen/gkeygen/__init__.py b/gkeys-gen/gkeygen/__init__.py index 495f798..e990779 100644 --- a/gkeys-gen/gkeygen/__init__.py +++ b/gkeys-gen/gkeygen/__init__.py @@ -6,7 +6,7 @@ from collections import OrderedDict from gkeygen.actions import Action_Map, Available_Actions -__version__ = 'Git' +__version__ = '0.1' __license__ = 'GPLv2' diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py index 7256297..503d359 100644 --- a/gkeys/gkeys/__init__.py +++ b/gkeys/gkeys/__init__.py @@ -8,7 +8,7 @@ from collections import OrderedDict from gkeys.action_map import Action_Map, Available_Actions -__version__ = 'Git' +__version__ = '0.1' __license__ = 'GPLv2'
[gentoo-commits] proj/gentoo-keys:master commit in: gkeys/, gkeys-gen/gkeygen/, gkeys-gen/
commit: 7bfa40a4b350767ec8e8d2812620bb8be6ce48a4 Author: Brian Dolbec dolsen AT gentoo DOT org AuthorDate: Tue Jan 6 20:20:30 2015 + Commit: Brian Dolbec dolsen AT gentoo DOT org CommitDate: Tue Jan 6 21:19:39 2015 + URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7bfa40a4 gkeys-gen: Setup.py updates for man page generation --- gkeys-gen/gkeygen/__init__.py | 20 +++ gkeys-gen/setup.py| 80 --- gkeys/setup.py| 76 ++-- 3 files changed, 168 insertions(+), 8 deletions(-) diff --git a/gkeys-gen/gkeygen/__init__.py b/gkeys-gen/gkeygen/__init__.py index 7e8b64e..495f798 100644 --- a/gkeys-gen/gkeygen/__init__.py +++ b/gkeys-gen/gkeygen/__init__.py @@ -1,5 +1,25 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +from collections import OrderedDict + +from gkeygen.actions import Action_Map, Available_Actions + + __version__ = 'Git' __license__ = 'GPLv2' + + +subdata = OrderedDict() +for cmd in Available_Actions: +subdata[cmd] = Action_Map[cmd]['desc'] + +Gkeys_Map = { +'options': ['help', 'config', 'debug'], +'desc': 'OpenPGP/GPG key generator tool', +'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to manage +the GPG keys used for validation on users and Gentoo's infrastracutre servers. +Gkeys-gen is a tool for generating OpnPGP/GPG keys according to a selected spec.''', +'sub-cmds': subdata, +'authors': ['Brian Dolbec dol...@gentoo.org', 'Pavlos Ratis daster...@gentoo.org'], +} diff --git a/gkeys-gen/setup.py b/gkeys-gen/setup.py index 063bff1..fc93bf0 100755 --- a/gkeys-gen/setup.py +++ b/gkeys-gen/setup.py @@ -1,11 +1,26 @@ #!/usr/bin/env python + +import collections import os import sys -from distutils.core import setup +from distutils.core import setup, Command +from distutils.command.build import build + from gkeygen import __version__, __license__ +from gkeygen import Gkeys_Map +from gkeygen.actions import Action_Map, Available_Actions + +try: +from py2man import manpages +except ImportError: +print('creating py2man symlink') +os.symlink('../py2man', 'py2man') +from py2man import manpages + + # this affects the names of all the directories we do stuff with sys.path.insert(0, './') @@ -18,10 +33,61 @@ except ImportError: EPREFIX='' +class x_build(build): + Build command with extra build_man call. + +def run(self): +build.run(self) +self.run_command('build_man') + + +class build_man(Command): + Perform substitutions in manpages. + +user_options = [ +] + +def initialize_options(self): +self.build_base = None + +def finalize_options(self): +self.set_undefined_options('build', +('build_base', 'build_base')) + +def run(self): +# create the main page +basepath = os.path.dirname(__file__) +docpath = os.path.join(basepath, 'doc') +templatepath = os.path.dirname(manpages.__file__) +man = manpages.ManPage('gkey-gen', __version__, None, +docpath, Gkeys_Map['authors']) +man.read_template(templatepath, 'command.template') +man.make_prog(Gkeys_Map) +man.read_template(templatepath, 'sub-command.template') +man.make_subpages(Action_Map, Available_Actions) + + +def get_manpages(): +linguas = os.environ.get('LINGUAS') +if linguas is not None: +linguas = linguas.split() + +for dirpath, dirnames, filenames in os.walk('doc'): +groups = collections.defaultdict(list) +for f in filenames: +fn, suffix = f.rsplit('.', 1) +groups[suffix].append(os.path.join(dirpath, f)) + +topdir = dirpath[len('doc/'):] +if not topdir or linguas is None or topdir in linguas: +for g, mans in groups.items(): +yield [os.path.join('$mandir', topdir, 'man%s' % g), mans] + + setup( -name='gkeygen', +name='gkeys-gen', version=__version__, -description=Gentoo gpg key management key generator, +description=OpenPGP/GPG key generator, author='', author_email='', maintainer='Gentoo-Keys Team', @@ -30,12 +96,16 @@ setup( download_url='', packages=['gkeygen'], scripts=['bin/gkey-gen'], -data_files=( +data_files=list(get_manpages()) + [ (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys-gen.conf']), -), +], license=__license__, long_description=open('README.md').read(), keywords='gpg', +cmdclass = { +'build': x_build, +'build_man': build_man, +}, classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers, Users', diff --git a/gkeys/setup.py b/gkeys/setup.py index 23af045..d6b38af 100755 --- a/gkeys/setup.py +++ b/gkeys/setup.py @@ -1,11 +1,26 @@