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

Fix keyring_info when using keyring library #4964

Merged
merged 4 commits into from Jul 24, 2022

Conversation

sargunv
Copy link
Contributor

@sargunv sargunv commented Jul 21, 2022

SUMMARY

The docs say this module works with the keyring library, but actually this line was clobbering any passphrase retrieved from that library, making it useless on any system without the alternate method (gnome-keyring).

After this change, it'll only use the alternate method if the first one didn't work, so the return value from the first one will actually get passed through.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

keyring_info

ADDITIONAL INFORMATION

Reproduction:

# tested on macOS

- name: Save a password to the keychain
  community.general.keyring:
    service: example-service
    username: example-user
    password: example-password
    keyring_password: ""

- name: Read it back from the keychain
  community.general.keyring_info:
    service: example-service
    username: example-user
    keyring_password: ""
  register: example_result

- debug:
    msg: "{{ example_result }}"

before the change

ok: [localhost] => 
    msg:
        changed: false
        failed: false
        msg: Password for example-service@example-user does not exist.

after the change

ok: [localhost] => 
    msg:
        changed: false
        failed: false
        msg: Successfully retrieved password for example-service@example-user
        passphrase: example-password

This line used to always clobber the passphrase retrieved via the `keyring` library, making it useless on everything except gnome-keyring. After this change, it'll only use the alternate method if the default one didn't work.
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review system labels Jul 21, 2022
@ahussey-redhat
Copy link
Contributor

Hi @sargunv , thanks for identifying this issue and raising a PR.

Your fix resolves the bug.
I confirmed against the keyring module, and this bug is only located in this keyring_info module.

@ahussey-redhat
Copy link
Contributor

@felixfontein , could you please review this PR?

Copy link
Contributor

@ahussey-redhat ahussey-redhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per my comment

Hi @sargunv , thanks for identifying this issue and raising a PR.

Your fix resolves the bug.
I confirmed against the keyring module, and this bug is only located in this keyring_info module.

This PR is approved from my perspective.

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-5 labels Jul 21, 2022
@felixfontein
Copy link
Collaborator

@sargunv thanks for your contribution! Could you please add a changelog fragment? Thanks.

@sargunv
Copy link
Contributor Author

sargunv commented Jul 21, 2022

added!

@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed small_patch Hopefully easy to review labels Jul 21, 2022
@github-actions
Copy link

github-actions bot commented Jul 21, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Jul 21, 2022
Co-authored-by: Felix Fontein <felix@fontein.de>
@ansibullbot ansibullbot removed the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI label Jul 24, 2022
@felixfontein felixfontein merged commit e242670 into ansible-collections:main Jul 24, 2022
@patchback
Copy link

patchback bot commented Jul 24, 2022

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/e2426707e2c38b5c106f000d66bc76a46ab5cd03/pr-4964

Backported as #4991

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jul 24, 2022
patchback bot pushed a commit that referenced this pull request Jul 24, 2022
* Fix keyring_info when using keyring library

This line used to always clobber the passphrase retrieved via the `keyring` library, making it useless on everything except gnome-keyring. After this change, it'll only use the alternate method if the default one didn't work.

* delete whitespace

* add changelog fragment

* Update changelogs/fragments/4964-fix-keyring-info.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e242670)
This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants