summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--auth1.c3
-rw-r--r--serverloop.c33
-rw-r--r--session.c37
-rw-r--r--session.h4
5 files changed, 51 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index baef6fab..bcdce186 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,6 +54,13 @@
- markus@cvs.openbsd.org 2002/01/31 15:00:05
[serverloop.c]
no need for WNOHANG; ok stevesk@
+ - markus@cvs.openbsd.org 2002/02/03 17:53:25
+ [auth1.c serverloop.c session.c session.h]
+ don't use channel_input_channel_request and callback
+ use new server_input_channel_req() instead:
+ server_input_channel_req does generic request parsing on server side
+ session_input_channel_req handles just session specific things now
+ ok djm@
20020130
- (djm) Delay PRNG seeding until we need it in ssh-keygen, from markus@
@@ -7456,4 +7463,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
-$Id: ChangeLog,v 1.1814 2002/02/05 01:20:16 djm Exp $
+$Id: ChangeLog,v 1.1815 2002/02/05 01:21:42 djm Exp $
diff --git a/auth1.c b/auth1.c
index 73fffec3..bae00fb5 100644
--- a/auth1.c
+++ b/auth1.c
@@ -10,7 +10,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: auth1.c,v 1.34 2001/12/28 14:50:54 markus Exp $");
+RCSID("$OpenBSD: auth1.c,v 1.35 2002/02/03 17:53:25 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -22,6 +22,7 @@ RCSID("$OpenBSD: auth1.c,v 1.34 2001/12/28 14:50:54 markus Exp $");
#include "servconf.h"
#include "compat.h"
#include "auth.h"
+#include "channels.h"
#include "session.h"
#include "misc.h"
#include "uidswap.h"
diff --git a/serverloop.c b/serverloop.c
index bd1d048e..b8a5f160 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.96 2002/01/31 15:00:05 markus Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.97 2002/02/03 17:53:25 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
@@ -902,8 +902,6 @@ server_request_session(char *ctype)
channel_free(c);
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;
}
@@ -1004,6 +1002,33 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
}
xfree(rtype);
}
+static void
+server_input_channel_req(int type, u_int32_t seq, void *ctxt)
+{
+ Channel *c;
+ int id, reply, success = 0;
+ char *rtype;
+
+ id = packet_get_int();
+ rtype = packet_get_string(NULL);
+ reply = packet_get_char();
+
+ debug("server_input_channel_req: channel %d request %s reply %d",
+ id, rtype, reply);
+
+ if ((c = channel_lookup(id)) == NULL)
+ packet_disconnect("server_input_channel_req: "
+ "unknown channel %d", id);
+ if (c->type == SSH_CHANNEL_LARVAL || c->type == SSH_CHANNEL_OPEN)
+ success = session_input_channel_req(c, rtype);
+ if (reply) {
+ packet_start(success ?
+ SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
+ packet_put_int(c->remote_id);
+ packet_send();
+ }
+ xfree(rtype);
+}
static void
server_init_dispatch_20(void)
@@ -1017,7 +1042,7 @@ server_init_dispatch_20(void)
dispatch_set(SSH2_MSG_CHANNEL_OPEN, &server_input_channel_open);
dispatch_set(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, &channel_input_open_confirmation);
dispatch_set(SSH2_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
- dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
+ dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &server_input_channel_req);
dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request);
/* client_alive */
diff --git a/session.c b/session.c
index 2b4bbb66..c6e527ff 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.122 2002/01/29 22:46:41 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.123 2002/02/03 17:53:25 markus Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -1729,28 +1729,18 @@ session_auth_agent_req(Session *s)
}
}
-void
-session_input_channel_req(int id, void *arg)
+int
+session_input_channel_req(Channel *c, const char *rtype)
{
- u_int len;
- int reply;
int success = 0;
- char *rtype;
Session *s;
- Channel *c;
-
- rtype = packet_get_string(&len);
- reply = packet_get_char();
-
- s = session_by_channel(id);
- if (s == NULL)
- fatal("session_input_channel_req: channel %d: no session", id);
- c = channel_lookup(id);
- if (c == NULL)
- fatal("session_input_channel_req: channel %d: bad channel", id);
- debug("session_input_channel_req: session %d channel %d request %s reply %d",
- s->self, id, rtype, reply);
+ if ((s = session_by_channel(c->self)) == NULL) {
+ log("session_input_channel_req: no session %d req %.100s",
+ c->self, rtype);
+ return 0;
+ }
+ debug("session_input_channel_req: session %d req %s", s->self, rtype);
/*
* a session is in LARVAL state until a shell, a command
@@ -1774,14 +1764,7 @@ session_input_channel_req(int id, void *arg)
if (strcmp(rtype, "window-change") == 0) {
success = session_window_change_req(s);
}
-
- if (reply) {
- packet_start(success ?
- SSH2_MSG_CHANNEL_SUCCESS : SSH2_MSG_CHANNEL_FAILURE);
- packet_put_int(c->remote_id);
- packet_send();
- }
- xfree(rtype);
+ return success;
}
void
diff --git a/session.h b/session.h
index 6d5b8e69..ec8284a5 100644
--- a/session.h
+++ b/session.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.h,v 1.13 2001/10/10 22:18:47 markus Exp $ */
+/* $OpenBSD: session.h,v 1.14 2002/02/03 17:53:25 markus Exp $ */
/*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -29,7 +29,7 @@
void do_authenticated(Authctxt *);
int session_open(Authctxt*, int);
-void session_input_channel_req(int, void *);
+int session_input_channel_req(Channel *, const char *);
void session_close_by_pid(pid_t, int);
void session_close_by_channel(int, void *);
void session_destroy_all(void);