|
|
@ -2007,8 +2007,22 @@ class AnsibleModule(object):
|
|
|
|
if os.path.exists(b_dest):
|
|
|
|
if os.path.exists(b_dest):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
dest_stat = os.stat(b_dest)
|
|
|
|
dest_stat = os.stat(b_dest)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# copy mode and ownership
|
|
|
|
os.chmod(b_src, dest_stat.st_mode & PERM_BITS)
|
|
|
|
os.chmod(b_src, dest_stat.st_mode & PERM_BITS)
|
|
|
|
os.chown(b_src, dest_stat.st_uid, dest_stat.st_gid)
|
|
|
|
os.chown(b_src, dest_stat.st_uid, dest_stat.st_gid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# try to copy flags if possible
|
|
|
|
|
|
|
|
if hasattr(os, 'chflags') and hasattr(dest_stat, 'st_flags'):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
os.chflags(b_src, dest_stat.st_flags)
|
|
|
|
|
|
|
|
except OSError:
|
|
|
|
|
|
|
|
e = get_exception()
|
|
|
|
|
|
|
|
for err in 'EOPNOTSUPP', 'ENOTSUP':
|
|
|
|
|
|
|
|
if hasattr(errno, err) and e.errno == getattr(errno, err):
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise
|
|
|
|
except OSError:
|
|
|
|
except OSError:
|
|
|
|
e = get_exception()
|
|
|
|
e = get_exception()
|
|
|
|
if e.errno != errno.EPERM:
|
|
|
|
if e.errno != errno.EPERM:
|
|
|
|