From c4fb6482cc43d3844150f19fc0409c1db9c6542e Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 21 Jun 2022 01:18:19 -0400 Subject: [PATCH 1/8] Fix sec bug with server creation roles Retain current java version in dropdown. --- app/classes/web/panel_handler.py | 33 ++++++++++++++++--- app/classes/web/server_handler.py | 11 ++++++- .../templates/panel/server_config.html | 9 ++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index a29908d9..48f93132 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -633,6 +633,24 @@ class PanelHandler(BaseHandler): ) return page_data["java_versions"] = Helpers.find_java_installs() + server_obj: Servers = self.controller.servers.get_server_obj(server_id) + current_java = shlex.split(server_obj.execution_command)[0] + page_java = [] + page_data["java_versions"].append("java") + page_data["current_java"] = current_java + for version in page_data["java_versions"]: + temp_version = version + "/bin/java" + if os.name == "nt": + if version == "java" and current_java != version: + page_java.append(version) + else: + if temp_version != current_java and version != "java": + page_java.append(version) + else: + if version != current_java: + page_java.append(version) + + page_data["java_versions"] = page_java if subpage == "files": if ( @@ -1371,10 +1389,17 @@ class PanelHandler(BaseHandler): return execution_list = shlex.split(execution_command) if java_selection: - if self.helper.is_os_windows(): - execution_list[0] = '"' + java_selection + '/bin/java"' + if java_selection != "java": + if ( + self.helper.is_os_windows() + and not "/bin/java" in java_selection + ): + if not "/bin/java" in java_selection: + execution_list[0] = '"' + java_selection + '/bin/java"' + else: + execution_list[0] = '"' + java_selection + '"' else: - execution_list[0] = '"' + java_selection + '"' + execution_list[0] = "java" execution_command = "" for item in execution_list: execution_command += item + " " @@ -1407,7 +1432,7 @@ class PanelHandler(BaseHandler): server_obj.path = server_obj.path server_obj.log_path = server_obj.log_path server_obj.executable = server_obj.executable - server_obj.execution_command = server_obj.execution_command + server_obj.execution_command = execution_command server_obj.server_ip = server_obj.server_ip server_obj.server_port = server_obj.server_port server_obj.executable_update_url = server_obj.executable_update_url diff --git a/app/classes/web/server_handler.py b/app/classes/web/server_handler.py index 4d961ad9..3505e1de 100644 --- a/app/classes/web/server_handler.py +++ b/app/classes/web/server_handler.py @@ -17,6 +17,15 @@ logger = logging.getLogger(__name__) class ServerHandler(BaseHandler): + def get_user_roles(self): + user_roles = {} + for user_id in self.controller.users.get_all_user_ids(): + user_roles_list = self.controller.users.get_user_roles_names(user_id) + # user_servers = + # self.controller.servers.get_authorized_servers(user.user_id) + user_roles[user_id] = user_roles_list + return user_roles + @tornado.web.authenticated def get(self, page): ( @@ -283,7 +292,7 @@ class ServerHandler(BaseHandler): if not superuser: user_roles = self.controller.roles.get_all_roles() else: - user_roles = self.controller.roles.get_all_roles() + user_roles = self.get_user_roles() server = bleach.clean(self.get_argument("server", "")) server_name = bleach.clean(self.get_argument("server_name", "")) min_mem = bleach.clean(self.get_argument("min_memory", "")) diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index 6fbfd080..49e5861b 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -81,11 +81,18 @@ {% end %}
+ {% end %} + {% if data['super_user'] %}
+ {% else %} +