mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Prevent user creation if username exists in system users
This commit is contained in:
parent
613ba60041
commit
272558f3af
3 changed files with 13 additions and 0 deletions
|
@ -132,6 +132,7 @@
|
||||||
"mail_alias_remove_failed" : "Unable to remove mail alias '{:s}'",
|
"mail_alias_remove_failed" : "Unable to remove mail alias '{:s}'",
|
||||||
"mail_forward_remove_failed" : "Unable to remove mail forward '{:s}'",
|
"mail_forward_remove_failed" : "Unable to remove mail forward '{:s}'",
|
||||||
"user_unknown" : "Unknown user",
|
"user_unknown" : "Unknown user",
|
||||||
|
"system_username_exists" : "Username already exists in the system users",
|
||||||
"user_creation_failed" : "Unable to create user",
|
"user_creation_failed" : "Unable to create user",
|
||||||
"user_created" : "User successfully created",
|
"user_created" : "User successfully created",
|
||||||
"user_deletion_failed" : "Unable to delete user",
|
"user_deletion_failed" : "Unable to delete user",
|
||||||
|
|
|
@ -131,6 +131,7 @@
|
||||||
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
||||||
"mail_alias_remove_failed" : "Impossible de supprimer l'adresse mail supplémentaire '{:s}'",
|
"mail_alias_remove_failed" : "Impossible de supprimer l'adresse mail supplémentaire '{:s}'",
|
||||||
"mail_forward_remove_failed" : "Impossible de supprimer l'adresse mail de transfert '{:s}'",
|
"mail_forward_remove_failed" : "Impossible de supprimer l'adresse mail de transfert '{:s}'",
|
||||||
|
"system_username_exists" : "Le nom d'utilisateur existe déjà dans les utilisateurs système",
|
||||||
"user_unknown" : "Utilisateur inconnu",
|
"user_unknown" : "Utilisateur inconnu",
|
||||||
"user_creation_failed" : "Impossible de créer l'utilisateur",
|
"user_creation_failed" : "Impossible de créer l'utilisateur",
|
||||||
"user_created" : "Utilisateur créé avec succès",
|
"user_created" : "Utilisateur créé avec succès",
|
||||||
|
|
11
user.py
11
user.py
|
@ -96,15 +96,26 @@ def user_create(auth, username, firstname, lastname, mail, password):
|
||||||
password
|
password
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import pwd
|
||||||
from yunohost.domain import domain_list
|
from yunohost.domain import domain_list
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
|
||||||
|
# Validate uniqueness of username and mail in LDAP
|
||||||
auth.validate_uniqueness({
|
auth.validate_uniqueness({
|
||||||
'uid' : username,
|
'uid' : username,
|
||||||
'mail' : mail
|
'mail' : mail
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Validate uniqueness of username in system users
|
||||||
|
try:
|
||||||
|
pwd.getpwnam(username)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise MoulinetteError(errno.EEXIST, m18n.n('system_username_exists'))
|
||||||
|
|
||||||
|
# Check that the mail domain exists
|
||||||
if mail[mail.find('@')+1:] not in domain_list(auth)['domains']:
|
if mail[mail.find('@')+1:] not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('mail_domain_unknown',
|
m18n.n('mail_domain_unknown',
|
||||||
|
|
Loading…
Add table
Reference in a new issue