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:
Roman 2019-10-11 19:40:19 +02:00 committed by Toshio Kuratomi
parent 29939383e6
commit 504d76e956
4 changed files with 16 additions and 14 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "acl - fixed module failure if there are spaces in a path"

View file

@ -190,10 +190,10 @@ def build_command(module, mode, path, follow, default, recursive, recalculate_ma
'''Builds and returns a getfacl/setfacl command.'''
if mode == 'set':
cmd = [module.get_bin_path('setfacl', True)]
cmd.append('-m "%s"' % entry)
cmd.extend(['-m', entry])
elif mode == 'rm':
cmd = [module.get_bin_path('setfacl', True)]
cmd.append('-x "%s"' % entry)
cmd.extend(['-x', entry])
else: # mode == 'get'
cmd = [module.get_bin_path('getfacl', True)]
# prevents absolute path warnings and removes headers
@ -241,7 +241,7 @@ def acl_changed(module, cmd):
def run_acl(module, cmd, check_rc=True):
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:
module.fail_json(msg=to_native(e))

View file

@ -43,7 +43,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_file }}"
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: verify output
@ -60,7 +60,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_file }}"
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: verify output
@ -88,7 +88,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_file }}"
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: verify output
@ -110,7 +110,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_dir }}"
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: verify output
@ -122,7 +122,7 @@
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
##############################################################################
- name: Cleanup
shell: "setfacl -b {{ test_dir }}"
shell: "setfacl -b {{ test_dir | quote }}"
##############################################################################
- name: Same as previous but using entry shorthand
acl:
@ -133,7 +133,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_dir }}"
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: verify output
@ -153,7 +153,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_dir }}"
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: verify output
@ -165,7 +165,7 @@
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
##############################################################################
- name: Cleanup
shell: "setfacl -b {{ test_dir }}"
shell: "setfacl -b {{ test_dir | quote }}"
##############################################################################
- name: Set default acls
acl:
@ -186,7 +186,7 @@
register: output
- name: get getfacl output
shell: "getfacl {{ test_dir }}"
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: verify output

View file

@ -32,5 +32,5 @@
vars:
test_user: ansible_user
test_group: ansible_group
test_file: /tmp/ansible_file
test_dir: /tmp/ansible_dir
test_file: '{{ output_dir }}/ansible file'
test_dir: "{{ output_dir }}/ansible_dir/with some space"