aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-11-18 18:08:09 +0200
committerTommi Virtanen <tv@eagain.net>2007-11-18 18:08:09 +0200
commit107833667a2b2445f2de4224829f4d9eaa6e73d0 (patch)
treefaa799928814aec712f95ac280037365c2e8666a
parentWhen autocreating repositories on push, set git-daemon-export-ok etc. (diff)
downloadgitosis-gentoo-107833667a2b2445f2de4224829f4d9eaa6e73d0.zip
gitosis-gentoo-107833667a2b2445f2de4224829f4d9eaa6e73d0.tar.gz
gitosis-gentoo-107833667a2b2445f2de4224829f4d9eaa6e73d0.tar.bz2
Let *.pub files have multiple lines, each containing one SSH key.
Makes managing accounts and access for people with multiple client machines easier.
-rw-r--r--gitosis/ssh.py10
-rw-r--r--gitosis/test/test_ssh.py15
2 files changed, 19 insertions, 6 deletions
diff --git a/gitosis/ssh.py b/gitosis/ssh.py
index 7a70ed4..3eb5c37 100644
--- a/gitosis/ssh.py
+++ b/gitosis/ssh.py
@@ -13,12 +13,10 @@ def readKeys(keydir):
path = os.path.join(keydir, filename)
f = file(path)
- try:
- line = f.readline()
- finally:
- f.close()
- line = line.rstrip('\n')
- yield (basename, line)
+ for line in f:
+ line = line.rstrip('\n')
+ yield (basename, line)
+ f.close()
COMMENT = '### autogenerated by gitosis, DO NOT EDIT'
diff --git a/gitosis/test/test_ssh.py b/gitosis/test/test_ssh.py
index 3b29310..16650c6 100644
--- a/gitosis/test/test_ssh.py
+++ b/gitosis/test/test_ssh.py
@@ -73,6 +73,21 @@ class ReadKeys_Test(object):
('wsmith', KEY_2),
]))
+ def test_multiple_lines(self):
+ tmp = maketemp()
+ keydir = os.path.join(tmp, 'two')
+ mkdir(keydir)
+ writeFile(os.path.join(keydir, 'jdoe.pub'), KEY_1+'\n'+KEY_2+'\n')
+
+ gen = ssh.readKeys(keydir=keydir)
+ got = frozenset(gen)
+
+ eq(got,
+ frozenset([
+ ('jdoe', KEY_1),
+ ('jdoe', KEY_2),
+ ]))
+
class GenerateAuthorizedKeys_Test(object):
def test_simple(self):
def k():