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

Namespace the passwordstore lockfile (#8689)

* Namespace the lockfile

When passwordstore needs to grab a lock, it creates a statically file (within /tmp, typically). This is unfortunate, when there might be more than one user using the passwordstore functionality on that machine. Prepend the user to the filename, to bypass further issues.

* Update plugins/lookup/passwordstore.py

specifically reference the argument number in the format string.

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

* Add changelog fragment for PR#8689

* Update 8689-passwordstore-lock-naming.yml

I was sure that was a copy/paste.

* Update changelogs/fragments/8689-passwordstore-lock-naming.yml

specify the type of plugin

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

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Adam Tygart 2024-08-12 00:33:07 -05:00 committed by GitHub
parent 57e28e5a73
commit 8989b6c4d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- passwordstore lookup plugin - add the current user to the lockfile file name to address issues on multi-user systems (https://github.com/ansible-collections/community.general/pull/8689).

View file

@ -469,7 +469,8 @@ class LookupModule(LookupBase):
def opt_lock(self, type): def opt_lock(self, type):
if self.get_option('lock') == type: if self.get_option('lock') == type:
tmpdir = os.environ.get('TMPDIR', '/tmp') tmpdir = os.environ.get('TMPDIR', '/tmp')
lockfile = os.path.join(tmpdir, '.passwordstore.lock') user = os.environ.get('USER')
lockfile = os.path.join(tmpdir, '.{0}.passwordstore.lock'.format(user))
with FileLock().lock_file(lockfile, tmpdir, self.lock_timeout): with FileLock().lock_file(lockfile, tmpdir, self.lock_timeout):
self.locked = type self.locked = type
yield yield