mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
backups: Allow remote repository usernames to start with numbers
Although useradd recommends starting with either a lowercase letter or an underscore, there is nothing that consistently adheres to this recommendation across systems. Because some systems do not follow this recommendation and this recommendation is not a hard requirement, we should not prevent connections at the validation stage. Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
b9fe3fb491
commit
5e6a661648
@ -95,7 +95,7 @@ def repository_validator(path):
|
||||
hostname = hostname.split('%')[0]
|
||||
|
||||
# Validate username using Unix username regex
|
||||
if not re.match(r'[a-z_][a-z0-9_-]*$', username):
|
||||
if not re.match(r'[a-z0-9_][a-z0-9_-]*$', username):
|
||||
raise ValidationError(_(f'Invalid username: {username}'))
|
||||
|
||||
# The hostname should either be a valid IP address or hostname
|
||||
|
||||
@ -34,8 +34,10 @@ def test_repository_paths_validation():
|
||||
|
||||
def test_repository_username_validation():
|
||||
"""Test that usernames in repository string are validated properly."""
|
||||
valid_usernames = ['sshuser', 'cypher_punk-2077', '_user', '_-_']
|
||||
invalid_usernames = ['1two', 'somebody else']
|
||||
valid_usernames = [
|
||||
'sshuser', 'cypher_punk-2077', '_user', '_-_', '1two', '1234'
|
||||
]
|
||||
invalid_usernames = ['somebody else']
|
||||
path_string = '{}@example.org:~/backups'
|
||||
_validate_repository(valid_usernames, invalid_usernames, path_string)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user