~ubuntu-branches/ubuntu/lucid/openssh/lucid

« back to all changes in this revision

Viewing changes to monitor_wrap.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-09-30 23:09:58 UTC
  • mfrom: (1.13.3 upstream) (29 hardy)
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20080930230958-o6vsgn8c4mm959s0
Tags: 1:5.1p1-3
* Remove unnecessary ssh-vulnkey output in non-verbose mode when no
  compromised or unknown keys were found (closes: #496495).
* Configure with --disable-strip; dh_strip will deal with stripping
  binaries and will honour DEB_BUILD_OPTIONS (thanks, Bernhard R. Link;
  closes: #498681).
* Fix handling of zero-length server banners (thanks, Tomas Mraz; closes:
  #497026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $OpenBSD: monitor_wrap.c,v 1.55 2007/02/19 10:45:58 dtucker Exp $ */
 
1
/* $OpenBSD: monitor_wrap.c,v 1.63 2008/07/10 18:08:11 markus Exp $ */
2
2
/*
3
3
 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4
4
 * Copyright 2002 Markus Friedl <markus@openbsd.org>
41
41
#include <openssl/bn.h>
42
42
#include <openssl/dh.h>
43
43
 
 
44
#include "openbsd-compat/sys-queue.h"
44
45
#include "xmalloc.h"
45
46
#include "ssh.h"
46
47
#include "dh.h"
222
223
        mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_PWNAM, &m);
223
224
 
224
225
        if (buffer_get_char(&m) == 0) {
225
 
                buffer_free(&m);
226
 
                return (NULL);
 
226
                pw = NULL;
 
227
                goto out;
227
228
        }
228
229
        pw = buffer_get_string(&m, &len);
229
230
        if (len != sizeof(struct passwd))
237
238
        pw->pw_dir = buffer_get_string(&m, NULL);
238
239
        pw->pw_shell = buffer_get_string(&m, NULL);
239
240
 
 
241
out:
240
242
        /* copy options block as a Match directive may have changed some */
241
243
        newopts = buffer_get_string(&m, &len);
242
244
        if (len != sizeof(*newopts))
494
496
 
495
497
        /* Mac structure */
496
498
        mac->name = buffer_get_string(&b, NULL);
497
 
        if (mac->name == NULL || mac_init(mac, mac->name) == -1)
498
 
                fatal("%s: can not init mac %s", __func__, mac->name);
 
499
        if (mac->name == NULL || mac_setup(mac, mac->name) == -1)
 
500
                fatal("%s: can not setup mac %s", __func__, mac->name);
499
501
        mac->enabled = buffer_get_int(&b);
500
502
        mac->key = buffer_get_string(&b, &len);
501
503
        if (len > mac->key_len)
589
591
        u_char *blob, *p;
590
592
        u_int bloblen, plen;
591
593
        u_int32_t seqnr, packets;
592
 
        u_int64_t blocks;
 
594
        u_int64_t blocks, bytes;
593
595
 
594
596
        buffer_init(&m);
595
597
 
638
640
        buffer_put_string(&m, blob, bloblen);
639
641
        xfree(blob);
640
642
 
641
 
        packet_get_state(MODE_OUT, &seqnr, &blocks, &packets);
642
 
        buffer_put_int(&m, seqnr);
643
 
        buffer_put_int64(&m, blocks);
644
 
        buffer_put_int(&m, packets);
645
 
        packet_get_state(MODE_IN, &seqnr, &blocks, &packets);
646
 
        buffer_put_int(&m, seqnr);
647
 
        buffer_put_int64(&m, blocks);
648
 
        buffer_put_int(&m, packets);
 
643
        packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes);
 
644
        buffer_put_int(&m, seqnr);
 
645
        buffer_put_int64(&m, blocks);
 
646
        buffer_put_int(&m, packets);
 
647
        buffer_put_int64(&m, bytes);
 
648
        packet_get_state(MODE_IN, &seqnr, &blocks, &packets, &bytes);
 
649
        buffer_put_int(&m, seqnr);
 
650
        buffer_put_int64(&m, blocks);
 
651
        buffer_put_int(&m, packets);
 
652
        buffer_put_int64(&m, bytes);
649
653
 
650
654
        debug3("%s: New keys have been sent", __func__);
651
655
 skip:
682
686
{
683
687
        Buffer m;
684
688
        char *p, *msg;
685
 
        int success = 0;
 
689
        int success = 0, tmp1 = -1, tmp2 = -1;
 
690
 
 
691
        /* Kludge: ensure there are fds free to receive the pty/tty */
 
692
        if ((tmp1 = dup(pmonitor->m_recvfd)) == -1 ||
 
693
            (tmp2 = dup(pmonitor->m_recvfd)) == -1) {
 
694
                error("%s: cannot allocate fds for pty", __func__);
 
695
                if (tmp1 > 0)
 
696
                        close(tmp1);
 
697
                if (tmp2 > 0)
 
698
                        close(tmp2);
 
699
                return 0;
 
700
        }
 
701
        close(tmp1);
 
702
        close(tmp2);
686
703
 
687
704
        buffer_init(&m);
688
705
        mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_PTY, &m);
706
723
        buffer_append(&loginmsg, msg, strlen(msg));
707
724
        xfree(msg);
708
725
 
709
 
        *ptyfd = mm_receive_fd(pmonitor->m_recvfd);
710
 
        *ttyfd = mm_receive_fd(pmonitor->m_recvfd);
 
726
        if ((*ptyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1 ||
 
727
            (*ttyfd = mm_receive_fd(pmonitor->m_recvfd)) == -1)
 
728
                fatal("%s: receive fds failed", __func__);
711
729
 
712
730
        /* Success */
713
731
        return (1);
726
744
        buffer_free(&m);
727
745
 
728
746
        /* closed dup'ed master */
729
 
        if (close(s->ptymaster) < 0)
730
 
                error("close(s->ptymaster): %s", strerror(errno));
 
747
        if (s->ptymaster != -1 && close(s->ptymaster) < 0)
 
748
                error("close(s->ptymaster/%d): %s",
 
749
                    s->ptymaster, strerror(errno));
731
750
 
732
751
        /* unlink pty from session */
733
752
        s->ttyfd = -1;