/[monit]/monit/protocols/ssh.c
ViewVC logotype

Diff of /monit/protocols/ssh.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by hauk, Sat Oct 25 19:17:14 2003 UTC revision 1.7 by hauk, Mon Nov 17 14:13:11 2003 UTC
# Line 43  Line 43 
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    }    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26