diff --git a/docs/changelog.rst b/docs/changelog.rst index 8249f7c..b597907 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,10 @@ Changelog ========= +* :release:`0.11.3 <2015-02-21>` +* :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 + * :release:`0.11.2 <2015-02-06>` * :bug:`-` fix wrong variable name in managemails.models.MailAddress.set_forward_addresses and typo in diff --git a/gnuviechadmin/gnuviechadmin/__init__.py b/gnuviechadmin/gnuviechadmin/__init__.py index 47f224e..2e822b8 100644 --- a/gnuviechadmin/gnuviechadmin/__init__.py +++ b/gnuviechadmin/gnuviechadmin/__init__.py @@ -1,3 +1,3 @@ from gnuviechadmin.celery import app as celery_app -__version__ = '0.11.2' +__version__ = '0.11.3' diff --git a/gnuviechadmin/osusers/forms.py b/gnuviechadmin/osusers/forms.py index ed1a6c1..975f102 100644 --- a/gnuviechadmin/osusers/forms.py +++ b/gnuviechadmin/osusers/forms.py @@ -85,14 +85,15 @@ class AddSshPublicKeyForm(forms.ModelForm): def clean(self): keytext = self.cleaned_data.get('publickeytext') - alg, data, comment = SshPublicKey.objects.parse_keytext(keytext) - if SshPublicKey.objects.filter( - user=self.osuser, algorithm=alg, data=data - ).exists(): - self.add_error( - 'publickeytext', - forms.ValidationError(DUPLICATE_SSH_PUBLIC_KEY_FOR_USER) - ) + if keytext is not None: + alg, data, comment = SshPublicKey.objects.parse_keytext(keytext) + if SshPublicKey.objects.filter( + user=self.osuser, algorithm=alg, data=data + ).exists(): + self.add_error( + 'publickeytext', + forms.ValidationError(DUPLICATE_SSH_PUBLIC_KEY_FOR_USER) + ) def save(self, commit=True): """ diff --git a/gnuviechadmin/osusers/models.py b/gnuviechadmin/osusers/models.py index ddde5e5..28e93a7 100644 --- a/gnuviechadmin/osusers/models.py +++ b/gnuviechadmin/osusers/models.py @@ -528,9 +528,9 @@ class SshPublicKeyManager(models.Manager): if 'comment' in headers: comment = headers['comment'] else: - parts = keytext.split() - if len(parts) > 3: - raise ValueError("unsupported key format") + parts = keytext.split(None, 2) + if len(parts) < 2: + raise ValueError('invalid SSH public key') data = parts[1] comment = len(parts) == 3 and parts[2] or "" keybytes = base64.b64decode(data) diff --git a/gnuviechadmin/osusers/views.py b/gnuviechadmin/osusers/views.py index 0f74cf7..3c8c637 100644 --- a/gnuviechadmin/osusers/views.py +++ b/gnuviechadmin/osusers/views.py @@ -107,6 +107,10 @@ class ListSshPublicKeys( model = SshPublicKey context_object_name = 'keys' + def get_queryset(self): + return SshPublicKey.objects.filter( + user=self.get_hosting_package().osuser) + def get_context_data(self, **kwargs): context = super(ListSshPublicKeys, self).get_context_data(**kwargs) context.update({