|
|
|
@ -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))
|
|
|
|
|