mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GT-2685 Improved Ghidra Server interface binding and remote address
identification. Minor fixes to database cleanup and project conversion.
This commit is contained in:
@@ -217,7 +217,7 @@ public class ClientUtil {
|
||||
excMsg = exc.toString();
|
||||
}
|
||||
if (exc instanceof IOException) {
|
||||
Msg.showError(ClientUtil.class, parent, title, excMsg);
|
||||
Msg.showError(ClientUtil.class, parent, title, excMsg, exc);
|
||||
}
|
||||
else {
|
||||
// show the stacktrace for non-IOException
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package ghidra.framework.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.net.UnknownHostException;
|
||||
import java.rmi.*;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
@@ -124,15 +123,16 @@ class ServerConnectTask extends Task {
|
||||
return name;
|
||||
}
|
||||
|
||||
private static void setOutgoingIpAddress(InetAddress destAddr, int serverPort)
|
||||
throws IOException {
|
||||
InetSocketAddress sockAddr = new InetSocketAddress(destAddr, serverPort);
|
||||
Socket s = new Socket();
|
||||
s.connect(sockAddr, 5000);
|
||||
String ip = s.getLocalAddress().getHostAddress();
|
||||
System.setProperty("java.rmi.server.hostname", ip);
|
||||
s.close();
|
||||
}
|
||||
// private static void setOutgoingIpAddress(InetAddress destAddr, int serverPort)
|
||||
// throws IOException {
|
||||
// // TODO: this may not be needed since we do not create remote objects on the client
|
||||
// InetSocketAddress sockAddr = new InetSocketAddress(destAddr, serverPort);
|
||||
// Socket s = new Socket();
|
||||
// s.connect(sockAddr, 5000);
|
||||
// String ip = s.getLocalAddress().getHostAddress();
|
||||
// System.setProperty("java.rmi.server.hostname", ip);
|
||||
// s.close();
|
||||
// }
|
||||
|
||||
private static boolean isSSLHandshakeCancelled(SSLHandshakeException e) throws IOException {
|
||||
if (e.getMessage().indexOf("bad_certificate") > 0) {
|
||||
@@ -158,9 +158,7 @@ class ServerConnectTask extends Task {
|
||||
*/
|
||||
public static GhidraServerHandle getGhidraServerHandle(ServerInfo server) throws IOException {
|
||||
|
||||
setOutgoingIpAddress(InetAddress.getByName(server.getServerName()), server.getPortNumber());
|
||||
Registry reg = LocateRegistry.getRegistry(server.getServerName(), server.getPortNumber());
|
||||
checkServerBindNames(reg);
|
||||
// setOutgoingIpAddress(InetAddress.getByName(server.getServerName()), server.getPortNumber());
|
||||
|
||||
GhidraServerHandle gsh = null;
|
||||
try {
|
||||
@@ -170,6 +168,18 @@ class ServerConnectTask extends Task {
|
||||
// for their keystore which should cancel any connection attempt
|
||||
testServerSSLConnection(server);
|
||||
|
||||
Registry reg;
|
||||
try {
|
||||
// attempt to connect with older Ghidra Server registry without using SSL/TLS
|
||||
reg = LocateRegistry.getRegistry(server.getServerName(), server.getPortNumber());
|
||||
checkServerBindNames(reg);
|
||||
}
|
||||
catch (IOException e) {
|
||||
reg = LocateRegistry.getRegistry(server.getServerName(), server.getPortNumber(),
|
||||
new SslRMIClientSocketFactory());
|
||||
checkServerBindNames(reg);
|
||||
}
|
||||
|
||||
gsh = (GhidraServerHandle) reg.lookup(GhidraServerHandle.BIND_NAME);
|
||||
gsh.checkCompatibility(GhidraServerHandle.INTERFACE_VERSION);
|
||||
}
|
||||
|
||||
@@ -229,9 +229,8 @@ public class PrivateDatabase extends Database {
|
||||
/**
|
||||
* If a cumulative change files exists, it will be deleted.
|
||||
* @throws IOException
|
||||
* @throws CancelledException
|
||||
*/
|
||||
public void updateCheckoutCopy() throws CancelledException, IOException {
|
||||
public void updateCheckoutCopy() throws IOException {
|
||||
if (!isCheckOutCopy) {
|
||||
throw new IOException("Database is not a checkout copy");
|
||||
}
|
||||
|
||||
@@ -469,6 +469,21 @@ public class LocalDatabaseItem extends LocalFolderItem implements DatabaseItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCheckout() throws IOException {
|
||||
if (isVersioned) {
|
||||
throw new UnsupportedOperationException(
|
||||
"clearCheckout is not applicable to versioned item");
|
||||
}
|
||||
if (fileSystem.isReadOnly()) {
|
||||
throw new ReadOnlyException();
|
||||
}
|
||||
synchronized (fileSystem) {
|
||||
privateDb.updateCheckoutCopy(); // removes change data
|
||||
super.clearCheckout();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ghidra.framework.store.local.LocalFolderItem#deleteCurrentVersion()
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user