mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
Split rerserved usernames list - possible solution demostration #551
This commit contains an implementation only for module repro - Loop through all the loaded modules - Get each module reserved_username attribute - Check the username against the reserved_username
This commit is contained in:
parent
89146f64ce
commit
a017a9bf4a
@ -28,7 +28,6 @@ from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.views import ServiceView
|
||||
|
||||
version = 2
|
||||
|
||||
depends = ['apps']
|
||||
@ -62,6 +61,7 @@ description = [
|
||||
|
||||
service = None
|
||||
|
||||
reserved_usernames = ['repro']
|
||||
|
||||
def init():
|
||||
"""Initialize the repro module."""
|
||||
|
||||
@ -30,23 +30,7 @@ from plinth.errors import ActionError
|
||||
from plinth.modules import first_boot
|
||||
from plinth.modules.security import set_restricted_access
|
||||
from plinth.utils import is_user_admin
|
||||
|
||||
# Usernames used by optional services (that might not be installed yet).
|
||||
RESERVED_USERNAMES = [
|
||||
'debian-deluged',
|
||||
'Debian-minetest',
|
||||
'debian-tor',
|
||||
'debian-transmission',
|
||||
'ejabberd',
|
||||
'ez-ipupd',
|
||||
'monkeysphere',
|
||||
'mumble-server',
|
||||
'node-restore',
|
||||
'quasselcore',
|
||||
'radicale',
|
||||
'repro',
|
||||
'privoxy',
|
||||
]
|
||||
from plinth import module_loader
|
||||
|
||||
GROUP_CHOICES = (
|
||||
('admin', _('admin')),
|
||||
@ -78,8 +62,10 @@ class ValidNewUsernameCheckMixin(object):
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
|
||||
if username in RESERVED_USERNAMES:
|
||||
return False
|
||||
for module_name, module in module_loader.loaded_modules.items():
|
||||
for reserved_username in getattr(module, 'reserved_usernames', []):
|
||||
if username == reserved_username:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user