OLD | NEW |
---|---|
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 "content/common/sandbox_mac.h" | 5 #include "content/common/sandbox_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 } | 163 } |
164 | 164 |
165 if (sandbox_type == SANDBOX_TYPE_RENDERER) { | 165 if (sandbox_type == SANDBOX_TYPE_RENDERER) { |
166 // Now disconnect from WindowServer, after all objects have been warmed up. | 166 // Now disconnect from WindowServer, after all objects have been warmed up. |
167 // Shutting down the connection requires connecting to WindowServer, | 167 // Shutting down the connection requires connecting to WindowServer, |
168 // so do this before actually engaging the sandbox. This may cause two log | 168 // so do this before actually engaging the sandbox. This may cause two log |
169 // messages to be printed to the system logger on certain OS versions. | 169 // messages to be printed to the system logger on certain OS versions. |
170 CGSSetDenyWindowServerConnections(true); | 170 CGSSetDenyWindowServerConnections(true); |
171 CGSShutdownServerConnections(); | 171 CGSShutdownServerConnections(); |
172 | 172 |
173 // Allow the process to continue without a LaunchServices ASN. The | 173 LaunchServicesNotAvailable(); |
174 // INIT_Process function in HIServices will abort if it cannot connect to | |
175 // launchservicesd to get an ASN. By setting this flag, HIServices skips | |
176 // that. | |
177 SetApplicationIsDaemon(true); | |
178 } | 174 } |
179 } | 175 } |
180 | 176 |
181 // Load the appropriate template for the given sandbox type. | 177 // Load the appropriate template for the given sandbox type. |
182 // Returns the template as a string or an empty string on error. | 178 // Returns the template as a string or an empty string on error. |
183 std::string LoadSandboxTemplate(int sandbox_type) { | 179 std::string LoadSandboxTemplate(int sandbox_type) { |
184 // We use a custom sandbox definition to lock things down as tightly as | 180 // We use a custom sandbox definition to lock things down as tightly as |
185 // possible. | 181 // possible. |
186 int sandbox_profile_resource_id = -1; | 182 int sandbox_profile_resource_id = -1; |
187 | 183 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 base::FilePath::CharType canonical_path[MAXPATHLEN]; | 306 base::FilePath::CharType canonical_path[MAXPATHLEN]; |
311 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { | 307 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { |
312 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " | 308 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " |
313 << path.value(); | 309 << path.value(); |
314 return path; | 310 return path; |
315 } | 311 } |
316 | 312 |
317 return base::FilePath(canonical_path); | 313 return base::FilePath(canonical_path); |
318 } | 314 } |
319 | 315 |
316 // static | |
317 void Sandbox::LaunchServicesNotAvailable() { | |
318 // Allow the process to continue without a LaunchServices ASN. The | |
319 // INIT_Process function in HIServices will abort if it cannot connect to | |
320 // launchservicesd to get an ASN. By setting this flag, HIServices skips | |
321 // that. | |
322 SetApplicationIsDaemon(true); | |
Robert Sesek
2017/06/16 19:28:59
I think this call should just move to https://cs.c
Greg K
2017/06/16 20:32:11
Done.
| |
323 } | |
324 | |
320 } // namespace content | 325 } // namespace content |
OLD | NEW |