From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 43CF7138A1A for ; Wed, 11 Feb 2015 17:38:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F3A21E0936; Wed, 11 Feb 2015 17:37:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 29D9FE0937 for ; Wed, 11 Feb 2015 17:37:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 51FAD340813 for ; Wed, 11 Feb 2015 17:37:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9442E118AE for ; Wed, 11 Feb 2015 17:37:50 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1422679229.9ecc173ca9dfa1b22af86ba9412c6f6777cbb54b.dolsen@gentoo> Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/ X-VCS-Repository: proj/gentoo-keys X-VCS-Files: gkeys/gkeys/actions.py gkeys/gkeys/lib.py X-VCS-Directories: gkeys/gkeys/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 9ecc173ca9dfa1b22af86ba9412c6f6777cbb54b X-VCS-Branch: master Date: Wed, 11 Feb 2015 17:37:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d4ed4969-787a-4f81-95b5-512e06ce0925 X-Archives-Hash: 27f02740099e65f861f9dbc7c942006e commit: 9ecc173ca9dfa1b22af86ba9412c6f6777cbb54b Author: Brian Dolbec gentoo org> AuthorDate: Wed Jan 28 21:30:04 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Jan 31 04:40:29 2015 +0000 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 = 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) + else: + sig_path = None + 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 = 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) return (verified, messages) diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py index 4ae534d..9687c24 100644 --- a/gkeys/gkeys/lib.py +++ b/gkeys/gkeys/lib.py @@ -311,7 +311,7 @@ class GkeysGPG(GPG): results = self.runGPG(task='verify', inputfile=[signature,filepath]) else: self.set_keydir(gkey.keydir, 'decrypt', reset=True) - self.logger.debug("** Calling runGPG with Running 'gpg %s --decrypt %s and %s'" + 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]