Import debian 5.9p1-1
[openssh.git] / clientloop.c
index c19b01f..18a85c5 100644 (file)
 #include "msg.h"
 #include "roaming.h"
 
+#ifdef GSSAPI
+#include "ssh-gss.h"
+#endif
+
 /* import options */
 extern Options options;
 
@@ -541,16 +545,21 @@ client_global_request_reply(int type, u_int32_t seq, void *ctxt)
 static void
 server_alive_check(void)
 {
-       if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
-               logit("Timeout, server %s not responding.", host);
-               cleanup_exit(255);
+       if (compat20) {
+               if (packet_inc_alive_timeouts() > options.server_alive_count_max) {
+                       logit("Timeout, server %s not responding.", host);
+                       cleanup_exit(255);
+               }
+               packet_start(SSH2_MSG_GLOBAL_REQUEST);
+               packet_put_cstring("keepalive@openssh.com");
+               packet_put_char(1);     /* boolean: want reply */
+               packet_send();
+               /* Insert an empty placeholder to maintain ordering */
+               client_register_global_confirm(NULL, NULL);
+       } else {
+               packet_send_ignore(0);
+               packet_send();
        }
-       packet_start(SSH2_MSG_GLOBAL_REQUEST);
-       packet_put_cstring("keepalive@openssh.com");
-       packet_put_char(1);     /* boolean: want reply */
-       packet_send();
-       /* Insert an empty placeholder to maintain ordering */
-       client_register_global_confirm(NULL, NULL);
 }
 
 /*
@@ -610,7 +619,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
         */
 
        timeout_secs = INT_MAX; /* we use INT_MAX to mean no timeout */
-       if (options.server_alive_interval > 0 && compat20)
+       if (options.server_alive_interval > 0)
                timeout_secs = options.server_alive_interval;
        set_control_persist_exit_time();
        if (control_persist_exit_time > 0) {
@@ -1508,6 +1517,15 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
                /* Do channel operations unless rekeying in progress. */
                if (!rekeying) {
                        channel_after_select(readset, writeset);
+
+#ifdef GSSAPI
+                       if (options.gss_renewal_rekey &&
+                           ssh_gssapi_credentials_updated(GSS_C_NO_CONTEXT)) {
+                               debug("credentials updated - forcing rekey");
+                               need_rekeying = 1;
+                       }
+#endif
+
                        if (need_rekeying || packet_need_rekeying()) {
                                debug("need rekeying");
                                xxx_kex->done = 0;
@@ -1601,8 +1619,10 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
                exit_status = 0;
        }
 
-       if (received_signal)
-               fatal("Killed by signal %d.", (int) received_signal);
+       if (received_signal) {
+               debug("Killed by signal %d.", (int) received_signal);
+               cleanup_exit((int) received_signal + 128);
+       }
 
        /*
         * In interactive mode (with pseudo tty) display a message indicating