Accounting for when permissions are not returned from file.check_perms, eg. windows systems.

This commit is contained in:
Gareth J. Greenaway 2019-01-08 17:35:30 -08:00 committed by Ch3LL
parent 53ba0689a8
commit a155fd7650
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73

View File

@ -2503,6 +2503,7 @@ def managed(name,
ret, 'Defaults must be formed as a dict')
if not replace and os.path.exists(name):
ret_perms = {}
# Check and set the permissions if necessary
if salt.utils.platform.is_windows():
ret = __salt__['file.check_perms'](
@ -2514,17 +2515,17 @@ def managed(name,
inheritance=win_inheritance,
reset=win_perms_reset)
else:
ret, perms = __salt__['file.check_perms'](
ret, ret_perms = __salt__['file.check_perms'](
name, ret, user, group, mode, attrs, follow_symlinks)
if __opts__['test']:
if isinstance(perms, dict) and \
'lmode' in perms and \
mode != perms['lmode']:
if isinstance(ret_perms, dict) and \
'lmode' in ret_perms and \
mode != ret_perms['lmode']:
ret['comment'] = ('File {0} will be updated with permissions '
'{1} from its current '
'state of {2}'.format(name,
mode,
perms['lmode']))
ret_perms['lmode']))
else:
ret['comment'] = 'File {0} not updated'.format(name)
elif not ret['changes'] and ret['result']: