OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <dirent.h> | 8 #include <dirent.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 for (file_handle_mapping_vector::const_iterator | 53 for (file_handle_mapping_vector::const_iterator |
54 it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { | 54 it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { |
55 fd_shuffle.push_back(InjectionArc(it->first, it->second, false)); | 55 fd_shuffle.push_back(InjectionArc(it->first, it->second, false)); |
56 } | 56 } |
57 | 57 |
58 if (!ShuffleFileDescriptors(fd_shuffle)) | 58 if (!ShuffleFileDescriptors(fd_shuffle)) |
59 exit(127); | 59 exit(127); |
60 | 60 |
61 CloseSuperfluousFds(fd_shuffle); | 61 CloseSuperfluousFds(fd_shuffle); |
62 | 62 |
| 63 // If we are using the SUID sandbox, it sets a magic environment variable |
| 64 // ("SBX_D"), so we remove that variable from the environment here on the |
| 65 // off chance that it's already set. |
| 66 unsetenv("SBX_D"); |
| 67 |
63 scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); | 68 scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); |
64 for (size_t i = 0; i < argv.size(); i++) | 69 for (size_t i = 0; i < argv.size(); i++) |
65 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); | 70 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
66 argv_cstr[argv.size()] = NULL; | 71 argv_cstr[argv.size()] = NULL; |
67 execvp(argv_cstr[0], argv_cstr.get()); | 72 execvp(argv_cstr[0], argv_cstr.get()); |
68 exit(127); | 73 exit(127); |
69 } else { | 74 } else { |
70 if (wait) | 75 if (wait) |
71 HANDLE_EINTR(waitpid(pid, 0, 0)); | 76 HANDLE_EINTR(waitpid(pid, 0, 0)); |
72 | 77 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); | 280 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); |
276 } | 281 } |
277 state = KEY_NAME; | 282 state = KEY_NAME; |
278 break; | 283 break; |
279 } | 284 } |
280 } | 285 } |
281 return true; | 286 return true; |
282 } | 287 } |
283 | 288 |
284 } // namespace base | 289 } // namespace base |
OLD | NEW |