From 62442cb0a7ed06c2068ae0eeeb56f88766babc59 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 7 Sep 2018 10:51:09 -0400 Subject: [PATCH] More changes --- .../modules/hashdatabase/HashDbManager.java | 10 ++------ .../hashdatabase/HashLookupSettings.java | 25 ++++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java index ac8bb3b7c0..003b5ecff1 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java @@ -563,8 +563,7 @@ public class HashDbManager implements PropertyChangeListener { for (HashDbInfo hashDbInfo : hashDbInfoList) { try { if(hashDbInfo.isFileDatabaseType()){ - // ELTODO - String dbPath = this.getValidFilePath(hashDbInfo.getHashSetName(), hashDbInfo.getPath(), hashDbInfo.isPathIsRelative()); + String dbPath = this.getValidFilePath(hashDbInfo.getHashSetName(), hashDbInfo.getPath()); if (dbPath != null) { addHashDatabase(SleuthkitJNI.openHashDatabase(dbPath), hashDbInfo.getHashSetName(), hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(), hashDbInfo.getKnownFilesType()); } else { @@ -645,12 +644,7 @@ public class HashDbManager implements PropertyChangeListener { return true; } - private String getValidFilePath(String hashSetName, String configuredPath, boolean pathIsRelative) { - - if (pathIsRelative) { - // the path should be modified to be inside the current UserConfigFolder - // (e.g. C:\Users\elivis\AppData\Roaming\autopsy\config) - } + private String getValidFilePath(String hashSetName, String configuredPath) { // Check the configured path. File database = new File(configuredPath); if (database.exists()) { diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java index bc01963052..5f4ee56cbf 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettings.java @@ -286,8 +286,17 @@ final class HashLookupSettings implements Serializable { */ static boolean writeSettings(HashLookupSettings settings) { - // Check if any of the hash database paths are in Windows user directory. - // If so, edit the path so that it always gets updated to be the current user directory path. + /* NOTE: to support JIRA-4177, we need to check if any of the hash + database paths are in Windows user directory. If so, replace the path + with USER_DIR_PLACEHOLDER so that it always gets updated to be the + current user directory path. Therefore we have to modify HashLookupSettings + contents that are stored to disk. To make sure that some thread doesn't + access the path at the wrong time (i.e. while it is replaced USER_DIR_PLACEHOLDER), + we need to make a copy of the HashLookupSettings, edit the copy, and save + the copy to disk. This way the HashLookupSettings objects that the rest + of the code is using is never modified and alsways contains actual path + to the hash database. + */ boolean modified = editHashDbPathsInUserDir(settings); try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(SERIALIZATION_FILE_PATH))) { out.writeObject(settings); @@ -347,7 +356,6 @@ final class HashLookupSettings implements Serializable { private boolean searchDuringIngest; private final boolean sendIngestMessages; private String path; - private final boolean pathIsRelative; // flag that the path is relative to PlatformUtil.getUserConfigDirectory() private final String version; private final boolean readOnly; private final int referenceSetID; @@ -368,7 +376,6 @@ final class HashLookupSettings implements Serializable { this.knownFilesType = knownFilesType; this.searchDuringIngest = searchDuringIngest; this.sendIngestMessages = sendIngestMessages; - this.pathIsRelative = true; // ELTODO this.path = path; this.referenceSetID = -1; this.version = ""; @@ -385,7 +392,6 @@ final class HashLookupSettings implements Serializable { this.searchDuringIngest = searchDuringIngest; this.sendIngestMessages = sendIngestMessages; this.path = ""; - this.pathIsRelative = true; // ELTODO dbType = DatabaseType.CENTRAL_REPOSITORY; } @@ -400,7 +406,6 @@ final class HashLookupSettings implements Serializable { this.version = ""; this.readOnly = false; this.dbType = DatabaseType.FILE; - this.pathIsRelative = true; // ELTODO if (fileTypeDb.hasIndexOnly()) { this.path = fileTypeDb.getIndexPath(); } else { @@ -414,7 +419,6 @@ final class HashLookupSettings implements Serializable { this.readOnly = ! centralRepoDb.isUpdateable(); this.searchDuringIngest = centralRepoDb.getSearchDuringIngest(); this.sendIngestMessages = centralRepoDb.getSendIngestMessages(); - this.pathIsRelative = true; // ELTODO this.path = ""; this.referenceSetID = centralRepoDb.getReferenceSetID(); this.dbType = DatabaseType.CENTRAL_REPOSITORY; @@ -498,13 +502,6 @@ final class HashLookupSettings implements Serializable { this.path = path; } - /** - * @return ELTODO - */ - boolean isPathIsRelative() { - return pathIsRelative; - } - int getReferenceSetID(){ return referenceSetID; }