1. 修复角色推送 step3 失败

pull/26/head
yumaojun 2015-11-28 22:54:59 +08:00
parent 4672884255
commit b7d9e41b43
4 changed files with 9 additions and 6 deletions

View File

@ -438,7 +438,7 @@ class Tasks(Command):
use template to render pushed sudoers file
:return:
"""
module_args1 = 'test'
module_args1 = file_path
ret1 = self.__run(module_args1, "script")
module_args2 = 'visudo -c | grep "parsed OK" &> /dev/null && echo "ok" || echo "failed"'
ret2 = self.__run(module_args2, "shell")

View File

@ -353,6 +353,7 @@ def perm_role_edit(request):
role = PermRole.objects.get(id=role_id)
role_pass = CRYPTOR.decrypt(role.password)
role_sudos = role.sudo.all()
sudo_all = PermSudo.objects.all()
if request.method == "GET":
return my_render('jperm/perm_role_edit.html', locals(), request)
@ -364,6 +365,7 @@ def perm_role_edit(request):
role_sudo_names = request.POST.getlist("sudo_name")
role_sudos = [PermSudo.objects.get(name=sudo_name) for sudo_name in role_sudo_names]
key_content = request.POST.get("role_key", "")
try:
if not role:
raise ServerError('角色用户不能存在')
@ -384,6 +386,7 @@ def perm_role_edit(request):
role.comment = role_comment
role.sudo = role_sudos
role.save()
msg = u"更新系统角色: %s" % role.name
return HttpResponseRedirect('/jperm/role/')
@ -393,7 +396,6 @@ def perm_role_edit(request):
return my_render('jperm/perm_role_edit.html', locals(), request)
@require_role('admin')
def perm_role_push(request):
"""

View File

@ -9,7 +9,7 @@ log = debug
host = 127.0.0.1
port = 3306
user = jumpserver
password = mysql234
password = mysql1234
database = jumpserver
[websocket]

View File

@ -58,14 +58,15 @@
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="sudo" class="col-sm-2 control-label">角色Sudo命令<span class="red-fonts">*</span></label>
<div class="col-sm-8" id="sudo_name">
<div class="col-sm-8">
<select name="sudo_name" data-placeholder="请选择Sudo别名" class="chosen-select form-control m-b" multiple tabindex="2">
{% for sudo in role_sudos %}
<option selected >{{ sudo.name }}</option>
{% for sudo in sudo_all %}
<option value="{{ sudo.name }}" {% if sudo in role_sudos %} selected {% endif %}>{{ sudo.name }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="role_comment" class="col-sm-2 control-label">备注</label>