diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED index 528d3a50883..297974626fe 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED @@ -168,6 +168,7 @@ LocalDiskPanel.imageWriterError.isDirectory=Error - VHD path is a directory LocalDiskPanel.localDiskMessage.unspecified=Unspecified LocalDiskPanel.moduleErrorMessage.body=A module caused an error listening to LocalDiskPanel updates. See log to determine which module. Some data could be incomplete. LocalDiskPanel.moduleErrorMessage.title=Module Error +LocalDiskSelectionDialog.columnName.Details=Details LocalDiskSelectionDialog.columnName.diskName=Disk Name LocalDiskSelectionDialog.columnName.diskSize=Disk Size LocalDiskSelectionDialog.errorMessage.disksNotDetected=Disks were not detected. On some systems it requires admin privileges (or "Run as administrator"). diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.form b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.form index 3e6f74573f8..baa5bc8628d 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.form @@ -7,6 +7,7 @@ + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.java index 2bca31e1fd2..17005176180 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskSelectionDialog.java @@ -18,19 +18,25 @@ */ package org.sleuthkit.autopsy.casemodule; +import java.awt.Component; import java.awt.Window; import java.util.ArrayList; import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.logging.Level; import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JTable; import javax.swing.SwingWorker; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; @@ -56,7 +62,8 @@ final class LocalDiskSelectionDialog extends JDialog { private static final long serialVersionUID = 1L; private List disks; private final LocalDiskModel model; - + private final TooltipCellRenderer tooltipCellRenderer = new TooltipCellRenderer(); + /** * Creates a new LocalDiskSelectionDialog instance. */ @@ -69,6 +76,10 @@ final class LocalDiskSelectionDialog extends JDialog { initComponents(); refreshTable(); + for (Enumeration e = localDiskTable.getColumnModel().getColumns(); e.hasMoreElements();) { + e.nextElement().setCellRenderer(tooltipCellRenderer); + } + localDiskTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { @@ -82,10 +93,7 @@ public void valueChanged(ListSelectionEvent e) { * Display the dialog. */ void display() { - setModal(true); - setSize(getPreferredSize()); setLocationRelativeTo(this.getParent()); - setAlwaysOnTop(false); setVisible(true); } @@ -109,6 +117,7 @@ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(org.openide.util.NbBundle.getMessage(LocalDiskSelectionDialog.class, "LocalDiskSelectionDialog.title")); // NOI18N setAlwaysOnTop(true); + setModal(true); setResizable(false); org.openide.awt.Mnemonics.setLocalizedText(selectLocalDiskLabel, org.openide.util.NbBundle.getMessage(LocalDiskSelectionDialog.class, "LocalDiskSelectionDialog.selectLocalDiskLabel.text")); // NOI18N @@ -255,6 +264,21 @@ LocalDisk getLocalDiskSelection() { } return null; } + + /** + * Shows tooltip for cell. + */ + private class TooltipCellRenderer extends DefaultTableCellRenderer { + public Component getTableCellRendererComponent( + JTable table, Object value, + boolean isSelected, boolean hasFocus, + int row, int column) { + JLabel c = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + String tooltip = value == null ? "" : value.toString(); + c.setToolTipText(tooltip); + return c; + } + } @NbBundle.Messages({ "LocalDiskSelectionDialog.tableMessage.loading=Loading local disks...", @@ -295,13 +319,17 @@ public int getRowCount() { @Override public int getColumnCount() { - return 2; - + if (PlatformUtil.isLinuxOS()) { + return 3; + } else { + return 2; + } } @NbBundle.Messages({ "LocalDiskSelectionDialog.columnName.diskName=Disk Name", - "LocalDiskSelectionDialog.columnName.diskSize=Disk Size" + "LocalDiskSelectionDialog.columnName.diskSize=Disk Size", + "LocalDiskSelectionDialog.columnName.Details=Details" }) @Override @@ -311,6 +339,8 @@ public String getColumnName(int columnIndex) { return Bundle.LocalDiskSelectionDialog_columnName_diskName(); case 1: return Bundle.LocalDiskSelectionDialog_columnName_diskSize(); + case 2: + return Bundle.LocalDiskSelectionDialog_columnName_Details(); default: return "Unnamed"; //NON-NLS } @@ -337,6 +367,8 @@ public Object getValueAt(int rowIndex, int columnIndex) { return disks.get(rowIndex).getName(); case 1: return disks.get(rowIndex).getReadableSize(); + case 2: + return disks.get(rowIndex).getDetail(); default: return disks.get(rowIndex).getPath(); } diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/coreutils/Bundle.properties-MERGED index a0d535f8e62..f7525c8a68c 100755 --- a/Core/src/org/sleuthkit/autopsy/coreutils/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/coreutils/Bundle.properties-MERGED @@ -11,6 +11,8 @@ GetOrGenerateThumbnailTask.generatingPreviewFor=Generating preview for {0} GetOrGenerateThumbnailTask.loadingThumbnailFor=Loading thumbnail for {0} ImageUtils.ffmpegLoadedError.msg=OpenCV FFMpeg library failed to load, see log for more details ImageUtils.ffmpegLoadedError.title=OpenCV FFMpeg +LocalDisk_getDetail_autopsyConfig=Autopsy Config +LocalDisk_getDetail_cdRom=CD-ROM OpenIDE-Module-Name=CoreUtils JLNK.noPrefPath.text=No preferred path found PlatformUtil.nameUnknown=unknown diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/LocalDisk.java b/Core/src/org/sleuthkit/autopsy/coreutils/LocalDisk.java index dce10640aa9..741deb7f704 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/LocalDisk.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/LocalDisk.java @@ -18,6 +18,17 @@ */ package org.sleuthkit.autopsy.coreutils; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import org.openide.util.NbBundle.Messages; + /** * Representation of a PhysicalDisk or partition. */ @@ -26,11 +37,17 @@ public class LocalDisk { private String name; private String path; private long size; + private String mountPoint; + private static final Logger logger = Logger.getLogger(LocalDisk.class.getName()); public LocalDisk(String name, String path, long size) { this.name = name; this.path = path; this.size = size; + mountPoint = ""; + if (PlatformUtil.isLinuxOS() ) { + findLinuxMointPoint(this.path); + } } public String getName() { @@ -44,6 +61,30 @@ public String getPath() { public long getSize() { return size; } + + /** + * Returns details about the mount point + * of the drive as well as if it is an Autopsy + * config or iso. + * + * NOTE: Currently only works for linux. + */ + @Messages({ + "LocalDisk_getDetail_autopsyConfig=Autopsy Config", + "LocalDisk_getDetail_cdRom=CD-ROM", + }) + public String getDetail() { + String toRet = mountPoint == null ? "" : mountPoint; + if(isConfigDrive()) { + toRet += ", " + Bundle.LocalDisk_getDetail_autopsyConfig(); + } + + if (isCDDrive()) { + toRet += ", " + Bundle.LocalDisk_getDetail_cdRom(); + } + + return toRet; + } public String getReadableSize() { int unit = 1024; @@ -60,4 +101,44 @@ public String toString() { return name + ": " + getReadableSize(); } + private void findLinuxMointPoint(String path) { + try { + List commandLine = new ArrayList<>(); + commandLine.add("/bin/bash"); + commandLine.add("-c"); + commandLine.add("df -h | grep " + path + " | awk '{print $6}'"); + + ProcessBuilder pb = new ProcessBuilder(commandLine); + Process process = pb.start(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + StringBuilder builder = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + builder.append(line); + } + this.mountPoint = builder.toString(); + process.destroy(); + } catch (IOException ex) { + logger.log(Level.WARNING, "Unable to find the mount point for the device", ex); + } + } + + /** + * If AutopsyConfig folder is present, linux autopsy will display drive + * details including 'Autopsy Config'. + */ + private boolean isConfigDrive() { + Path path = Paths.get(this.mountPoint, "AutopsyConfig"); + File configFile = new File(path.toString()); + return configFile.exists(); + } + + /** + * For linux autopsy, determines if drive is CD-ROM if the device starts + * with /dev/sr. + */ + private boolean isCDDrive() { + return this.path.toString().trim().toLowerCase().startsWith("/dev/sr"); + } } diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java index fada0b0eab6..20725626886 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java @@ -335,6 +335,15 @@ public static boolean isWindowsOS() { return PlatformUtil.getOSName().toLowerCase().contains("windows"); //NON-NLS } + /** + * Check if running on Linux OS + * + * @return true if running on Linux OS + */ + public static boolean isLinuxOS() { + return PlatformUtil.getOSName().toLowerCase().contains("linux"); + } + /** * Convert file path (quote) for OS specific * @@ -406,11 +415,12 @@ public static List getPhysicalDrives() { } // Linux drives } else { + int drivelength = isLinuxOS() ? 3 : 5; File dev = new File("/dev/"); File[] files = dev.listFiles(); for (File f : files) { String name = f.getName(); - if ((name.contains("hd") || name.contains("sd") || name.contains("disk")) && f.canRead() && name.length() <= 5) { //NON-NLS + if ((name.contains("hd") || name.contains("sd") || name.contains("sr") || name.contains("disk")) && f.canRead() && name.length() <= drivelength) { //NON-NLS String path = "/dev/" + name; //NON-NLS if (canReadDrive(path)) { try { @@ -449,11 +459,12 @@ public static List getPartitions() { } } } else { + int partitionLength = isLinuxOS() ? 4 : 7; File dev = new File("/dev/"); File[] files = dev.listFiles(); for (File f : files) { String name = f.getName(); - if ((name.contains("hd") || name.contains("sd") || name.contains("disk")) && f.canRead() && name.length() <= 7) { //NON-NLS + if ((name.contains("hd") || name.contains("sd") || name.contains("disk")) && f.canRead() && name.length() <= partitionLength) { //NON-NLS String path = "/dev/" + name; //NON-NLS if (canReadDrive(path)) { drives.add(new LocalDisk(path, path, f.getTotalSpace()));