Fix packaging of logical imager executable

This commit is contained in:
Richard Cordovano 2019-06-26 14:23:55 -04:00
parent 32f200a1f1
commit 0abcb7374c
4 changed files with 36 additions and 19 deletions

View File

@ -46,6 +46,7 @@ ConfigVisualPanel3.copyStatus.saved=Saved
ConfigVisualPanel3.copyStatus.savingInProgress=Saving file, please wait ConfigVisualPanel3.copyStatus.savingInProgress=Saving file, please wait
# {0} - configurationLocation # {0} - configurationLocation
ConfigVisualPanel3.description.text=Press Save to write the imaging tool and configuration file to the destination.\nDestination: {0} ConfigVisualPanel3.description.text=Press Save to write the imaging tool and configuration file to the destination.\nDestination: {0}
ConfigVisualPanel3.errorMsg.cannotFindLogicalImager=Cannot locate logical imager, cannot copy to destination
# {0} - configFilename # {0} - configFilename
ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0} ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0}
ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file

View File

@ -35,7 +35,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import static org.sleuthkit.autopsy.logicalimager.configuration.CreateLogicalImagerAction.getTskLogicalImagerExe; import static org.sleuthkit.autopsy.logicalimager.configuration.CreateLogicalImagerAction.getLogicalImagerExe;
/** /**
* Configuration visual panel 3 * Configuration visual panel 3
@ -92,7 +92,8 @@ class ConfigVisualPanel3 extends javax.swing.JPanel {
"ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0}", "ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0}",
"# {0} - reason", "# {0} - reason",
"ConfigVisualPanel3.reason=\nReason: ", "ConfigVisualPanel3.reason=\nReason: ",
"ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file",}) "ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file"
})
void saveConfigFile() { void saveConfigFile() {
boolean saveSuccess = true; boolean saveSuccess = true;
executableStatusLabel.setForeground(Color.BLACK); executableStatusLabel.setForeground(Color.BLACK);
@ -142,14 +143,22 @@ class ConfigVisualPanel3 extends javax.swing.JPanel {
} }
/** /**
* Write the logical imager executable to the specified location * Writes the logical imager executable to the specified location.
* *
* @param destDir the location to write the logical imager executable to * @param destDir The destination directory.
* *
* @throws IOException * @throws IOException If the executable cannot be found or copying fails.
*/ */
@NbBundle.Messages({
"ConfigVisualPanel3.errorMsg.cannotFindLogicalImager=Cannot locate logical imager, cannot copy to destination"
})
private void writeTskLogicalImagerExe(Path destDir) throws IOException { private void writeTskLogicalImagerExe(Path destDir) throws IOException {
FileUtils.copyFileToDirectory(getTskLogicalImagerExe(), destDir.toFile()); File logicalImagerExe = getLogicalImagerExe();
if (logicalImagerExe != null && logicalImagerExe.exists()) {
FileUtils.copyFileToDirectory(getLogicalImagerExe(), destDir.toFile());
} else {
throw new IOException(Bundle.ConfigVisualPanel3_errorMsg_cannotFindLogicalImager());
}
} }
/** /**

View File

@ -21,6 +21,8 @@ package org.sleuthkit.autopsy.logicalimager.configuration;
import java.awt.Component; import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -30,11 +32,11 @@ import org.openide.WizardDescriptor;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
import org.openide.awt.ActionReference; import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration; import org.openide.awt.ActionRegistration;
import org.openide.modules.InstalledFileLocator;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.CallableSystemAction;
import static org.sleuthkit.autopsy.coreutils.PlatformUtil.getInstallModulesPath;
/** /**
* Configuration Logical Imager * Configuration Logical Imager
@ -45,9 +47,19 @@ import static org.sleuthkit.autopsy.coreutils.PlatformUtil.getInstallModulesPath
@Messages("CTL_CreateLogicalImagerAction=Create Logical Imager") @Messages("CTL_CreateLogicalImagerAction=Create Logical Imager")
public final class CreateLogicalImagerAction extends CallableSystemAction { public final class CreateLogicalImagerAction extends CallableSystemAction {
private static final String DISPLAY_NAME = Bundle.CTL_CreateLogicalImagerAction(); private static final long serialVersionUID = 1L;
private static final String TSK_LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS private static final String LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS
private static final String TSK_LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS private static final String LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS
private static final Path LOGICAL_IMAGER_EXE_PATH = Paths.get(LOGICAL_IMAGER_DIR, LOGICAL_IMAGER_EXE);
/**
* Finds the installed logical imager executable.
*
* @return A File object for the executable or null if it is not found.
*/
static File getLogicalImagerExe() {
return InstalledFileLocator.getDefault().locate(LOGICAL_IMAGER_EXE_PATH.toString(), CreateLogicalImagerAction.class.getPackage().getName(), false);
}
@NbBundle.Messages({ @NbBundle.Messages({
"CreateLogicalImagerAction.title=Create Logical Imager" "CreateLogicalImagerAction.title=Create Logical Imager"
@ -82,7 +94,7 @@ public final class CreateLogicalImagerAction extends CallableSystemAction {
@Override @Override
public String getName() { public String getName() {
return DISPLAY_NAME; return Bundle.CTL_CreateLogicalImagerAction();
} }
@Override @Override
@ -92,13 +104,8 @@ public final class CreateLogicalImagerAction extends CallableSystemAction {
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
File tskLogicalImagerExe = getTskLogicalImagerExe(); File logicalImagerExe = getLogicalImagerExe();
return tskLogicalImagerExe.exists(); return logicalImagerExe != null && logicalImagerExe.exists();
} }
static public File getTskLogicalImagerExe() {
String installModulesPath = getInstallModulesPath();
File tskLogicalImagerExe = new File(installModulesPath + File.separator + TSK_LOGICAL_IMAGER_DIR + File.separator + TSK_LOGICAL_IMAGER_EXE);
return tskLogicalImagerExe;
}
} }

View File

@ -8,7 +8,7 @@
<property name="i586" location="${basedir}/Core/release/modules/lib/i586" /> <property name="i586" location="${basedir}/Core/release/modules/lib/i586" />
<property name="i686" location="${basedir}/Core/release/modules/lib/i686"/> <property name="i686" location="${basedir}/Core/release/modules/lib/i686"/>
<property name="crt" location="${basedir}/thirdparty/crt" /> <property name="crt" location="${basedir}/thirdparty/crt" />
<property name="tsk_logical_imager_dir" location="${basedir}/Core/release/modules/tsk_logical_imager"/> <property name="tsk_logical_imager_dir" location="${basedir}/Core/release/tsk_logical_imager"/>
<import file="build-windows-installer.xml" /> <import file="build-windows-installer.xml" />