mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00: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:
@@ -836,8 +836,11 @@ class AnsibleModule(object):
|
|||||||
except OSError, e:
|
except OSError, e:
|
||||||
sys.stderr.write("could not cleanup %s: %s" % (tmp_dest, e))
|
sys.stderr.write("could not cleanup %s: %s" % (tmp_dest, e))
|
||||||
|
|
||||||
try:
|
try: # leaves tmp file behind when sudo and not root
|
||||||
shutil.move(src, tmp_dest)
|
if os.getenv("SUDO_USER") and os.getuid() != 0:
|
||||||
|
shutil.copy(src, tmp_dest)
|
||||||
|
else:
|
||||||
|
shutil.move(src, tmp_dest)
|
||||||
if self.selinux_enabled():
|
if self.selinux_enabled():
|
||||||
self.set_context_if_different(tmp_dest, context, False)
|
self.set_context_if_different(tmp_dest, context, False)
|
||||||
os.rename(tmp_dest, dest)
|
os.rename(tmp_dest, dest)
|
||||||
|
|||||||
Reference in New Issue
Block a user