Browse Source

Merge branch 'v3' of github.com:jumpserver/jumpserver into v3

pull/9235/head
ibuler 2 years ago
parent
commit
a377317d6e
  1. 1
      Dockerfile
  2. 1
      Dockerfile.loong64
  3. 1
      apps/rbac/const.py
  4. 4
      apps/terminal/signal_handlers.py
  5. 17
      apps/terminal/utils/db_port_mapper.py

1
Dockerfile

@ -36,6 +36,7 @@ ARG TOOLS=" \
default-mysql-client \
locales \
openssh-client \
procps \
sshpass \
telnet \
unzip \

1
Dockerfile.loong64

@ -36,6 +36,7 @@ ARG TOOLS=" \
default-mysql-client \
locales \
openssh-client \
procps \
sshpass \
telnet \
unzip \

1
apps/rbac/const.py

@ -94,6 +94,7 @@ exclude_permissions = (
('terminal', 'sessionsharing', 'view,add,change,delete', 'sessionsharing'),
('terminal', 'session', 'delete,share', 'session'),
('terminal', 'session', 'delete,change', 'command'),
('applications', '*', '*', '*'),
)

4
apps/terminal/signal_handlers.py

@ -42,10 +42,10 @@ def on_applet_create(sender, instance, created=False, **kwargs):
@receiver(django_ready)
def init_db_port_mapper(sender, **kwargs):
def check_db_port_mapper(sender, **kwargs):
logger.info('Init db port mapper')
try:
db_port_manager.init()
db_port_manager.check()
except (ProgrammingError,) as e:
pass

17
apps/terminal/utils/db_port_mapper.py

@ -34,9 +34,22 @@ class DBPortManager(object):
def magnus_listen_port_range(self):
return settings.MAGNUS_PORTS
def init(self):
@staticmethod
def fetch_dbs():
with tmp_to_root_org():
db_ids = Asset.objects.filter(platform__category=Category.DATABASE).values_list('id', flat=True)
dbs = Asset.objects.filter(platform__category=Category.DATABASE).order_by('id')
return dbs
def check(self):
dbs = self.fetch_dbs()
for db in dbs:
port = self.get_port_by_db(db, raise_exception=False)
if not port:
self.add(db)
def init(self):
dbs = self.fetch_dbs()
db_ids = dbs.values_list('id', flat=True)
db_ids = [str(i) for i in db_ids]
mapper = dict(zip(self.all_available_ports, list(db_ids)))
self.set_mapper(mapper)

Loading…
Cancel
Save