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 #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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 | 375 |
376 free(saved_envvar); | 376 free(saved_envvar); |
377 } | 377 } |
378 | 378 |
379 return true; | 379 return true; |
380 } | 380 } |
381 | 381 |
382 int main(int argc, char **argv) { | 382 int main(int argc, char **argv) { |
383 if (argc <= 1) { | 383 if (argc <= 1) { |
| 384 if (argc == 0) { |
| 385 return 1; |
| 386 } |
| 387 |
384 fprintf(stderr, "Usage: %s <renderer process> <args...>\n", argv[0]); | 388 fprintf(stderr, "Usage: %s <renderer process> <args...>\n", argv[0]); |
385 return 1; | 389 return 1; |
386 } | 390 } |
387 | 391 |
388 // In the SUID sandbox, if we succeed in calling MoveToNewNamespaces() | 392 // In the SUID sandbox, if we succeed in calling MoveToNewNamespaces() |
389 // below, then the zygote and all the renderers are in an alternate PID | 393 // below, then the zygote and all the renderers are in an alternate PID |
390 // namespace and do not know their real PIDs. As such, they report the wrong | 394 // namespace and do not know their real PIDs. As such, they report the wrong |
391 // PIDs to the task manager. | 395 // PIDs to the task manager. |
392 // | 396 // |
393 // To fix this, when the zygote spawns a new renderer, it gives the renderer | 397 // To fix this, when the zygote spawns a new renderer, it gives the renderer |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (!DropRoot()) | 436 if (!DropRoot()) |
433 return 1; | 437 return 1; |
434 if (!SetupChildEnvironment()) | 438 if (!SetupChildEnvironment()) |
435 return 1; | 439 return 1; |
436 | 440 |
437 execv(argv[1], &argv[1]); | 441 execv(argv[1], &argv[1]); |
438 FatalError("execv failed"); | 442 FatalError("execv failed"); |
439 | 443 |
440 return 1; | 444 return 1; |
441 } | 445 } |
OLD | NEW |