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

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

Issue 2094913002: Make base::Environment::Create() return unique_ptrs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit, rebase Created 4 years, 5 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 (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 14
14 #include "base/environment.h" 15 #include "base/environment.h"
15 #include "base/files/scoped_file.h" 16 #include "base/files/scoped_file.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/posix/eintr_wrapper.h" 18 #include "base/posix/eintr_wrapper.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "sandbox/linux/suid/common/sandbox.h" 20 #include "sandbox/linux/suid/common/sandbox.h"
20 21
21 namespace { 22 namespace {
22 23
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // Get the IPC file descriptor used to communicate with the setuid helper. 56 // Get the IPC file descriptor used to communicate with the setuid helper.
56 int GetIPCDescriptor(base::Environment* env) { 57 int GetIPCDescriptor(base::Environment* env) {
57 return EnvToInt(env, sandbox::kSandboxDescriptorEnvironmentVarName); 58 return EnvToInt(env, sandbox::kSandboxDescriptorEnvironmentVarName);
58 } 59 }
59 60
60 } // namespace 61 } // namespace
61 62
62 namespace sandbox { 63 namespace sandbox {
63 64
64 SetuidSandboxClient* SetuidSandboxClient::Create() { 65 SetuidSandboxClient* SetuidSandboxClient::Create() {
65 base::Environment* environment(base::Environment::Create()); 66 return new SetuidSandboxClient(base::Environment::Create());
66 CHECK(environment);
67 return new SetuidSandboxClient(environment);
68 } 67 }
69 68
70 SetuidSandboxClient::SetuidSandboxClient(base::Environment* env) 69 SetuidSandboxClient::SetuidSandboxClient(std::unique_ptr<base::Environment> env)
71 : env_(env), sandboxed_(false) { 70 : env_(std::move(env)), sandboxed_(false) {
71 DCHECK(env_);
72 } 72 }
73 73
74 SetuidSandboxClient::~SetuidSandboxClient() { 74 SetuidSandboxClient::~SetuidSandboxClient() {
75 } 75 }
76 76
77 void SetuidSandboxClient::CloseDummyFile() { 77 void SetuidSandboxClient::CloseDummyFile() {
78 // When we're launched through the setuid sandbox, SetupLaunchOptions 78 // When we're launched through the setuid sandbox, SetupLaunchOptions
79 // arranges for kZygoteIdFd to be a dummy file descriptor to satisfy an 79 // arranges for kZygoteIdFd to be a dummy file descriptor to satisfy an
80 // ancient setuid sandbox ABI requirement. However, the descriptor is no 80 // ancient setuid sandbox ABI requirement. However, the descriptor is no
81 // longer needed, so we can simply close it right away now. 81 // longer needed, so we can simply close it right away now.
(...skipping 60 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
« no previous file with comments | « sandbox/linux/suid/client/setuid_sandbox_client.h ('k') | sandbox/linux/suid/client/setuid_sandbox_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698