mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #39855 from Foxlik/use_regex_to_compare_authorized_keys
Use regular expression instead of split when replacing authorized_keys
This commit is contained in:
commit
c59ae9a82c
1 changed files with 2 additions and 9 deletions
|
@ -149,15 +149,8 @@ def _replace_auth_key(
|
|||
# Commented Line
|
||||
lines.append(line)
|
||||
continue
|
||||
comps = line.split()
|
||||
if len(comps) < 2:
|
||||
# Not a valid line
|
||||
lines.append(line)
|
||||
continue
|
||||
key_ind = 1
|
||||
if comps[0][:4:] not in ['ssh-', 'ecds']:
|
||||
key_ind = 2
|
||||
if comps[key_ind] == key:
|
||||
comps = re.findall(r'((.*)\s)?(ssh-[a-z0-9-]+|ecdsa-[a-z0-9-]+)\s([a-zA-Z0-9+/]+={0,2})(\s(.*))?', line)
|
||||
if comps[0][3] == key:
|
||||
lines.append(auth_line)
|
||||
else:
|
||||
lines.append(line)
|
||||
|
|
Loading…
Add table
Reference in a new issue