From d2f770d47d62ef306f63e3e8f4a67c721c5753d8 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Thu, 6 Mar 2008 18:49:33 -0500 Subject: [PATCH] Clean up key validation - allow non- stuff@stuff comments, etc. --- fas/fas/user.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fas/fas/user.py b/fas/fas/user.py index ff4251e..1aa8fbb 100644 --- a/fas/fas/user.py +++ b/fas/fas/user.py @@ -63,15 +63,14 @@ class ValidSSHKey(validators.FancyValidator): def validate_python(self, value, state): # value = value.file.read() print dir(value) - email_pattern = "[a-zA-Z0-9\.\+\-_]+@[a-zA-Z0-9\.\-]+" keylines = value.split('\n') print "KEYLINES: %s" % keylines for keyline in keylines: if not keyline: continue keyline = keyline.strip() - m = re.match('ssh-[dr]s[as] [^ ]+ ' + email_pattern, keyline) - if not m or m.end() < len(keyline): + m = re.match('^(rsa|dsa|ssh-rsa|ssh-dss) [ \t]*[^ \t]+.*$', keyline) + if not m: raise validators.Invalid(_('Error - Not a valid ssh key: %s') % keyline, value, state) class ValidUsername(validators.FancyValidator):