Commit 80071eb9 by Scott Duckworth

treat KeyInfo as object not tuple

parent c14af483
...@@ -75,17 +75,18 @@ class UserKey(models.Model): ...@@ -75,17 +75,18 @@ class UserKey(models.Model):
def clean(self): def clean(self):
try: try:
type, b64key, comment, self.fingerprint = key_parse(self.key) info = key_parse(self.key)
if comment: self.fingerprint = info.fingerprint
self.key = "%s %s %s" % (type.decode(), b64key.decode(), comment) if info.comment:
self.key = "%s %s %s" % (info.type.decode(), info.b64key.decode(), info.comment)
else: else:
self.key = "%s %s" % (type.decode(), b64key.decode()) self.key = "%s %s" % (info.type.decode(), info.b64key.decode())
except SSHKeyFormatError as e: except SSHKeyFormatError as e:
raise ValidationError(str(e)) raise ValidationError(str(e))
if not self.name: if not self.name:
if not comment: if not info.comment:
raise ValidationError('Name or key comment required') raise ValidationError('Name or key comment required')
self.name = comment self.name = info.comment
def validate_unique(self, exclude=None): def validate_unique(self, exclude=None):
if self.pk is None: if self.pk is None:
......
...@@ -146,7 +146,8 @@ def lookup_by_fingerprint_main(): ...@@ -146,7 +146,8 @@ def lookup_by_fingerprint_main():
) )
sys.exit(1) sys.exit(1)
try: try:
type, b64key, comment, fingerprint = key_parse(key) info = key_parse(key)
fingerprint = info.fingerprint
except SSHKeyFormatError as e: except SSHKeyFormatError as e:
sys.stderr.write("Error: " + str(e)) sys.stderr.write("Error: " + str(e))
sys.exit(1) sys.exit(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment