salt.states.file.copy now copies file user/group ownership and permissions from source

This commit is contained in:
Nitin Madhok 2014-09-24 16:51:45 -04:00
parent 3ce955c774
commit 03e3da4181

View File

@ -3524,12 +3524,15 @@ def copy(name, source, force=False, makedirs=False):
# All tests pass, move the file into place
try:
shutil.copy(source, name)
source_user = __salt__['file.get_user'](source)
source_group = __salt__['file.get_group'](source)
source_mode = __salt__['file.get_mode'](source)
__salt__['file.check_perms'](name, ret, source_user, source_group, source_mode)
ret['comment'] = 'Copied "{0}" to "{1}"'.format(source, name)
ret['changes'] = {name: source}
except (IOError, OSError):
return _error(
ret, 'Failed to copy "{0}" to "{1}"'.format(source, name))
ret['comment'] = 'Copied "{0}" to "{1}"'.format(source, name)
ret['changes'] = {name: source}
return ret