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

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

Issue 1180373004: Cleanup: Remove various DoNothing functions and use base::DoNothing(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/scoped_process_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <sys/ptrace.h> 7 #include <sys/ptrace.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/posix/eintr_wrapper.h" 15 #include "base/posix/eintr_wrapper.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/sys_info.h" 17 #include "base/sys_info.h"
17 #include "sandbox/linux/services/scoped_process.h" 18 #include "sandbox/linux/services/scoped_process.h"
18 #include "sandbox/linux/services/yama.h" 19 #include "sandbox/linux/services/yama.h"
19 #include "sandbox/linux/tests/unit_tests.h" 20 #include "sandbox/linux/tests/unit_tests.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 namespace sandbox { 23 namespace sandbox {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // However, parent can ptrace process1. 145 // However, parent can ptrace process1.
145 ASSERT_TRUE(CanPtrace(process1.GetPid())); 146 ASSERT_TRUE(CanPtrace(process1.GetPid()));
146 147
147 // A sibling can ptrace process2 which disables any Yama protection. 148 // A sibling can ptrace process2 which disables any Yama protection.
148 ScopedProcess process2(base::Bind(&SetYamaRestrictions, false)); 149 ScopedProcess process2(base::Bind(&SetYamaRestrictions, false));
149 ASSERT_TRUE(process2.WaitForClosureToRun()); 150 ASSERT_TRUE(process2.WaitForClosureToRun());
150 ASSERT_TRUE(CanSubProcessPtrace(process2.GetPid())); 151 ASSERT_TRUE(CanSubProcessPtrace(process2.GetPid()));
151 } 152 }
152 } 153 }
153 154
154 void DoNothing() {}
155
156 SANDBOX_TEST(Yama, RestrictPtraceIsDefault) { 155 SANDBOX_TEST(Yama, RestrictPtraceIsDefault) {
157 if (!Yama::IsPresent() || HasLinux32Bug()) 156 if (!Yama::IsPresent() || HasLinux32Bug())
158 return; 157 return;
159 158
160 CHECK(Yama::DisableYamaRestrictions()); 159 CHECK(Yama::DisableYamaRestrictions());
161 ScopedProcess process1(base::Bind(&DoNothing)); 160 ScopedProcess process1(base::Bind(&base::DoNothing));
162 161
163 if (Yama::IsEnforcing()) { 162 if (Yama::IsEnforcing()) {
164 // Check that process1 is protected by Yama, even though it has 163 // Check that process1 is protected by Yama, even though it has
165 // been created from a process that disabled Yama. 164 // been created from a process that disabled Yama.
166 CHECK(!CanSubProcessPtrace(process1.GetPid())); 165 CHECK(!CanSubProcessPtrace(process1.GetPid()));
167 } 166 }
168 } 167 }
169 168
170 } // namespace 169 } // namespace
171 170
172 } // namespace sandbox 171 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/scoped_process_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698