GT-3187 GhidraServer jaas config params strike back

This commit is contained in:
dev747368 2019-10-03 14:26:53 -04:00
parent 0077735568
commit 2826eb2807

View file

@ -529,10 +529,22 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
String rootPath = null;
int defaultPasswordExpiration = -1;
boolean autoProvision = false;
String jaasConfigFileStr = null;
File jaasConfigFile = null;
// Network name resolution disabled by default
InetNameLookup.setLookupEnabled(false);
// Initialize application
try {
ApplicationLayout layout = new GhidraServerApplicationLayout();
ApplicationConfiguration configuration = new ApplicationConfiguration();
configuration.setInitializeLogging(false);
Application.initializeApplication(layout, configuration);
}
catch (IOException e) {
System.err.println("Failed to initialize the application!");
System.exit(-1);
}
// Process command line options
for (int i = 0; i < args.length; i++) {
@ -635,8 +647,10 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
}
}
else if (s.startsWith("-jaas")) {
String jaasConfigFileStr;
if (s.length() == 5) {
jaasConfigFileStr = ((i + 1) < args.length - 1) ? args[++i] : "";
i++;
jaasConfigFileStr = (i < args.length) ? args[i] : "";
}
else {
jaasConfigFileStr = s.substring(5);
@ -646,6 +660,13 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
displayUsage("Missing -jaas config file path argument");
System.exit(-1);
}
jaasConfigFile = getServerCfgFile(jaasConfigFileStr);
if (!jaasConfigFile.isFile()) {
displayUsage(
"JAAS config file (-jaas <configfile>) does not exist or is not file: " +
jaasConfigFile.getAbsolutePath());
System.exit(-1);
}
}
else if (s.equals("-autoProvision")) {
autoProvision = true;
@ -664,18 +685,6 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
System.exit(-1);
}
// Initialize application
try {
ApplicationLayout layout = new GhidraServerApplicationLayout();
ApplicationConfiguration configuration = new ApplicationConfiguration();
configuration.setInitializeLogging(false);
Application.initializeApplication(layout, configuration);
}
catch (IOException e) {
System.err.println("Failed to initialize the application!");
System.exit(-1);
}
File serverRoot = new File(rootPath);
if (!serverRoot.isAbsolute()) {
ResourceFile installRoot = Application.getInstallationDirectory();
@ -686,19 +695,11 @@ public class GhidraServer extends UnicastRemoteObject implements GhidraServerHan
serverRoot = new File(installRoot.getFile(false), rootPath);
}
File jaasConfigFile = null;
if (authMode == JAAS_LOGIN) {
if (jaasConfigFileStr == null) {
if (jaasConfigFile == null) {
displayUsage("JAAS config file argument (-jaas <configfile>) not specified");
System.exit(-1);
}
jaasConfigFile = getServerCfgFile(jaasConfigFileStr);
if (!jaasConfigFile.isFile()) {
displayUsage(
"JAAS config file (-jaas <configfile>) does not exist or is not file: " +
jaasConfigFile.getAbsolutePath());
System.exit(-1);
}
}
try {