projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix 'Duplicate Session' on Windows, broken during the config revamp.
[u/mdw/putty]
/
unix
/
uxproxy.c
diff --git
a/unix/uxproxy.c
b/unix/uxproxy.c
index
cd256fd
..
b441b80
100644
(file)
--- a/
unix/uxproxy.c
+++ b/
unix/uxproxy.c
@@
-98,6
+98,8
@@
static void sk_localproxy_close (Socket s)
del234(localproxy_by_fromfd, ps);
del234(localproxy_by_tofd, ps);
del234(localproxy_by_fromfd, ps);
del234(localproxy_by_tofd, ps);
+ uxsel_del(ps->to_cmd);
+ uxsel_del(ps->from_cmd);
close(ps->to_cmd);
close(ps->from_cmd);
close(ps->to_cmd);
close(ps->from_cmd);
@@
-207,7
+209,7
@@
static int localproxy_select_result(int fd, int event)
} else if (ret == 0) {
return plug_closing(s->plug, NULL, 0, 0);
} else {
} else if (ret == 0) {
return plug_closing(s->plug, NULL, 0, 0);
} else {
- return plug_receive(s->plug,
1
, buf, ret);
+ return plug_receive(s->plug,
0
, buf, ret);
}
} else if (event == 2) {
assert(fd == s->to_cmd);
}
} else if (event == 2) {
assert(fd == s->to_cmd);
@@
-221,8
+223,8
@@
static int localproxy_select_result(int fd, int event)
Socket platform_new_connection(SockAddr addr, char *hostname,
int port, int privport,
Socket platform_new_connection(SockAddr addr, char *hostname,
int port, int privport,
- int oobinline, int nodelay,
Plug plug
,
-
const Config *cfg
)
+ int oobinline, int nodelay,
int keepalive
,
+
Plug plug, Conf *conf
)
{
char *cmd;
{
char *cmd;
@@
-241,10
+243,10
@@
Socket platform_new_connection(SockAddr addr, char *hostname,
Local_Proxy_Socket ret;
int to_cmd_pipe[2], from_cmd_pipe[2], pid;
Local_Proxy_Socket ret;
int to_cmd_pipe[2], from_cmd_pipe[2], pid;
- if (c
fg->proxy_type
!= PROXY_CMD)
+ if (c
onf_get_int(conf, CONF_proxy_type)
!= PROXY_CMD)
return NULL;
return NULL;
- cmd = format_telnet_command(addr, port, c
fg
);
+ cmd = format_telnet_command(addr, port, c
onf
);
ret = snew(struct Socket_localproxy_tag);
ret->fn = &socket_fn_table;
ret = snew(struct Socket_localproxy_tag);
ret->fn = &socket_fn_table;
@@
-263,6
+265,8
@@
Socket platform_new_connection(SockAddr addr, char *hostname,
ret->error = dupprintf("pipe: %s", strerror(errno));
return (Socket)ret;
}
ret->error = dupprintf("pipe: %s", strerror(errno));
return (Socket)ret;
}
+ cloexec(to_cmd_pipe[1]);
+ cloexec(from_cmd_pipe[0]);
pid = fork();
pid = fork();
@@
-270,19
+274,20
@@
Socket platform_new_connection(SockAddr addr, char *hostname,
ret->error = dupprintf("fork: %s", strerror(errno));
return (Socket)ret;
} else if (pid == 0) {
ret->error = dupprintf("fork: %s", strerror(errno));
return (Socket)ret;
} else if (pid == 0) {
- int i;
close(0);
close(1);
dup2(to_cmd_pipe[0], 0);
dup2(from_cmd_pipe[1], 1);
close(0);
close(1);
dup2(to_cmd_pipe[0], 0);
dup2(from_cmd_pipe[1], 1);
- for (i = 3; i < 127; i++)
-
close(i
);
+ close(to_cmd_pipe[0]);
+
close(from_cmd_pipe[1]
);
fcntl(0, F_SETFD, 0);
fcntl(1, F_SETFD, 0);
fcntl(0, F_SETFD, 0);
fcntl(1, F_SETFD, 0);
- execl("/bin/sh", "sh", "-c", cmd, NULL);
+ execl("/bin/sh", "sh", "-c", cmd,
(void *)
NULL);
_exit(255);
}
_exit(255);
}
+ sfree(cmd);
+
close(to_cmd_pipe[0]);
close(from_cmd_pipe[1]);
close(to_cmd_pipe[0]);
close(from_cmd_pipe[1]);
@@
-299,5
+304,8
@@
Socket platform_new_connection(SockAddr addr, char *hostname,
uxsel_set(ret->from_cmd, 1, localproxy_select_result);
uxsel_set(ret->from_cmd, 1, localproxy_select_result);
+ /* We are responsible for this and don't need it any more */
+ sk_addr_free(addr);
+
return (Socket) ret;
}
return (Socket) ret;
}