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

Diff of /monit/protocols/smtp.c

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

revision 1.20 by hauk, Sat Sep 10 12:47:51 2005 UTC revision 1.21 by martinp, Mon Sep 26 15:55:06 2005 UTC
# Line 47  Line 47 
47  int check_smtp(Socket_T s) {  int check_smtp(Socket_T s) {
48    
49    int status;    int status;
50      char separator;
51    char buf[STRLEN];    char buf[STRLEN];
52    
53    ASSERT(s);    ASSERT(s);
54    
55    if(socket_readln(s, buf, sizeof(buf)) <= 0) {    /* Read (multiline) SMTP greeting */
56      log("SMTP: error receiving data -- %s\n", STRERROR);    do {
57      return FALSE;      if(socket_readln(s, buf, sizeof(buf)) <= 0) {
58    }        log("SMTP: error receiving data -- %s\n", STRERROR);
59          return FALSE;
60        }
61        Util_chomp(buf);
62        sscanf(buf, "%d%c%*s", &status, &separator);
63        if(status != 220) {
64          log("SMTP error: %s\n", buf);
65          return FALSE;
66        }
67      } while(separator == '-');
68    
   Util_chomp(buf);  
     
   sscanf(buf, "%d %*s", &status);  
   if(status != 220) {  
     log("SMTP error: %s\n", buf);  
     return FALSE;  
   }  
   
   /* Read past banners */  
   while(NULL != socket_readln(s, buf, STRLEN)) {  
      if(!Util_startsWith(buf, "220")) break;  
   }  
69        
70      /* Terminate the session */
71    if(socket_print(s, "QUIT\r\n") < 0) {    if(socket_print(s, "QUIT\r\n") < 0) {
72      log("SMTP: error sending data -- %s\n", STRERROR);      log("SMTP: error sending data -- %s\n", STRERROR);
73      return FALSE;      return FALSE;
74    }    }
   
75    if(socket_readln(s, buf, sizeof(buf)) <= 0) {    if(socket_readln(s, buf, sizeof(buf)) <= 0) {
76      log("SMTP: error receiving data -- %s\n", STRERROR);      log("SMTP: error receiving data -- %s\n", STRERROR);
77      return FALSE;      return FALSE;
78    }    }
   
79    Util_chomp(buf);    Util_chomp(buf);
     
80    sscanf(buf, "%d %*s", &status);    sscanf(buf, "%d %*s", &status);
81    if(status != 221) {    if(status != 221) {
82      log("SMTP error: %s\n", buf);      log("SMTP error: %s\n", buf);

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

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