Mercurial > dropbear
comparison common-session.c @ 297:79bf1023cf11 agent-client
propagate from branch 'au.asn.ucc.matt.dropbear' (head 0501e6f661b5415eb76f3b312d183c3adfbfb712)
to branch 'au.asn.ucc.matt.dropbear.cli-agent' (head 01038174ec27245b51bd43a66c01ad930880f67b)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 21 Mar 2006 16:20:59 +0000 |
parents | 7f9adaf85fca |
children | bf29e6659fb9 |
comparison
equal
deleted
inserted
replaced
225:ca7e76d981d9 | 297:79bf1023cf11 |
---|---|
60 ses.maxfd = sock; | 60 ses.maxfd = sock; |
61 | 61 |
62 ses.connecttimeout = 0; | 62 ses.connecttimeout = 0; |
63 | 63 |
64 kexfirstinitialise(); /* initialise the kex state */ | 64 kexfirstinitialise(); /* initialise the kex state */ |
65 chaninitialise(); /* initialise the channel state */ | |
66 | 65 |
67 ses.writepayload = buf_new(MAX_TRANS_PAYLOAD_LEN); | 66 ses.writepayload = buf_new(MAX_TRANS_PAYLOAD_LEN); |
68 ses.transseq = 0; | 67 ses.transseq = 0; |
69 | 68 |
70 ses.readbuf = NULL; | 69 ses.readbuf = NULL; |
124 | 123 |
125 timeout.tv_sec = SELECT_TIMEOUT; | 124 timeout.tv_sec = SELECT_TIMEOUT; |
126 timeout.tv_usec = 0; | 125 timeout.tv_usec = 0; |
127 FD_ZERO(&writefd); | 126 FD_ZERO(&writefd); |
128 FD_ZERO(&readfd); | 127 FD_ZERO(&readfd); |
129 assert(ses.payload == NULL); | 128 dropbear_assert(ses.payload == NULL); |
130 if (ses.sock != -1) { | 129 if (ses.sock != -1) { |
131 FD_SET(ses.sock, &readfd); | 130 FD_SET(ses.sock, &readfd); |
132 if (!isempty(&ses.writequeue)) { | 131 if (!isempty(&ses.writequeue)) { |
133 FD_SET(ses.sock, &writefd); | 132 FD_SET(ses.sock, &writefd); |
134 } | 133 } |
231 if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n", | 230 if (atomicio(write, ses.sock, LOCAL_IDENT "\r\n", |
232 strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { | 231 strlen(LOCAL_IDENT "\r\n")) == DROPBEAR_FAILURE) { |
233 dropbear_exit("Error writing ident string"); | 232 dropbear_exit("Error writing ident string"); |
234 } | 233 } |
235 | 234 |
236 /* We allow up to 9 lines before the actual version string, to | 235 /* If they send more than 50 lines, something is wrong */ |
237 * account for wrappers/cruft etc. According to the spec only the client | 236 for (i = 0; i < 50; i++) { |
238 * needs to handle this, but no harm in letting the server handle it too */ | |
239 for (i = 0; i < 10; i++) { | |
240 len = ident_readln(ses.sock, linebuf, sizeof(linebuf)); | 237 len = ident_readln(ses.sock, linebuf, sizeof(linebuf)); |
241 | 238 |
242 if (len < 0 && errno != EINTR) { | 239 if (len < 0 && errno != EINTR) { |
243 /* It failed */ | 240 /* It failed */ |
244 break; | 241 break; |
257 } else { | 254 } else { |
258 /* linebuf is already null terminated */ | 255 /* linebuf is already null terminated */ |
259 ses.remoteident = m_malloc(len); | 256 ses.remoteident = m_malloc(len); |
260 memcpy(ses.remoteident, linebuf, len); | 257 memcpy(ses.remoteident, linebuf, len); |
261 } | 258 } |
259 | |
260 /* Shall assume that 2.x will be backwards compatible. */ | |
261 if (strncmp(ses.remoteident, "SSH-2.", 6) != 0 | |
262 && strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) { | |
263 dropbear_exit("Incompatible remote version '%s'", ses.remoteident); | |
264 } | |
262 | 265 |
263 TRACE(("remoteident: %s", ses.remoteident)) | 266 TRACE(("remoteident: %s", ses.remoteident)) |
264 | 267 |
265 } | 268 } |
266 | 269 |