OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <limits.h> | 11 #include <limits.h> |
(...skipping 18 matching lines...) Expand all Loading... |
30 #include "process_util.h" | 30 #include "process_util.h" |
31 #include "suid_unsafe_environment_variables.h" | 31 #include "suid_unsafe_environment_variables.h" |
32 | 32 |
33 #if !defined(CLONE_NEWPID) | 33 #if !defined(CLONE_NEWPID) |
34 #define CLONE_NEWPID 0x20000000 | 34 #define CLONE_NEWPID 0x20000000 |
35 #endif | 35 #endif |
36 #if !defined(CLONE_NEWNET) | 36 #if !defined(CLONE_NEWNET) |
37 #define CLONE_NEWNET 0x40000000 | 37 #define CLONE_NEWNET 0x40000000 |
38 #endif | 38 #endif |
39 | 39 |
| 40 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; |
40 static const char kSandboxDescriptorEnvironmentVarName[] = "SBX_D"; | 41 static const char kSandboxDescriptorEnvironmentVarName[] = "SBX_D"; |
41 static const char kSandboxHelperPidEnvironmentVarName[] = "SBX_HELPER_PID"; | 42 static const char kSandboxHelperPidEnvironmentVarName[] = "SBX_HELPER_PID"; |
42 | 43 |
43 // These are the magic byte values which the sandboxed process uses to request | 44 // These are the magic byte values which the sandboxed process uses to request |
44 // that it be chrooted. | 45 // that it be chrooted. |
45 static const char kMsgChrootMe = 'C'; | 46 static const char kMsgChrootMe = 'C'; |
46 static const char kMsgChrootSuccessful = 'O'; | 47 static const char kMsgChrootSuccessful = 'O'; |
47 | 48 |
48 static void FatalError(const char *msg, ...) | 49 static void FatalError(const char *msg, ...) |
49 __attribute__((noreturn, format(printf, 1, 2))); | 50 __attribute__((noreturn, format(printf, 1, 2))); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 if (!DropRoot()) | 348 if (!DropRoot()) |
348 return 1; | 349 return 1; |
349 if (!SetupChildEnvironment()) | 350 if (!SetupChildEnvironment()) |
350 return 1; | 351 return 1; |
351 | 352 |
352 execv(argv[1], &argv[1]); | 353 execv(argv[1], &argv[1]); |
353 FatalError("execv failed"); | 354 FatalError("execv failed"); |
354 | 355 |
355 return 1; | 356 return 1; |
356 } | 357 } |
OLD | NEW |