From 76691f813a844e8c18d8de5fd2cc2d0117a9602e Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 22 Dec 2007 22:52:44 -0800 Subject: Move the SSH username extraction to the ssh class, and the tests over as well. --- gitosis/init.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'gitosis/init.py') diff --git a/gitosis/init.py b/gitosis/init.py index 94be4e1..f1f8121 100644 --- a/gitosis/init.py +++ b/gitosis/init.py @@ -27,20 +27,6 @@ def read_ssh_pubkey(fp=None): #pragma: no cover line = fp.readline() return line -class InsecureSSHKeyUsername(Exception): - """Username contains not allowed characters""" - - def __str__(self): - return '%s: %s' % (self.__doc__, ': '.join(self.args)) - -def ssh_extract_user(pubkey): - """Find the username for a given SSH public key line.""" - _, user = pubkey.rsplit(None, 1) - if ssh.isSafeUsername(user): - return user - else: - raise InsecureSSHKeyUsername(repr(user)) - def initial_commit(git_dir, cfg, pubkey, user): """Import the initial files into the gitosis-admin repository.""" repository.fast_import( @@ -126,7 +112,7 @@ class Main(app.App): log.info('Reading SSH public key...') pubkey = read_ssh_pubkey() - user = ssh_extract_user(pubkey) + user = ssh.extract_user(pubkey) if user is None: log.error('Cannot parse user from SSH public key.') sys.exit(1) -- cgit v1.2.3