users: Add list of restricted usernammes

List is derived from optional services installed.
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2016-08-12 18:48:16 +05:30
1 parent 3a69958165
commit c8c6bc377b
2 files changed
+24 -4

No files matched your search

+21 -2
View File
@@ -27,6 +27,23 @@ from django.utils.translation import ugettext as _, ugettext_lazy
from plinth import actions
from plinth.errors import ActionError
# Usernames used by optional services (that might not be installed yet).
RESTRICTED_USERNAMES = [
'debian-deluged',
'Debian-minetest',
'debian-tor',
'debian-transmission',
'ejabberd',
'ez-ipupd',
'monkeysphere',
'mumble-server',
'node-restore',
'quasselcore',
'radicale',
'repro',
'privoxy',
]
GROUP_CHOICES = (
('admin', _('admin')),
('wiki', _('wiki')),
@@ -66,7 +83,8 @@ class CreateUserForm(UserCreationForm):
# Exit code 0 means that the username is already in use.
raise ValidationError(_('Username is reserved'))
except subprocess.CalledProcessError:
pass
if username in RESTRICTED_USERNAMES:
raise ValidationError(_('Username is reserved'))
return super().clean()
@@ -139,7 +157,8 @@ class UserUpdateForm(forms.ModelForm):
# Exit code 0 means that the username is already in use.
raise ValidationError(_('Username is reserved'))
except subprocess.CalledProcessError:
pass
if username in RESTRICTED_USERNAMES:
raise ValidationError(_('Username is reserved'))
return super().clean()