43 |
*/ |
*/ |
44 |
int check_ssh(Socket_T s) { |
int check_ssh(Socket_T s) { |
45 |
|
|
|
int n; |
|
46 |
char buf[STRLEN]; |
char buf[STRLEN]; |
47 |
|
|
48 |
ASSERT(s); |
ASSERT(s); |
49 |
|
|
50 |
if((n= socket_read(s, buf, sizeof(buf))) <= 0) { |
if(!socket_readln(s, buf, sizeof(buf))) { |
51 |
log("SSH: error receiving identification string -- %s\n", STRERROR); |
log("SSH: error receiving identification string -- %s\n", STRERROR); |
52 |
return FALSE; |
return FALSE; |
53 |
} |
} |
54 |
|
|
55 |
if(! Util_startsWith(buf, "SSH-")) { |
if(! Util_startsWith(buf, "SSH-")) { |
56 |
log("SSH: protocol error %s\n", buf); |
log("SSH: protocol error %s", buf); |
57 |
return FALSE; |
return FALSE; |
58 |
} |
} |
59 |
|
|
60 |
/* send identification string back to server */ |
/* send identification string back to server */ |
61 |
if(socket_write(s, buf, n) <= 0) { |
if(socket_write(s, buf, strlen(buf)) <= 0) { |
62 |
log("SSH: error sending identification string -- %s\n", STRERROR); |
log("SSH: error sending identification string -- %s\n", STRERROR); |
63 |
return FALSE; |
return FALSE; |
64 |
} |
} |