mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 15:11:23 -07:00
Apply Gilles's patch to atomic_move based on github comment. (Email address not supplied
since wasn't from a pull request)
This commit is contained in:
parent
bdeb370d79
commit
68f7ea6099
1 changed files with 3 additions and 2 deletions
|
@ -812,9 +812,9 @@ class AnsibleModule(object):
|
||||||
rc = False
|
rc = False
|
||||||
context = None
|
context = None
|
||||||
if os.path.exists(dest):
|
if os.path.exists(dest):
|
||||||
st = os.stat(dest)
|
|
||||||
os.chmod(src, st.st_mode & 07777)
|
|
||||||
try:
|
try:
|
||||||
|
st = os.stat(dest)
|
||||||
|
os.chmod(src, st.st_mode & 07777)
|
||||||
os.chown(src, st.st_uid, st.st_gid)
|
os.chown(src, st.st_uid, st.st_gid)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
if e.errno != errno.EPERM:
|
if e.errno != errno.EPERM:
|
||||||
|
@ -838,6 +838,7 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
try: # leaves tmp file behind when sudo and not root
|
try: # leaves tmp file behind when sudo and not root
|
||||||
if os.getenv("SUDO_USER") and os.getuid() != 0:
|
if os.getenv("SUDO_USER") and os.getuid() != 0:
|
||||||
|
# cleanup will happen by 'rm' of tempdir
|
||||||
shutil.copy(src, tmp_dest)
|
shutil.copy(src, tmp_dest)
|
||||||
else:
|
else:
|
||||||
shutil.move(src, tmp_dest)
|
shutil.move(src, tmp_dest)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue