/[monit]/monit/p.y
ViewVC logotype

Diff of /monit/p.y

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

revision 1.25 by chopp, Fri Oct 11 20:59:57 2002 UTC revision 1.26 by chopp, Fri Oct 25 15:50:46 2002 UTC
# Line 34  Line 34 
34   */   */
35    
36  #include <config.h>  #include <config.h>
     
37  #include <stdio.h>  #include <stdio.h>
38  #include <stdlib.h>  #include <stdlib.h>
39  #include <errno.h>  #include <errno.h>
40    #include <ctype.h>
41        
42  #ifdef HAVE_SYS_TYPES_H  #ifdef HAVE_SYS_TYPES_H
43  #include <sys/types.h>  #include <sys/types.h>
# Line 96  Line 96 
96      int  ssl;      int  ssl;
97      char *request;      char *request;
98      char *pathname;      char *pathname;
99        char *certmd5;
100      Protocol_T protocol;      Protocol_T protocol;
101    };    };
102    
# Line 125  Line 126 
126    static struct MailFilter mtf= { NULL, NULL, NULL, FALSE, FALSE, FALSE,    static struct MailFilter mtf= { NULL, NULL, NULL, FALSE, FALSE, FALSE,
127                                    FALSE, FALSE };                                    FALSE, FALSE };
128    static struct PortSet portset= { -1, NULL, 0, SOCK_STREAM, AF_INET, FALSE,    static struct PortSet portset= { -1, NULL, 0, SOCK_STREAM, AF_INET, FALSE,
129                                     NULL, NULL, NULL };                                     NULL, NULL, NULL, NULL };
130    static struct ResourceSet resourceset= { 0, 0, RESOURCE_OPERATOR_GREATER,    static struct ResourceSet resourceset= { 0, 0, RESOURCE_OPERATOR_GREATER,
131                                             1, RESOURCE_ACTION_ALERT };                                             1, RESOURCE_ACTION_ALERT };
132    
# Line 155  Line 156 
156    static void check_hostname (char *);    static void check_hostname (char *);
157    static void createprocinfo();    static void createprocinfo();
158    static char *append_hostname(char *);    static char *append_hostname(char *);
159      static void cleanup_md5_string(char *);
160  %}  %}
161    
162  %union {  %union {
# Line 169  Line 171 
171  %token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL  %token HOST PORT TYPE UDP TCP TCPSSL PROTOCOL
172  %token ALERT MAILFORMAT UNIXSOCKET  %token ALERT MAILFORMAT UNIXSOCKET
173  %token TIMEOUT RESTART CHECKSUM EXPECT EVERY  %token TIMEOUT RESTART CHECKSUM EXPECT EVERY
174  %token DEFAULT HTTP FTP SMTP POP IMAP NNTP  %token DEFAULT HTTP FTP SMTP POP IMAP NNTP CERTMD5
175  %token <string> STRING PATH MAILADDR MAILFROM MAILSUBJECT  %token <string> STRING PATH MAILADDR MAILFROM MAILSUBJECT
176  %token <string> MAILBODY  %token <string> MAILBODY
177  %token <number> NUMBER  %token <number> NUMBER
# Line 377  unixsocket      : UNIXSOCKET PATH { Line 379  unixsocket      : UNIXSOCKET PATH {
379    
380  type            : /* EMPTY */ { portset.type= SOCK_STREAM; }  type            : /* EMPTY */ { portset.type= SOCK_STREAM; }
381                  | TYPE TCP    { portset.type= SOCK_STREAM;  }                  | TYPE TCP    { portset.type= SOCK_STREAM;  }
382                  | TYPE TCPSSL { portset.type= SOCK_STREAM;                  | TYPE TCPSSL certmd5 { portset.type= SOCK_STREAM;
383                                  portset.ssl= TRUE; }                                          portset.ssl= TRUE; }
384                  | TYPE UDP    { portset.type= SOCK_DGRAM; }                  | TYPE UDP    { portset.type= SOCK_DGRAM; }
385                  ;                  ;
386    
387    certmd5         : /* EMPTY */    { portset.certmd5= NULL; }
388                    | CERTMD5 STRING { portset.certmd5= $2; }
389                    | EXPECT CERTMD5 STRING { portset.certmd5= $3; }
390                    ;
391    
392  protocol        : /* EMPTY */  { portset.protocol= addprotocol(P_DEFAULT); }  protocol        : /* EMPTY */  { portset.protocol= addprotocol(P_DEFAULT); }
393                  | PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); }                  | PROTOCOL DEFAULT { portset.protocol= addprotocol(P_DEFAULT); }
394                  | PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);}                  | PROTOCOL HTTP request {portset.protocol= addprotocol(P_HTTP);}
# Line 692  static void addchecksum(char *filename, Line 699  static void addchecksum(char *filename,
699    if ( sum ) {    if ( sum ) {
700            
701      c->md5= sum;      c->md5= sum;
702    
703            
704    } else if ( ! set_md5sum(&c->md5, filename) ) {    } else if ( ! set_md5sum(&c->md5, filename) ) {
705            
# Line 701  static void addchecksum(char *filename, Line 709  static void addchecksum(char *filename,
709    
710    }    }
711    
712      
713      if (c->md5 != NULL) {
714      
715        cleanup_md5_string(c->md5);
716    
717      }
718    
719    c->next= current->checksumlist;    c->next= current->checksumlist;
720    current->checksumlist= c;    current->checksumlist= c;
721    
# Line 764  static void addport(struct PortSet *pp) Line 779  static void addport(struct PortSet *pp)
779    p->request= pp->request;    p->request= pp->request;
780    p->protocol= pp->protocol;    p->protocol= pp->protocol;
781    p->pathname= pp->pathname;    p->pathname= pp->pathname;
782      p->certmd5= pp->certmd5;
783    
784      if (p->certmd5 != NULL) {
785        
786        cleanup_md5_string(p->certmd5);
787    
788      }
789    
790    if ( pp->family == AF_INET ) {    if ( pp->family == AF_INET ) {
791      snprintf(address, STRLEN, "INET[%s:%d]", pp->hostname, pp->port);      snprintf(address, STRLEN, "INET[%s:%d]", pp->hostname, pp->port);
# Line 1165  static char *append_hostname(char *addr) Line 1187  static char *append_hostname(char *addr)
1187    
1188  }  }
1189    
1190    /*
1191     * Cleans up an md5 string, tolower and remove byte sperators
1192     */
1193    
1194    static void cleanup_md5_string(char *md5string) {
1195    
1196      int i= 0, j= 0;
1197    
1198      if (md5string == NULL) {
1199    
1200        return;
1201    
1202      }
1203    
1204    
1205      while (md5string[i] != '\0') {
1206    
1207        if (isxdigit((int) md5string[i])) {
1208          
1209          md5string[j]=tolower(md5string[i]);
1210          j++;
1211    
1212        }
1213    
1214        i++;
1215    
1216      }
1217      
1218      md5string[j]='\0';
1219    
1220      return;
1221    
1222    }

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

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