OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/installer/util/user_experiment.h" | 5 #include "chrome/installer/util/user_experiment.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <sddl.h> | 8 #include <sddl.h> |
9 #include <wtsapi32.h> | 9 #include <wtsapi32.h> |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // to do so. That is the process that needs the key. | 129 // to do so. That is the process that needs the key. |
130 std::string key(switches::kToastResultsKey); | 130 std::string key(switches::kToastResultsKey); |
131 std::string toast_key = current_cmd_line.GetSwitchValueASCII(key); | 131 std::string toast_key = current_cmd_line.GetSwitchValueASCII(key); |
132 if (!toast_key.empty()) { | 132 if (!toast_key.empty()) { |
133 cmd_line->AppendSwitchASCII(key, toast_key); | 133 cmd_line->AppendSwitchASCII(key, toast_key); |
134 | 134 |
135 // Use handle inheritance to make sure the duplicated toast results key | 135 // Use handle inheritance to make sure the duplicated toast results key |
136 // gets inherited by the child process. | 136 // gets inherited by the child process. |
137 base::LaunchOptions options; | 137 base::LaunchOptions options; |
138 options.inherit_handles = true; | 138 options.inherit_handles = true; |
139 return base::LaunchProcess(*cmd_line, options, NULL); | 139 base::Process process = base::LaunchProcess(*cmd_line, options); |
| 140 return process.IsValid(); |
140 } | 141 } |
141 } | 142 } |
142 | 143 |
143 return base::LaunchProcess(*cmd_line, base::LaunchOptions(), NULL); | 144 base::Process process = base::LaunchProcess(*cmd_line, base::LaunchOptions()); |
| 145 return process.IsValid(); |
144 } | 146 } |
145 | 147 |
146 // For System level installs, setup.exe lives in the system temp, which | 148 // For System level installs, setup.exe lives in the system temp, which |
147 // is normally c:\windows\temp. In many cases files inside this folder | 149 // is normally c:\windows\temp. In many cases files inside this folder |
148 // are not accessible for execution by regular user accounts. | 150 // are not accessible for execution by regular user accounts. |
149 // This function changes the permissions so that any authenticated user | 151 // This function changes the permissions so that any authenticated user |
150 // can launch |exe| later on. This function should only be called if the | 152 // can launch |exe| later on. This function should only be called if the |
151 // code is running at the system level. | 153 // code is running at the system level. |
152 bool FixDACLsForExecute(const base::FilePath& exe) { | 154 bool FixDACLsForExecute(const base::FilePath& exe) { |
153 // The general strategy to is to add an ACE to the exe DACL the quick | 155 // The general strategy to is to add an ACE to the exe DACL the quick |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 << console_id; | 235 << console_id; |
234 return false; | 236 return false; |
235 } | 237 } |
236 // Note: Handle inheritance must be true in order for the child process to be | 238 // Note: Handle inheritance must be true in order for the child process to be |
237 // able to use the duplicated handle above (Google Update results). | 239 // able to use the duplicated handle above (Google Update results). |
238 base::LaunchOptions options; | 240 base::LaunchOptions options; |
239 options.as_user = user_token; | 241 options.as_user = user_token; |
240 options.inherit_handles = true; | 242 options.inherit_handles = true; |
241 options.empty_desktop_name = true; | 243 options.empty_desktop_name = true; |
242 VLOG(1) << __FUNCTION__ << " launching " << cmd_line->GetCommandLineString(); | 244 VLOG(1) << __FUNCTION__ << " launching " << cmd_line->GetCommandLineString(); |
243 bool launched = base::LaunchProcess(*cmd_line, options, NULL); | 245 base::Process process = base::LaunchProcess(*cmd_line, options); |
244 ::CloseHandle(user_token); | 246 ::CloseHandle(user_token); |
245 VLOG(1) << __FUNCTION__ << " result: " << launched; | 247 VLOG(1) << __FUNCTION__ << " result: " << process.IsValid(); |
246 return launched; | 248 return process.IsValid(); |
247 } | 249 } |
248 | 250 |
249 // A helper function that writes to HKLM if the handle was passed through the | 251 // A helper function that writes to HKLM if the handle was passed through the |
250 // command line, but HKCU otherwise. |experiment_group| is the value to write | 252 // command line, but HKCU otherwise. |experiment_group| is the value to write |
251 // and |last_write| is used when writing to HKLM to determine whether to close | 253 // and |last_write| is used when writing to HKLM to determine whether to close |
252 // the handle when done. | 254 // the handle when done. |
253 void SetClient(const base::string16& experiment_group, bool last_write) { | 255 void SetClient(const base::string16& experiment_group, bool last_write) { |
254 static int reg_key_handle = -1; | 256 static int reg_key_handle = -1; |
255 if (reg_key_handle == -1) { | 257 if (reg_key_handle == -1) { |
256 // If a specific Toast Results key handle (presumably to our HKLM key) was | 258 // If a specific Toast Results key handle (presumably to our HKLM key) was |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (outcome != kToastExpUninstallGroup) | 523 if (outcome != kToastExpUninstallGroup) |
522 return; | 524 return; |
523 // The user wants to uninstall. This is a best effort operation. Note that | 525 // The user wants to uninstall. This is a best effort operation. Note that |
524 // we waited for chrome to exit so the uninstall would not detect chrome | 526 // we waited for chrome to exit so the uninstall would not detect chrome |
525 // running. | 527 // running. |
526 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( | 528 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( |
527 switches::kSystemLevelToast); | 529 switches::kSystemLevelToast); |
528 | 530 |
529 CommandLine cmd(InstallUtil::GetChromeUninstallCmd( | 531 CommandLine cmd(InstallUtil::GetChromeUninstallCmd( |
530 system_level_toast, product.distribution()->GetType())); | 532 system_level_toast, product.distribution()->GetType())); |
531 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 533 base::LaunchProcess(cmd, base::LaunchOptions()); |
532 } | 534 } |
533 | 535 |
534 } // namespace installer | 536 } // namespace installer |
OLD | NEW |