summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 22:18:36 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 22:18:36 +0000
commit816153386f5cf5f06657bb7f49e59ba1ca545043 (patch)
treef27698295a3a5ec82ac4fd7e25ad727ff85aef66 /chrome/installer
parent5c63806e0751f1c6ee95f460fdd1fee2d342c32b (diff)
downloadchromium_src-816153386f5cf5f06657bb7f49e59ba1ca545043.zip
chromium_src-816153386f5cf5f06657bb7f49e59ba1ca545043.tar.gz
chromium_src-816153386f5cf5f06657bb7f49e59ba1ca545043.tar.bz2
[Fixit-Dec-2012] Set the working directory of setup.exe to the temp dir when moving setup.exe to the temp dir.
setup.exe should never have the install directory as its working directory or it will fail to delete some folders (even after it has been moved to the temp folder itself) as it's automatically given a handle to its working directory by Windows. Arbitrarily choose the temp directory as the working directory (obtaining this path should always succeed, but if it doesn't: proceed anyways as it's preferable to leave some files behind then to abort the self-destruct). BUG=159995 TEST=Application folder is deleted upon user-level Chrome self-destruct! Review URL: https://chromiumcodereview.appspot.com/11693008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/uninstall.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index a85890b..e8a81eb 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -476,13 +476,24 @@ DeleteResult DeleteLocalState(const std::vector<FilePath>& local_state_folders,
return result;
}
+// Moves setup to a temporary file, outside of the install folder. Also attempts
+// to change the current directory to the TMP directory. On Windows, each
+// process has a handle to its CWD. If setup.exe's CWD happens to be within the
+// install directory, deletion will fail as a result of the open handle.
bool MoveSetupOutOfInstallFolder(const InstallerState& installer_state,
const FilePath& setup_exe) {
bool ret = false;
+ FilePath tmp_dir;
FilePath temp_file;
- if (!file_util::CreateTemporaryFile(&temp_file)) {
+ if (!PathService::Get(base::DIR_TEMP, &tmp_dir)) {
+ NOTREACHED();
+ } else if (!file_util::CreateTemporaryFileInDir(tmp_dir, &temp_file)) {
LOG(ERROR) << "Failed to create temporary file for setup.exe.";
} else {
+ VLOG(1) << "Changing current directory to: " << tmp_dir.value();
+ if (!file_util::SetCurrentDirectory(tmp_dir))
+ PLOG(ERROR) << "Failed to change the current directory.";
+
VLOG(1) << "Attempting to move setup to: " << temp_file.value();
ret = file_util::Move(setup_exe, temp_file);
PLOG_IF(ERROR, !ret) << "Failed to move setup to " << temp_file.value();