Compare commits

..

2 commits

Author SHA1 Message Date
Klaas Demter
03e9ed4c58
Merge 889ca91b48 into 9343c6f56f 2025-10-20 11:20:42 +02:00
Klaas Demter
889ca91b48 Fixes #462 notice permission denied on authorized_key module 2025-05-20 12:36:42 +02:00
3 changed files with 1 additions and 36 deletions

View file

@ -226,7 +226,6 @@ import tempfile
import re
import shlex
import errno
import traceback
from operator import itemgetter
from ansible.module_utils._text import to_native
@ -483,8 +482,7 @@ def readfile(module, filename):
return f.read()
except IOError as e:
if e.errno == errno.EACCES:
module.fail_json(msg="Permission denied on file or path for authorized keys file: %s" % filename,
exception=traceback.format_exc())
module.fail_json(msg="Permission denied on file or path for authorized keys file: {}".format(filename))
elif e.errno == errno.ENOENT:
return ''
else:

View file

@ -1,30 +0,0 @@
---
# -------------------------------------------------------------
# check permissions
- name: Create a file that is not accessible
ansible.builtin.file:
state: touch
path: "{{ output_dir | expanduser }}/file_permissions"
owner: root
group: root
mode: '0000'
- name: Try to delete a key from an unreadable file
ansible.posix.authorized_key:
user: root
key: "{{ dss_key_basic }}"
state: absent
path: "{{ output_dir | expanduser }}/file_permissions"
register: result
ignore_errors: true
- name: Assert that the key deletion has failed
ansible.builtin.assert:
that:
- result.failed == True
- name: Remove the file
ansible.builtin.file:
state: absent
path: "{{ output_dir | expanduser }}/file_permissions"

View file

@ -34,6 +34,3 @@
- name: Test for specifying key as a path
ansible.builtin.import_tasks: check_path.yml
- name: Test for permission denied files
ansible.builtin.import_tasks: check_permissions.yml