summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2017-03-08 10:28:23 -0500
committerBrian Coca <brian.coca+git@gmail.com>2017-03-08 10:28:23 -0500
commitac4ce958106b6a01bb4e452689a31a9903f211d8 (patch)
treec74c7f7a1ffa1e72eb115e9aaf9cf093627c2d63
parentdae298e429ac49264e865a2dc99572c33d40ee5f (diff)
downloadansible-ac4ce958106b6a01bb4e452689a31a9903f211d8.tar.gz
backport of file cache perms fix
see #13093
-rw-r--r--lib/ansible/plugins/cache/jsonfile.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py
index e1669068fc..5af9046355 100644
--- a/lib/ansible/plugins/cache/jsonfile.py
+++ b/lib/ansible/plugins/cache/jsonfile.py
@@ -63,8 +63,11 @@ class CacheModule(BaseCacheModule):
try:
os.makedirs(self._cache_dir)
except (OSError,IOError) as e:
- display.warning("error in 'jsonfile' cache plugin while trying to create cache dir %s : %s" % (self._cache_dir, to_bytes(e)))
- return None
+ raise AnsibleError("error in 'jsonfile' cache plugin while trying to create cache dir %s : %s" % (self._cache_dir, to_bytes(e)))
+ 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):
""" This checks the in memory cache first as the fact was not expired at 'gather time'
@@ -124,7 +127,7 @@ class CacheModule(BaseCacheModule):
return False
else:
display.warning("error in 'jsonfile' cache plugin while trying to stat %s : %s" % (cachefile, to_bytes(e)))
- pass
+ return False
if time.time() - st.st_mtime <= self._timeout:
return False