mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #8689/8989b6c4 backport][stable-9] Namespace the passwordstore lockfile (#8746)
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>
(cherry picked from commit 8989b6c4d4
)
Co-authored-by: Adam Tygart <adam.tygart@gmail.com>
This commit is contained in:
parent
b1b6134f69
commit
176f6a62ae
2 changed files with 4 additions and 1 deletions
2
changelogs/fragments/8689-passwordstore-lock-naming.yml
Normal file
2
changelogs/fragments/8689-passwordstore-lock-naming.yml
Normal 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).
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue