void *exec_payload, lxc_attach_options_t *options,
pid_t *attached_process)
{
+ __do_free char *cwd = NULL;
int i, ret, status;
int ipc_sockets[2];
- char *cwd, *new_cwd;
+ char *new_cwd;
signed long personality;
pid_t attached_pid, init_pid, pid;
struct lxc_proc_context_info *init_ctx;
if (options->namespaces == -1) {
ERROR("Failed to automatically determine the "
"namespaces which the container uses");
- free(cwd);
lxc_proc_put_context_info(init_ctx);
return -1;
}
for (j = 0; j < i; j++)
close(init_ctx->ns_fd[j]);
- free(cwd);
lxc_proc_put_context_info(init_ctx);
return -1;
}
ret = lxc_attach_terminal(name, lxcpath, conf, &terminal);
if (ret < 0) {
ERROR("Failed to setup new terminal");
- free(cwd);
lxc_proc_put_context_info(init_ctx);
return -1;
}
ret = socketpair(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0, ipc_sockets);
if (ret < 0) {
SYSERROR("Could not set up required IPC mechanism for attaching");
- free(cwd);
lxc_proc_put_context_info(init_ctx);
return -1;
}
pid = fork();
if (pid < 0) {
SYSERROR("Failed to create first subprocess");
- free(cwd);
lxc_proc_put_context_info(init_ctx);
return -1;
}
if (ret < 0)
WARN("Could not change directory to \"%s\"", new_cwd);
}
- free(cwd);
/* Create attached process. */
payload.ipc_socket = ipc_sockets[1];
/* close unneeded file descriptors */
close(ipc_sockets[1]);
- free(cwd);
+ free_disarm(cwd);
lxc_proc_close_ns_fd(init_ctx);
if (options->attach_flags & LXC_ATTACH_TERMINAL)
lxc_attach_terminal_close_pts(&terminal);