OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox | 5 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox |
6 | 6 |
7 #define _GNU_SOURCE | 7 #define _GNU_SOURCE |
8 #include <asm/unistd.h> | 8 #include <asm/unistd.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include <sys/types.h> | 22 #include <sys/types.h> |
23 #include <unistd.h> | 23 #include <unistd.h> |
24 #include <stdbool.h> | 24 #include <stdbool.h> |
25 | 25 |
26 #include "suid_unsafe_environment_variables.h" | 26 #include "suid_unsafe_environment_variables.h" |
27 | 27 |
28 #if !defined(CLONE_NEWPID) | 28 #if !defined(CLONE_NEWPID) |
29 #define CLONE_NEWPID 0x20000000 | 29 #define CLONE_NEWPID 0x20000000 |
30 #endif | 30 #endif |
31 | 31 |
32 #if defined(LINUX_SANDBOX_CHROME_PATH) | |
33 static const char kChromeBinary[] = LINUX_SANDBOX_CHROME_PATH; | |
34 #endif | |
35 | |
36 static const char kSandboxDescriptorEnvironmentVarName[] = "SBX_D"; | 32 static const char kSandboxDescriptorEnvironmentVarName[] = "SBX_D"; |
37 | 33 |
38 // These are the magic byte values which the sandboxed process uses to request | 34 // These are the magic byte values which the sandboxed process uses to request |
39 // that it be chrooted. | 35 // that it be chrooted. |
40 static const char kMsgChrootMe = 'C'; | 36 static const char kMsgChrootMe = 'C'; |
41 static const char kMsgChrootSuccessful = 'O'; | 37 static const char kMsgChrootSuccessful = 'O'; |
42 | 38 |
43 static void FatalError(const char *msg, ...) | 39 static void FatalError(const char *msg, ...) |
44 __attribute__((noreturn, format(printf,1,2))); | 40 __attribute__((noreturn, format(printf,1,2))); |
45 | 41 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 if (!DropRoot()) | 298 if (!DropRoot()) |
303 return 1; | 299 return 1; |
304 if (!SetupChildEnvironment()) | 300 if (!SetupChildEnvironment()) |
305 return 1; | 301 return 1; |
306 | 302 |
307 execv(argv[1], &argv[1]); | 303 execv(argv[1], &argv[1]); |
308 FatalError("execv failed"); | 304 FatalError("execv failed"); |
309 | 305 |
310 return 1; | 306 return 1; |
311 } | 307 } |
OLD | NEW |