1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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 <felix@fontein.de>

* Update changelogs/fragments/1589-passwordstore-fix-passwordstore.py-to-be-compatible-with-gopass.yaml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 73b3ec09e5)

Co-authored-by: Paul Haerle <hello@phaer.org>
This commit is contained in:
patchback[bot] 2021-01-25 12:59:22 +01:00 committed by GitHub
parent cc3fefd325
commit 3221b25393
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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).

View file

@ -214,7 +214,7 @@ class LookupModule(LookupBase):
name, value = line.split(':', 1) name, value = line.split(':', 1)
self.passdict[name.strip()] = value.strip() self.passdict[name.strip()] = value.strip()
except (subprocess.CalledProcessError) as e: 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.' # if pass returns 1 and return string contains 'is not in the password store.'
# We need to determine if this is valid or Error. # We need to determine if this is valid or Error.
if not self.paramvals['create']: if not self.paramvals['create']: