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
17e89bb5
Commit
17e89bb5
authored
Apr 19, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
һbug
parent
d5fba23d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
connect.py
connect.py
+8
-1
api.py
jumpserver/api.py
+5
-1
No files found.
connect.py
View file @
17e89bb5
...
@@ -188,8 +188,12 @@ def get_user_hostgroup_host(username, gid):
...
@@ -188,8 +188,12 @@ def get_user_hostgroup_host(username, gid):
def
verify_connect
(
username
,
part_ip
):
def
verify_connect
(
username
,
part_ip
):
ip_matched
=
[]
ip_matched
=
[]
try
:
hosts_attr
=
get_user_host
(
username
)
hosts_attr
=
get_user_host
(
username
)
hosts
=
hosts_attr
.
values
()
hosts
=
hosts_attr
.
values
()
except
ServerError
,
e
:
color_print
(
e
,
'red'
)
return
False
for
ip_info
in
hosts
:
for
ip_info
in
hosts
:
for
info
in
ip_info
[
1
:]:
for
info
in
ip_info
[
1
:]:
if
part_ip
in
info
:
if
part_ip
in
info
:
...
@@ -217,7 +221,11 @@ def print_prompt():
...
@@ -217,7 +221,11 @@ def print_prompt():
def
print_user_host
(
username
):
def
print_user_host
(
username
):
try
:
hosts_attr
=
get_user_host
(
username
)
hosts_attr
=
get_user_host
(
username
)
except
ServerError
,
e
:
color_print
(
e
,
'red'
)
return
hosts
=
hosts_attr
.
keys
()
hosts
=
hosts_attr
.
keys
()
hosts
.
sort
()
hosts
.
sort
()
for
ip
in
hosts
:
for
ip
in
hosts
:
...
@@ -267,7 +275,6 @@ def connect(username, password, host, port, login_name):
...
@@ -267,7 +275,6 @@ def connect(username, password, host, port, login_name):
global
channel
global
channel
win_size
=
get_win_size
()
win_size
=
get_win_size
()
channel
=
ssh
.
invoke_shell
(
height
=
win_size
[
0
],
width
=
win_size
[
1
])
channel
=
ssh
.
invoke_shell
(
height
=
win_size
[
0
],
width
=
win_size
[
1
])
#channel.resize_pty(height=win_size[0], width=win_size[1])
try
:
try
:
signal
.
signal
(
signal
.
SIGWINCH
,
set_win_size
)
signal
.
signal
(
signal
.
SIGWINCH
,
set_win_size
)
except
:
except
:
...
...
jumpserver/api.py
View file @
17e89bb5
...
@@ -349,7 +349,9 @@ def get_user_host(username):
...
@@ -349,7 +349,9 @@ def get_user_host(username):
"""Get the hosts of under the user control."""
"""Get the hosts of under the user control."""
hosts_attr
=
{}
hosts_attr
=
{}
asset_all
=
user_perm_asset_api
(
username
)
asset_all
=
user_perm_asset_api
(
username
)
user
=
User
.
objects
.
get
(
username
=
username
)
user
=
User
.
objects
.
filter
(
username
=
username
)
if
user
:
user
=
user
[
0
]
for
asset
in
asset_all
:
for
asset
in
asset_all
:
alias
=
AssetAlias
.
objects
.
filter
(
user
=
user
,
host
=
asset
)
alias
=
AssetAlias
.
objects
.
filter
(
user
=
user
,
host
=
asset
)
if
alias
and
alias
[
0
]
.
alias
!=
''
:
if
alias
and
alias
[
0
]
.
alias
!=
''
:
...
@@ -357,6 +359,8 @@ def get_user_host(username):
...
@@ -357,6 +359,8 @@ def get_user_host(username):
else
:
else
:
hosts_attr
[
asset
.
ip
]
=
[
asset
.
id
,
asset
.
ip
,
asset
.
comment
]
hosts_attr
[
asset
.
ip
]
=
[
asset
.
id
,
asset
.
ip
,
asset
.
comment
]
return
hosts_attr
return
hosts_attr
else
:
raise
ServerError
(
'User
%
s does not exit!'
%
username
)
def
get_connect_item
(
username
,
ip
):
def
get_connect_item
(
username
,
ip
):
...
...
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