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

Side by Side Diff: base/memory/shared_memory_win_unittest.cc

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Synced Created 3 years, 9 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 | « base/memory/shared_memory_unittest.cc ('k') | base/process/process_metrics_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <windows.h> 5 #include <windows.h>
6 #include <sddl.h> 6 #include <sddl.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 win::ScopedHandle communication_pipe = 193 win::ScopedHandle communication_pipe =
194 CreateCommunicationPipe(communication_pipe_name); 194 CreateCommunicationPipe(communication_pipe_name);
195 ASSERT_TRUE(communication_pipe.Get()); 195 ASSERT_TRUE(communication_pipe.Get());
196 196
197 win::ScopedHandle lowered_process_token = CreateLowIntegritySID(); 197 win::ScopedHandle lowered_process_token = CreateLowIntegritySID();
198 ASSERT_TRUE(lowered_process_token.Get()); 198 ASSERT_TRUE(lowered_process_token.Get());
199 199
200 base::LaunchOptions options; 200 base::LaunchOptions options;
201 options.as_user = lowered_process_token.Get(); 201 options.as_user = lowered_process_token.Get();
202 base::Process process = SpawnChildWithOptions("LowerPermissions", options); 202
203 ASSERT_TRUE(process.IsValid()); 203 base::SpawnChildResult spawn_child =
204 SpawnChildWithOptions("LowerPermissions", options);
205 ASSERT_TRUE(spawn_child.process.IsValid());
204 206
205 SharedMemory memory; 207 SharedMemory memory;
206 memory.CreateAndMapAnonymous(1001); 208 memory.CreateAndMapAnonymous(1001);
207 209
208 // Duplicate into child process, giving only FILE_MAP_READ permissions. 210 // Duplicate into child process, giving only FILE_MAP_READ permissions.
209 HANDLE raw_handle = nullptr; 211 HANDLE raw_handle = nullptr;
210 ::DuplicateHandle(::GetCurrentProcess(), memory.handle().GetHandle(), 212 ::DuplicateHandle(::GetCurrentProcess(), memory.handle().GetHandle(),
211 process.Handle(), &raw_handle, 213 spawn_child.process.Handle(), &raw_handle,
212 FILE_MAP_READ | SECTION_QUERY, FALSE, 0); 214 FILE_MAP_READ | SECTION_QUERY, FALSE, 0);
213 ASSERT_TRUE(raw_handle); 215 ASSERT_TRUE(raw_handle);
214 216
215 WriteHandleToPipe(communication_pipe.Get(), raw_handle); 217 WriteHandleToPipe(communication_pipe.Get(), raw_handle);
216 218
217 int exit_code; 219 int exit_code;
218 EXPECT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), 220 EXPECT_TRUE(spawn_child.process.WaitForExitWithTimeout(
219 &exit_code)); 221 TestTimeouts::action_max_timeout(), &exit_code));
220 EXPECT_EQ(0, exit_code); 222 EXPECT_EQ(0, exit_code);
221 } 223 }
222 224
223 } // namespace 225 } // namespace
224 } // namespace base 226 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_unittest.cc ('k') | base/process/process_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698