From 23051a4a0533f228f9eb35112cbd4cd1c7f92659 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 10 Dec 2015 14:42:01 +0800 Subject: [PATCH 1/2] bug fix --- jperm/views.py | 4 ++-- jumpserver/api.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jperm/views.py b/jperm/views.py index 1c6e0fd37..aa1791386 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -430,7 +430,6 @@ def perm_role_push(request): group_assets_obj.extend(asset_group.asset_set.all()) calc_assets = list(set(assets_obj) | set(group_assets_obj)) push_resource = gen_resource(calc_assets) - logger.debug('Push role res: %s' % push_resource) # 调用Ansible API 进行推送 password_push = True if request.POST.get("use_password") else False @@ -451,7 +450,8 @@ def perm_role_push(request): # 3. 推送sudo配置文件 if password_push or key_push: sudo_list = set([sudo for sudo in role.sudo.all()]) # set(sudo1, sudo2, sudo3) - ret['sudo'] = task.push_sudo_file([role], sudo_list) + if sudo_list: + ret['sudo'] = task.push_sudo_file([role], sudo_list) logger.debug('推送role结果: %s' % ret) success_asset = {} diff --git a/jumpserver/api.py b/jumpserver/api.py index a904fe0e1..534f60d00 100644 --- a/jumpserver/api.py +++ b/jumpserver/api.py @@ -491,7 +491,6 @@ def defend_attack(func): return HttpResponse('Forbidden', status=403) request.session['visit'] = request.session.get('visit', 1) + 1 request.session.set_expiry(300) - logger.debug(request.session.get('visit')) return func(request, *args, **kwargs) return _deco From 014d0935ba95e27aacf2afc401708d162fb099c0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 10 Dec 2015 21:55:21 +0800 Subject: [PATCH 2/2] bug fix --- jperm/ansible_api.py | 1 - jumpserver.conf | 2 +- templates/jasset/asset_list.html | 10 ++++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/jperm/ansible_api.py b/jperm/ansible_api.py index 0fa0296b2..1fb081966 100644 --- a/jperm/ansible_api.py +++ b/jperm/ansible_api.py @@ -363,7 +363,6 @@ class MyTask(MyRunner): self.run("user", module_args, become=True) return self.results - @staticmethod def gen_sudo_script(role_list, sudo_list): # receive role_list = [role1, role2] sudo_list = [sudo1, sudo2] diff --git a/jumpserver.conf b/jumpserver.conf index d5f4ed930..6297ab00a 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -13,7 +13,7 @@ password = mysql234 database = jumpserver [websocket] -web_socket_host = 127.0.0.1:3000 +web_socket_host = j:3000 [mail] mail_enable = 1 diff --git a/templates/jasset/asset_list.html b/templates/jasset/asset_list.html index 428c4bf73..3f1359de5 100644 --- a/templates/jasset/asset_list.html +++ b/templates/jasset/asset_list.html @@ -229,9 +229,10 @@ data: {}, success: function(data){ var dataArray = data.split(','); - console.log(data+'a'); - console.log(dataArray); - if (dataArray.length == 1 && data != 'error'){ + if (data == 'error' || data == '' || data == null || data == undefined){ + layer.alert('没有授权角色') + } + else if (dataArray.length == 1 && data != 'error'){ var title = 'Jumpserver Web Terminal' + ' '+ hostname +''; console.log(new_url+data); layer.open({ @@ -242,9 +243,6 @@ area: ['628px', '452px'], content: new_url+data }); - //window.open(new_url + data, '', 'location=no, resizeable=no, height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,status=no'); - } else if (data == 'error' || data == '' || data == null || data == undefined){ - layer.alert('没有授权角色') } else { aUrl = ''; $.each(dataArray, function(index, value){