mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
02d9c328af
commit
56515a38d5
1 changed files with 2 additions and 1 deletions
|
@ -1010,7 +1010,8 @@ class AnsibleModule(object):
|
||||||
if self.selinux_enabled():
|
if self.selinux_enabled():
|
||||||
self.set_context_if_different(
|
self.set_context_if_different(
|
||||||
tmp_dest.name, context, False)
|
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.chown(tmp_dest.name, dest_stat.st_uid, dest_stat.st_gid)
|
||||||
os.rename(tmp_dest.name, dest)
|
os.rename(tmp_dest.name, dest)
|
||||||
except (shutil.Error, OSError, IOError), e:
|
except (shutil.Error, OSError, IOError), e:
|
||||||
|
|
Loading…
Reference in a new issue