diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-05 06:09:47 +0200 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-05 06:09:47 +0200 |
commit | 99c73b377a45d3e008e73cca9073dc006e1cfaae (patch) | |
tree | b2b33909e71916ba176521d28663d90fc8b40fc4 /serverloop.c | |
parent | - markus@cvs.openbsd.org 2001/05/04 14:34:34 (diff) | |
download | openssh-99c73b377a45d3e008e73cca9073dc006e1cfaae.tar.xz openssh-99c73b377a45d3e008e73cca9073dc006e1cfaae.zip |
- markus@cvs.openbsd.org 2001/05/04 23:47:34
[channels.c channels.h clientloop.c nchan.c nchan.h serverloop.c ssh.c]
move to Channel **channels (instead of Channel *channels), fixes realloc
problems. channel_new now returns a Channel *, favour Channel * over
channel id. remove old channel_allocate interface.
Diffstat (limited to 'serverloop.c')
-rw-r--r-- | serverloop.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/serverloop.c b/serverloop.c index 2ca892e5d..5b3135564 100644 --- a/serverloop.c +++ b/serverloop.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: serverloop.c,v 1.63 2001/04/29 19:16:52 markus Exp $"); +RCSID("$OpenBSD: serverloop.c,v 1.64 2001/05/04 23:47:34 markus Exp $"); #include "xmalloc.h" #include "packet.h" @@ -801,7 +801,8 @@ server_input_window_size(int type, int plen, void *ctxt) Channel * server_request_direct_tcpip(char *ctype) { - int sock, newch; + Channel *c; + int sock; char *target, *originator; int target_port, originator_port; @@ -820,16 +821,20 @@ server_request_direct_tcpip(char *ctype) xfree(originator); if (sock < 0) return NULL; - newch = channel_new(ctype, SSH_CHANNEL_CONNECTING, + c = channel_new(ctype, SSH_CHANNEL_CONNECTING, sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1); - return (newch >= 0) ? channel_lookup(newch) : NULL; + if (c == NULL) { + error("server_request_direct_tcpip: channel_new failed"); + close(sock); + } + return c; } Channel * server_request_session(char *ctype) { - int newch; + Channel *c; debug("input_session_request"); packet_done(); @@ -839,19 +844,22 @@ server_request_session(char *ctype) * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all * CHANNEL_REQUEST messages is registered. */ - newch = channel_new(ctype, SSH_CHANNEL_LARVAL, - -1, -1, -1, 0, CHAN_SES_PACKET_DEFAULT, + c = channel_new(ctype, SSH_CHANNEL_LARVAL, + -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT, 0, xstrdup("server-session"), 1); - if (session_open(newch) == 1) { - channel_register_callback(newch, SSH2_MSG_CHANNEL_REQUEST, - session_input_channel_req, (void *)0); - channel_register_cleanup(newch, session_close_by_channel); - return channel_lookup(newch); - } else { - debug("session open failed, free channel %d", newch); - channel_free(newch); + if (c == NULL) { + error("server_request_session: channel_new failed"); + return NULL; + } + if (session_open(c->self) != 1) { + debug("session open failed, free channel %d", c->self); + channel_free(c); + return NULL; } - return NULL; + channel_register_callback(c->self, SSH2_MSG_CHANNEL_REQUEST, + session_input_channel_req, (void *)0); + channel_register_cleanup(c->self, session_close_by_channel); + return c; } void |