Merge remote-tracking branch 'origin/GT-2685_ghidra1_ServerChanges'

This commit is contained in:
ghidra1
2019-06-03 11:33:21 -04:00
16 changed files with 259 additions and 213 deletions

View File

@@ -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

View File

@@ -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,16 +123,6 @@ 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 boolean isSSLHandshakeCancelled(SSLHandshakeException e) throws IOException {
if (e.getMessage().indexOf("bad_certificate") > 0) {
if (ApplicationKeyManagerFactory.getPreferredKeyStore() == null) {
@@ -158,10 +147,6 @@ 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);
GhidraServerHandle gsh = null;
try {
// Test SSL Handshake to ensure that user is able to decrypt keystore.
@@ -170,6 +155,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);
}

View File

@@ -47,6 +47,9 @@ public interface GhidraServerHandle extends Remote {
* 9: Added support for transient checkouts (7.2)
* 10: Added BlockStreamServer (7.4)
* 11: Revised password hash to SHA-256 (9.0)
* - version 9.1 switched to using SSL/TLS for RMI registry connection preventing
* older clients the ability to connect to the server. Remote interface remained
* unchanged allowing 9.1 clients to connect to 9.0 server.
*/
public static final int INTERFACE_VERSION = 11;

View File

@@ -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");
}

View File

@@ -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()
*/