Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: goopdate/process_launcher.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « goopdate/process_launcher.h ('k') | goopdate/resource_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2008-2010 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16
17 #include "omaha/goopdate/process_launcher.h"
18 #include "omaha/base/browser_utils.h"
19 #include "omaha/base/const_object_names.h"
20 #include "omaha/base/debug.h"
21 #include "omaha/base/exception_barrier.h"
22 #include "omaha/base/logging.h"
23 #include "omaha/base/system.h"
24 #include "omaha/base/vista_utils.h"
25 #include "omaha/base/vistautil.h"
26 #include "omaha/core/google_update_core.h"
27
28 namespace omaha {
29
30 ProcessLauncher::ProcessLauncher() : StdMarshalInfo(true) {
31 CORE_LOG(L6, (_T("[ProcessLauncher::ProcessLauncher]")));
32 }
33
34 ProcessLauncher::~ProcessLauncher() {
35 CORE_LOG(L6, (_T("[ProcessLauncher::~ProcessLauncher]")));
36 }
37
38 STDMETHODIMP ProcessLauncher::LaunchCmdLine(const TCHAR* cmd_line) {
39 CORE_LOG(L1, (_T("[ProcessLauncher::LaunchCmdLine][%s]"), cmd_line));
40 // The exception barrier is needed, because any exceptions that are thrown
41 // in this method will get caught by the COM run time. We compile with
42 // exceptions off, and do not expect to throw any exceptions. This barrier
43 // will treat an exception in this method as a unhandled exception.
44 ExceptionBarrier barrier;
45 if (cmd_line == NULL) {
46 return E_INVALIDARG;
47 }
48
49 // http://b/3329538: In the impersonated case, need to create a fresh
50 // environment block and ::CreateProcess. RunAsCurrentUser does just that.
51 HRESULT hr = vista::RunAsCurrentUser(cmd_line);
52 if (FAILED(hr)) {
53 UTIL_LOG(LW, (_T("[RunAsCurrentUser failed][0x%x]"), hr));
54 }
55 return hr;
56 }
57
58 STDMETHODIMP ProcessLauncher::LaunchBrowser(DWORD type, const TCHAR* url) {
59 CORE_LOG(L1, (_T("[ProcessLauncher::LaunchBrowser][%d][%s]"), type, url));
60 // The exception barrier is needed, because any exceptions that are thrown
61 // in this method will get caught by the COM run time. We compile with
62 // exceptions off, and do not expect to throw any exceptions. This barrier
63 // will treat an exception in this method as a unhandled exception.
64 ExceptionBarrier barrier;
65 if (type >= BROWSER_MAX || url == NULL) {
66 return E_INVALIDARG;
67 }
68 return RunBrowser(static_cast<BrowserType>(type), url);
69 }
70
71 // This method delegates to the internal interface exposed by the system
72 // service, and if the service cannot be instantiated, exposed by a Local COM
73 // Server.
74 //
75 // Non elevated callers can request a command to be run elevated.
76 // The command must be registered before by elevated code to prevent
77 // launching untrusted commands. The security of the command is based on
78 // having the correct registry ACLs for the machine Omaha registry.
79 STDMETHODIMP ProcessLauncher::LaunchCmdElevated(const WCHAR* app_guid,
80 const WCHAR* cmd_id,
81 DWORD caller_proc_id,
82 ULONG_PTR* proc_handle) {
83 CORE_LOG(L3, (_T("[ProcessLauncher::LaunchCmdElevated]")
84 _T("[app %s][cmd %s][pid %d]"),
85 app_guid, cmd_id, caller_proc_id));
86
87 ExceptionBarrier barrier;
88
89 ASSERT1(app_guid);
90 ASSERT1(cmd_id);
91 ASSERT1(proc_handle);
92
93 CComPtr<IGoogleUpdateCore> google_update_core;
94 HRESULT hr =
95 google_update_core.CoCreateInstance(__uuidof(GoogleUpdateCoreClass));
96
97 if (FAILED(hr)) {
98 CORE_LOG(LE, (_T("[CoCreate GoogleUpdateCoreClass failed][0x%x]"), hr));
99
100 if (!vista_util::IsVistaOrLater() && !vista_util::IsUserAdmin()) {
101 return hr;
102 }
103
104 hr = System::CoCreateInstanceAsAdmin(NULL,
105 __uuidof(GoogleUpdateCoreMachineClass),
106 IID_PPV_ARGS(&google_update_core));
107 if (FAILED(hr)) {
108 CORE_LOG(LE, (_T("[GoogleUpdateCoreMachineClass failed][0x%x]"), hr));
109 return hr;
110 }
111 }
112
113 ASSERT1(google_update_core);
114 hr = ::CoSetProxyBlanket(google_update_core, RPC_C_AUTHN_DEFAULT,
115 RPC_C_AUTHZ_DEFAULT, COLE_DEFAULT_PRINCIPAL, RPC_C_AUTHN_LEVEL_DEFAULT,
116 RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DEFAULT);
117 if (FAILED(hr)) {
118 return hr;
119 }
120
121 return google_update_core->LaunchCmdElevated(app_guid,
122 cmd_id,
123 caller_proc_id,
124 proc_handle);
125 }
126
127 } // namespace omaha
128
OLDNEW
« no previous file with comments | « goopdate/process_launcher.h ('k') | goopdate/resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698