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
82b9c251
Commit
82b9c251
authored
Nov 20, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
[Update] Merge it
parents
66b8e59a
d563a11a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
16 deletions
+31
-16
domain.py
apps/assets/api/domain.py
+1
-1
base.py
apps/assets/backends/base.py
+7
-5
domain.py
apps/assets/models/domain.py
+4
-1
domain_gateway_list.html
apps/assets/templates/assets/domain_gateway_list.html
+1
-1
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
terminal.py
apps/terminal/api_v2/terminal.py
+7
-0
terminal.py
apps/terminal/serializers_v2/terminal.py
+0
-3
jms
jms
+11
-5
No files found.
apps/assets/api/domain.py
View file @
82b9c251
...
@@ -44,4 +44,4 @@ class GatewayTestConnectionApi(SingleObjectMixin, APIView):
...
@@ -44,4 +44,4 @@ class GatewayTestConnectionApi(SingleObjectMixin, APIView):
if
ok
:
if
ok
:
return
Response
(
"ok"
)
return
Response
(
"ok"
)
else
:
else
:
return
Response
({
"
failed"
:
e
},
status
=
404
)
return
Response
({
"
error"
:
e
},
status
=
400
)
apps/assets/backends/base.py
View file @
82b9c251
...
@@ -38,6 +38,9 @@ class AssetUserQuerySet(list):
...
@@ -38,6 +38,9 @@ class AssetUserQuerySet(list):
if
len
(
v
)
==
0
:
if
len
(
v
)
==
0
:
return
self
return
self
if
k
.
find
(
"__in"
)
>=
0
:
if
k
.
find
(
"__in"
)
>=
0
:
_k
=
k
.
split
(
'__'
)[
0
]
in_kwargs
[
_k
]
=
v
else
:
in_kwargs
[
k
]
=
v
in_kwargs
[
k
]
=
v
for
k
in
in_kwargs
:
for
k
in
in_kwargs
:
kwargs
.
pop
(
k
)
kwargs
.
pop
(
k
)
...
@@ -45,17 +48,16 @@ class AssetUserQuerySet(list):
...
@@ -45,17 +48,16 @@ class AssetUserQuerySet(list):
if
len
(
in_kwargs
)
==
0
:
if
len
(
in_kwargs
)
==
0
:
return
self
return
self
for
i
in
self
:
for
i
in
self
:
matched
=
Tru
e
matched
=
Fals
e
for
k
,
v
in
in_kwargs
.
items
():
for
k
,
v
in
in_kwargs
.
items
():
key
=
k
.
split
(
'__'
)[
0
]
attr
=
getattr
(
i
,
k
,
None
)
attr
=
getattr
(
i
,
key
,
None
)
# 如果属性或者value中是uuid,则转换成string
# 如果属性或者value中是uuid,则转换成string
if
isinstance
(
v
[
0
],
uuid
.
UUID
):
if
isinstance
(
v
[
0
],
uuid
.
UUID
):
v
=
[
str
(
i
)
for
i
in
v
]
v
=
[
str
(
i
)
for
i
in
v
]
if
isinstance
(
attr
,
uuid
.
UUID
):
if
isinstance
(
attr
,
uuid
.
UUID
):
attr
=
str
(
attr
)
attr
=
str
(
attr
)
if
attr
not
in
v
:
if
v
in
attr
:
matched
=
Fals
e
matched
=
Tru
e
if
matched
:
if
matched
:
queryset
.
append
(
i
)
queryset
.
append
(
i
)
return
AssetUserQuerySet
(
queryset
)
return
AssetUserQuerySet
(
queryset
)
...
...
apps/assets/models/domain.py
View file @
82b9c251
...
@@ -3,9 +3,9 @@
...
@@ -3,9 +3,9 @@
import
uuid
import
uuid
import
random
import
random
import
re
import
paramiko
import
paramiko
from
django.db
import
models
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -63,6 +63,9 @@ class Gateway(AssetUser):
...
@@ -63,6 +63,9 @@ class Gateway(AssetUser):
def
test_connective
(
self
,
local_port
=
None
):
def
test_connective
(
self
,
local_port
=
None
):
if
local_port
is
None
:
if
local_port
is
None
:
local_port
=
self
.
port
local_port
=
self
.
port
if
not
re
.
match
(
r'\w+$'
,
self
.
password
):
return
False
,
_
(
"Password should not contain special characters"
)
client
=
paramiko
.
SSHClient
()
client
=
paramiko
.
SSHClient
()
client
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
client
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
proxy
=
paramiko
.
SSHClient
()
proxy
=
paramiko
.
SSHClient
()
...
...
apps/assets/templates/assets/domain_gateway_list.html
View file @
82b9c251
...
@@ -139,7 +139,7 @@ $(document).ready(function(){
...
@@ -139,7 +139,7 @@ $(document).ready(function(){
method
:
"POST"
,
method
:
"POST"
,
body
:
JSON
.
stringify
({
'port'
:
parseInt
(
data
.
port
)}),
body
:
JSON
.
stringify
({
'port'
:
parseInt
(
data
.
port
)}),
success_message
:
"{% trans 'Can be connected' %}"
,
success_message
:
"{% trans 'Can be connected' %}"
,
fail_message
:
"{% trans 'The connection fails' %}"
{
#
fail_message
:
"{% trans 'The connection fails' %}"
#
}
})
})
});
});
</script>
</script>
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
82b9c251
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
82b9c251
This diff is collapsed.
Click to expand it.
apps/terminal/api_v2/terminal.py
View file @
82b9c251
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
status
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
django.conf
import
settings
from
common.permissions
import
IsSuperUser
,
WithBootstrapToken
from
common.permissions
import
IsSuperUser
,
WithBootstrapToken
...
@@ -17,6 +18,9 @@ class TerminalViewSet(viewsets.ModelViewSet):
...
@@ -17,6 +18,9 @@ class TerminalViewSet(viewsets.ModelViewSet):
queryset
=
Terminal
.
objects
.
filter
(
is_deleted
=
False
)
queryset
=
Terminal
.
objects
.
filter
(
is_deleted
=
False
)
serializer_class
=
serializers
.
TerminalSerializer
serializer_class
=
serializers
.
TerminalSerializer
permission_classes
=
[
IsSuperUser
]
permission_classes
=
[
IsSuperUser
]
http_method_names
=
[
'get'
,
'put'
,
'patch'
,
'delete'
,
'head'
,
'options'
,
'trace'
]
class
TerminalRegistrationApi
(
generics
.
CreateAPIView
):
class
TerminalRegistrationApi
(
generics
.
CreateAPIView
):
...
@@ -29,6 +33,9 @@ class TerminalRegistrationApi(generics.CreateAPIView):
...
@@ -29,6 +33,9 @@ class TerminalRegistrationApi(generics.CreateAPIView):
serializer
=
serializers
.
TerminalSerializer
(
serializer
=
serializers
.
TerminalSerializer
(
data
=
data
,
context
=
{
'request'
:
request
}
data
=
data
,
context
=
{
'request'
:
request
}
)
)
if
not
settings
.
SECURITY_SERVICE_ACCOUNT_REGISTRATION
:
data
=
{
"error"
:
"service account registration disabled"
}
return
Response
(
data
=
data
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
serializer
.
is_valid
(
raise_exception
=
True
)
serializer
.
is_valid
(
raise_exception
=
True
)
terminal
=
serializer
.
save
()
terminal
=
serializer
.
save
()
sa_serializer
=
serializer
.
sa_serializer_class
(
instance
=
terminal
.
user
)
sa_serializer
=
serializer
.
sa_serializer_class
(
instance
=
terminal
.
user
)
...
...
apps/terminal/serializers_v2/terminal.py
View file @
82b9c251
...
@@ -28,9 +28,6 @@ class TerminalSerializer(serializers.ModelSerializer):
...
@@ -28,9 +28,6 @@ class TerminalSerializer(serializers.ModelSerializer):
valid
=
super
()
.
is_valid
(
raise_exception
=
raise_exception
)
valid
=
super
()
.
is_valid
(
raise_exception
=
raise_exception
)
if
not
valid
:
if
not
valid
:
return
valid
return
valid
if
not
settings
.
SECURITY_SERVICE_ACCOUNT_REGISTRATION
:
error
=
{
"error"
:
"service account registration disabled"
}
raise
serializers
.
ValidationError
(
error
)
data
=
{
'name'
:
self
.
validated_data
.
get
(
'name'
)}
data
=
{
'name'
:
self
.
validated_data
.
get
(
'name'
)}
kwargs
=
{
'data'
:
data
}
kwargs
=
{
'data'
:
data
}
if
self
.
instance
and
self
.
instance
.
user
:
if
self
.
instance
and
self
.
instance
.
user
:
...
...
jms
View file @
82b9c251
...
@@ -114,7 +114,7 @@ def check_pid(pid):
...
@@ -114,7 +114,7 @@ def check_pid(pid):
""" Check For the existence of a unix pid. """
""" Check For the existence of a unix pid. """
try
:
try
:
os
.
kill
(
pid
,
0
)
os
.
kill
(
pid
,
0
)
except
OSError
:
except
(
OSError
,
ProcessLookupError
)
:
return
False
return
False
else
:
else
:
return
True
return
True
...
@@ -231,6 +231,9 @@ def get_start_worker_kwargs(queue, num):
...
@@ -231,6 +231,9 @@ def get_start_worker_kwargs(queue, num):
if
os
.
getuid
()
==
0
:
if
os
.
getuid
()
==
0
:
os
.
environ
.
setdefault
(
'C_FORCE_ROOT'
,
'1'
)
os
.
environ
.
setdefault
(
'C_FORCE_ROOT'
,
'1'
)
server_hostname
=
os
.
environ
.
get
(
"SERVER_HOSTNAME"
)
if
not
server_hostname
:
server_hostname
=
'
%
h'
cmd
=
[
cmd
=
[
'celery'
,
'worker'
,
'celery'
,
'worker'
,
...
@@ -238,7 +241,7 @@ def get_start_worker_kwargs(queue, num):
...
@@ -238,7 +241,7 @@ def get_start_worker_kwargs(queue, num):
'-l'
,
'INFO'
,
'-l'
,
'INFO'
,
'-c'
,
str
(
num
),
'-c'
,
str
(
num
),
'-Q'
,
queue
,
'-Q'
,
queue
,
'-n'
,
'{}@
%
h'
.
format
(
queu
e
)
'-n'
,
'{}@
{}'
.
format
(
queue
,
server_hostnam
e
)
]
]
return
{
"cmd"
:
cmd
,
"cwd"
:
APPS_DIR
}
return
{
"cmd"
:
cmd
,
"cwd"
:
APPS_DIR
}
...
@@ -437,6 +440,12 @@ def stop_service(srv, sig=15):
...
@@ -437,6 +440,12 @@ def stop_service(srv, sig=15):
print
(
"Stop service: {}"
.
format
(
s
),
end
=
''
)
print
(
"Stop service: {}"
.
format
(
s
),
end
=
''
)
pid
=
get_pid
(
s
)
pid
=
get_pid
(
s
)
os
.
kill
(
pid
,
sig
)
os
.
kill
(
pid
,
sig
)
with
LOCK
:
process
=
processes
.
pop
(
s
,
None
)
if
process
is
None
:
print
(
"
\033
[31m No process found
\033
[0m"
)
continue
process
.
wait
(
1
)
for
i
in
range
(
STOP_TIMEOUT
):
for
i
in
range
(
STOP_TIMEOUT
):
if
i
==
STOP_TIMEOUT
-
1
:
if
i
==
STOP_TIMEOUT
-
1
:
print
(
"
\033
[31m Error
\033
[0m"
)
print
(
"
\033
[31m Error
\033
[0m"
)
...
@@ -447,9 +456,6 @@ def stop_service(srv, sig=15):
...
@@ -447,9 +456,6 @@ def stop_service(srv, sig=15):
time
.
sleep
(
1
)
time
.
sleep
(
1
)
continue
continue
with
LOCK
:
processes
.
pop
(
s
,
None
)
if
srv
==
"all"
:
if
srv
==
"all"
:
stop_daemon_service
()
stop_daemon_service
()
...
...
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