Let *.pub files have multiple lines, each containing one SSH key.

Makes managing accounts and access for people with multiple client
machines easier.
This commit is contained in:
Tommi Virtanen 2007-11-18 18:08:09 +02:00
parent bda6572c92
commit 107833667a
2 changed files with 19 additions and 6 deletions

View file

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

View file

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