- /*
- * Create the pipes to the proxy command, and spawn the proxy
- * command process.
- */
- if (pipe(to_cmd_pipe) < 0 ||
- pipe(from_cmd_pipe) < 0) {
- ret->error = dupprintf("pipe: %s", strerror(errno));
- return (Socket)ret;
- }
- cloexec(to_cmd_pipe[1]);
- cloexec(from_cmd_pipe[0]);
-
- pid = fork();
-
- if (pid < 0) {
- ret->error = dupprintf("fork: %s", strerror(errno));
- sfree(cmd);
- return (Socket)ret;
- } else if (pid == 0) {
- close(0);
- close(1);
- dup2(to_cmd_pipe[0], 0);
- dup2(from_cmd_pipe[1], 1);
- close(to_cmd_pipe[0]);
- close(from_cmd_pipe[1]);
- noncloexec(0);
- noncloexec(1);
- execl("/bin/sh", "sh", "-c", cmd, (void *)NULL);
- _exit(255);
- }
+ if (proxytype == PROXY_CMD) {
+ cmd = format_telnet_command(addr, port, conf);
+
+ /*
+ * Create the pipes to the proxy command, and spawn the proxy
+ * command process.
+ */
+ if (pipe(to_cmd_pipe) < 0 ||
+ pipe(from_cmd_pipe) < 0) {
+ ret->error = dupprintf("pipe: %s", strerror(errno));
+ sfree(cmd);
+ return (Socket)ret;
+ }
+ cloexec(to_cmd_pipe[1]);
+ cloexec(from_cmd_pipe[0]);
+
+ pid = fork();
+
+ if (pid < 0) {
+ ret->error = dupprintf("fork: %s", strerror(errno));
+ sfree(cmd);
+ return (Socket)ret;
+ } else if (pid == 0) {
+ close(0);
+ close(1);
+ dup2(to_cmd_pipe[0], 0);
+ dup2(from_cmd_pipe[1], 1);
+ close(to_cmd_pipe[0]);
+ close(from_cmd_pipe[1]);
+ noncloexec(0);
+ noncloexec(1);
+ execl("/bin/sh", "sh", "-c", cmd, (void *)NULL);
+ _exit(255);
+ }