aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-12-11 22:50:04 +0200
committerTommi Virtanen <tv@eagain.net>2007-12-11 22:50:04 +0200
commitb5e966c10771ccc02a084d3b0e5ebeb760214508 (patch)
tree21acb3cfcd0e1f39a3263f1fc4dd4ed7c7d973d0
parentEnforce safe usernames also when reading public key files from keydir. (diff)
downloadgitosis-gentoo-b5e966c10771ccc02a084d3b0e5ebeb760214508.tar.gz
gitosis-gentoo-b5e966c10771ccc02a084d3b0e5ebeb760214508.tar.bz2
gitosis-gentoo-b5e966c10771ccc02a084d3b0e5ebeb760214508.zip
Allow underscores, dots and dashes in SSH username local parts.
-rw-r--r--gitosis/ssh.py2
-rw-r--r--gitosis/test/test_init.py27
2 files changed, 28 insertions, 1 deletions
diff --git a/gitosis/ssh.py b/gitosis/ssh.py
index 9e8d258..3fe846f 100644
--- a/gitosis/ssh.py
+++ b/gitosis/ssh.py
@@ -3,7 +3,7 @@ import logging
log = logging.getLogger('gitosis.ssh')
-_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9]*(@[a-z][a-z0-9.-]*)?$')
+_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9_.-]*(@[a-z][a-z0-9.-]*)?$')
def isSafeUsername(user):
match = _ACCEPTABLE_USER_RE.match(user)
diff --git a/gitosis/test/test_init.py b/gitosis/test/test_init.py
index 559a0c8..e7f0150 100644
--- a/gitosis/test/test_init.py
+++ b/gitosis/test/test_init.py
@@ -36,6 +36,33 @@ def test_ssh_extract_user_domain_dashes():
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@ridiculously-long.example.com')
eq(got, 'fakeuser@ridiculously-long.example.com')
+def test_ssh_extract_user_underscore():
+ got = init.ssh_extract_user(
+ 'ssh-somealgo '
+ +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake_user@example.com')
+ eq(got, 'fake_user@example.com')
+
+def test_ssh_extract_user_dot():
+ got = init.ssh_extract_user(
+ 'ssh-somealgo '
+ +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u.ser@example.com')
+ eq(got, 'fake.u.ser@example.com')
+
+def test_ssh_extract_user_dash():
+ got = init.ssh_extract_user(
+ 'ssh-somealgo '
+ +'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+ +'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u-ser@example.com')
+ eq(got, 'fake.u-ser@example.com')
+
def test_ssh_extract_user_no_at():
got = init.ssh_extract_user(
'ssh-somealgo '