void program_client_local_exited(struct program_client_local *plclient);
static
-void exec_child(const char *bin_path, const char *const *args, const char *const *envs,
+void exec_child(const char *bin_path, const char *const *args,
+ ARRAY_TYPE(const_string) *envs,
int in_fd, int out_fd, int *extra_fds, bool drop_stderr)
{
ARRAY_TYPE(const_string) exec_args;
/* Setup environment */
env_clean();
- if (envs != NULL) {
- for(; *envs != NULL; envs++)
- env_put(*envs);
+ if (array_is_created(envs)) {
+ const char *const *env;
+
+ array_foreach(envs, env) {
+ env_put(*env);
+ }
}
/* Execute */
}
if (plclient->pid == 0) {
- unsigned int count;
- const char *const *envs = NULL;
-
/* child */
if (fd_in[1] >= 0 && close(fd_in[1]) < 0)
i_error("close(pipe:in:wr) failed: %m");
restrict_access(&pclient->set.restrict_set, pclient->set.home,
!pclient->set.allow_root);
- if (array_is_created(&pclient->envs))
- envs = array_get(&pclient->envs, &count);
-
- exec_child(pclient->path, pclient->args, envs,
+ exec_child(pclient->path, pclient->args, &pclient->envs,
fd_in[0], fd_out[1], child_extra_fds,
pclient->set.drop_stderr);
i_unreached();