Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

salt.modules.gpg: allow getting keys by short key ID #37087

Merged
merged 1 commit into from
Oct 20, 2016
Merged

salt.modules.gpg: allow getting keys by short key ID #37087

merged 1 commit into from
Oct 20, 2016

Conversation

vutny
Copy link
Contributor

@vutny vutny commented Oct 19, 2016

What does this PR do?

It restores the ability of the gpg exec module to handle short GnuPG key IDs (last 8 chars of the fingerprint) in such functions as get_key, get_secret_key, delete_key and trust_key. Also, fixed some docstrings.

What issues does this PR fix or reference?

Modern versions of python-gnupg module always return long key ID (16 chars) as a result of calling list_keys() method. But the documentation for the Salt gpg module clearly says that you're able to use short key IDs in the example sections. This PR allows to use both short and long key ID as an argument for the functions mentioned above.

Previous Behavior

I've imported public key into my keyring.

# salt-call gpg.list_keys
local:
    |_
      ----------
      created:
          2011-10-13
      expires:
          2019-07-02
      fingerprint:
          B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
      keyLength:
          4096
      keyid:
          7FCC7D46ACCC4CF8
      ownerTrust:
          Unknown
      trust:
          Unknown
      uids:
          - PostgreSQL Debian Repository

But, unfortunately, I can't get information about it directly.

# salt-call gpg.get_key ACCC4CF8
local:
    False

New Behavior

Now gpg module supports short key IDs as well:

# salt-call gpg.get_key ACCC4CF8
local:
    ----------
    created:
        2011-10-13
    expires:
        2019-07-02
    fingerprint:
        B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
    keyLength:
        4096
    keyid:
        7FCC7D46ACCC4CF8
    ownerTrust:
        Unknown
    trust:
        Unknown
    uids:
        - PostgreSQL Debian Repository

Tests written?

No

@cachedout cachedout merged commit 38fdd28 into saltstack:2015.8 Oct 20, 2016
@cachedout
Copy link
Contributor

Thank you, @vutny

@vutny vutny deleted the gpg-fix-short-keyid branch October 20, 2016 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants