OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_host.h" | 5 #include "sandbox/linux/suid/client/setuid_sandbox_host.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 for (unsigned i = 0; kSUIDUnsafeEnvironmentVariables[i]; ++i) { | 79 for (unsigned i = 0; kSUIDUnsafeEnvironmentVariables[i]; ++i) { |
80 const char* env_var = kSUIDUnsafeEnvironmentVariables[i]; | 80 const char* env_var = kSUIDUnsafeEnvironmentVariables[i]; |
81 // Get the saved environment variable corresponding to envvar. | 81 // Get the saved environment variable corresponding to envvar. |
82 std::unique_ptr<std::string> saved_env_var( | 82 std::unique_ptr<std::string> saved_env_var( |
83 CreateSavedVariableName(env_var)); | 83 CreateSavedVariableName(env_var)); |
84 if (!saved_env_var) | 84 if (!saved_env_var) |
85 continue; | 85 continue; |
86 | 86 |
87 std::string value; | 87 std::string value; |
88 if (env->GetVar(env_var, &value)) | 88 if (env->GetVar(env_var, &value)) |
89 env->SetVar(saved_env_var->c_str(), value); | 89 env->SetVar(*saved_env_var, value); |
90 else | 90 else |
91 env->UnSetVar(saved_env_var->c_str()); | 91 env->UnSetVar(*saved_env_var); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 const char* GetDevelSandboxPath() { | 95 const char* GetDevelSandboxPath() { |
96 return getenv("CHROME_DEVEL_SANDBOX"); | 96 return getenv("CHROME_DEVEL_SANDBOX"); |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 SetuidSandboxHost* SetuidSandboxHost::Create() { | 101 SetuidSandboxHost* SetuidSandboxHost::Create() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // kZygoteIdFd. Fixing this requires a sandbox API change. :( | 185 // kZygoteIdFd. Fixing this requires a sandbox API change. :( |
186 fds_to_remap->push_back(std::make_pair(dummy_fd->get(), kZygoteIdFd)); | 186 fds_to_remap->push_back(std::make_pair(dummy_fd->get(), kZygoteIdFd)); |
187 } | 187 } |
188 | 188 |
189 void SetuidSandboxHost::SetupLaunchEnvironment() { | 189 void SetuidSandboxHost::SetupLaunchEnvironment() { |
190 SaveSUIDUnsafeEnvironmentVariables(env_.get()); | 190 SaveSUIDUnsafeEnvironmentVariables(env_.get()); |
191 SetSandboxAPIEnvironmentVariable(env_.get()); | 191 SetSandboxAPIEnvironmentVariable(env_.get()); |
192 } | 192 } |
193 | 193 |
194 } // namespace sandbox | 194 } // namespace sandbox |
OLD | NEW |