Убрано ограничение на название пользователей и групп

legacy27 3.5.0_alpha3
父節點 04c0c9a973
當前提交 22ae85d9f4

@ -16,7 +16,7 @@
import sys
from calculate.lib.datavars import (ReadonlyVariable, Variable,
VariableError)
VariableError, VariableInterface)
from calculate.ldap.variables.helpers import (LdapSearchHelper, LdapMaxHelper)
from calculate.unix.variables.helpers import (UnixUserHelper, UnixGroupHelper,
UnixActionHelper)
@ -29,8 +29,18 @@ from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate)
setLocalTranslate('cl_unix3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
class GroupNameHelper(VariableInterface):
"""
Вспомогательный объект для проверки имени группы
"""
def check_group_name(self, gname):
if len(gname) > 32:
raise VariableError(_("Wrong group name length"))
if ":" in gname:
raise VariableError(_("Wrong group name"))
class VariableUrUnixGroupName(LdapSearchHelper, UnixActionHelper, Variable):
class VariableUrUnixGroupName(GroupNameHelper,
LdapSearchHelper, UnixActionHelper, Variable):
"""
Название группы
"""
@ -54,8 +64,7 @@ class VariableUrUnixGroupName(LdapSearchHelper, UnixActionHelper, Variable):
def check(self, value):
if not value:
raise VariableError(_("You should specify group name"))
if not re.match("^[a-zA-Z_]([a-zA-Z0-9_ -]*[a-zA-Z0-9_-])?$", value):
raise VariableError(_("Wrong group name"))
self.check_group_name(value)
if value == "list":
raise VariableError(_("List is using as keyword"))
if self.check_name(value):
@ -392,7 +401,7 @@ class VariableUrUnixGroupUsersDel(UnixUserHelper, Variable):
return _("Not change")
class VariableUrUnixGroupNewname(UnixGroupHelper, Variable):
class VariableUrUnixGroupNewname(GroupNameHelper, UnixGroupHelper, Variable):
opt = ("-n", "--new-name")
value = ""
metavalue = "NEW_GROUP"
@ -407,7 +416,7 @@ class VariableUrUnixGroupNewname(UnixGroupHelper, Variable):
def check(self, value):
if value == self.Get('ur_unix_group_name'):
return
# raise VariableError(_("The new group name is the same as the old"))
self.check_group_name(value)
if self.search_ldap_group_name(value):
raise VariableError(
_("Group {name} already exists").format(name=value))

@ -18,7 +18,8 @@ import sys
from os import path
from calculate.lib.cl_ldap import LDAPConnectError
from calculate.lib.datavars import (ReadonlyVariable, Variable,
VariableError, PasswordError)
VariableError, PasswordError,
VariableInterface)
from calculate.ldap.variables.helpers import (HashHelper,
LdapMaxHelper)
from calculate.unix.variables.helpers import (UnixUserHelper, UnixGroupHelper,
@ -35,7 +36,20 @@ setLocalTranslate('cl_unix3', sys.modules[__name__])
__ = getLazyLocalTranslate(_)
class VariableUrUnixLogin(UnixUserHelper, UnixActionHelper, Variable):
class UserNameHelper(VariableInterface):
"""
Вспомогательный объект для проверки имени группы
"""
def check_user_name(self, uname):
if len(uname) > 32:
raise VariableError(_("Wrong user name length"))
if ":" in uname:
raise VariableError(_("Wrong user name"))
class VariableUrUnixLogin(UserNameHelper, UnixUserHelper, UnixActionHelper,
Variable):
"""
Логин настраиваемого пользователя
"""
@ -56,8 +70,7 @@ class VariableUrUnixLogin(UnixUserHelper, UnixActionHelper, Variable):
def check_new(self, value):
if not value:
raise VariableError(_("You should specify login"))
if not re.match("^[a-zA-Z_]([a-zA-Z0-9_ -]*[a-zA-Z0-9_-])?$", value):
raise VariableError(_("Wrong user login"))
self.check_user_name(value)
if value == "list":
raise VariableError(_("List is using as keyword"))
if self.search_ldap_user_name(value):

載入中…
取消
儲存