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

Side by Side Diff: sandbox/linux/services/credentials_unittest.cc

Issue 1310773006: Update sandbox/linux from upstream (Closed) Base URL: ssh://ssh.github.com/domokit/mojo.git@master
Patch Set: Update to 3909ebfa69566f7374a6900e63cd4d3c73a35378 Created 5 years, 4 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 | « sandbox/linux/services/credentials.cc ('k') | sandbox/linux/services/namespace_sandbox.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sandbox/linux/services/credentials.h" 5 #include "sandbox/linux/services/credentials.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <pthread.h>
10 #include <signal.h>
9 #include <stdio.h> 11 #include <stdio.h>
10 #include <sys/capability.h> 12 #include <sys/capability.h>
11 #include <sys/stat.h> 13 #include <sys/stat.h>
12 #include <sys/types.h> 14 #include <sys/types.h>
13 #include <unistd.h> 15 #include <unistd.h>
14 16
15 #include <vector> 17 #include <vector>
16 18
17 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
18 #include "base/files/file_util.h" 20 #include "base/files/file_util.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 232
231 const cap_value_t allowed_cap = CAP_SYS_CHROOT; 233 const cap_value_t allowed_cap = CAP_SYS_CHROOT;
232 for (const cap_flag_t flag : {CAP_EFFECTIVE, CAP_PERMITTED}) { 234 for (const cap_flag_t flag : {CAP_EFFECTIVE, CAP_PERMITTED}) {
233 PCHECK(cap_set_flag(expected_cap.get(), flag, 1, &allowed_cap, CAP_SET) == 235 PCHECK(cap_set_flag(expected_cap.get(), flag, 1, &allowed_cap, CAP_SET) ==
234 0); 236 0);
235 } 237 }
236 238
237 CHECK_EQ(0, cap_compare(expected_cap.get(), actual_cap.get())); 239 CHECK_EQ(0, cap_compare(expected_cap.get(), actual_cap.get()));
238 } 240 }
239 241
242 volatile sig_atomic_t signal_handler_called;
243 void SignalHandler(int sig) {
244 signal_handler_called = 1;
245 }
246
247 // Disabled on ASAN because of crbug.com/451603.
248 SANDBOX_TEST(Credentials, DISABLE_ON_ASAN(DropFileSystemAccessPreservesTLS)) {
249 // Probably missing kernel support.
250 if (!Credentials::MoveToNewUserNS()) return;
251 CHECK(Credentials::DropFileSystemAccess(ProcUtil::OpenProc().get()));
252
253 // In glibc, pthread_getattr_np makes an assertion about the cached PID/TID in
254 // TLS.
255 pthread_attr_t attr;
256 EXPECT_EQ(0, pthread_getattr_np(pthread_self(), &attr));
257
258 // raise also uses the cached TID in glibc.
259 struct sigaction action = {};
260 action.sa_handler = &SignalHandler;
261 PCHECK(sigaction(SIGUSR1, &action, nullptr) == 0);
262
263 PCHECK(raise(SIGUSR1) == 0);
264 CHECK_EQ(1, signal_handler_called);
265 }
266
240 } // namespace. 267 } // namespace.
241 268
242 } // namespace sandbox. 269 } // namespace sandbox.
OLDNEW
« no previous file with comments | « sandbox/linux/services/credentials.cc ('k') | sandbox/linux/services/namespace_sandbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698