Skip to content

Commit

Permalink
Let *.pub files have multiple lines, each containing one SSH key.
Browse files Browse the repository at this point in the history
Makes managing accounts and access for people with multiple client
machines easier.
  • Loading branch information
tv42 committed Nov 18, 2007
1 parent bda6572 commit 1078336
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gitosis/ssh.py
Expand Up @@ -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'

Expand Down
15 changes: 15 additions & 0 deletions gitosis/test/test_ssh.py
Expand Up @@ -73,6 +73,21 @@ def test_two(self):
('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():
Expand Down

0 comments on commit 1078336

Please sign in to comment.