Skip to content

Commit 4fade27

Browse files
committed
Fix deduplication of collected files on case insensitive targets
(DIS-2945)
1 parent 7e98198 commit 4fade27

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

acquire/acquire.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@
9999

100100
def misc_windows_user_homes(target: Target) -> Iterator[fsutil.TargetPath]:
101101
misc_dirs = {
102-
("windows/serviceprofiles/localservice", False),
103-
("windows/serviceprofiles/networkservice", False),
104-
("windows/system32/config/systemprofile", False),
105-
("users", True),
106-
("documents and settings", True),
102+
("Windows/ServiceProfiles/LocalService", False),
103+
("Windows/ServiceProfiles/NetworkService", False),
104+
("Windows/System32/config/systemprofile", False),
105+
("Users", True),
106+
("Documents and Settings", True),
107107
}
108108

109109
for fs in target.fs.path().iterdir():
@@ -146,7 +146,7 @@ def misc_osx_user_homes(target: Target) -> Iterator[fsutil.TargetPath]:
146146
def from_user_home(target: Target, path: str) -> Iterator[str]:
147147
try:
148148
for user_details in target.user_details.all_with_home():
149-
yield normalize_path(target, user_details.home_path.joinpath(path))
149+
yield normalize_path(target, user_details.home_path.joinpath(path), lower_case=False)
150150
except Exception as e:
151151
log.warning("Error occurred when requesting all user homes")
152152
log.debug("", exc_info=e)

acquire/collector.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ def serialize_path(path: Any) -> str:
7474

7575
# Naive way to serialize TargetPath filesystem's metadata is
7676
# to rely on uniqueness of `path._fs` object
77-
fs_id = id(path._fs)
78-
return f"{path._fs.__type__}:{fs_id}:{path}"
77+
fs = path._fs
78+
fs_id = id(fs)
79+
fs_type = fs.__type__
80+
path = str(path)
81+
if not fs.case_sensitive:
82+
path = path.lower()
83+
84+
return f"{fs_type}:{fs_id}:{path}"
7985

8086

8187
@dataclass

acquire/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ def persist_execution_report(path: Path, report_data: dict) -> Path:
371371
SYSVOL_SUBST = re.compile(r"^(/\?\?/)?[cC]:")
372372

373373

374-
def normalize_path(target: Target, path: Path, resolve: bool = False) -> str:
374+
def normalize_path(target: Target, path: Path, resolve: bool = False, lower_case: bool = True) -> str:
375375
if resolve:
376376
path = path.resolve()
377377

378378
path = path.as_posix()
379379

380-
if not target.fs.case_sensitive:
380+
if not target.fs.case_sensitive and lower_case:
381381
path = path.lower()
382382

383383
if target.os == "windows":

0 commit comments

Comments
 (0)