mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2817 from sfromm/issue2810
Set selinux context on file after shutil.move in atomic_move()
This commit is contained in:
commit
4ecc7ea2e0
1 changed files with 2 additions and 2 deletions
|
@ -820,11 +820,9 @@ class AnsibleModule(object):
|
||||||
raise
|
raise
|
||||||
if self.selinux_enabled():
|
if self.selinux_enabled():
|
||||||
context = self.selinux_context(dest)
|
context = self.selinux_context(dest)
|
||||||
self.set_context_if_different(src, context, False)
|
|
||||||
else:
|
else:
|
||||||
if self.selinux_enabled():
|
if self.selinux_enabled():
|
||||||
context = self.selinux_default_context(dest)
|
context = self.selinux_default_context(dest)
|
||||||
self.set_context_if_different(src, context, False)
|
|
||||||
# Ensure file is on same partition to make replacement atomic
|
# Ensure file is on same partition to make replacement atomic
|
||||||
dest_dir = os.path.dirname(dest)
|
dest_dir = os.path.dirname(dest)
|
||||||
dest_file = os.path.basename(dest)
|
dest_file = os.path.basename(dest)
|
||||||
|
@ -839,6 +837,8 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.move(src, tmp_dest)
|
shutil.move(src, tmp_dest)
|
||||||
|
if self.selinux_enabled():
|
||||||
|
self.set_context_if_different(tmp_dest, context, False)
|
||||||
os.rename(tmp_dest, dest)
|
os.rename(tmp_dest, dest)
|
||||||
rc = True
|
rc = True
|
||||||
except (shutil.Error, OSError, IOError), e:
|
except (shutil.Error, OSError, IOError), e:
|
||||||
|
|
Loading…
Reference in a new issue