]> andersk Git - openssh.git/commitdiff
- markus@cvs.openbsd.org 2001/04/05 21:05:24
authormouring <mouring>
Thu, 5 Apr 2001 23:37:36 +0000 (23:37 +0000)
committermouring <mouring>
Thu, 5 Apr 2001 23:37:36 +0000 (23:37 +0000)
     [clientloop.c ssh.c]
     don't request a session for 'ssh -N', pointed out slade@shore.net

ChangeLog
clientloop.c
ssh.c

index 683f621fde34c35a9f8f4ec24b54ff37373e3a30..5ab1eb968c3866a67dc8583f1bcd4bc3b1d2a1a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,9 @@
    - markus@cvs.openbsd.org 2001/04/05 21:02:46
      [buffer.c]
      better error message
+   - markus@cvs.openbsd.org 2001/04/05 21:05:24
+     [clientloop.c ssh.c]
+     don't request a session for 'ssh -N', pointed out slade@shore.net
 
 20010405
  - OpenBSD CVS Sync                                              
index 74610c6b188bae90b13de4b5de3abaf46a2e891c..ad20b2f0e7794158f4eaec2f5ff0f0eb9b0ad0c4 100644 (file)
@@ -59,7 +59,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.59 2001/04/05 20:01:10 markus Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.60 2001/04/05 21:05:23 markus Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -128,6 +128,7 @@ static u_int buffer_high;/* Soft max buffer size. */
 static int connection_in;      /* Connection to server (input). */
 static int connection_out;     /* Connection to server (output). */
 static int need_rekeying;      /* Set to non-zero if rekeying is requested. */
+static int session_closed = 0; /* In SSH2: login session closed. */
 
 void   client_init_dispatch(void);
 int    session_ident = -1;
@@ -788,6 +789,15 @@ simple_escape_filter(Channel *c, char *buf, int len)
        return process_escapes(&c->input, &c->output, &c->extended, buf, len);
 }
 
+void
+client_channel_closed(int id, void *arg)
+{
+       if (id != session_ident)
+               error("client_channel_closed: id %d != session_ident %d",
+                   id, session_ident);
+       session_closed = 1;
+}
+
 /*
  * Implements the interactive session with the server.  This is called after
  * the user has been authenticated, and a command has been started on the
@@ -851,6 +861,9 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
                if (escape_char != -1)
                        channel_register_filter(session_ident,
                            simple_escape_filter);
+               if (session_ident != -1)
+                       channel_register_cleanup(session_ident,
+                           client_channel_closed);
        } else {
                /* Check if we should immediately send eof on stdin. */
                client_check_initial_eof_on_stdin();
@@ -862,12 +875,10 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
                /* Process buffered packets sent by the server. */
                client_process_buffered_input_packets();
 
-               rekeying = (xxx_kex != NULL && !xxx_kex->done);
-
-               if (compat20 && !channel_still_open()) {
-                       debug2("!channel_still_open.");
+               if (compat20 && session_closed && !channel_still_open())
                        break;
-               }
+
+               rekeying = (xxx_kex != NULL && !xxx_kex->done);
 
                if (rekeying) {
                        debug("rekeying in progress");
diff --git a/ssh.c b/ssh.c
index 6847814c054d8feb80b66e9df670a6a23d92e978..278e7eda4a494fc4fb7752bcc878610d915a5bdf 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.105 2001/03/26 08:07:09 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.106 2001/04/05 21:05:24 markus Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -946,9 +946,6 @@ ssh_session2_callback(int id, void *arg)
 
        debug("client_init id %d arg %ld", id, (long)arg);
 
-       if (no_shell_flag)
-               goto done;
-
        if (tty_flag) {
                struct winsize ws;
                char *cp;
@@ -1011,15 +1008,14 @@ ssh_session2_callback(int id, void *arg)
        }
        /* channel_callback(id, SSH2_MSG_OPEN_CONFIGMATION, client_init, 0); */
 
-done:
        /* register different callback, etc. XXX */
        packet_set_interactive(interactive);
 }
 
 int
-ssh_session2(void)
+ssh_session2_command(void)
 {
-       int window, packetmax, id;
+       int id, window, packetmax;
        int in, out, err;
 
        if (stdin_null_flag) {
@@ -1041,14 +1037,6 @@ ssh_session2(void)
        if (!isatty(err))
                set_nonblock(err);
 
-       /* XXX should be pre-session */
-       ssh_init_forwarding();
-
-       /* If requested, let ssh continue in the background. */
-       if (fork_after_authentication_flag)
-               if (daemon(1, 1) < 0)
-                       fatal("daemon() failed: %.200s", strerror(errno));
-
        window = CHAN_SES_WINDOW_DEFAULT;
        packetmax = CHAN_SES_PACKET_DEFAULT;
        if (!tty_flag) {
@@ -1060,10 +1048,30 @@ ssh_session2(void)
            window, packetmax, CHAN_EXTENDED_WRITE,
            xstrdup("client-session"), /*nonblock*/0);
 
+debug("channel_new: %d", id);
+
        channel_open(id);
        channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION,
             ssh_session2_callback, (void *)0);
 
+       return id;
+}
+
+int
+ssh_session2(void)
+{
+       int id;
+
+       /* XXX should be pre-session */
+       ssh_init_forwarding();
+
+       id = no_shell_flag ? -1 : ssh_session2_command();
+
+       /* If requested, let ssh continue in the background. */
+       if (fork_after_authentication_flag)
+               if (daemon(1, 1) < 0)
+                       fatal("daemon() failed: %.200s", strerror(errno));
+
        return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id);
 }
 
This page took 0.06057 seconds and 5 git commands to generate.