mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Compare commits
4 commits
b3d50f283b
...
cb958b6a17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb958b6a17 | ||
|
|
889ca91b48 | ||
|
|
dabaca4b70 | ||
|
|
26b9b1438d |
3 changed files with 15 additions and 14 deletions
|
|
@ -237,8 +237,6 @@ stages:
|
|||
test: rhel/8.8
|
||||
- name: RHEL 9.2
|
||||
test: rhel/9.2
|
||||
- name: FreeBSD 13.2
|
||||
test: freebsd/13.2
|
||||
|
||||
- stage: Remote_2_15
|
||||
displayName: Remote 2.15
|
||||
|
|
@ -254,8 +252,6 @@ stages:
|
|||
test: rhel/8.7
|
||||
- name: RHEL 9.1
|
||||
test: rhel/9.1
|
||||
- name: FreeBSD 13.2
|
||||
test: freebsd/13.2
|
||||
|
||||
## Finally
|
||||
|
||||
|
|
|
|||
3
changelogs/fragments/639_fix_authorized_key.yml
Normal file
3
changelogs/fragments/639_fix_authorized_key.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- ansible.posix.authorized_key - fixes error on permission denied in authorized_key module (https://github.com/ansible-collections/ansible.posix/issues/462).
|
||||
|
|
@ -225,6 +225,7 @@ import os.path
|
|||
import tempfile
|
||||
import re
|
||||
import shlex
|
||||
import errno
|
||||
from operator import itemgetter
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
|
@ -475,16 +476,17 @@ def parsekey(module, raw_key, rank=None):
|
|||
return (key, key_type, options, comment, rank)
|
||||
|
||||
|
||||
def readfile(filename):
|
||||
|
||||
if not os.path.isfile(filename):
|
||||
return ''
|
||||
|
||||
f = open(filename)
|
||||
def readfile(module, filename):
|
||||
try:
|
||||
return f.read()
|
||||
finally:
|
||||
f.close()
|
||||
with open(filename, 'r') as f:
|
||||
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: {}".format(filename))
|
||||
elif e.errno == errno.ENOENT:
|
||||
return ''
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def parsekeys(module, lines):
|
||||
|
|
@ -597,7 +599,7 @@ def enforce_state(module, params):
|
|||
# check current state -- just get the filename, don't create file
|
||||
do_write = False
|
||||
params["keyfile"] = keyfile(module, user, do_write, path, manage_dir)
|
||||
existing_content = readfile(params["keyfile"])
|
||||
existing_content = readfile(module, params["keyfile"])
|
||||
existing_keys = parsekeys(module, existing_content)
|
||||
|
||||
# Add a place holder for keys that should exist in the state=present and
|
||||
|
|
|
|||
Loading…
Reference in a new issue