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

Side by Side Diff: sandbox/linux/suid/client/setuid_sandbox_client.cc

Issue 2578483002: Namespace sandbox: add check for unprivileged use of CLONE_NEWUSER (Closed)
Patch Set: Created 4 years 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 (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/suid/client/setuid_sandbox_client.h" 5 #include "sandbox/linux/suid/client/setuid_sandbox_client.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/wait.h> 9 #include <sys/wait.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/environment.h" 15 #include "base/environment.h"
16 #include "base/files/scoped_file.h" 16 #include "base/files/scoped_file.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/posix/eintr_wrapper.h" 18 #include "base/posix/eintr_wrapper.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "sandbox/linux/suid/common/sandbox.h" 20 #include "sandbox/linux/suid/common/sandbox.h"
21 21
22 namespace { 22 namespace {
23 23
24 bool IsFileSystemAccessDenied() { 24 bool IsFileSystemAccessDenied() {
25 base::ScopedFD root_dir(HANDLE_EINTR(open("/", O_RDONLY))); 25 base::ScopedFD root_dir(HANDLE_EINTR(open("/proc/self/exe", O_RDONLY)));
Tom (Use chromium acct) 2016/12/14 04:13:48 Without this, when running as root, IsFileSystemAc
mdempsky 2016/12/14 05:11:11 Hm, so my best guess is that because with the setu
Tom (Use chromium acct) 2016/12/14 21:10:26 ok that makes sense.
26 return !root_dir.is_valid(); 26 return !root_dir.is_valid();
27 } 27 }
28 28
29 int GetHelperApi(base::Environment* env) { 29 int GetHelperApi(base::Environment* env) {
30 std::string api_string; 30 std::string api_string;
31 int api_number = 0; // Assume API version 0 if no environment was found. 31 int api_number = 0; // Assume API version 0 if no environment was found.
32 if (env->GetVar(sandbox::kSandboxEnvironmentApiProvides, &api_string) && 32 if (env->GetVar(sandbox::kSandboxEnvironmentApiProvides, &api_string) &&
33 !base::StringToInt(api_string, &api_number)) { 33 !base::StringToInt(api_string, &api_number)) {
34 // It's an error if we could not convert the API number. 34 // It's an error if we could not convert the API number.
35 api_number = -1; 35 api_number = -1;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 bool SetuidSandboxClient::IsInNewNETNamespace() const { 143 bool SetuidSandboxClient::IsInNewNETNamespace() const {
144 return env_->HasVar(kSandboxNETNSEnvironmentVarName); 144 return env_->HasVar(kSandboxNETNSEnvironmentVarName);
145 } 145 }
146 146
147 bool SetuidSandboxClient::IsSandboxed() const { 147 bool SetuidSandboxClient::IsSandboxed() const {
148 return sandboxed_; 148 return sandboxed_;
149 } 149 }
150 150
151 } // namespace sandbox 151 } // namespace sandbox
OLDNEW
« sandbox/linux/services/credentials.cc ('K') | « sandbox/linux/services/credentials.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698