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
f73ba9cc
Commit
f73ba9cc
authored
Dec 26, 2014
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
显示id
parent
4eec31e4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
connect.py
connect.py
+8
-8
No files found.
connect.py
View file @
f73ba9cc
...
...
@@ -151,7 +151,7 @@ def posix_shell(chan, user, host):
def
get_user_host
(
username
):
hosts_
comments
=
{}
hosts_
attr
=
{}
try
:
user
=
User
.
objects
.
get
(
username
=
username
)
except
ObjectDoesNotExist
:
...
...
@@ -159,10 +159,10 @@ def get_user_host(username):
else
:
perm_all
=
user
.
permission_set
.
all
()
for
perm
in
perm_all
:
hosts_
comments
[
perm
.
asset
.
ip
]
=
perm
.
asset
.
comment
hosts
=
hosts_
comments
.
keys
()
hosts_
attr
[
perm
.
asset
.
ip
]
=
[
perm
.
asset
.
id
,
perm
.
asset
.
comment
]
hosts
=
hosts_
attr
.
keys
()
hosts
.
sort
()
return
hosts_
comments
,
hosts
return
hosts_
attr
,
hosts
def
get_connect_item
(
username
,
ip
):
...
...
@@ -190,14 +190,14 @@ def get_connect_item(username, ip):
def
verify_connect
(
username
,
part_ip
):
ip_matched
=
[]
hosts_
comments
,
hosts
=
get_user_host
(
username
)
hosts_
mix
,
hosts
=
get_user_host
(
username
)
for
ip
in
hosts
:
if
part_ip
in
ip
:
ip_matched
.
append
(
ip
)
if
len
(
ip_matched
)
>
1
:
for
ip
in
ip_matched
:
print
'
%
s --
%
s'
%
(
ip
,
hosts_comments
[
ip
])
print
'
[
%
s]
%
s --
%
s'
%
(
hosts_mix
[
ip
][
0
],
ip
,
hosts_mix
[
ip
][
1
])
elif
len
(
ip_matched
)
<
1
:
red_print
(
'No Permission or No host.'
)
else
:
...
...
@@ -220,9 +220,9 @@ def print_prompt():
def
print_user_host
(
username
):
hosts_
comments
,
hosts
=
get_user_host
(
username
)
hosts_
attr
,
hosts
=
get_user_host
(
username
)
for
ip
in
hosts
:
print
'
%
s --
%
s'
%
(
ip
,
hosts_comments
[
ip
])
print
'
[
%
s]
%
s --
%
s'
%
(
hosts_attr
[
ip
][
0
],
ip
,
hosts_attr
[
ip
][
1
])
def
connect
(
username
,
password
,
host
,
port
):
...
...
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