fix broken ssh public key handling
- make sure that AddSshPublicKeyForm does not try to parse the key if it is None - split the key text into a maximum of 3 parts to allow whitespace in comments - update changelog
This commit is contained in:
parent
dd38edd498
commit
25b5b82a06
3 changed files with 13 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
* :bug:`-` fix handling of OpenSSH formatted keys with whitespace in comments
|
||||||
* :bug:`-` the ssh key list does not show SSH keys of other users anymore
|
* :bug:`-` the ssh key list does not show SSH keys of other users anymore
|
||||||
|
|
||||||
* :release:`0.11.2 <2015-02-06>`
|
* :release:`0.11.2 <2015-02-06>`
|
||||||
|
|
|
@ -85,6 +85,7 @@ class AddSshPublicKeyForm(forms.ModelForm):
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
keytext = self.cleaned_data.get('publickeytext')
|
keytext = self.cleaned_data.get('publickeytext')
|
||||||
|
if keytext is not None:
|
||||||
alg, data, comment = SshPublicKey.objects.parse_keytext(keytext)
|
alg, data, comment = SshPublicKey.objects.parse_keytext(keytext)
|
||||||
if SshPublicKey.objects.filter(
|
if SshPublicKey.objects.filter(
|
||||||
user=self.osuser, algorithm=alg, data=data
|
user=self.osuser, algorithm=alg, data=data
|
||||||
|
|
|
@ -528,9 +528,9 @@ class SshPublicKeyManager(models.Manager):
|
||||||
if 'comment' in headers:
|
if 'comment' in headers:
|
||||||
comment = headers['comment']
|
comment = headers['comment']
|
||||||
else:
|
else:
|
||||||
parts = keytext.split()
|
parts = keytext.split(None, 2)
|
||||||
if len(parts) > 3:
|
if len(parts) < 2:
|
||||||
raise ValueError("unsupported key format")
|
raise ValueError('invalid SSH public key')
|
||||||
data = parts[1]
|
data = parts[1]
|
||||||
comment = len(parts) == 3 and parts[2] or ""
|
comment = len(parts) == 3 and parts[2] or ""
|
||||||
keybytes = base64.b64decode(data)
|
keybytes = base64.b64decode(data)
|
||||||
|
|
Loading…
Reference in a new issue