1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix sudo_user copy regression

Treat errno 13 (permission denied) as one of the special cases in
atomic_move.

This type of error can occur because of sudo'ing to non-root user.

Fixes #3705
This commit is contained in:
Lorin Hochstein 2013-07-30 16:14:25 -04:00
parent 8cc13590b4
commit a303fca193

View file

@ -867,8 +867,8 @@ class AnsibleModule(object):
# Optimistically try a rename, solves some corner cases and can avoid useless work. # Optimistically try a rename, solves some corner cases and can avoid useless work.
os.rename(src, dest) os.rename(src, dest)
except (IOError,OSError), e: except (IOError,OSError), e:
# only try workarounds for errno 18 (cross device) and 1 (not permited) # only try workarounds for errno 18 (cross device), 1 (not permited) and 13 (permission denied)
if e.errno != errno.EPERM and e.errno != errno.EXDEV: if e.errno != errno.EPERM and e.errno != errno.EXDEV and e.errno != errno.EACCES:
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e)) self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e))
dest_dir = os.path.dirname(dest) dest_dir = os.path.dirname(dest)