mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes cache file modules with bad path permissions
now module will fail to load and report an error (turned into warning as this should not be fatal) fixes #13093
This commit is contained in:
parent
770ab76ed0
commit
406505bfe5
1 changed files with 6 additions and 3 deletions
9
lib/ansible/plugins/cache/base.py
vendored
9
lib/ansible/plugins/cache/base.py
vendored
|
@ -91,8 +91,11 @@ class BaseFileCacheModule(BaseCacheModule):
|
||||||
try:
|
try:
|
||||||
os.makedirs(self._cache_dir)
|
os.makedirs(self._cache_dir)
|
||||||
except (OSError,IOError) as e:
|
except (OSError,IOError) as e:
|
||||||
display.warning("error in '%s' cache plugin while trying to create cache dir %s : %s" % (self.plugin_name, self._cache_dir, to_bytes(e)))
|
raise AnsibleError("error in '%s' cache plugin while trying to create cache dir %s : %s" % (self.plugin_name, self._cache_dir, to_bytes(e)))
|
||||||
return None
|
else:
|
||||||
|
for x in (os.R_OK, os.W_OK, os.X_OK):
|
||||||
|
if not os.access(self._cache_dir, x):
|
||||||
|
raise AnsibleError("error in '%s' cache, configured path (%s) does not have necessary permissions (rwx), disabling plugin" % (self.plugin_name, self._cache_dir))
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
""" This checks the in memory cache first as the fact was not expired at 'gather time'
|
""" This checks the in memory cache first as the fact was not expired at 'gather time'
|
||||||
|
@ -146,7 +149,7 @@ class BaseFileCacheModule(BaseCacheModule):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
display.warning("error in '%s' cache plugin while trying to stat %s : %s" % (self.plugin_name, cachefile, to_bytes(e)))
|
display.warning("error in '%s' cache plugin while trying to stat %s : %s" % (self.plugin_name, cachefile, to_bytes(e)))
|
||||||
pass
|
return False
|
||||||
|
|
||||||
if time.time() - st.st_mtime <= self._timeout:
|
if time.time() - st.st_mtime <= self._timeout:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue