]> andersk Git - gssapi-openssh.git/blobdiff - openssh/monitor_wrap.c
merged OpenSSH 5.1p1 to trunk
[gssapi-openssh.git] / openssh / monitor_wrap.c
index c16f789a73348465c722ac8bba4f556f829f2fc9..54000e05985fd899571a7df67fa2ef49e7b4275e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_wrap.c,v 1.60 2007/10/29 04:08:08 dtucker Exp $ */
+/* $OpenBSD: monitor_wrap.c,v 1.63 2008/07/10 18:08:11 markus Exp $ */
 /*
  * Copyright 2002 Niels Provos <provos@citi.umich.edu>
  * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -41,6 +41,7 @@
 #include <openssl/bn.h>
 #include <openssl/dh.h>
 
+#include "openbsd-compat/sys-queue.h"
 #include "xmalloc.h"
 #include "ssh.h"
 #include "dh.h"
@@ -572,7 +573,7 @@ mm_send_keystate(struct monitor *monitor)
        u_char *blob, *p;
        u_int bloblen, plen;
        u_int32_t seqnr, packets;
-       u_int64_t blocks;
+       u_int64_t blocks, bytes;
 
        buffer_init(&m);
 
@@ -621,14 +622,16 @@ mm_send_keystate(struct monitor *monitor)
        buffer_put_string(&m, blob, bloblen);
        xfree(blob);
 
-       packet_get_state(MODE_OUT, &seqnr, &blocks, &packets);
+       packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes);
        buffer_put_int(&m, seqnr);
        buffer_put_int64(&m, blocks);
        buffer_put_int(&m, packets);
-       packet_get_state(MODE_IN, &seqnr, &blocks, &packets);
+       buffer_put_int64(&m, bytes);
+       packet_get_state(MODE_IN, &seqnr, &blocks, &packets, &bytes);
        buffer_put_int(&m, seqnr);
        buffer_put_int64(&m, blocks);
        buffer_put_int(&m, packets);
+       buffer_put_int64(&m, bytes);
 
        debug3("%s: New keys have been sent", __func__);
  skip:
@@ -665,7 +668,20 @@ mm_pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, size_t namebuflen)
 {
        Buffer m;
        char *p, *msg;
-       int success = 0;
+       int success = 0, tmp1 = -1, tmp2 = -1;
+
+       /* Kludge: ensure there are fds free to receive the pty/tty */
+       if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
+           (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
+               error("%s: cannot allocate fds for pty", __func__);
+               if (tmp1 > 0)
+                       close(tmp1);
+               if (tmp2 > 0)
+                       close(tmp2);
+               return 0;
+       }
+       close(tmp1);
+       close(tmp2);
 
        buffer_init(&m);
        mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, &m);
@@ -710,8 +726,9 @@ mm_session_pty_cleanup2(Session *s)
        buffer_free(&m);
 
        /* closed dup'ed master */
-       if (close(s->ptymaster) < 0)
-               error("close(s->ptymaster): %s", strerror(errno));
+       if (s->ptymaster != -1 && close(s->ptymaster) < 0)
+               error("close(s->ptymaster/%d): %s",
+                   s->ptymaster, strerror(errno));
 
        /* unlink pty from session */
        s->ttyfd = -1;
This page took 0.248815 seconds and 4 git commands to generate.