mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
users: Add list of restricted usernammes
List is derived from optional services installed.
This commit is contained in:
parent
3a69958165
commit
c8c6bc377b
@ -35,7 +35,7 @@ from plinth import cfg
|
|||||||
from plinth.errors import ActionError, DomainRegistrationError
|
from plinth.errors import ActionError, DomainRegistrationError
|
||||||
from plinth.modules.pagekite.utils import PREDEFINED_SERVICES, run
|
from plinth.modules.pagekite.utils import PREDEFINED_SERVICES, run
|
||||||
from plinth.modules.security import set_restricted_access
|
from plinth.modules.security import set_restricted_access
|
||||||
from plinth.modules.users.forms import GROUP_CHOICES
|
from plinth.modules.users.forms import GROUP_CHOICES, RESTRICTED_USERNAMES
|
||||||
from plinth.utils import format_lazy
|
from plinth.utils import format_lazy
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -55,7 +55,8 @@ class State1Form(auth.forms.UserCreationForm):
|
|||||||
# Exit code 0 means that the username is already in use.
|
# Exit code 0 means that the username is already in use.
|
||||||
raise ValidationError(_('Username is reserved'))
|
raise ValidationError(_('Username is reserved'))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
if username in RESTRICTED_USERNAMES:
|
||||||
|
raise ValidationError(_('Username is reserved'))
|
||||||
|
|
||||||
return super().clean()
|
return super().clean()
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,23 @@ from django.utils.translation import ugettext as _, ugettext_lazy
|
|||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth.errors import ActionError
|
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 = (
|
GROUP_CHOICES = (
|
||||||
('admin', _('admin')),
|
('admin', _('admin')),
|
||||||
('wiki', _('wiki')),
|
('wiki', _('wiki')),
|
||||||
@ -66,7 +83,8 @@ class CreateUserForm(UserCreationForm):
|
|||||||
# Exit code 0 means that the username is already in use.
|
# Exit code 0 means that the username is already in use.
|
||||||
raise ValidationError(_('Username is reserved'))
|
raise ValidationError(_('Username is reserved'))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
if username in RESTRICTED_USERNAMES:
|
||||||
|
raise ValidationError(_('Username is reserved'))
|
||||||
|
|
||||||
return super().clean()
|
return super().clean()
|
||||||
|
|
||||||
@ -139,7 +157,8 @@ class UserUpdateForm(forms.ModelForm):
|
|||||||
# Exit code 0 means that the username is already in use.
|
# Exit code 0 means that the username is already in use.
|
||||||
raise ValidationError(_('Username is reserved'))
|
raise ValidationError(_('Username is reserved'))
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
if username in RESTRICTED_USERNAMES:
|
||||||
|
raise ValidationError(_('Username is reserved'))
|
||||||
|
|
||||||
return super().clean()
|
return super().clean()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user