acl: fix module failure if there're spaces in a path (#63280)
* Make acl module to work with whitespaces in path * Added a changelog fragment * Add quotes to changelog fragment
This commit is contained in:
parent
29939383e6
commit
504d76e956
4 changed files with 16 additions and 14 deletions
2
changelogs/fragments/63280-fix_acl_spaces_in_path.yml
Normal file
2
changelogs/fragments/63280-fix_acl_spaces_in_path.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "acl - fixed module failure if there are spaces in a path"
|
|
@ -190,10 +190,10 @@ def build_command(module, mode, path, follow, default, recursive, recalculate_ma
|
||||||
'''Builds and returns a getfacl/setfacl command.'''
|
'''Builds and returns a getfacl/setfacl command.'''
|
||||||
if mode == 'set':
|
if mode == 'set':
|
||||||
cmd = [module.get_bin_path('setfacl', True)]
|
cmd = [module.get_bin_path('setfacl', True)]
|
||||||
cmd.append('-m "%s"' % entry)
|
cmd.extend(['-m', entry])
|
||||||
elif mode == 'rm':
|
elif mode == 'rm':
|
||||||
cmd = [module.get_bin_path('setfacl', True)]
|
cmd = [module.get_bin_path('setfacl', True)]
|
||||||
cmd.append('-x "%s"' % entry)
|
cmd.extend(['-x', entry])
|
||||||
else: # mode == 'get'
|
else: # mode == 'get'
|
||||||
cmd = [module.get_bin_path('getfacl', True)]
|
cmd = [module.get_bin_path('getfacl', True)]
|
||||||
# prevents absolute path warnings and removes headers
|
# prevents absolute path warnings and removes headers
|
||||||
|
@ -241,7 +241,7 @@ def acl_changed(module, cmd):
|
||||||
def run_acl(module, cmd, check_rc=True):
|
def run_acl(module, cmd, check_rc=True):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(rc, out, err) = module.run_command(' '.join(cmd), check_rc=check_rc)
|
(rc, out, err) = module.run_command(cmd, check_rc=check_rc)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
module.fail_json(msg=to_native(e))
|
module.fail_json(msg=to_native(e))
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_file }}"
|
shell: "getfacl {{ test_file | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_file }}"
|
shell: "getfacl {{ test_file | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_file }}"
|
shell: "getfacl {{ test_file | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_dir }}"
|
shell: "getfacl {{ test_dir | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
shell: "setfacl -b {{ test_dir }}"
|
shell: "setfacl -b {{ test_dir | quote }}"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Same as previous but using entry shorthand
|
- name: Same as previous but using entry shorthand
|
||||||
acl:
|
acl:
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_dir }}"
|
shell: "getfacl {{ test_dir | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_dir }}"
|
shell: "getfacl {{ test_dir | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
shell: "setfacl -b {{ test_dir }}"
|
shell: "setfacl -b {{ test_dir | quote }}"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Set default acls
|
- name: Set default acls
|
||||||
acl:
|
acl:
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: get getfacl output
|
||||||
shell: "getfacl {{ test_dir }}"
|
shell: "getfacl {{ test_dir | quote }}"
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: verify output
|
||||||
|
|
|
@ -32,5 +32,5 @@
|
||||||
vars:
|
vars:
|
||||||
test_user: ansible_user
|
test_user: ansible_user
|
||||||
test_group: ansible_group
|
test_group: ansible_group
|
||||||
test_file: /tmp/ansible_file
|
test_file: '{{ output_dir }}/ansible file'
|
||||||
test_dir: /tmp/ansible_dir
|
test_dir: "{{ output_dir }}/ansible_dir/with some space"
|
||||||
|
|
Loading…
Reference in a new issue