From 1f09a40c772e8d65908735e048608ec1ba8b95d0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 5 Apr 2016 22:34:37 +0800 Subject: [PATCH 1/3] fix(user manage and connect first login) When delete a user, but didn't delete the user sysuser key. When create a user with same username, error occur. When user login tty, and type a num first, it will search a host, but login the asset with the id. fixed --- connect.py | 2 +- juser/user_api.py | 2 ++ juser/views.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/connect.py b/connect.py index 0dc6d57fc..2194a7a84 100755 --- a/connect.py +++ b/connect.py @@ -436,10 +436,10 @@ class Nav(object): """ def __init__(self, user): self.user = user - self.search_result = None self.user_perm = get_group_user_perm(self.user) self.perm_assets = sorted(self.user_perm.get('asset', []).keys(), key=lambda x: [int(num) for num in x.ip.split('.') if num.isdigit()]) + self.search_result = self.perm_assets self.perm_asset_groups = self.user_perm.get('asset_group', []) @staticmethod diff --git a/juser/user_api.py b/juser/user_api.py index f2964eade..d077659b4 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -181,6 +181,8 @@ def server_del_user(username): 删除系统上的某用户 """ bash('userdel -r -f %s' % username) + print('rm -f %s/%s_*.pem' % (os.path.join(KEY_DIR, 'user'), username)) + bash('rm -f %s/%s_*.pem' % (os.path.join(KEY_DIR, 'user'), username)) def get_display_msg(user, password='', ssh_key_pwd='', send_mail_need=False): diff --git a/juser/views.py b/juser/views.py index 90c3d2f53..81e854d85 100644 --- a/juser/views.py +++ b/juser/views.py @@ -254,7 +254,7 @@ def user_del(request): user = get_object(User, id=user_id) if user and user.username != 'admin': logger.debug(u"删除用户 %s " % user.username) - bash('userdel -r %s' % user.username) + server_del_user(user.username) user.delete() return HttpResponse('删除成功') From 777997202b80b5bbdf026ab64402f0ab3ec645c8 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 5 Apr 2016 22:37:55 +0800 Subject: [PATCH 2/3] patch again with 1f09a40c772e8d65908735e048608ec1ba8b95d0 print => debug --- juser/user_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juser/user_api.py b/juser/user_api.py index d077659b4..03ed65938 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -181,7 +181,7 @@ def server_del_user(username): 删除系统上的某用户 """ bash('userdel -r -f %s' % username) - print('rm -f %s/%s_*.pem' % (os.path.join(KEY_DIR, 'user'), username)) + logger.debug('rm -f %s/%s_*.pem' % (os.path.join(KEY_DIR, 'user'), username)) bash('rm -f %s/%s_*.pem' % (os.path.join(KEY_DIR, 'user'), username)) From 35cc9661323269cc9a7cb6b29b7258388fbad889 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 5 Apr 2016 23:44:01 +0800 Subject: [PATCH 3/3] change(info) Modify some nav info May be clearly. --- connect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connect.py b/connect.py index 2194a7a84..e9bcee094 100755 --- a/connect.py +++ b/connect.py @@ -450,11 +450,11 @@ class Nav(object): """ msg = """\n\033[1;32m### 欢迎使用Jumpserver开源跳板机系统 ### \033[0m - 1) 输入 \033[32mID\033[0m 直接登录. - 2) 输入 \033[32m/\033[0m + \033[32mIP, 主机名 or 备注 \033[0m搜索. + 1) 输入 \033[32mID\033[0m 直接登录 或 输入\033[32m部分 IP,主机名,备注\033[0m 进行搜索登录(如果唯一). + 2) 输入 \033[32m/\033[0m + \033[32mIP, 主机名 or 备注 \033[0m搜索. 如: /ip 3) 输入 \033[32mP/p\033[0m 显示您有权限的主机. 4) 输入 \033[32mG/g\033[0m 显示您有权限的主机组. - 5) 输入 \033[32mG/g\033[0m\033[0m + \033[32m组ID\033[0m 显示该组下主机. + 5) 输入 \033[32mG/g\033[0m\033[0m + \033[32m组ID\033[0m 显示该组下主机. 如: g1 6) 输入 \033[32mE/e\033[0m 批量执行命令. 7) 输入 \033[32mU/u\033[0m 批量上传文件. 8) 输入 \033[32mD/d\033[0m 批量下载文件.