Merge branch 'master' of github.com:jumpserver/jumpserver

pull/825/head
ibuler 2016-07-26 18:42:40 +08:00
commit b5b14373d0
3 changed files with 34 additions and 31 deletions

View File

@ -316,6 +316,8 @@ class MyTask(MyRunner):
"""
push the ssh authorized key to target.
"""
if user == 'root':
return {"status": "failed", "msg": "root cann't be delete"}
module_args = 'user="%s" key="{{ lookup("file", "%s") }}" state="absent"' % (user, key_path)
self.run("authorized_key", module_args, become=True)
@ -361,6 +363,8 @@ class MyTask(MyRunner):
"""
delete a host user.
"""
if username == 'root':
return {"status": "failed", "msg": "root cann't be delete"}
module_args = 'name=%s state=absent remove=yes move_home=yes force=yes' % username
self.run("user", module_args, become=True)
return self.results
@ -371,6 +375,8 @@ class MyTask(MyRunner):
:param username:
:return:
"""
if username == 'root':
return {"status": "failed", "msg": "root cann't be delete"}
module_args = "sed -i 's/^%s.*//' /etc/sudoers" % username
self.run("command", module_args, become=True)
return self.results

View File

@ -333,7 +333,6 @@ def perm_role_delete(request):
raise ServerError(u"role_id %s 无数据记录" % role_id)
# 删除推送到主机上的role
filter_type = request.GET.get("filter_type")
print filter_type
if filter_type:
if filter_type == "recycle_assets":
recycle_assets = [push.asset for push in role.perm_push.all() if push.success]

View File

@ -87,39 +87,37 @@ function remove_role(role_id){
url: "{% url 'role_del' %}",
data: {id: role_id, filter_type: 'recycle_assets'},
success: function(data) {
console.log(data)
if (data) {
msg = data + "的系统用户会被删除,包括其家目录,请谨慎操作!"
}
else {
msg = "该角色无已推送的系统用户, 可以安全删除"
}
if (confirm(msg)) {
var msg = data + " 资产上的系统用户会被删除, 包括其家目录,请谨慎操作!";
layer.alert(msg, {
title: '警告',
closeBtn: 0
}, function(){
layer.confirm('危险动作, 除非你非常明白自己在做什么,否则请取消', {
title: '再次确认',
btn: ['确认', '取消']
}, function(){
$.ajax({
type: "POST",
url: "{% url 'role_del' %}",
data: "id=" + role_id,
success: function(msg){
alert( "成功: " + msg );
layer.msg( "成功: " + msg );
var del_row = $('tbody#edittbody>tr#' + role_id);
del_row.remove()
},
error: function (msg) {
console.log(msg);
alert("失败: " + msg.responseText)
layer.alert("失败: " + msg.responseText)
}
});
}
},
}, function(){
layer.msg('取消', {icon: 1})
})
})},
error: function(error) {
alert(error)
},
}
});
}
</script>