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

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

Issue 2733323002: Changing multiprocess test SpawnChild to return a struct. (Closed)
Patch Set: Fixed bots. 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
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 base::SpawnChildResult spawn_result =
204 SpawnChildWithOptions("LowerPermissions", options);
205 base::Process process = std::move(spawn_result.process);
203 ASSERT_TRUE(process.IsValid()); 206 ASSERT_TRUE(process.IsValid());
204 207
205 SharedMemory memory; 208 SharedMemory memory;
206 memory.CreateAndMapAnonymous(1001); 209 memory.CreateAndMapAnonymous(1001);
207 210
208 // Duplicate into child process, giving only FILE_MAP_READ permissions. 211 // Duplicate into child process, giving only FILE_MAP_READ permissions.
209 HANDLE raw_handle = nullptr; 212 HANDLE raw_handle = nullptr;
210 ::DuplicateHandle(::GetCurrentProcess(), memory.handle().GetHandle(), 213 ::DuplicateHandle(::GetCurrentProcess(), memory.handle().GetHandle(),
211 process.Handle(), &raw_handle, 214 process.Handle(), &raw_handle,
212 FILE_MAP_READ | SECTION_QUERY, FALSE, 0); 215 FILE_MAP_READ | SECTION_QUERY, FALSE, 0);
213 ASSERT_TRUE(raw_handle); 216 ASSERT_TRUE(raw_handle);
214 217
215 WriteHandleToPipe(communication_pipe.Get(), raw_handle); 218 WriteHandleToPipe(communication_pipe.Get(), raw_handle);
216 219
217 int exit_code; 220 int exit_code;
218 EXPECT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), 221 EXPECT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(),
219 &exit_code)); 222 &exit_code));
220 EXPECT_EQ(0, exit_code); 223 EXPECT_EQ(0, exit_code);
221 } 224 }
222 225
223 } // namespace 226 } // namespace
224 } // namespace base 227 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698