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>
pull/2838/head
Brian Coca 12 years ago
parent c3547a2308
commit bdeb370d79

@ -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…
Cancel
Save