Ghidra is a software reverse engineering (SRE) framework
GP-3473: Ghidra can now launch Eclipse snap installation from Script Manager
Ryan Kurtz0ac2959fe74d
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseConnectorTask.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseConnectorTask.javaindex 5294bff7ba..7bf85d9559 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseConnectorTask.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseConnectorTask.java@@ -102,7 +102,7 @@ class EclipseConnectorTask extends Task {Process process = null;try {ProcessBuilder processBuilder = createEclipseProcessBuilder(eclipseExecutableFile,- eclipseService.getEclipseWorkspaceDir());+ eclipseService.getEclipseWorkspaceDir(), eclipseService.getEclipseDropinsDir());processBuilder.redirectErrorStream(true);processBuilder.directory(eclipseExecutableFile.getParentFile());process = processBuilder.start();@@ -163,10 +163,11 @@ class EclipseConnectorTask extends Task {** @param eclipseExecutableFile The Eclipse executable file.* @param eclipseWorkspaceDir The Eclipse workspace directory. Could be null.+ * @param eclipseDropinsDir The eclipse dropins directory.* @return A {@link ProcessBuilder} to launch Eclipse.*/private ProcessBuilder createEclipseProcessBuilder(File eclipseExecutableFile,- File eclipseWorkspaceDir) {+ File eclipseWorkspaceDir, File eclipseDropinsDir) {List<String> args = new ArrayList<>();args.add(eclipseExecutableFile.getAbsolutePath());@@ -178,6 +179,7 @@ class EclipseConnectorTask extends Task {args.add("--launcher.appendVmargs");args.add("-vmargs");args.add("-Dghidra.install.dir=" + Application.getInstallationDirectory());+ args.add("-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=" + eclipseDropinsDir);// Eclipse on OS X can have file locking issues if the user home directory is networked.// The following property is set in the launch script if we should disable file lockingdiff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseIntegrationPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseIntegrationPlugin.javaindex b9122c4709..f66fc4e3ca 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseIntegrationPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/eclipse/EclipseIntegrationPlugin.java@@ -20,6 +20,8 @@ import java.util.*;import java.util.zip.ZipEntry;import java.util.zip.ZipFile;+import org.apache.commons.lang3.SystemUtils;+import docking.options.OptionsService;import docking.widgets.OptionDialog;import generic.jar.ResourceFile;@@ -110,7 +112,7 @@ public class EclipseIntegrationPlugin extends ProgramPlugin implements EclipseInif (mainFeaturesDir.isDirectory()) {featuresDirs.add(mainFeaturesDir);}- File dropinsDir = new File(eclipseInstallDir, "dropins");+ File dropinsDir = getEclipseDropinsDir();if (dropinsDir.isDirectory()) {featuresDirs.add(dropinsDir);for (File dir : dropinsDir.listFiles(File::isDirectory)) {@@ -273,15 +275,17 @@ public class EclipseIntegrationPlugin extends ProgramPlugin implements EclipseInreturn eclipseInstallDir;}- /**- * Gets the Eclipse dropins directory.- *- * @return The Eclipse dropins directory.- * @throws FileNotFoundException if the dropins directory does not exist.- */+ @Overridepublic File getEclipseDropinsDir() throws FileNotFoundException {File eclipseInstallDir = getEclipseInstallDir();- File dropinsDir = new File(eclipseInstallDir, "dropins");+ File dropinsDir;+ if (eclipseInstallDir.getAbsolutePath().startsWith("/snap/eclipse")) {+ dropinsDir = new File(SystemUtils.getUserHome(), "snap/eclipse/dropins");+ }+ else {+ dropinsDir = new File(eclipseInstallDir, "dropins");+ }+ FileUtilities.mkdirs(dropinsDir);if (!dropinsDir.isDirectory()) {throw new FileNotFoundException("Eclipse dropins directory does not exist.");}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/EclipseIntegrationService.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/EclipseIntegrationService.javaindex ffb90bf6d9..ca3db4d623 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/EclipseIntegrationService.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/EclipseIntegrationService.java@@ -41,6 +41,15 @@ public interface EclipseIntegrationService {*/public File getEclipseExecutableFile() throws FileNotFoundException;+ /**+ * Gets the Eclipse dropins directory. If it doesn't exist, it will be created.+ *+ * @return The Eclipse dropins directory.+ * @throws FileNotFoundException if the dropins directory was not found and could not be+ * created.+ */+ public File getEclipseDropinsDir() throws FileNotFoundException;+/*** Gets the Eclipse workspace directory. If it is defined, the directory may or may not exist.* If it is undefined, Eclipse will be in control of selecting a workspace directory to use.