Commit bdeb370d by Brian Coca

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>
parent c3547a23
...@@ -836,7 +836,10 @@ class AnsibleModule(object): ...@@ -836,7 +836,10 @@ 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
if os.getenv("SUDO_USER") and os.getuid() != 0:
shutil.copy(src, tmp_dest)
else:
shutil.move(src, tmp_dest) 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment