summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Makefile.in16
-rw-r--r--clientloop.c9
-rw-r--r--monitor.c14
-rw-r--r--monitor_wrap.c9
-rw-r--r--packet.c30
-rw-r--r--roaming.h31
-rw-r--r--roaming_common.c100
-rw-r--r--roaming_dummy.c55
-rw-r--r--serverloop.c8
-rw-r--r--sshconnect.c8
-rw-r--r--sshd.c7
12 files changed, 254 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f73a6bcd..8ed7db993 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,10 +83,11 @@
83 ok markus@ 83 ok markus@
84 - andreas@cvs.openbsd.org 2009/05/28 16:50:16 84 - andreas@cvs.openbsd.org 2009/05/28 16:50:16
85 [sshd.c packet.c serverloop.c monitor_wrap.c clientloop.c sshconnect.c 85 [sshd.c packet.c serverloop.c monitor_wrap.c clientloop.c sshconnect.c
86 monitor.c] 86 monitor.c Added roaming.h roaming_common.c roaming_dummy.c]
87 Keep track of number of bytes read and written. Needed for upcoming 87 Keep track of number of bytes read and written. Needed for upcoming
88 changes. Most code from Martin Forssen, maf at appgate dot com. 88 changes. Most code from Martin Forssen, maf at appgate dot com.
89 ok markus@ 89 ok markus@
90 Also, applied appropriate changes to Makefile.in
90 91
9120090616 9220090616
92 - (dtucker) [configure.ac defines.h] Bug #1607: handle the case where fsid_t 93 - (dtucker) [configure.ac defines.h] Bug #1607: handle the case where fsid_t
diff --git a/Makefile.in b/Makefile.in
index 312b8d2b1..75eb06d6f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.298 2008/11/05 05:20:46 djm Exp $ 1# $Id: Makefile.in,v 1.299 2009/06/21 08:53:53 dtucker Exp $
2 2
3# uncomment if you run a non bourne compatable shell. Ie. csh 3# uncomment if you run a non bourne compatable shell. Ie. csh
4#SHELL = @SH@ 4#SHELL = @SH@
@@ -74,7 +74,8 @@ LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \
74 entropy.o scard-opensc.o gss-genr.o umac.o jpake.o schnorr.o 74 entropy.o scard-opensc.o gss-genr.o umac.o jpake.o schnorr.o
75 75
76SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ 76SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
77 sshconnect.o sshconnect1.o sshconnect2.o mux.o 77 sshconnect.o sshconnect1.o sshconnect2.o mux.o \
78 roaming_common.o
78 79
79SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ 80SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
80 sshpty.o sshlogin.o servconf.o serverloop.o \ 81 sshpty.o sshlogin.o servconf.o serverloop.o \
@@ -86,7 +87,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
86 auth-krb5.o \ 87 auth-krb5.o \
87 auth2-gss.o gss-serv.o gss-serv-krb5.o \ 88 auth2-gss.o gss-serv.o gss-serv-krb5.o \
88 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \ 89 loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
89 audit.o audit-bsm.o platform.o sftp-server.o sftp-common.o 90 audit.o audit-bsm.o platform.o sftp-server.o sftp-common.o \
91 roaming_common.o
90 92
91MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out sshd_config.5.out ssh_config.5.out 93MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-rand-helper.8.out ssh-keysign.8.out sshd_config.5.out ssh_config.5.out
92MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-rand-helper.8 ssh-keysign.8 sshd_config.5 ssh_config.5 94MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-rand-helper.8 ssh-keysign.8 sshd_config.5 ssh_config.5
@@ -151,11 +153,11 @@ ssh-agent$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-agent.o
151ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o 153ssh-keygen$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keygen.o
152 $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) 154 $(LD) -o $@ ssh-keygen.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
153 155
154ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o 156ssh-keysign$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keysign.o roaming_dummy.o
155 $(LD) -o $@ ssh-keysign.o readconf.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) 157 $(LD) -o $@ ssh-keysign.o readconf.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
156 158
157ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o 159ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
158 $(LD) -o $@ ssh-keyscan.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS) 160 $(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
159 161
160sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o 162sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
161 $(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) 163 $(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
diff --git a/clientloop.c b/clientloop.c
index d5a06556a..43f001bc4 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.211 2009/05/27 06:33:39 andreas Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.212 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -109,6 +109,7 @@
109#include "misc.h" 109#include "misc.h"
110#include "match.h" 110#include "match.h"
111#include "msg.h" 111#include "msg.h"
112#include "roaming.h"
112 113
113/* import options */ 114/* import options */
114extern Options options; 115extern Options options;
@@ -634,7 +635,7 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
634static void 635static void
635client_process_net_input(fd_set *readset) 636client_process_net_input(fd_set *readset)
636{ 637{
637 int len; 638 int len, cont = 0;
638 char buf[8192]; 639 char buf[8192];
639 640
640 /* 641 /*
@@ -643,8 +644,8 @@ client_process_net_input(fd_set *readset)
643 */ 644 */
644 if (FD_ISSET(connection_in, readset)) { 645 if (FD_ISSET(connection_in, readset)) {
645 /* Read as much as possible. */ 646 /* Read as much as possible. */
646 len = read(connection_in, buf, sizeof(buf)); 647 len = roaming_read(connection_in, buf, sizeof(buf), &cont);
647 if (len == 0) { 648 if (len == 0 && cont == 0) {
648 /* 649 /*
649 * Received EOF. The remote host has closed the 650 * Received EOF. The remote host has closed the
650 * connection. 651 * connection.
diff --git a/monitor.c b/monitor.c
index 61242e6d0..36a9e1dc1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.102 2009/05/25 06:48:01 andreas Exp $ */ 1/* $OpenBSD: monitor.c,v 1.103 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -125,6 +125,8 @@ struct {
125 u_int ilen; 125 u_int ilen;
126 u_char *output; 126 u_char *output;
127 u_int olen; 127 u_int olen;
128 u_int64_t sent_bytes;
129 u_int64_t recv_bytes;
128} child_state; 130} child_state;
129 131
130/* Functions on the monitor that answer unprivileged requests */ 132/* Functions on the monitor that answer unprivileged requests */
@@ -1679,6 +1681,10 @@ monitor_apply_keystate(struct monitor *pmonitor)
1679 child_state.olen); 1681 child_state.olen);
1680 memset(child_state.output, 0, child_state.olen); 1682 memset(child_state.output, 0, child_state.olen);
1681 xfree(child_state.output); 1683 xfree(child_state.output);
1684
1685 /* Roaming */
1686 if (compat20)
1687 roam_set_bytes(child_state.sent_bytes, child_state.recv_bytes);
1682} 1688}
1683 1689
1684static Kex * 1690static Kex *
@@ -1794,6 +1800,12 @@ mm_get_keystate(struct monitor *pmonitor)
1794 child_state.input = buffer_get_string(&m, &child_state.ilen); 1800 child_state.input = buffer_get_string(&m, &child_state.ilen);
1795 child_state.output = buffer_get_string(&m, &child_state.olen); 1801 child_state.output = buffer_get_string(&m, &child_state.olen);
1796 1802
1803 /* Roaming */
1804 if (compat20) {
1805 child_state.sent_bytes = buffer_get_int64(&m);
1806 child_state.recv_bytes = buffer_get_int64(&m);
1807 }
1808
1797 buffer_free(&m); 1809 buffer_free(&m);
1798} 1810}
1799 1811
diff --git a/monitor_wrap.c b/monitor_wrap.c
index d71d4a8c5..b696d7821 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_wrap.c,v 1.66 2009/05/25 06:48:01 andreas Exp $ */ 1/* $OpenBSD: monitor_wrap.c,v 1.67 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -77,6 +77,7 @@
77#include "channels.h" 77#include "channels.h"
78#include "session.h" 78#include "session.h"
79#include "servconf.h" 79#include "servconf.h"
80#include "roaming.h"
80 81
81/* Imports */ 82/* Imports */
82extern int compat20; 83extern int compat20;
@@ -660,6 +661,12 @@ mm_send_keystate(struct monitor *monitor)
660 buffer_put_string(&m, buffer_ptr(input), buffer_len(input)); 661 buffer_put_string(&m, buffer_ptr(input), buffer_len(input));
661 buffer_put_string(&m, buffer_ptr(output), buffer_len(output)); 662 buffer_put_string(&m, buffer_ptr(output), buffer_len(output));
662 663
664 /* Roaming */
665 if (compat20) {
666 buffer_put_int64(&m, get_sent_bytes());
667 buffer_put_int64(&m, get_recv_bytes());
668 }
669
663 mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, &m); 670 mm_request_send(monitor->m_recvfd, MONITOR_REQ_KEYEXPORT, &m);
664 debug3("%s: Finished sending state", __func__); 671 debug3("%s: Finished sending state", __func__);
665 672
diff --git a/packet.c b/packet.c
index cecab82e9..f3f8389a3 100644
--- a/packet.c
+++ b/packet.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: packet.c,v 1.162 2009/05/27 06:36:07 andreas Exp $ */ 1/* $OpenBSD: packet.c,v 1.163 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -77,6 +77,7 @@
77#include "canohost.h" 77#include "canohost.h"
78#include "misc.h" 78#include "misc.h"
79#include "ssh.h" 79#include "ssh.h"
80#include "roaming.h"
80 81
81#ifdef PACKET_DEBUG 82#ifdef PACKET_DEBUG
82#define DBG(x) x 83#define DBG(x) x
@@ -1012,7 +1013,7 @@ packet_send(void)
1012int 1013int
1013packet_read_seqnr(u_int32_t *seqnr_p) 1014packet_read_seqnr(u_int32_t *seqnr_p)
1014{ 1015{
1015 int type, len, ret, ms_remain; 1016 int type, len, ret, ms_remain, cont;
1016 fd_set *setp; 1017 fd_set *setp;
1017 char buf[8192]; 1018 char buf[8192];
1018 struct timeval timeout, start, *timeoutp = NULL; 1019 struct timeval timeout, start, *timeoutp = NULL;
@@ -1061,8 +1062,7 @@ packet_read_seqnr(u_int32_t *seqnr_p)
1061 if ((ret = select(active_state->connection_in + 1, setp, 1062 if ((ret = select(active_state->connection_in + 1, setp,
1062 NULL, NULL, timeoutp)) >= 0) 1063 NULL, NULL, timeoutp)) >= 0)
1063 break; 1064 break;
1064 if (errno != EAGAIN && errno != EINTR && 1065 if (errno != EAGAIN && errno != EINTR)
1065 errno != EWOULDBLOCK)
1066 break; 1066 break;
1067 if (active_state->packet_timeout_ms == -1) 1067 if (active_state->packet_timeout_ms == -1)
1068 continue; 1068 continue;
@@ -1078,7 +1078,11 @@ packet_read_seqnr(u_int32_t *seqnr_p)
1078 cleanup_exit(255); 1078 cleanup_exit(255);
1079 } 1079 }
1080 /* Read data from the socket. */ 1080 /* Read data from the socket. */
1081 len = read(active_state->connection_in, buf, sizeof(buf)); 1081 do {
1082 cont = 0;
1083 len = roaming_read(active_state->connection_in, buf,
1084 sizeof(buf), &cont);
1085 } while (len == 0 && cont);
1082 if (len == 0) { 1086 if (len == 0) {
1083 logit("Connection closed by %.200s", get_remote_ipaddr()); 1087 logit("Connection closed by %.200s", get_remote_ipaddr());
1084 cleanup_exit(255); 1088 cleanup_exit(255);
@@ -1624,23 +1628,23 @@ void
1624packet_write_poll(void) 1628packet_write_poll(void)
1625{ 1629{
1626 int len = buffer_len(&active_state->output); 1630 int len = buffer_len(&active_state->output);
1631 int cont;
1627 1632
1628 if (len > 0) { 1633 if (len > 0) {
1629 len = write(active_state->connection_out, 1634 cont = 0;
1630 buffer_ptr(&active_state->output), len); 1635 len = roaming_write(active_state->connection_out,
1636 buffer_ptr(&active_state->output), len, &cont);
1631 if (len == -1) { 1637 if (len == -1) {
1632 if (errno == EINTR || errno == EAGAIN || 1638 if (errno == EINTR || errno == EAGAIN)
1633 errno == EWOULDBLOCK)
1634 return; 1639 return;
1635 fatal("Write failed: %.100s", strerror(errno)); 1640 fatal("Write failed: %.100s", strerror(errno));
1636 } 1641 }
1637 if (len == 0) 1642 if (len == 0 && !cont)
1638 fatal("Write connection closed"); 1643 fatal("Write connection closed");
1639 buffer_consume(&active_state->output, len); 1644 buffer_consume(&active_state->output, len);
1640 } 1645 }
1641} 1646}
1642 1647
1643
1644/* 1648/*
1645 * Calls packet_write_poll repeatedly until all pending output data has been 1649 * Calls packet_write_poll repeatedly until all pending output data has been
1646 * written. 1650 * written.
@@ -1673,8 +1677,7 @@ packet_write_wait(void)
1673 if ((ret = select(active_state->connection_out + 1, 1677 if ((ret = select(active_state->connection_out + 1,
1674 NULL, setp, NULL, timeoutp)) >= 0) 1678 NULL, setp, NULL, timeoutp)) >= 0)
1675 break; 1679 break;
1676 if (errno != EAGAIN && errno != EINTR && 1680 if (errno != EAGAIN && errno != EINTR)
1677 errno != EWOULDBLOCK)
1678 break; 1681 break;
1679 if (active_state->packet_timeout_ms == -1) 1682 if (active_state->packet_timeout_ms == -1)
1680 continue; 1683 continue;
@@ -1713,7 +1716,6 @@ packet_not_very_much_data_to_write(void)
1713 return buffer_len(&active_state->output) < 128 * 1024; 1716 return buffer_len(&active_state->output) < 128 * 1024;
1714} 1717}
1715 1718
1716
1717static void 1719static void
1718packet_set_tos(int interactive) 1720packet_set_tos(int interactive)
1719{ 1721{
diff --git a/roaming.h b/roaming.h
new file mode 100644
index 000000000..88193453a
--- /dev/null
+++ b/roaming.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2004-2009 AppGate Network Security AB
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef ROAMING_H
18#define ROAMING_H
19
20extern int resume_in_progress;
21
22void add_recv_bytes(u_int64_t);
23ssize_t roaming_write(int, const void *, size_t, int *);
24ssize_t roaming_read(int, void *, size_t, int *);
25ssize_t roaming_atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
26u_int64_t get_recv_bytes(void);
27u_int64_t get_sent_bytes(void);
28void roam_set_bytes(u_int64_t, u_int64_t);
29int resume_kex(void);
30
31#endif /* ROAMING */
diff --git a/roaming_common.c b/roaming_common.c
new file mode 100644
index 000000000..5a871b23e
--- /dev/null
+++ b/roaming_common.c
@@ -0,0 +1,100 @@
1/*
2 * Copyright (c) 2004-2009 AppGate Network Security AB
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <sys/types.h>
18#include <sys/socket.h>
19#include <sys/uio.h>
20
21#include <errno.h>
22#include <inttypes.h>
23#include <stdarg.h>
24#include <unistd.h>
25
26#include "atomicio.h"
27#include "log.h"
28#include "packet.h"
29#include "xmalloc.h"
30#include "cipher.h"
31#include "buffer.h"
32#include "roaming.h"
33
34static u_int64_t write_bytes = 0;
35static u_int64_t read_bytes = 0;
36
37int resume_in_progress = 0;
38
39u_int64_t
40get_recv_bytes(void)
41{
42 return read_bytes;
43}
44
45void
46add_recv_bytes(u_int64_t num)
47{
48 read_bytes += num;
49}
50
51u_int64_t
52get_sent_bytes(void)
53{
54 return write_bytes;
55}
56
57void
58roam_set_bytes(u_int64_t sent, u_int64_t recv)
59{
60 read_bytes = recv;
61 write_bytes = sent;
62}
63
64ssize_t
65roaming_write(int fd, const void *buf, size_t count, int *cont)
66{
67 ssize_t ret;
68
69 ret = write(fd, buf, count);
70 if (ret > 0 && !resume_in_progress) {
71 write_bytes += ret;
72 }
73 debug("Wrote %d bytes for a total of %lld", ret, write_bytes);
74 return ret;
75}
76
77ssize_t
78roaming_read(int fd, void *buf, size_t count, int *cont)
79{
80 ssize_t ret = read(fd, buf, count);
81 if (ret > 0) {
82 if (!resume_in_progress) {
83 read_bytes += ret;
84 }
85 }
86 return ret;
87}
88
89ssize_t
90roaming_atomicio(ssize_t(*f)(), int fd, void *buf, size_t count)
91{
92 ssize_t ret = atomicio(f, fd, buf, count);
93
94 if ((f == write || f == vwrite) && ret > 0 && !resume_in_progress) {
95 write_bytes += ret;
96 } else if (f == read && ret > 0 && !resume_in_progress) {
97 read_bytes += ret;
98 }
99 return ret;
100}
diff --git a/roaming_dummy.c b/roaming_dummy.c
new file mode 100644
index 000000000..cd1d20257
--- /dev/null
+++ b/roaming_dummy.c
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) 2004-2009 AppGate Network Security AB
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/*
18 * This file is included in the client programs which should not
19 * support roaming.
20 */
21
22#include <sys/types.h>
23#include <unistd.h>
24
25int resume_in_progress = 0;
26
27u_int64_t get_recv_bytes()
28{
29 return 0;
30}
31
32ssize_t
33roaming_write(int fd, const void *buf, size_t count, int *cont)
34{
35 return write(fd, buf, count);
36}
37
38ssize_t
39roaming_read(int fd, void *buf, size_t count, int *cont)
40{
41 if (cont)
42 *cont = 0;
43 return read(fd, buf, count);
44}
45
46void
47add_recv_bytes(u_int64_t num)
48{
49}
50
51int
52resume_kex()
53{
54 return 1;
55}
diff --git a/serverloop.c b/serverloop.c
index 53cb67d7b..d8cb54bc7 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.c,v 1.158 2009/05/25 06:48:01 andreas Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.159 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -78,6 +78,7 @@
78#include "auth-options.h" 78#include "auth-options.h"
79#include "serverloop.h" 79#include "serverloop.h"
80#include "misc.h" 80#include "misc.h"
81#include "roaming.h"
81 82
82extern ServerOptions options; 83extern ServerOptions options;
83 84
@@ -391,8 +392,11 @@ process_input(fd_set *readset)
391 392
392 /* Read and buffer any input data from the client. */ 393 /* Read and buffer any input data from the client. */
393 if (FD_ISSET(connection_in, readset)) { 394 if (FD_ISSET(connection_in, readset)) {
394 len = read(connection_in, buf, sizeof(buf)); 395 int cont = 0;
396 len = roaming_read(connection_in, buf, sizeof(buf), &cont);
395 if (len == 0) { 397 if (len == 0) {
398 if (cont)
399 return;
396 verbose("Connection closed by %.100s", 400 verbose("Connection closed by %.100s",
397 get_remote_ipaddr()); 401 get_remote_ipaddr());
398 connection_closed = 1; 402 connection_closed = 1;
diff --git a/sshconnect.c b/sshconnect.c
index dee3ba544..3e57e859d 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.213 2009/05/27 06:38:16 andreas Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.214 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -56,6 +56,7 @@
56#include "atomicio.h" 56#include "atomicio.h"
57#include "misc.h" 57#include "misc.h"
58#include "dns.h" 58#include "dns.h"
59#include "roaming.h"
59#include "version.h" 60#include "version.h"
60 61
61char *client_version_string = NULL; 62char *client_version_string = NULL;
@@ -452,7 +453,7 @@ ssh_exchange_identification(int timeout_ms)
452 } 453 }
453 } 454 }
454 455
455 len = atomicio(read, connection_in, &buf[i], 1); 456 len = roaming_atomicio(read, connection_in, &buf[i], 1);
456 457
457 if (len != 1 && errno == EPIPE) 458 if (len != 1 && errno == EPIPE)
458 fatal("ssh_exchange_identification: " 459 fatal("ssh_exchange_identification: "
@@ -537,7 +538,8 @@ ssh_exchange_identification(int timeout_ms)
537 compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1, 538 compat20 ? PROTOCOL_MAJOR_2 : PROTOCOL_MAJOR_1,
538 compat20 ? PROTOCOL_MINOR_2 : minor1, 539 compat20 ? PROTOCOL_MINOR_2 : minor1,
539 SSH_VERSION, compat20 ? "\r\n" : "\n"); 540 SSH_VERSION, compat20 ? "\r\n" : "\n");
540 if (atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf)) 541 if (roaming_atomicio(vwrite, connection_out, buf, strlen(buf))
542 != strlen(buf))
541 fatal("write: %.100s", strerror(errno)); 543 fatal("write: %.100s", strerror(errno));
542 client_version_string = xstrdup(buf); 544 client_version_string = xstrdup(buf);
543 chop(client_version_string); 545 chop(client_version_string);
diff --git a/sshd.c b/sshd.c
index 3b5cd3cfd..91831e208 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.366 2009/01/22 10:02:34 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.367 2009/05/28 16:50:16 andreas Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -117,6 +117,7 @@
117#include "ssh-gss.h" 117#include "ssh-gss.h"
118#endif 118#endif
119#include "monitor_wrap.h" 119#include "monitor_wrap.h"
120#include "roaming.h"
120#include "version.h" 121#include "version.h"
121 122
122#ifdef LIBWRAP 123#ifdef LIBWRAP
@@ -419,7 +420,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
419 server_version_string = xstrdup(buf); 420 server_version_string = xstrdup(buf);
420 421
421 /* Send our protocol version identification. */ 422 /* Send our protocol version identification. */
422 if (atomicio(vwrite, sock_out, server_version_string, 423 if (roaming_atomicio(vwrite, sock_out, server_version_string,
423 strlen(server_version_string)) 424 strlen(server_version_string))
424 != strlen(server_version_string)) { 425 != strlen(server_version_string)) {
425 logit("Could not write ident string to %s", get_remote_ipaddr()); 426 logit("Could not write ident string to %s", get_remote_ipaddr());
@@ -429,7 +430,7 @@ sshd_exchange_identification(int sock_in, int sock_out)
429 /* Read other sides version identification. */ 430 /* Read other sides version identification. */
430 memset(buf, 0, sizeof(buf)); 431 memset(buf, 0, sizeof(buf));
431 for (i = 0; i < sizeof(buf) - 1; i++) { 432 for (i = 0; i < sizeof(buf) - 1; i++) {
432 if (atomicio(read, sock_in, &buf[i], 1) != 1) { 433 if (roaming_atomicio(read, sock_in, &buf[i], 1) != 1) {
433 logit("Did not receive identification string from %s", 434 logit("Did not receive identification string from %s",
434 get_remote_ipaddr()); 435 get_remote_ipaddr());
435 cleanup_exit(255); 436 cleanup_exit(255);