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 "base/process/launch.h" | 5 #include "base/process/launch.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 CloseSuperfluousFds(fd_shuffle2); | 429 CloseSuperfluousFds(fd_shuffle2); |
430 | 430 |
431 // Set NO_NEW_PRIVS by default. Since NO_NEW_PRIVS only exists in kernel | 431 // Set NO_NEW_PRIVS by default. Since NO_NEW_PRIVS only exists in kernel |
432 // 3.5+, do not check the return value of prctl here. | 432 // 3.5+, do not check the return value of prctl here. |
433 #if defined(OS_LINUX) | 433 #if defined(OS_LINUX) |
434 #ifndef PR_SET_NO_NEW_PRIVS | 434 #ifndef PR_SET_NO_NEW_PRIVS |
435 #define PR_SET_NO_NEW_PRIVS 38 | 435 #define PR_SET_NO_NEW_PRIVS 38 |
436 #endif | 436 #endif |
437 if (!options.allow_new_privs) { | 437 if (!options.allow_new_privs) { |
438 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { | 438 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { |
439 DCHECK_EQ(EINVAL, errno); | 439 // Only log if the error is not EINVAL (i.e. not supported). |
| 440 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); |
440 } | 441 } |
441 } | 442 } |
442 #endif | 443 #endif |
443 | 444 |
444 for (size_t i = 0; i < argv.size(); i++) | 445 for (size_t i = 0; i < argv.size(); i++) |
445 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); | 446 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
446 argv_cstr[argv.size()] = NULL; | 447 argv_cstr[argv.size()] = NULL; |
447 execvp(argv_cstr[0], argv_cstr.get()); | 448 execvp(argv_cstr[0], argv_cstr.get()); |
448 | 449 |
449 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); | 450 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 std::string* output, | 649 std::string* output, |
649 int* exit_code) { | 650 int* exit_code) { |
650 // Run |execve()| with the current environment and store "unlimited" data. | 651 // Run |execve()| with the current environment and store "unlimited" data. |
651 GetAppOutputInternalResult result = GetAppOutputInternal( | 652 GetAppOutputInternalResult result = GetAppOutputInternal( |
652 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 653 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
653 exit_code); | 654 exit_code); |
654 return result == EXECUTE_SUCCESS; | 655 return result == EXECUTE_SUCCESS; |
655 } | 656 } |
656 | 657 |
657 } // namespace base | 658 } // namespace base |
OLD | NEW |