Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
0481e83e
Commit
0481e83e
authored
Apr 06, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into windowResize
parents
ff8b5bd6
35cc9661
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
9 deletions
+15
-9
connect.py
connect.py
+11
-8
install.py
install/install.py
+1
-0
user_api.py
juser/user_api.py
+2
-0
views.py
juser/views.py
+1
-1
No files found.
connect.py
View file @
0481e83e
...
@@ -436,10 +436,10 @@ class Nav(object):
...
@@ -436,10 +436,10 @@ class Nav(object):
"""
"""
def
__init__
(
self
,
user
):
def
__init__
(
self
,
user
):
self
.
user
=
user
self
.
user
=
user
self
.
search_result
=
None
self
.
user_perm
=
get_group_user_perm
(
self
.
user
)
self
.
user_perm
=
get_group_user_perm
(
self
.
user
)
self
.
perm_assets
=
sorted
(
self
.
user_perm
.
get
(
'asset'
,
[])
.
keys
(),
self
.
perm_assets
=
sorted
(
self
.
user_perm
.
get
(
'asset'
,
[])
.
keys
(),
key
=
lambda
x
:
[
int
(
num
)
for
num
in
x
.
ip
.
split
(
'.'
)
if
num
.
isdigit
()])
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'
,
[])
self
.
perm_asset_groups
=
self
.
user_perm
.
get
(
'asset_group'
,
[])
@staticmethod
@staticmethod
...
@@ -450,11 +450,11 @@ class Nav(object):
...
@@ -450,11 +450,11 @@ class Nav(object):
"""
"""
msg
=
"""
\n\033
[1;32m### 欢迎使用Jumpserver开源跳板机系统 ###
\033
[0m
msg
=
"""
\n\033
[1;32m### 欢迎使用Jumpserver开源跳板机系统 ###
\033
[0m
1) 输入
\033
[32mID
\033
[0m 直接登录.
1) 输入
\033
[32mID
\033
[0m 直接登录
或 输入
\033
[32m部分 IP,主机名,备注
\033
[0m 进行搜索登录(如果唯一)
.
2) 输入
\033
[32m/
\033
[0m +
\033
[32mIP, 主机名 or 备注
\033
[0m搜索.
2) 输入
\033
[32m/
\033
[0m +
\033
[32mIP, 主机名 or 备注
\033
[0m搜索.
如: /ip
3) 输入
\033
[32mP/p
\033
[0m 显示您有权限的主机.
3) 输入
\033
[32mP/p
\033
[0m 显示您有权限的主机.
4) 输入
\033
[32mG/g
\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 批量执行命令.
6) 输入
\033
[32mE/e
\033
[0m 批量执行命令.
7) 输入
\033
[32mU/u
\033
[0m 批量上传文件.
7) 输入
\033
[32mU/u
\033
[0m 批量上传文件.
8) 输入
\033
[32mD/d
\033
[0m 批量下载文件.
8) 输入
\033
[32mD/d
\033
[0m 批量下载文件.
...
@@ -470,7 +470,7 @@ class Nav(object):
...
@@ -470,7 +470,7 @@ class Nav(object):
gid
=
int
(
str_r
.
lstrip
(
'g'
))
gid
=
int
(
str_r
.
lstrip
(
'g'
))
# 获取资产组包含的资产
# 获取资产组包含的资产
asset_group
=
get_object
(
AssetGroup
,
id
=
gid
)
asset_group
=
get_object
(
AssetGroup
,
id
=
gid
)
if
asset_group
:
if
asset_group
and
asset_group
in
self
.
perm_asset_groups
:
self
.
search_result
=
list
(
asset_group
.
asset_set
.
all
())
self
.
search_result
=
list
(
asset_group
.
asset_set
.
all
())
else
:
else
:
color_print
(
'没有该资产组或没有权限'
)
color_print
(
'没有该资产组或没有权限'
)
...
@@ -489,8 +489,10 @@ class Nav(object):
...
@@ -489,8 +489,10 @@ class Nav(object):
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
# 匹配 ip, hostname, 备注
# 匹配 ip, hostname, 备注
self
.
search_result
=
[
asset
for
asset
in
self
.
perm_assets
if
str_r
in
str
(
asset
.
ip
)
str_r
=
str_r
.
lower
()
or
str_r
in
str
(
asset
.
hostname
)
or
str_r
in
str
(
asset
.
comment
)]
self
.
search_result
=
[
asset
for
asset
in
self
.
perm_assets
if
str_r
in
str
(
asset
.
ip
)
.
lower
()
or
str_r
in
str
(
asset
.
hostname
)
.
lower
()
or
str_r
in
str
(
asset
.
comment
)
.
lower
()]
else
:
else
:
# 如果没有输入就展现所有
# 如果没有输入就展现所有
self
.
search_result
=
self
.
perm_assets
self
.
search_result
=
self
.
perm_assets
...
@@ -532,8 +534,8 @@ class Nav(object):
...
@@ -532,8 +534,8 @@ class Nav(object):
color_print
(
'没有映射用户'
,
'red'
)
color_print
(
'没有映射用户'
,
'red'
)
return
return
ssh_tty
=
SshTty
(
login_user
,
asset
,
role
)
print
(
'Connecting
%
s ...'
%
asset
.
hostname
)
print
(
'Connecting
%
s ...'
%
asset
.
hostname
)
ssh_tty
=
SshTty
(
login_user
,
asset
,
role
)
ssh_tty
.
connect
()
ssh_tty
.
connect
()
except
(
KeyError
,
ValueError
):
except
(
KeyError
,
ValueError
):
color_print
(
'请输入正确ID'
,
'red'
)
color_print
(
'请输入正确ID'
,
'red'
)
...
@@ -781,6 +783,7 @@ def main():
...
@@ -781,6 +783,7 @@ def main():
else
:
else
:
nav
.
search
(
option
)
nav
.
search
(
option
)
if
len
(
nav
.
search_result
)
==
1
:
if
len
(
nav
.
search_result
)
==
1
:
print
(
'Only match Host:
%
s '
%
nav
.
search_result
[
0
]
.
hostname
)
nav
.
try_connect
()
nav
.
try_connect
()
else
:
else
:
nav
.
print_search_result
()
nav
.
print_search_result
()
...
...
install/install.py
View file @
0481e83e
...
@@ -238,6 +238,7 @@ class PreSetup(object):
...
@@ -238,6 +238,7 @@ class PreSetup(object):
def
_require_pip
(
self
):
def
_require_pip
(
self
):
color_print
(
'开始安装依赖pip包'
,
'green'
)
color_print
(
'开始安装依赖pip包'
,
'green'
)
bash
(
'pip uninstall -y pycrypto'
)
bash
(
'pip uninstall -y pycrypto'
)
bash
(
'rm -rf /usr/lib64/python2.6/site-packages/Crypto/'
)
ret_code
=
bash
(
'pip install -r requirements.txt'
)
ret_code
=
bash
(
'pip install -r requirements.txt'
)
self
.
check_bash_return
(
ret_code
,
"安装JumpServer 依赖的python库失败!"
)
self
.
check_bash_return
(
ret_code
,
"安装JumpServer 依赖的python库失败!"
)
...
...
juser/user_api.py
View file @
0481e83e
...
@@ -181,6 +181,8 @@ def server_del_user(username):
...
@@ -181,6 +181,8 @@ def server_del_user(username):
删除系统上的某用户
删除系统上的某用户
"""
"""
bash
(
'userdel -r -f
%
s'
%
username
)
bash
(
'userdel -r -f
%
s'
%
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
))
def
get_display_msg
(
user
,
password
=
''
,
ssh_key_pwd
=
''
,
send_mail_need
=
False
):
def
get_display_msg
(
user
,
password
=
''
,
ssh_key_pwd
=
''
,
send_mail_need
=
False
):
...
...
juser/views.py
View file @
0481e83e
...
@@ -254,7 +254,7 @@ def user_del(request):
...
@@ -254,7 +254,7 @@ def user_del(request):
user
=
get_object
(
User
,
id
=
user_id
)
user
=
get_object
(
User
,
id
=
user_id
)
if
user
and
user
.
username
!=
'admin'
:
if
user
and
user
.
username
!=
'admin'
:
logger
.
debug
(
u"删除用户
%
s "
%
user
.
username
)
logger
.
debug
(
u"删除用户
%
s "
%
user
.
username
)
bash
(
'userdel -r
%
s'
%
user
.
username
)
server_del_user
(
user
.
username
)
user
.
delete
()
user
.
delete
()
return
HttpResponse
(
'删除成功'
)
return
HttpResponse
(
'删除成功'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment