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
Show 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):
if
ok
:
return
Response
(
"ok"
)
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):
if
len
(
v
)
==
0
:
return
self
if
k
.
find
(
"__in"
)
>=
0
:
_k
=
k
.
split
(
'__'
)[
0
]
in_kwargs
[
_k
]
=
v
else
:
in_kwargs
[
k
]
=
v
for
k
in
in_kwargs
:
kwargs
.
pop
(
k
)
...
...
@@ -45,17 +48,16 @@ class AssetUserQuerySet(list):
if
len
(
in_kwargs
)
==
0
:
return
self
for
i
in
self
:
matched
=
Tru
e
matched
=
Fals
e
for
k
,
v
in
in_kwargs
.
items
():
key
=
k
.
split
(
'__'
)[
0
]
attr
=
getattr
(
i
,
key
,
None
)
attr
=
getattr
(
i
,
k
,
None
)
# 如果属性或者value中是uuid,则转换成string
if
isinstance
(
v
[
0
],
uuid
.
UUID
):
v
=
[
str
(
i
)
for
i
in
v
]
if
isinstance
(
attr
,
uuid
.
UUID
):
attr
=
str
(
attr
)
if
attr
not
in
v
:
matched
=
Fals
e
if
v
in
attr
:
matched
=
Tru
e
if
matched
:
queryset
.
append
(
i
)
return
AssetUserQuerySet
(
queryset
)
...
...
apps/assets/models/domain.py
View file @
82b9c251
...
...
@@ -3,9 +3,9 @@
import
uuid
import
random
import
re
import
paramiko
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -63,6 +63,9 @@ class Gateway(AssetUser):
def
test_connective
(
self
,
local_port
=
None
):
if
local_port
is
None
:
local_port
=
self
.
port
if
not
re
.
match
(
r'\w+$'
,
self
.
password
):
return
False
,
_
(
"Password should not contain special characters"
)
client
=
paramiko
.
SSHClient
()
client
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
proxy
=
paramiko
.
SSHClient
()
...
...
apps/assets/templates/assets/domain_gateway_list.html
View file @
82b9c251
...
...
@@ -139,7 +139,7 @@ $(document).ready(function(){
method
:
"POST"
,
body
:
JSON
.
stringify
({
'port'
:
parseInt
(
data
.
port
)}),
success_message
:
"{% trans 'Can be connected' %}"
,
fail_message
:
"{% trans 'The connection fails' %}"
{
#
fail_message
:
"{% trans 'The connection fails' %}"
#
}
})
});
</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 @@
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
django.conf
import
settings
from
common.permissions
import
IsSuperUser
,
WithBootstrapToken
...
...
@@ -17,6 +18,9 @@ class TerminalViewSet(viewsets.ModelViewSet):
queryset
=
Terminal
.
objects
.
filter
(
is_deleted
=
False
)
serializer_class
=
serializers
.
TerminalSerializer
permission_classes
=
[
IsSuperUser
]
http_method_names
=
[
'get'
,
'put'
,
'patch'
,
'delete'
,
'head'
,
'options'
,
'trace'
]
class
TerminalRegistrationApi
(
generics
.
CreateAPIView
):
...
...
@@ -29,6 +33,9 @@ class TerminalRegistrationApi(generics.CreateAPIView):
serializer
=
serializers
.
TerminalSerializer
(
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
)
terminal
=
serializer
.
save
()
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):
valid
=
super
()
.
is_valid
(
raise_exception
=
raise_exception
)
if
not
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'
)}
kwargs
=
{
'data'
:
data
}
if
self
.
instance
and
self
.
instance
.
user
:
...
...
jms
View file @
82b9c251
...
...
@@ -114,7 +114,7 @@ def check_pid(pid):
""" Check For the existence of a unix pid. """
try
:
os
.
kill
(
pid
,
0
)
except
OSError
:
except
(
OSError
,
ProcessLookupError
)
:
return
False
else
:
return
True
...
...
@@ -231,6 +231,9 @@ def get_start_worker_kwargs(queue, num):
if
os
.
getuid
()
==
0
:
os
.
environ
.
setdefault
(
'C_FORCE_ROOT'
,
'1'
)
server_hostname
=
os
.
environ
.
get
(
"SERVER_HOSTNAME"
)
if
not
server_hostname
:
server_hostname
=
'
%
h'
cmd
=
[
'celery'
,
'worker'
,
...
...
@@ -238,7 +241,7 @@ def get_start_worker_kwargs(queue, num):
'-l'
,
'INFO'
,
'-c'
,
str
(
num
),
'-Q'
,
queue
,
'-n'
,
'{}@
%
h'
.
format
(
queu
e
)
'-n'
,
'{}@
{}'
.
format
(
queue
,
server_hostnam
e
)
]
return
{
"cmd"
:
cmd
,
"cwd"
:
APPS_DIR
}
...
...
@@ -437,6 +440,12 @@ def stop_service(srv, sig=15):
print
(
"Stop service: {}"
.
format
(
s
),
end
=
''
)
pid
=
get_pid
(
s
)
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
):
if
i
==
STOP_TIMEOUT
-
1
:
print
(
"
\033
[31m Error
\033
[0m"
)
...
...
@@ -447,9 +456,6 @@ def stop_service(srv, sig=15):
time
.
sleep
(
1
)
continue
with
LOCK
:
processes
.
pop
(
s
,
None
)
if
srv
==
"all"
:
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