summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-05-14 09:59:12 -0500
committerJames Cammarata <jimi@sngx.net>2014-05-21 14:55:39 -0500
commitd8526a6c80ed63f1ee6c0bbba1ffaf303e4e1dff (patch)
tree7323a9ff01509c5fd23ba2f9cc1102cab446b52d
parente0fe6ca5d84719644d33719cfab3cc6adae50a9d (diff)
downloadansible-d8526a6c80ed63f1ee6c0bbba1ffaf303e4e1dff.tar.gz
Only chown on atomic move if the uid/gid don't match the src/tmp file
This is a corner case for remote file systems that don't support chown() and where the source and destination for the atomic_move are on that remote file system. Fixes #7372
-rw-r--r--lib/ansible/module_utils/basic.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index c0b00d3865..681a973801 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -1010,7 +1010,8 @@ class AnsibleModule(object):
if self.selinux_enabled():
self.set_context_if_different(
tmp_dest.name, context, False)
- if dest_stat:
+ tmp_stat = os.stat(tmp_dest.name)
+ if dest_stat and (tmp_stat.st_uid != dest_stat.st_uid or tmp_stat.st_gid != dest_stat.st_gid):
os.chown(tmp_dest.name, dest_stat.st_uid, dest_stat.st_gid)
os.rename(tmp_dest.name, dest)
except (shutil.Error, OSError, IOError), e: