mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Add process_reset_environment() to the Process subsystem.
This patch adds a new function that allows us to reset the environment of a given process_t with a list of key/value pairs. See: https://bugs.torproject.org/28179
This commit is contained in:
parent
4f611a1df7
commit
b0d268a822
@ -441,6 +441,23 @@ process_get_argv(const process_t *process)
|
||||
return argv;
|
||||
}
|
||||
|
||||
/** This function clears the internal environment and copies over every string
|
||||
* from <b>env</b> as the new environment. */
|
||||
void
|
||||
process_reset_environment(process_t *process, const smartlist_t *env)
|
||||
{
|
||||
tor_assert(process);
|
||||
tor_assert(env);
|
||||
|
||||
/* Cleanup old environment. */
|
||||
SMARTLIST_FOREACH(process->environment, char *, x, tor_free(x));
|
||||
smartlist_free(process->environment);
|
||||
process->environment = smartlist_new();
|
||||
|
||||
SMARTLIST_FOREACH(env, char *, x,
|
||||
smartlist_add(process->environment, tor_strdup(x)));
|
||||
}
|
||||
|
||||
/** Set the given <b>key</b>/<b>value</b> pair as environment variable in the
|
||||
* given process. */
|
||||
void
|
||||
|
@ -83,6 +83,7 @@ void process_append_argument(process_t *process, const char *argument);
|
||||
const smartlist_t *process_get_arguments(const process_t *process);
|
||||
char **process_get_argv(const process_t *process);
|
||||
|
||||
void process_reset_environment(process_t *process, const smartlist_t *env);
|
||||
void process_set_environment(process_t *process,
|
||||
const char *key,
|
||||
const char *value);
|
||||
|
Loading…
Reference in New Issue
Block a user