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