mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 23:50:03 -06:00
When reading SSH pub key don't assume last character is newline
The code was attempting to strip off any trailing newline and then calling lstrip() on the rest. This assumes that the key has a trailing newline. At best this can cause the last character of the comment to be lost. If there is no comment it will fail to load the key because it is invalid. Patch by Félix-Antoine Fortin <felix-antoine.fortin@calculquebec.ca> https://pagure.io/freeipa/issue/7959 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
f606d82024
commit
21777e4ba0
@ -1562,12 +1562,13 @@ def update_ssh_keys(hostname, ssh_dir, create_sshfp):
|
||||
continue
|
||||
|
||||
for line in f:
|
||||
line = line[:-1].lstrip()
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
try:
|
||||
pubkey = SSHPublicKey(line)
|
||||
except (ValueError, UnicodeDecodeError):
|
||||
except (ValueError, UnicodeDecodeError) as e:
|
||||
logger.debug("Decoding line '%s' failed: %s", line, e)
|
||||
continue
|
||||
logger.info("Adding SSH public key from %s", filename)
|
||||
pubkeys.append(pubkey)
|
||||
|
Loading…
Reference in New Issue
Block a user