diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-08-09 10:42:37 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-09 10:45:48 -0400 |
commit | eb43401bfb6d69db66d256582a99e63de7d222d8 (patch) | |
tree | a3a27cd622b1d4797fa28bfe87d09d56401ba683 /src/common/util.c | |
parent | 94352368db9045a9704c713dbbc0f41ecc511910 (diff) | |
download | tor-eb43401bfb6d69db66d256582a99e63de7d222d8.tar.gz tor-eb43401bfb6d69db66d256582a99e63de7d222d8.zip |
Add a 'NoExec' option that causes tor_spawn_background() to fail
Core of an implementation for 22976.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 0858d17fe6..18108fc242 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -4142,6 +4142,20 @@ process_handle_waitpid_cb(int status, void *arg) #define CHILD_STATE_EXEC 8 #define CHILD_STATE_FAILEXEC 9 /** @} */ +/** + * Boolean. If true, then Tor may call execve or CreateProcess via + * tor_spawn_background. + **/ +static int may_spawn_background_process = 1; +/** + * Turn off may_spawn_background_process, so that all future calls to + * tor_spawn_background are guaranteed to fail. + **/ +void +tor_disable_spawning_background_processes(void) +{ + may_spawn_background_process = 0; +} /** Start a program in the background. If <b>filename</b> contains a '/', then * it will be treated as an absolute or relative path. Otherwise, on * non-Windows systems, the system path will be searched for <b>filename</b>. @@ -4166,6 +4180,9 @@ tor_spawn_background(const char *const filename, const char **argv, process_environment_t *env, process_handle_t **process_handle_out) { + if (may_spawn_background_process == 0) + return PROCESS_STATUS_ERROR; + #ifdef _WIN32 HANDLE stdout_pipe_read = NULL; HANDLE stdout_pipe_write = NULL; |