mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixed case in which move fails after remote user copies file and sudo to non root does the move
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
This commit is contained in:
parent
c3547a2308
commit
bdeb370d79
1 changed files with 5 additions and 2 deletions
|
@ -836,8 +836,11 @@ class AnsibleModule(object):
|
|||
except OSError, e:
|
||||
sys.stderr.write("could not cleanup %s: %s" % (tmp_dest, e))
|
||||
|
||||
try:
|
||||
shutil.move(src, tmp_dest)
|
||||
try: # leaves tmp file behind when sudo and not root
|
||||
if os.getenv("SUDO_USER") and os.getuid() != 0:
|
||||
shutil.copy(src, tmp_dest)
|
||||
else:
|
||||
shutil.move(src, tmp_dest)
|
||||
if self.selinux_enabled():
|
||||
self.set_context_if_different(tmp_dest, context, False)
|
||||
os.rename(tmp_dest, dest)
|
||||
|
|
Loading…
Reference in a new issue