Skip to content

Commit

Permalink
bugfix - Prevent passwordstore lookup to create subkey when create ==…
Browse files Browse the repository at this point in the history
… false

Fixes#9105
  • Loading branch information
mluzarreta committed Feb 4, 2025
1 parent e13d6de commit 1165453
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- passwordstore lookup plugin - Fix subkey creation even when `create == false` (https://github.com/ansible-collections/community.general/pull/9106).
5 changes: 1 addition & 4 deletions plugins/lookup/passwordstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,7 @@ def run(self, terms, variables, **kwargs):
self.parse_params(term) # parse the input into paramvals
with self.opt_lock('readwrite'):
if self.check_pass(): # password exists
if self.paramvals['overwrite']:
with self.opt_lock('write'):
result.append(self.update_password())
elif self.paramvals["subkey"] != "password" and not self.passdict.get(self.paramvals['subkey']): # password exists but not the subkey
if self.paramvals['overwrite'] or (self.paramvals["subkey"] == "password" and not self.passdict.get(self.paramvals['subkey'])): # if "overwrite", always update password, otherwise update password when it exists but not the subkey
with self.opt_lock('write'):
result.append(self.update_password())
else:
Expand Down

0 comments on commit 1165453

Please sign in to comment.