Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
systemsmanagement:saltstack:products:testing
py26-compat-salt
fix-wrong-recurse-behavior-on-for-linux_acl.pre...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-wrong-recurse-behavior-on-for-linux_acl.present-.patch of Package py26-compat-salt
From a1493031249f3db849933306d1dbbc2696cde4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= <psuarezhernandez@suse.com> Date: Thu, 6 Sep 2018 11:17:45 +0100 Subject: [PATCH] Fix wrong recurse behavior on for linux_acl.present state Fix typo on variable name Add unit tests to cover recursive cases of linux_acl states Fix recursive cases on linux_acl.absent state --- salt/states/linux_acl.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/salt/states/linux_acl.py b/salt/states/linux_acl.py index a6a54a7fcd..202a67c51f 100644 --- a/salt/states/linux_acl.py +++ b/salt/states/linux_acl.py @@ -66,7 +66,7 @@ def present(name, acl_type, acl_name='', perms='', recurse=False): ret['result'] = False return ret - __current_perms = __salt__['acl.getfacl'](name) + __current_perms = __salt__['acl.getfacl'](name, recursive=recurse) if acl_type.startswith(('d:', 'default:')): _acl_type = ':'.join(acl_type.split(':')[1:]) @@ -96,7 +96,18 @@ def present(name, acl_type, acl_name='', perms='', recurse=False): user = None if user: - if user[_search_name]['octal'] == sum([_octal.get(i, i) for i in perms]): + octal_sum = sum([_octal.get(i, i) for i in perms]) + need_refresh = False + for path in __current_perms: + acl_found = False + for user_acl in __current_perms[path].get(_acl_type, []): + if _search_name in user_acl and user_acl[_search_name]['octal'] == octal_sum: + acl_found = True + break + if not acl_found: + need_refresh = True + break + if not need_refresh: ret['comment'] = 'Permissions are in the desired state' else: ret['comment'] = 'Permissions have been updated' @@ -135,7 +146,7 @@ def absent(name, acl_type, acl_name='', perms='', recurse=False): ret['result'] = False return ret - __current_perms = __salt__['acl.getfacl'](name) + __current_perms = __salt__['acl.getfacl'](name, recursive=recurse) if acl_type.startswith(('d:', 'default:')): _acl_type = ':'.join(acl_type.split(':')[1:]) @@ -164,7 +175,18 @@ def absent(name, acl_type, acl_name='', perms='', recurse=False): except (AttributeError, IndexError, StopIteration, KeyError): user = None - if user: + need_refresh = False + for path in __current_perms: + acl_found = False + for user_acl in __current_perms[path].get(_acl_type, []): + if _search_name in user_acl: + acl_found = True + break + if acl_found: + need_refresh = True + break + + if user or need_refresh: ret['comment'] = 'Removing permissions' if __opts__['test']: -- 2.17.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor