summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-08 17:41:47 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-08 17:41:47 +0000
commit097a856b566ac0346fa50cee0fa6b69bc878ad3b (patch)
tree27fdcd6ef8a2a9eb6b92c6ac97f73aa6b771803a /chrome
parent1d2eb13fa0a3e8b1e03a22b8dd4d2af38b85b626 (diff)
downloadchromium_src-097a856b566ac0346fa50cee0fa6b69bc878ad3b.zip
chromium_src-097a856b566ac0346fa50cee0fa6b69bc878ad3b.tar.gz
chromium_src-097a856b566ac0346fa50cee0fa6b69bc878ad3b.tar.bz2
* Return error in case non admin user tries system level install.
BUG=5117,4973 TBR=huanr Review URL: http://codereview.chromium.org/13200 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chromium_strings.grd3
-rw-r--r--chrome/app/google_chrome_strings.grd3
-rwxr-xr-xchrome/installer/setup/main.cc28
-rw-r--r--chrome/installer/util/prebuild/create_string_rc.py1
-rwxr-xr-xchrome/installer/util/util_constants.cc4
-rwxr-xr-xchrome/installer/util/util_constants.h2
6 files changed, 33 insertions, 8 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd
index 90263f6..44ea50d 100644
--- a/chrome/app/chromium_strings.grd
+++ b/chrome/app/chromium_strings.grd
@@ -246,6 +246,9 @@ be available for now. -->
<message name="IDS_INSTALL_INVALID_ARCHIVE" desc="Error displayed when we can not open the installation archive.">
The installer archive is corrupted or invalid. Please download Chromium again.
</message>
+ <message name="IDS_INSTALL_INSUFFICIENT_RIGHTS" desc="Error displayed when a non admin user tries to attempt system level install/uninstall.">
+ You do not have appropriate rights for system-level install. Try running the installer again as Administrator.
+ </message>
<message name="IDS_UNINSTALL_FAILED" desc="Error during uninstall if we can not find the installation directory from registry.">
Chromium is not installed or it failed to find installation directory. Please download Chromium again.
</message>
diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd
index 52c9878..7fb00a9c 100644
--- a/chrome/app/google_chrome_strings.grd
+++ b/chrome/app/google_chrome_strings.grd
@@ -286,6 +286,9 @@ Chrome supports. -->
<message name="IDS_INSTALL_INVALID_ARCHIVE" desc="Error displayed when we can not open the installation archive.">
The installer archive is corrupted or invalid. Please download Google Chrome again.
</message>
+ <message name="IDS_INSTALL_INSUFFICIENT_RIGHTS" desc="Error displayed when a non admin user tries to attempt system level install/uninstall.">
+ You do not have appropriate rights for system-level install. Try running the installer again as Administrator.
+ </message>
<message name="IDS_UNINSTALL_FAILED" desc="Error during uninstall if we can not find the installation directory from registry.">
Google Chrome is not installed or it failed to find installation directory. Please download Google Chrome again.
</message>
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index 0a1ebc3..4aa4f37 100755
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -482,14 +482,26 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
return RenameChromeExecutables(system_install);
}
- if (system_install &&
- win_util::GetWinVersion() == win_util::WINVERSION_VISTA &&
- !IsUserAnAdmin()) {
- std::wstring exe = parsed_command_line.program();
- std::wstring params(command_line);
- DWORD exit_code = installer_util::UNKNOWN_STATUS;
- InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code);
- return exit_code;
+ if (system_install && !IsUserAnAdmin()) {
+ if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA &&
+ !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
+ std::wstring exe = parsed_command_line.program();
+ std::wstring params(command_line);
+ // Append --run-as-admin flag to let the new instance of setup.exe know
+ // that we already tried to launch ourselves as admin.
+ params.append(L" --");
+ params.append(installer_util::switches::kRunAsAdmin);
+ DWORD exit_code = installer_util::UNKNOWN_STATUS;
+ InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code);
+ return exit_code;
+ } else {
+ LOG(ERROR) << "Non admin user can not install system level Chrome.";
+ InstallUtil::WriteInstallerResult(system_install,
+ installer_util::INSUFFICIENT_RIGHTS,
+ IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE,
+ NULL);
+ return installer_util::INSUFFICIENT_RIGHTS;
+ }
}
// Check the existing version installed.
diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py
index c0a91ba..59ef430 100644
--- a/chrome/installer/util/prebuild/create_string_rc.py
+++ b/chrome/installer/util/prebuild/create_string_rc.py
@@ -48,6 +48,7 @@ kStringIds = [
'IDS_INSTALL_TEMP_DIR_FAILED',
'IDS_INSTALL_UNCOMPRESSION_FAILED',
'IDS_INSTALL_INVALID_ARCHIVE',
+ 'IDS_INSTALL_INSUFFICIENT_RIGHTS',
'IDS_UNINSTALL_FAILED',
]
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index 4ee1b02..e6147c5 100755
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -53,6 +53,10 @@ const wchar_t kRegisterChromeBrowser[] = L"register-chrome-browser";
// to support in-use updates. Also deletes opv key.
const wchar_t kRenameChromeExe[] = L"rename-chrome-exe";
+// When we try to relaunch setup.exe as admin on Vista, we append this command
+// line flag so that we try the launch only once.
+const wchar_t kRunAsAdmin[] = L"run-as-admin";
+
// Install Chrome to system wise location. The default is per user install.
const wchar_t kSystemLevel[] = L"system-level";
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index ec1f267..657c558 100755
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -24,6 +24,7 @@ enum InstallStatus {
TEMP_DIR_FAILED, // Unable to get Temp directory
UNCOMPRESSION_FAILED, // Failed to uncompress Chrome archive
INVALID_ARCHIVE, // Something wrong with the installer archive
+ INSUFFICIENT_RIGHTS, // User trying system level install is not Admin
CHROME_NOT_INSTALLED, // Chrome not installed (returned in case of uninstall)
CHROME_RUNNING, // Chrome currently running (when trying to uninstall)
UNINSTALL_CONFIRMED, // User has confirmed Chrome uninstall
@@ -69,6 +70,7 @@ extern const wchar_t kLogFile[];
extern const wchar_t kMakeChromeDefault[];
extern const wchar_t kRegisterChromeBrowser[];
extern const wchar_t kRenameChromeExe[];
+extern const wchar_t kRunAsAdmin[];
extern const wchar_t kSystemLevel[];
extern const wchar_t kUninstall[];
extern const wchar_t kVerboseLogging[];