mirror of https://github.com/jumpserver/jumpserver
bug fix
parent
5be2633795
commit
b7cfac4d1f
|
@ -312,6 +312,7 @@ class Tty(object):
|
||||||
port=connect_info.get('port'),
|
port=connect_info.get('port'),
|
||||||
username=connect_info.get('role_name'),
|
username=connect_info.get('role_name'),
|
||||||
password=connect_info.get('role_pass'),
|
password=connect_info.get('role_pass'),
|
||||||
|
allow_agent=False,
|
||||||
look_for_keys=False)
|
look_for_keys=False)
|
||||||
|
|
||||||
except paramiko.ssh_exception.AuthenticationException, paramiko.ssh_exception.SSHException:
|
except paramiko.ssh_exception.AuthenticationException, paramiko.ssh_exception.SSHException:
|
||||||
|
@ -748,7 +749,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
asset = nav.search_result[int(option)]
|
asset = nav.search_result[int(option)]
|
||||||
roles = get_role(login_user, asset)
|
roles = nav.user_perm.get('asset').get(asset).get('role')
|
||||||
if len(roles) > 1:
|
if len(roles) > 1:
|
||||||
role_check = dict(zip(range(len(roles)), roles))
|
role_check = dict(zip(range(len(roles)), roles))
|
||||||
print "\033[32m[ID] 角色\033[0m"
|
print "\033[32m[ID] 角色\033[0m"
|
||||||
|
@ -766,7 +767,7 @@ def main():
|
||||||
color_print('请输入正确ID', 'red')
|
color_print('请输入正确ID', 'red')
|
||||||
continue
|
continue
|
||||||
elif len(roles) == 1:
|
elif len(roles) == 1:
|
||||||
role = roles[0]
|
role = list(roles)[0]
|
||||||
else:
|
else:
|
||||||
color_print('没有映射用户', 'red')
|
color_print('没有映射用户', 'red')
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -23,7 +23,12 @@ def log_list(request, offset):
|
||||||
cmd = request.GET.get('cmd', '')
|
cmd = request.GET.get('cmd', '')
|
||||||
|
|
||||||
if offset == 'online':
|
if offset == 'online':
|
||||||
|
keyword = request.GET.get('keyword', '')
|
||||||
posts = Log.objects.filter(is_finished=False).order_by('-start_time')
|
posts = Log.objects.filter(is_finished=False).order_by('-start_time')
|
||||||
|
if keyword:
|
||||||
|
posts = posts.filter(Q(user__icontains=keyword) | Q(host__icontains=keyword) |
|
||||||
|
Q(login_type_icontains=keyword))
|
||||||
|
|
||||||
elif offset == 'exec':
|
elif offset == 'exec':
|
||||||
posts = ExecLog.objects.all().order_by('-id')
|
posts = ExecLog.objects.all().order_by('-id')
|
||||||
keyword = request.GET.get('keyword', '')
|
keyword = request.GET.get('keyword', '')
|
||||||
|
|
|
@ -71,17 +71,6 @@ def get_asset_info(asset):
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def get_role(user, asset):
|
|
||||||
"""
|
|
||||||
获取用户在这个资产上的授权角色列表
|
|
||||||
"""
|
|
||||||
roles = []
|
|
||||||
rules = PermRule.objects.filter(user=user, asset=asset)
|
|
||||||
for rule in rules:
|
|
||||||
roles.extend(list(rule.role.all()))
|
|
||||||
return roles
|
|
||||||
|
|
||||||
|
|
||||||
def get_role_key(user, role):
|
def get_role_key(user, role):
|
||||||
"""
|
"""
|
||||||
由于role的key的权限是所有人可以读的, ansible执行命令等要求为600,所以拷贝一份到特殊目录
|
由于role的key的权限是所有人可以读的, ansible执行命令等要求为600,所以拷贝一份到特殊目录
|
||||||
|
|
|
@ -237,7 +237,7 @@ def key_exist(username):
|
||||||
"""
|
"""
|
||||||
ssh key is exist or not
|
ssh key is exist or not
|
||||||
"""
|
"""
|
||||||
if os.path.isfile(os.path.join(KEY_DIR, 'user', username+'pem')):
|
if os.path.isfile(os.path.join(KEY_DIR, 'user', username+'.pem')):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -25,9 +25,6 @@ urlpatterns = patterns('juser.views',
|
||||||
(r'^forget_password/$', forget_password),
|
(r'^forget_password/$', forget_password),
|
||||||
|
|
||||||
(r'^change_info/$', 'change_info'),
|
(r'^change_info/$', 'change_info'),
|
||||||
(r'^change_role/$', 'chg_role'),
|
|
||||||
(r'^regen_ssh_key/$', 'regen_ssh_key'),
|
(r'^regen_ssh_key/$', 'regen_ssh_key'),
|
||||||
(r'^down_key/$', 'down_key'),
|
(r'^down_key/$', 'down_key'),
|
||||||
|
|
||||||
(r'runcommand/$', 'RunCommand'),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -248,10 +248,11 @@ def user_del(request):
|
||||||
user_id_list = user_ids.split(',')
|
user_id_list = user_ids.split(',')
|
||||||
else:
|
else:
|
||||||
return HttpResponse('错误请求')
|
return HttpResponse('错误请求')
|
||||||
|
|
||||||
for user_id in user_id_list:
|
for user_id in user_id_list:
|
||||||
user = get_object(User, id=user_id)
|
user = get_object(User, id=user_id)
|
||||||
if user:
|
if user and user.username != 'admin':
|
||||||
logger.debug("删除用户 %s " % user.username)
|
logger.debug(u"删除用户 %s " % user.username)
|
||||||
bash('userdel -r %s' % user.username)
|
bash('userdel -r %s' % user.username)
|
||||||
user.delete()
|
user.delete()
|
||||||
return HttpResponse('删除成功')
|
return HttpResponse('删除成功')
|
||||||
|
@ -418,9 +419,6 @@ def change_info(request):
|
||||||
error = '密码须大于6位'
|
error = '密码须大于6位'
|
||||||
|
|
||||||
if not error:
|
if not error:
|
||||||
# if password != user.password:
|
|
||||||
# password = CRYPTOR.md5_crypt(password)
|
|
||||||
|
|
||||||
User.objects.filter(id=user_id).update(name=name, email=email)
|
User.objects.filter(id=user_id).update(name=name, email=email)
|
||||||
if len(password) > 0:
|
if len(password) > 0:
|
||||||
user.set_password(password)
|
user.set_password(password)
|
||||||
|
@ -454,7 +452,7 @@ def down_key(request):
|
||||||
user = get_object(User, uuid=uuid_r)
|
user = get_object(User, uuid=uuid_r)
|
||||||
if user:
|
if user:
|
||||||
username = user.username
|
username = user.username
|
||||||
private_key_file = os.path.join(KEY_DIR, 'user', username+'pem')
|
private_key_file = os.path.join(KEY_DIR, 'user', username+'.pem')
|
||||||
print private_key_file
|
print private_key_file
|
||||||
if os.path.isfile(private_key_file):
|
if os.path.isfile(private_key_file):
|
||||||
f = open(private_key_file)
|
f = open(private_key_file)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<div class="wrapper wrapper-content animated fadeInRight">
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-12">
|
||||||
<div class="ibox float-e-margins">
|
<div class="ibox float-e-margins">
|
||||||
<div id="ibox-content" class="ibox-title">
|
<div id="ibox-content" class="ibox-title">
|
||||||
<h5> 批量命令日志 </h5>
|
<h5> 批量命令日志 </h5>
|
||||||
|
@ -33,10 +33,7 @@
|
||||||
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
||||||
<li class="active"><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
<li class="active"><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
||||||
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
||||||
</ul>
|
<div class="" style="float: right">
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<div class="">
|
|
||||||
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
|
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
|
||||||
|
@ -48,6 +45,8 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<table class="table table-striped table-bordered table-hover ">
|
<table class="table table-striped table-bordered table-hover ">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -33,10 +33,7 @@
|
||||||
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
||||||
<li><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
<li><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
||||||
<li class="active"><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
<li class="active"><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
||||||
</ul>
|
<div class="" style="float: right">
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<div class="">
|
|
||||||
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
|
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
|
||||||
|
@ -48,6 +45,8 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<table class="table table-striped table-bordered table-hover ">
|
<table class="table table-striped table-bordered table-hover ">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -70,7 +69,7 @@
|
||||||
<td class="text-center"> {{ post.id }} </td>
|
<td class="text-center"> {{ post.id }} </td>
|
||||||
<td class="text-center"> {{ post.user }} </td>
|
<td class="text-center"> {{ post.user }} </td>
|
||||||
<td class="text-center"> {{ post.host | truncatechars:30 }} </td>
|
<td class="text-center"> {{ post.host | truncatechars:30 }} </td>
|
||||||
<td class="text-center"> {{ post.filename | truncatechars:30 }} </td>
|
<td class="text-center"> {{ post.filename | truncatechars:20 }} </td>
|
||||||
<td class="text-center"> {{ post.type }} </td>
|
<td class="text-center"> {{ post.type }} </td>
|
||||||
<td class="text-center"> {{ post.remote_ip }} </td>
|
<td class="text-center"> {{ post.remote_ip }} </td>
|
||||||
<td class="text-center"> {{ post.datetime|date:"Y-m-d H:i:s"}} </td>
|
<td class="text-center"> {{ post.datetime|date:"Y-m-d H:i:s"}} </td>
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
|
||||||
<form class="form-inline" action="" method="get">
|
<form class="form-inline" action="" method="get">
|
||||||
<div class="form-group" id="date_5">
|
<div class="form-group" id="date_5">
|
||||||
<div class="input-daterange input-group" id="datepicker">
|
<div class="input-daterange input-group" id="datepicker">
|
||||||
|
@ -89,7 +88,7 @@
|
||||||
<input id="cmd" name="cmd" placeholder="命令" type="text" class="form-control" value="{{ cmd }}" style="width: 200px;">
|
<input id="cmd" name="cmd" placeholder="命令" type="text" class="form-control" value="{{ cmd }}" style="width: 200px;">
|
||||||
</div>
|
</div>
|
||||||
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
||||||
Search
|
- 搜索 -
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
|
|
|
@ -71,9 +71,20 @@
|
||||||
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
<li><a href="/jlog/log_list/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 历史记录 </a></li>
|
||||||
<li><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
<li><a href="/jlog/log_list/exec/" class="text-center"><i class="fa fa-bar-chart-o"></i> 命令记录 </a></li>
|
||||||
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
<li><a href="/jlog/log_list/file/" class="text-center"><i class="fa fa-bar-chart-o"></i> 上传下载 </a></li>
|
||||||
|
<div class="" style="float: right">
|
||||||
|
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" class="form-control input-sm" id="keyword" name="keyword" value="{{ keyword }}" placeholder="Search">
|
||||||
|
<div class="input-group-btn">
|
||||||
|
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
||||||
|
-搜索-
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<table class="table table-striped table-bordered table-hover ">
|
<table class="table table-striped table-bordered table-hover ">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -123,6 +123,7 @@
|
||||||
$(".gradeX input:checked").each(function() {
|
$(".gradeX input:checked").each(function() {
|
||||||
check_array.push($(this).attr("value"))
|
check_array.push($(this).attr("value"))
|
||||||
});
|
});
|
||||||
|
console.log(check_array.join(","));
|
||||||
$.post("/juser/user_del/",
|
$.post("/juser/user_del/",
|
||||||
{id: check_array.join(",")},
|
{id: check_array.join(",")},
|
||||||
function(data){
|
function(data){
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<li id="juser">
|
<li id="juser">
|
||||||
<a href="#"><i class="fa fa-group"></i> <span class="nav-label">用户管理</span><span class="fa arrow"></span></a>
|
<a href="#"><i class="fa fa-group"></i> <span class="nav-label">用户管理</span><span class="fa arrow"></span></a>
|
||||||
<ul class="nav nav-second-level">
|
<ul class="nav nav-second-level">
|
||||||
<li class="group_list group_edit"><a href="/juser/group_list/">查看用户组</a></li>
|
<li class="group_list group_edit group_add"><a href="/juser/group_list/">查看用户组</a></li>
|
||||||
<li class="user_list user_edit user_detail"><a href="/juser/user_list/">查看用户<span class="label {% ifequal user_active_num user_total_num %}label-primary {% else %}label-warning {% endifequal %}pull-right">{{ user_active_num }}/{{ user_total_num }}</span></a></li>
|
<li class="user_list user_edit user_detail user_add"><a href="/juser/user_list/">查看用户<span class="label {% ifequal user_active_num user_total_num %}label-primary {% else %}label-warning {% endifequal %}pull-right">{{ user_active_num }}/{{ user_total_num }}</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li id="jasset">
|
<li id="jasset">
|
||||||
|
|
Loading…
Reference in New Issue