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 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox | 5 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandbox |
6 | 6 |
7 #include "common/sandbox.h" | 7 #include "common/sandbox.h" |
8 | 8 |
9 #define _GNU_SOURCE | 9 #define _GNU_SOURCE |
10 #include <asm/unistd.h> | 10 #include <asm/unistd.h> |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 return 1; | 443 return 1; |
444 pid_t pid = pid_ul; | 444 pid_t pid = pid_ul; |
445 endptr = NULL; | 445 endptr = NULL; |
446 errno = 0; | 446 errno = 0; |
447 score = strtol(argv[3], &endptr, 10); | 447 score = strtol(argv[3], &endptr, 10); |
448 if (score == LONG_MAX || score == LONG_MIN || | 448 if (score == LONG_MAX || score == LONG_MIN || |
449 !endptr || *endptr || errno != 0) | 449 !endptr || *endptr || errno != 0) |
450 return 1; | 450 return 1; |
451 return AdjustOOMScore(pid, score); | 451 return AdjustOOMScore(pid, score); |
452 } | 452 } |
453 #if defined(OS_CHROMEOS) | |
454 if (argc == 3 && (0 == strcmp(argv[1], kAdjustLowMemMarginSwitch))) { | |
455 char* endptr = NULL; | |
456 errno = 0; | |
457 unsigned long margin_mb = strtoul(argv[2], &endptr, 10); | |
458 if (!endptr || *endptr || errno != 0) | |
459 return 1; | |
460 return AdjustLowMemoryMargin(margin_mb); | |
461 } | |
462 #endif | |
463 | 453 |
464 // Protect the core setuid sandbox functionality with an API version | 454 // Protect the core setuid sandbox functionality with an API version |
465 if (!CheckAndExportApiVersion()) { | 455 if (!CheckAndExportApiVersion()) { |
466 return 1; | 456 return 1; |
467 } | 457 } |
468 | 458 |
469 if (!MoveToNewNamespaces()) | 459 if (!MoveToNewNamespaces()) |
470 return 1; | 460 return 1; |
471 if (!SpawnChrootHelper()) | 461 if (!SpawnChrootHelper()) |
472 return 1; | 462 return 1; |
473 if (!DropRoot()) | 463 if (!DropRoot()) |
474 return 1; | 464 return 1; |
475 if (!SetupChildEnvironment()) | 465 if (!SetupChildEnvironment()) |
476 return 1; | 466 return 1; |
477 | 467 |
478 execv(argv[1], &argv[1]); | 468 execv(argv[1], &argv[1]); |
479 FatalError("execv failed"); | 469 FatalError("execv failed"); |
480 | 470 |
481 return 1; | 471 return 1; |
482 } | 472 } |
OLD | NEW |