From 6418033e51067189165866d0eecebbeea0f754cb Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Thu, 9 Oct 2014 10:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=87=EE=86=BD=E6=95=BC=20chgsudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 7 ------- webroot/AutoSa/AutoSa/views.py | 8 ++++++-- webroot/AutoSa/templates/info.html | 12 ++++++++++++ webroot/AutoSa/templates/showSudo.html | 2 -- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 743130e55..0e219b1ba 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,12 +1,5 @@ - - - diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index 4a7f54f37..1562c3485 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -637,11 +637,13 @@ def chgSudo(request): msg = '' if request.POST.get('add_host') or request.POST.get('del_host'): host = request.POST.get('add_host') if request.POST.get('add_host') else request.POST.get('del_host') - hosts = host.split(',') + hosts = str(host).split(',') ori_hosts = l.list('entryDN=cn=%s,ou=Sudoers,%s' % (str(username), ldap_base_dn), attr=['sudoHost']).get('sudoHost') if request.POST.get('add_host'): + if not ori_hosts: + ori_hosts = [] ori_hosts.extend(hosts) new_hosts = list(set(ori_hosts)) else: @@ -652,10 +654,12 @@ def chgSudo(request): if request.POST.get('add_cmd') or request.POST.get('del_cmd'): cmd = request.POST.get('add_cmd') if request.POST.get('add_cmd') else request.POST.get('del_cmd') - cmds = cmd.split(',') + cmds = str(cmd).split(',') ori_cmds = l.list('entryDN=cn=%s,ou=Sudoers,%s' % (str(username), ldap_base_dn), attr=['sudoCommand']).get('sudoCommand') if request.POST.get('add_cmd'): + if not ori_cmds: + ori_cmds = [] ori_cmds.extend(cmds) new_cmds = list(set(ori_cmds)) else: diff --git a/webroot/AutoSa/templates/info.html b/webroot/AutoSa/templates/info.html index cc3e2fbb4..34acc156c 100644 --- a/webroot/AutoSa/templates/info.html +++ b/webroot/AutoSa/templates/info.html @@ -21,6 +21,18 @@ history.go(-1); } + + + + + + + + + + diff --git a/webroot/AutoSa/templates/showSudo.html b/webroot/AutoSa/templates/showSudo.html index 5325d0faf..64f56c9c1 100644 --- a/webroot/AutoSa/templates/showSudo.html +++ b/webroot/AutoSa/templates/showSudo.html @@ -3,7 +3,6 @@
{{ username }} 允许sudo的主机: -

允许的sudo命令: -