| 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 #define PR_SET_NO_NEW_PRIVS 38 | 441 #define PR_SET_NO_NEW_PRIVS 38 |
| 442 #endif | 442 #endif |
| 443 if (!options.allow_new_privs) { | 443 if (!options.allow_new_privs) { |
| 444 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { | 444 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { |
| 445 // Only log if the error is not EINVAL (i.e. not supported). | 445 // Only log if the error is not EINVAL (i.e. not supported). |
| 446 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); | 446 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 #endif | 449 #endif |
| 450 | 450 |
| 451 #if defined(OS_POSIX) |
| 452 if (options.pre_exec_delegate != nullptr) { |
| 453 options.pre_exec_delegate->RunAsyncSafe(); |
| 454 } |
| 455 #endif |
| 456 |
| 451 for (size_t i = 0; i < argv.size(); i++) | 457 for (size_t i = 0; i < argv.size(); i++) |
| 452 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); | 458 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
| 453 argv_cstr[argv.size()] = NULL; | 459 argv_cstr[argv.size()] = NULL; |
| 454 execvp(argv_cstr[0], argv_cstr.get()); | 460 execvp(argv_cstr[0], argv_cstr.get()); |
| 455 | 461 |
| 456 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); | 462 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); |
| 457 RAW_LOG(ERROR, argv_cstr[0]); | 463 RAW_LOG(ERROR, argv_cstr[0]); |
| 458 _exit(127); | 464 _exit(127); |
| 459 } else { | 465 } else { |
| 460 // Parent process | 466 // Parent process |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 std::string* output, | 670 std::string* output, |
| 665 int* exit_code) { | 671 int* exit_code) { |
| 666 // Run |execve()| with the current environment and store "unlimited" data. | 672 // Run |execve()| with the current environment and store "unlimited" data. |
| 667 GetAppOutputInternalResult result = GetAppOutputInternal( | 673 GetAppOutputInternalResult result = GetAppOutputInternal( |
| 668 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 674 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
| 669 exit_code); | 675 exit_code); |
| 670 return result == EXECUTE_SUCCESS; | 676 return result == EXECUTE_SUCCESS; |
| 671 } | 677 } |
| 672 | 678 |
| 673 } // namespace base | 679 } // namespace base |
| OLD | NEW |