Merge branch 'release/0.11.3' into production

* release/0.11.3:
  bump version number, add release version to changelog
  fix broken ssh public key handling
  add appropriate filtering for SSH key list
This commit is contained in:
Jan Dittberner 2015-02-21 21:00:14 +01:00
commit c5962632d2
5 changed files with 21 additions and 12 deletions

View file

@ -1,6 +1,10 @@
Changelog 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>` * :release:`0.11.2 <2015-02-06>`
* :bug:`-` fix wrong variable name in * :bug:`-` fix wrong variable name in
managemails.models.MailAddress.set_forward_addresses and typo in managemails.models.MailAddress.set_forward_addresses and typo in

View file

@ -1,3 +1,3 @@
from gnuviechadmin.celery import app as celery_app from gnuviechadmin.celery import app as celery_app
__version__ = '0.11.2' __version__ = '0.11.3'

View file

@ -85,14 +85,15 @@ class AddSshPublicKeyForm(forms.ModelForm):
def clean(self): def clean(self):
keytext = self.cleaned_data.get('publickeytext') keytext = self.cleaned_data.get('publickeytext')
alg, data, comment = SshPublicKey.objects.parse_keytext(keytext) if keytext is not None:
if SshPublicKey.objects.filter( alg, data, comment = SshPublicKey.objects.parse_keytext(keytext)
user=self.osuser, algorithm=alg, data=data if SshPublicKey.objects.filter(
).exists(): user=self.osuser, algorithm=alg, data=data
self.add_error( ).exists():
'publickeytext', self.add_error(
forms.ValidationError(DUPLICATE_SSH_PUBLIC_KEY_FOR_USER) 'publickeytext',
) forms.ValidationError(DUPLICATE_SSH_PUBLIC_KEY_FOR_USER)
)
def save(self, commit=True): def save(self, commit=True):
""" """

View file

@ -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)

View file

@ -107,6 +107,10 @@ class ListSshPublicKeys(
model = SshPublicKey model = SshPublicKey
context_object_name = 'keys' context_object_name = 'keys'
def get_queryset(self):
return SshPublicKey.objects.filter(
user=self.get_hosting_package().osuser)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ListSshPublicKeys, self).get_context_data(**kwargs) context = super(ListSshPublicKeys, self).get_context_data(**kwargs)
context.update({ context.update({