From b7d9e41b430bb7abf30a25479bf44cf6c79e6d1b Mon Sep 17 00:00:00 2001 From: yumaojun <719118794@qq.com> Date: Sat, 28 Nov 2015 22:54:59 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=8E=A8=E9=80=81=20step3=20=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jperm/ansible_api.py | 2 +- jperm/views.py | 4 +++- jumpserver.conf | 2 +- templates/jperm/perm_role_edit.html | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/jperm/ansible_api.py b/jperm/ansible_api.py index 0f8036453..87ff2e72f 100644 --- a/jperm/ansible_api.py +++ b/jperm/ansible_api.py @@ -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") diff --git a/jperm/views.py b/jperm/views.py index 445d82845..84b4f5e37 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -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): """ diff --git a/jumpserver.conf b/jumpserver.conf index 6297ab00a..ac9506672 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -9,7 +9,7 @@ log = debug host = 127.0.0.1 port = 3306 user = jumpserver -password = mysql234 +password = mysql1234 database = jumpserver [websocket] diff --git a/templates/jperm/perm_role_edit.html b/templates/jperm/perm_role_edit.html index 2b1783b56..bd775a5a1 100644 --- a/templates/jperm/perm_role_edit.html +++ b/templates/jperm/perm_role_edit.html @@ -58,14 +58,15 @@