Check for Oracle Java before changing start string

This commit is contained in:
Andrew 2022-06-17 19:08:57 -04:00
parent b6104e283b
commit a2ad23548c

View File

@ -239,18 +239,22 @@ class ServerInstance:
"Detected nebulous java in start command. "
"Replacing with full java path."
)
which_java_raw = self.helper.which_java()
java_path = which_java_raw + "\\bin\\java"
if str(which_java_raw) != str(self.helper.get_servers_root_dir) or str(
self.helper.get_servers_root_dir
) in str(which_java_raw):
self.server_command[0] = java_path
else:
logger.critcal(
"Possible attack detected. User attempted to exec "
"java binary from server directory."
if "/Oracle/Java/" in str(shutil.which("java")):
logger.info(
"Oracle Java detected. Changing start command to avoid re-exec."
)
return
which_java_raw = self.helper.which_java()
java_path = which_java_raw + "\\bin\\java"
if str(which_java_raw) != str(self.helper.get_servers_root_dir) or str(
self.helper.get_servers_root_dir
) in str(which_java_raw):
self.server_command[0] = java_path
else:
logger.critcal(
"Possible attack detected. User attempted to exec "
"java binary from server directory."
)
return
self.server_path = Helpers.get_os_understandable_path(self.settings["path"])
# let's do some quick checking to make sure things actually exists