~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: John Arbash Meinel
  • Date: 2013-06-24 12:03:12 UTC
  • mfrom: (6437.77.2 2.5)
  • mto: This revision was merged to the branch mainline in revision 6579.
  • Revision ID: john@arbash-meinel.com-20130624120312-pmvck24x052csigx
Merge lp:bzr/2.5 r6515 to get the fix for bug #855155 (Dirstate.update_basis_by_delta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2009, 2011, 2012, 2013, 2016 Canonical Ltd
 
1
# Copyright (C) 2005, 2011 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
322
322
                return SIGNATURE_NOT_VALID, None
323
323
        # A signature from a revoked key gets this.
324
324
        # test_verify_revoked_signature()
325
 
        if ((result[0].summary & gpgme.SIGSUM_SYS_ERROR
326
 
             or result[0].status.strerror == 'Certificate revoked')):
 
325
        if result[0].summary & gpgme.SIGSUM_SYS_ERROR:
327
326
            return SIGNATURE_NOT_VALID, None
328
327
        # Other error types such as revoked keys should (I think) be caught by
329
328
        # SIGSUM_RED so anything else means something is buggy.
330
 
        raise errors.SignatureVerificationFailed(
331
 
            "Unknown GnuPG key verification result")
 
329
        raise errors.SignatureVerificationFailed("Unknown GnuPG key "\
 
330
                                                 "verification result")
332
331
 
333
332
    def set_acceptable_keys(self, command_line_input):
334
333
        """Set the acceptable keys for verifying with this GPGStrategy.
337
336
                                command line
338
337
        :return: nothing
339
338
        """
340
 
        patterns = None
 
339
        key_patterns = None
341
340
        acceptable_keys_config = self._config_stack.get('acceptable_keys')
 
341
        try:
 
342
            if isinstance(acceptable_keys_config, unicode):
 
343
                acceptable_keys_config = str(acceptable_keys_config)
 
344
        except UnicodeEncodeError:
 
345
            # gpg Context.keylist(pattern) does not like unicode
 
346
            raise errors.BzrCommandError(
 
347
                gettext('Only ASCII permitted in option names'))
 
348
 
342
349
        if acceptable_keys_config is not None:
343
 
            patterns = acceptable_keys_config
 
350
            key_patterns = acceptable_keys_config
344
351
        if command_line_input is not None: # command line overrides config
345
 
            patterns = command_line_input.split(',')
 
352
            key_patterns = command_line_input
 
353
        if key_patterns is not None:
 
354
            patterns = key_patterns.split(",")
346
355
 
347
 
        if patterns:
348
356
            self.acceptable_keys = []
349
357
            for pattern in patterns:
350
358
                result = self.context.keylist(pattern)