Fix CopyTreeWorkItem::IsFileInUse for non-elevated use.
This function has historically been opening a file for exclusive r/w/d with FILE_ALL_ACCESS. FILE_ALL_ACCESS is nearly almost never, ever the right choice when opening a file. This is especially true when opening a file from an ordinary non-elevated user session, since it attempts to gain things like WRITE_DAC and WRITE_OWNER and will fail if it's not possible to gain those access rights. A better way to determine if a file is "in use" (and what we really mean is "is an executable that is running") is simply to try to write to it. This is because CreateProcess opens its target with only exclusive write mode (read and execute are shared for obvious reasons). This change also eliminates the exact copy of this function, which included the incorrect formatting from the original, that was used in the unittest. R=gab@chromium.org BUG: 474401 Change-Id: I0488e2a5333f74353f46ae6c87795e2833a30b61 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905948 Commit-Queue: David Bienvenu <davidbienvenu@chromium.org> Reviewed-by:David Bienvenu <davidbienvenu@chromium.org> Auto-Submit: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#713858}
Showing
Please register or sign in to comment