From 3221b25393bc4d6381f4337b3fd3bb126a95faa9 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 25 Jan 2021 12:59:22 +0100 Subject: [PATCH] fix passwordstore.py to be compatible with gopass. (#1589) (#1674) * fix passwordstore.py to be compatible with gopass. ...even when used with create=true. The same output snippet matches for both, `pass` and `gopass`, but while `pass` returns `1` on a non-existant password, `gopass` returns `10`, or `11`, depending on whether a similar named password was stored. So I'd propose to change `e.returncode == 1` to `e.returncode != 0` to cover both cases here. What do you think? * Update passwordstore.py, fix typo * Add changelog fragment. * Update changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml Co-authored-by: Felix Fontein * Update changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit 73b3ec09e5b4c6c55c9de950dac897c2deecc045) Co-authored-by: Paul Haerle --- ...re-fix-passwordstore.py-to-be-compatible-with-gopass.yaml | 5 +++++ plugins/lookup/passwordstore.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml diff --git a/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml b/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml new file mode 100644 index 0000000000..8a781f4a90 --- /dev/null +++ b/changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml @@ -0,0 +1,5 @@ +bugfixes: + - passwordstore lookup plugin - fix compatibility with gopass when used with + ``create=true``. While pass returns 1 on a non-existent password, gopass + returns 10, or 11, depending on whether a similar named password was stored. + We now just check standard output and that the return code is not zero (https://github.com/ansible-collections/community.general/pull/1589). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index e3d486886c..4d0f646125 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -214,7 +214,7 @@ class LookupModule(LookupBase): name, value = line.split(':', 1) self.passdict[name.strip()] = value.strip() except (subprocess.CalledProcessError) as e: - if e.returncode == 1 and 'not in the password store' in e.output: + if e.returncode != 0 and 'not in the password store' in e.output: # if pass returns 1 and return string contains 'is not in the password store.' # We need to determine if this is valid or Error. if not self.paramvals['create']: