Добавлена перегенарация пароля и удаление сервиса

legacy27
parent ed77e9c61c
commit e978ae4196

@ -278,7 +278,8 @@ class UnixUsers(object):
user['loginShell'][0], user['loginShell'][0],
self.flag_to_visible(user['shadowFlag'][0]), self.flag_to_visible(user['shadowFlag'][0]),
self.flag_to_lock(user['shadowExpire'][0]), self.flag_to_lock(user['shadowExpire'][0]),
self.has_password(user['userPassword'][0]), self.has_password(user['userPassword'][0])
if 'userPassword' in user else None,
) )
def search_ldap_user(self, search_filter): def search_ldap_user(self, search_filter):
@ -554,7 +555,8 @@ class Unix(Ldap):
login=user, groups=", ".join(groups))) login=user, groups=", ".join(groups)))
return True return True
def modify_user(self, login, pw, pw_delete, gid, shell, visible, lock, comment): def modify_user(self, login, pw, pw_delete, gid, shell, visible, lock,
comment):
"""" """"
Изменить параметры пользователя в LDAP Изменить параметры пользователя в LDAP
""" """
@ -759,7 +761,10 @@ class Unix(Ldap):
groups_dn = self.clVars.Get('ld_unix_groups_dn') groups_dn = self.clVars.Get('ld_unix_groups_dn')
ug = UnixGroups(ldap_connect, groups_dn) ug = UnixGroups(ldap_connect, groups_dn)
yesno = lambda x: _("Yes") if x else _("No") yesno_map = {True: _("Yes"),
False: _("No"),
None: _("Unavailable")}
yesno = lambda x: yesno_map.get(x, _("Failed value"))
filters = (self.clVars.getInfo(x) filters = (self.clVars.getInfo(x)
for x in ('cl_unix_user_filter_login', for x in ('cl_unix_user_filter_login',

@ -58,7 +58,7 @@ class ClUnixGroupaddAction(Action):
# список задач для действия # список задач для действия
tasks = [ tasks = [
{'name': 'apply_ldif', {'name': 'apply_ldif',
'tasks': meta_tasks.ldif_task("unix.ld_unix_dn,unix.ld_unix_pw", 'tasks': meta_tasks.ldif_task("unix.ld_unix_bind_dn,unix.ld_unix_pw",
Actions.Setup) Actions.Setup)
}, },
] ]

@ -46,7 +46,7 @@ class ClUnixSetupAction(Action):
UnixError, UnixError,
LdapError) LdapError)
successMessage = __("Unix server configured!") successMessage = None
failedMessage = __("Failed to configure Unix server!") failedMessage = __("Failed to configure Unix server!")
interruptMessage = __("Unix server configuration manually interrupted") interruptMessage = __("Unix server configuration manually interrupted")
@ -70,34 +70,64 @@ class ClUnixSetupAction(Action):
'method': 'Unix.set_ldap_connection(' 'method': 'Unix.set_ldap_connection('
'ldap.ld_admin_dn,ldap.ld_admin_pw)', 'ldap.ld_admin_dn,ldap.ld_admin_pw)',
}, },
{'name': 'remove_old_db', {'name': 'remove_service',
'condition': lambda Get: (Get('cl_unix_remove_set') == 'on' or
Get('server.sr_unix_set') != 'on')
},
{'name': 'remove_only',
'message': _("Removing Unix service"),
'condition': lambda Get: (Get('cl_unix_remove_set') == 'on' and
Get('server.sr_unix_set') == 'on')
},
{'name': 'setup_service',
'condition': lambda Get: Get('server.sr_unix_set') != 'on'
},
{'name': 'remove_service:remove_old_db',
'method': 'Unix.remove_ldap_branch(ld_unix_dn)', 'method': 'Unix.remove_ldap_branch(ld_unix_dn)',
'condition': lambda Get: Get('server.sr_unix_set') == 'on' 'condition': lambda Get: Get('server.sr_unix_set') == 'on'
}, },
{'name': 'uninstall', {'name': 'remove_service:uninstall',
'tasks': uninstall_tasks, 'tasks': uninstall_tasks,
'condition': lambda Get: Get('server.sr_unix_set') == 'on' 'condition': lambda Get: Get('server.sr_unix_set') == 'on'
}, },
{'name': 'apply_ldif', {'name': 'setup_service:apply_ldif',
'tasks': meta_tasks.ldif_task("ldap.ld_admin_dn,ldap.ld_admin_pw", 'tasks': meta_tasks.ldif_task("ldap.ld_admin_dn,ldap.ld_admin_pw",
Actions.Setup) Actions.Setup)
}, },
{'name': 'set_unix', {'name': 'setup_service:set_unix',
'method': 'Server.service_install("unix")' 'method': 'Server.service_install("unix")'
}, },
{'name': 'generate_password',
'message': _("Create new Unix service password"),
'method': 'Unix.generate_password(ld_unix_bind_dn,'
'ld_unix_hash,"Unix")',
'condition': lambda Get: Get('cl_unix_pw_generate_set') == 'on'
},
{'name': 'templates', {'name': 'templates',
'message': __("Configure LDAP"), 'message': __("Configure system"),
'method': 'Server.applyTemplates(install.cl_source,' 'method': 'Server.applyTemplates(install.cl_source,'
'False,True,None,True,True)', 'False,True,None,True,True)',
}, },
{'name': 'save_creds',
'method': 'Server.save_service_data("unix",ld_unix_dn,ld_unix_pw)'
},
{'name': 'restart_slapd', {'name': 'restart_slapd',
'message': __("Restarting LDAP service"), 'message': __("Restarting LDAP service"),
'method': 'Server.restart_service("%s")' % Ldap.Service.LDAP, 'method': 'Server.restart_service("%s")' % Ldap.Service.LDAP,
}, },
#{'name': 'save_data', {'name': 'save_creds',
'method': 'Server.save_service_data("unix",'
'ld_unix_bind_dn,ld_unix_pw)',
'condition': lambda Get: Get('cl_unix_remove_set') != 'on'
},
{'name': 'success',
'message': __("Unix server configured!"),
'condition': lambda Get: Get('cl_unix_remove_set') != 'on',
'depend': (Tasks.success() & Tasks.hasnot("failed"))
},
{'name': 'success',
'message': __("Unix server removed!"),
'condition': lambda Get: Get('cl_unix_remove_set') == 'on',
'depend': (Tasks.success() & Tasks.hasnot("failed"))
}
# {'name': 'save_data',
# 'method': 'Unix.save_variables()' # 'method': 'Unix.save_variables()'
# } # }
] ]

@ -58,7 +58,7 @@ class ClUnixUseraddAction(Action):
# список задач для действия # список задач для действия
tasks = [ tasks = [
{'name': 'apply_ldif', {'name': 'apply_ldif',
'tasks': meta_tasks.ldif_task("unix.ld_unix_dn,unix.ld_unix_pw", 'tasks': meta_tasks.ldif_task("unix.ld_unix_bind_dn,unix.ld_unix_pw",
Actions.Setup) Actions.Setup)
}, },
{'name': "info", {'name': "info",

@ -78,12 +78,4 @@ class ClUnixUsermodAction(Action):
'unix.ur_unix_home_path)', 'unix.ur_unix_home_path)',
'condition': lambda Get: Get('unix.ur_unix_home_path_move') == 'on' 'condition': lambda Get: Get('unix.ur_unix_home_path_move') == 'on'
}, },
# {'name': 'apply_ldif',
# 'tasks': meta_tasks.ldif_task("unix.ld_unix_dn,unix.ld_unix_pw",
# Actions.Setup)
# },
# {'name': 'user_groups',
# 'method': 'Unix.add_user_in_groups(ur_unix_login,ur_unix_groups)',
# 'condition': lambda Get: Get('ur_unix_groups')
# },
] ]

@ -38,4 +38,7 @@ class VariableClUnixAction(UnixGroupHelper, UnixUserHelper, Variable):
raise VariableError(_("Unix service has not users")) raise VariableError(_("Unix service has not users"))
if value in Actions.GroupExists and not self.ldap_group_list(): if value in Actions.GroupExists and not self.ldap_group_list():
raise VariableError(_("Unix service has not groups")) raise VariableError(_("Unix service has not groups"))
# проверить соединение с ldap
if value != Actions.Setup:
self.Get('ldap.cl_ldap_connect')

@ -15,7 +15,8 @@
# limitations under the License. # limitations under the License.
import sys import sys
from calculate.lib.datavars import (ReadonlyVariable, Variable) from calculate.lib.datavars import (ReadonlyVariable, Variable,
VariableError)
from calculate.ldap.variables.helpers import (HashHelper, RandomPasswordHelper, from calculate.ldap.variables.helpers import (HashHelper, RandomPasswordHelper,
ServerEnvHelper) ServerEnvHelper)
@ -32,22 +33,23 @@ class VariableLdUnixLogin(ReadonlyVariable):
""" """
value = "Unix" value = "Unix"
# class VariableLdUnixDn(ServerEnvHelper, ReadonlyVariable):
# """
# DN настроенного сервиса
# """
# fallback_variable = "unix.ld_unix_dn"
# service = "unix"
# parameter = "dn"
class VariableLdUnixDn(ReadonlyVariable): class VariableLdUnixDn(ReadonlyVariable):
""" """
DN сервиса DN сервиса
""" """
value_format = "ou={ld_unix_login},{ldap.ld_services_dn}" value_format = "ou={ld_unix_login},{ldap.ld_services_dn}"
class VariableLdUnixBindDn(ServerEnvHelper, Variable):
"""
Пароль root
"""
service = "unix"
parameter = "DN"
@property
def fallback_value(self):
return self.Get('ld_unix_dn')
class VariableLdUnixUsersDn(ReadonlyVariable): class VariableLdUnixUsersDn(ReadonlyVariable):
""" """
@ -80,30 +82,43 @@ class VariableLdUnixPw(ServerEnvHelper, RandomPasswordHelper, Variable):
@property @property
def fallback_value(self): def fallback_value(self):
#return "test22"
return RandomPasswordHelper.get(self) return RandomPasswordHelper.get(self)
#def get(self): def get(self):
# if self.Get('ld_unix_pw_generate_set') == 'on': if self.Get('cl_unix_pw_generate_set') == 'on':
# return "test22" return RandomPasswordHelper.get(self)
# return RandomPasswordHelper.get(self) else:
# else: return super(VariableLdUnixPw, self).get()
# super(VariableLdUnixPw, self).get()
class VariableLdUnixPwGenerateSet(Variable): class VariableClUnixPwGenerateSet(Variable):
""" """
Перегенерировать пароль или нет Перегенерировать пароль или нет
""" """
type = "bool" type = "bool"
opt = ("-g", "--gen-password") opt = ("-g", "--gen-password")
value = "off"
def init(self): def init(self):
self.label = _("Generate new service password") self.label = _("Generate new service password")
self.help = _("generate new service password") self.help = _("generate new service password")
def get(self):
if self.Get('server.sr_unix_set') == 'on': class VariableClUnixRemoveSet(Variable):
return "off" """
else: Удалить сервис Unix
return "on" """
type = "bool"
guitype = "hidden"
opt = ("-r", "--remove")
value = "off"
def init(self):
self.label = _("Remove service")
self.help = _("remove service")
def check(self, value):
if self.Get('server.sr_unix_set') != 'on':
raise VariableError(_("Unix service is not setup"))

@ -469,7 +469,6 @@ class VariableUrUnixPw(Variable):
delete_pw = self.GetBool('ur_unix_pw_delete_set') delete_pw = self.GetBool('ur_unix_pw_delete_set')
change_lock = (self.GetBool('ur_unix_lock_set') != change_lock = (self.GetBool('ur_unix_lock_set') !=
self.GetBool('ur_unix_lock_exists_set')) self.GetBool('ur_unix_lock_exists_set'))
print delete_pw, change_lock, self.GetBool('ur_unix_lock_set')
if (self.Get('cl_unix_action') == Actions.Passwd and if (self.Get('cl_unix_action') == Actions.Passwd and
not delete_pw and not change_lock and not value): not delete_pw and not change_lock and not value):
raise PasswordError(_("Specify user password")) raise PasswordError(_("Specify user password"))

@ -18,7 +18,7 @@ import sys
from calculate.lib.datavars import VariableError, DataVarsError from calculate.lib.datavars import VariableError, DataVarsError
from calculate.core.server.func import WsdlBase from calculate.core.server.func import WsdlBase, CustomButton
from .unix import Unix, UnixError from .unix import Unix, UnixError
from calculate.ldap.ldap import LdapError from calculate.ldap.ldap import LdapError
from calculate.unix.variables.action import Actions from calculate.unix.variables.action import Actions
@ -88,15 +88,17 @@ class Wsdl(WsdlBase):
'server.sr_ldap_set', 'server.sr_ldap_set',
'server.sr_unix_set', 'server.sr_unix_set',
), ),
expert=('ld_unix_pw_generate_set', expert=('cl_unix_pw_generate_set',
'cl_unix_remove_set',
'cl_verbose_set',), 'cl_verbose_set',),
hide=(), hide=(),
custom_buttons=[ custom_buttons=[
('but0', _("Remove"), CustomButton.run_method(
Unix.Method.Setup, Unix.Method.Setup, "but0", _("Remove"),
"button", None, CustomButton.Behavior.setvalue(
lambda Get: Get('server.sr_unix_set') == 'on'), 'cl_unix_remove_set', 'on'),
('but1', None, _("Next"), "button_next"), lambda Get: Get('server.sr_unix_set') == 'on'),
CustomButton.next_button("but1")
] ]
), ),
], ],
@ -134,7 +136,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.UserAdd, 'cl_unix_action': Actions.UserAdd,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -193,7 +195,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.GroupAdd, 'cl_unix_action': Actions.GroupAdd,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -244,7 +246,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.GroupMod, 'cl_unix_action': Actions.GroupMod,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -266,14 +268,15 @@ class Wsdl(WsdlBase):
'ur_unix_group_users_del', 'ur_unix_group_users_del',
), ),
custom_buttons=[ custom_buttons=[
('but0', _("Back"), CustomButton.run_method(
Unix.Method.GroupShow, Unix.Method.GroupShow, 'but0', _("Back")),
"button"), CustomButton.run_method(
('but1', _("Delete"), Unix.Method.GroupDel, 'but1', _("Delete"),
Unix.Method.GroupDel, CustomButton.Behavior.linkerror(
"button",), source='ur_unix_group_name_exists',
('but2', _("Modify"), target='ur_unix_group_newname')),
Unix.Method.GroupMod, "button"), CustomButton.run_method(
Unix.Method.GroupMod, 'but2', _("Modify")),
] ]
), ),
], ],
@ -320,7 +323,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.GroupDel, 'cl_unix_action': Actions.GroupDel,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -367,7 +370,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.UserMod, 'cl_unix_action': Actions.UserMod,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -393,14 +396,12 @@ class Wsdl(WsdlBase):
'ur_unix_pw_delete_set', 'ur_unix_pw_delete_set',
), ),
custom_buttons=[ custom_buttons=[
('but0', _("Back"), CustomButton.run_method(Unix.Method.UserShow,
Unix.Method.UserShow, 'but0', _("Back")),
"button"), CustomButton.run_method(Unix.Method.UserDel,
('but1', _("Delete"), 'but1', _("Delete")),
Unix.Method.UserDel, CustomButton.run_method(Unix.Method.UserMod,
"button",), 'but2', _("Modify"))
('but2', _("Modify"),
Unix.Method.UserMod, "button"),
], ],
next_label=_("Perform") next_label=_("Perform")
), ),
@ -452,7 +453,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.UserDel, 'cl_unix_action': Actions.UserDel,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -499,7 +500,7 @@ class Wsdl(WsdlBase):
'server.cl_server_name': Unix.service_name, 'server.cl_server_name': Unix.service_name,
'cl_unix_action': Actions.Passwd, 'cl_unix_action': Actions.Passwd,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -552,7 +553,7 @@ class Wsdl(WsdlBase):
'cl_unix_action': Actions.GroupShow, 'cl_unix_action': Actions.GroupShow,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'core.cl_page_max!': '{ur_unix_group_count}', 'core.cl_page_max!': '{ur_unix_group_count}',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -574,12 +575,10 @@ class Wsdl(WsdlBase):
'cl_unix_group_fields', 'cl_unix_group_fields',
), ),
custom_buttons=[ custom_buttons=[
('but0', _("Add Group"), CustomButton.open_method(Unix.Method.GroupAdd,
Unix.Method.GroupAdd, 'but0', _("Add Group")),
"button_view"), CustomButton.run_method(Unix.Method.GroupShow,
('but1', _("Show"), 'but1', _("Show"))
Unix.Method.GroupShow,
"button"),
] ]
), ),
], ],
@ -618,7 +617,7 @@ class Wsdl(WsdlBase):
'cl_unix_action': Actions.UserShow, 'cl_unix_action': Actions.UserShow,
'cl_autoupdate_set': 'on', 'cl_autoupdate_set': 'on',
'core.cl_page_max!': '{ur_unix_user_count}', 'core.cl_page_max!': '{ur_unix_user_count}',
'ldap.cl_ldap_bind_dn!': '{ld_unix_dn}', 'ldap.cl_ldap_bind_dn!': '{ld_unix_bind_dn}',
'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}', 'ldap.cl_ldap_bind_pw!': '{ld_unix_pw}',
# 'cl_dispatch_conf_default': "usenew" # 'cl_dispatch_conf_default': "usenew"
}, },
@ -646,12 +645,10 @@ class Wsdl(WsdlBase):
'cl_unix_user_fields', 'cl_unix_user_fields',
), ),
custom_buttons=[ custom_buttons=[
('but0', _("Add User"), CustomButton.open_method(Unix.Method.UserAdd,
Unix.Method.UserAdd, 'but0', _("Add User")),
"button_view"), CustomButton.run_method(Unix.Method.UserShow,
('but1', _("Show"), 'but1', _("Show")),
Unix.Method.UserShow,
"button"),
] ]
), ),
], ],

Loading…
Cancel
Save