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

Diff of /monit/p.y

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

revision 1.209 by martinp, Thu Aug 4 10:38:43 2005 UTC revision 1.210 by chopp, Fri Aug 5 09:38:09 2005 UTC
# Line 150  Line 150 
150    static struct myuid uidset;    static struct myuid uidset;
151    static struct myperm permset;    static struct myperm permset;
152    static struct mysize sizeset;    static struct mysize sizeset;
153      static struct mymatch matchset;
154    static struct myicmp icmpset;    static struct myicmp icmpset;
155    static struct mymail mailset;    static struct mymail mailset;
156    static struct myport portset;    static struct myport portset;
# Line 188  Line 189 
189    static gid_t get_gid(char *, gid_t);    static gid_t get_gid(char *, gid_t);
190    static void  addchecksum(Checksum_T);    static void  addchecksum(Checksum_T);
191    static void  addperm(Perm_T);    static void  addperm(Perm_T);
192      static void  addmatch(Match_T, int, int);
193      static void  addmatchpath(Match_T, int);
194    static void  adduid(Uid_T);    static void  adduid(Uid_T);
195    static void  addgid(Gid_T);    static void  addgid(Gid_T);
196    static void  addeuid(uid_t);    static void  addeuid(uid_t);
# Line 257  Line 260 
260  %token TIMESTAMP CHANGED SECOND MINUTE HOUR DAY  %token TIMESTAMP CHANGED SECOND MINUTE HOUR DAY
261  %token SSLAUTO SSLV2 SSLV3 TLSV1 CERTMD5  %token SSLAUTO SSLV2 SSLV3 TLSV1 CERTMD5
262  %token BYTE KILOBYTE MEGABYTE GIGABYTE  %token BYTE KILOBYTE MEGABYTE GIGABYTE
263  %token INODE SPACE PERMISSION SIZE  %token INODE SPACE PERMISSION SIZE MATCH NOT IGNORE
264  %token EXEC UNMONITOR ICMP ICMPECHO NONEXIST INVALID DATA RECOVERED  %token EXEC UNMONITOR ICMP ICMPECHO NONEXIST INVALID DATA RECOVERED
265  %token URL CONTENT PID PPID  %token URL CONTENT PID PPID
266  %token <url> URLOBJECT  %token <url> URLOBJECT
# Line 325  optfile         : start Line 328  optfile         : start
328                  | gid                  | gid
329                  | checksum                  | checksum
330                  | size                  | size
331                    | match
332                  | mode                  | mode
333                  | group                  | group
334                  | depend                  | depend
# Line 973  eventoption     : CHANGED    { eventset Line 977  eventoption     : CHANGED    { eventset
977                  | PERMISSION { eventset |= EVENT_PERMISSION; }                  | PERMISSION { eventset |= EVENT_PERMISSION; }
978                  | RESOURCE   { eventset |= EVENT_RESOURCE; }                  | RESOURCE   { eventset |= EVENT_RESOURCE; }
979                  | SIZE       { eventset |= EVENT_SIZE; }                  | SIZE       { eventset |= EVENT_SIZE; }
980                    | MATCH      { eventset |= EVENT_MATCH; }
981                  | TIMEOUT    { eventset |= EVENT_TIMEOUT; }                  | TIMEOUT    { eventset |= EVENT_TIMEOUT; }
982                  | TIMESTAMP  { eventset |= EVENT_TIMESTAMP; }                  | TIMESTAMP  { eventset |= EVENT_TIMESTAMP; }
983                  | UID        { eventset |= EVENT_UID; }                  | UID        { eventset |= EVENT_UID; }
# Line 1252  permission      : IF FAILED PERMISSION N Line 1257  permission      : IF FAILED PERMISSION N
1257                    }                    }
1258                  ;                  ;
1259    
1260    match           : IF matchflagnot MATCH PATH THEN action1 {
1261                        matchset.ignore= FALSE;
1262                        matchset.match_path= xstrdup($4);
1263                        matchset.match_string= NULL;
1264                        addmatchpath(&matchset, $<number>6);
1265                      }
1266                    | IF matchflagnot MATCH STRING THEN action1 {
1267                        matchset.ignore= FALSE;
1268                        matchset.match_path= NULL;
1269                        matchset.match_string= xstrdup($4);
1270                        addmatch(&matchset, $<number>6, 0);
1271                      }
1272                    | IGNORE matchflagnot MATCH PATH {
1273                        matchset.ignore= TRUE;
1274                        matchset.match_path= xstrdup($4);
1275                        matchset.match_string= NULL;
1276                        addmatchpath(&matchset, ACTION_IGNORE);
1277                      }
1278                    | IGNORE matchflagnot MATCH STRING {
1279                        matchset.ignore= TRUE;
1280                        matchset.match_path= NULL;
1281                        matchset.match_string= xstrdup($4);
1282                        addmatch(&matchset, ACTION_IGNORE, 0);
1283                      }
1284                    ;
1285    
1286    matchflagnot      : /* empty */ {
1287                      matchset.not= FALSE;
1288                      }
1289                    | NOT {
1290                      matchset.not= TRUE;
1291                      }
1292                    ;
1293    
1294    
1295  size            : IF SIZE operator NUMBER unit THEN action1 recovery {  size            : IF SIZE operator NUMBER unit THEN action1 recovery {
1296                      sizeset.operator= $<number>3;                      sizeset.operator= $<number>4;
1297                      sizeset.size= ((unsigned long)$4 * $<number>5);                      sizeset.size= ((unsigned long)$4 * $<number>5);
1298                      addeventaction(&(sizeset).action, $<number>7, $<number>8);                      addeventaction(&(sizeset).action, $<number>7, $<number>8);
1299                      addsize(&sizeset, FALSE);                      addsize(&sizeset, FALSE);
# Line 1900  static void addperm(Perm_T ps) { Line 1940  static void addperm(Perm_T ps) {
1940    
1941  }  }
1942    
1943    /*
1944     * Set Match object in the current service
1945     */
1946    static void addmatch(Match_T ms, int actionnumber, int linenumber) {
1947    
1948      Match_T m;
1949      Match_T ml;
1950      int     reg_return;
1951      
1952      ASSERT(ms);
1953    
1954      NEW(m);
1955    #ifdef HAVE_REGEX_H
1956      NEW(m->regex_comp);
1957    #endif
1958    
1959      m->match_string= ms->match_string;
1960      m->match_path= ms->match_path;
1961      m->action= ms->action;
1962      m->not= ms->not;
1963      m->ignore= ms->ignore;
1964      m->next=NULL;
1965    
1966      addeventaction(&(m->action), actionnumber, ACTION_IGNORE);
1967    
1968    #ifdef HAVE_REGEX_H
1969      reg_return= regcomp(m->regex_comp, ms->match_string, REG_NOSUB|REG_EXTENDED);
1970    
1971      if (reg_return!=0) {
1972        char errbuf[STRLEN];
1973        regerror(reg_return, ms->regex_comp, errbuf, STRLEN);
1974        if (m->match_path != NULL)
1975            yyerror2("regex parsing error:%s on line %i of", errbuf, linenumber);
1976        else
1977            yyerror2("regex parsing error:%s", errbuf);
1978      }
1979    #endif
1980    
1981      if (current->matchlist) {
1982        /* Find the end of the list */
1983        for(ml=current->matchlist; ml->next; ml=ml->next);
1984    
1985        ml->next= m;
1986        
1987      } else {
1988    
1989        current->matchlist= m;
1990            
1991      }
1992    }
1993    
1994    static void addmatchpath(Match_T ms, int actionnumber) {
1995    
1996      FILE *handle;
1997      char buf[2048];
1998      int linenumber=0;
1999    
2000      ASSERT(ms->match_path);
2001    
2002      handle=fopen(ms->match_path, "r");
2003    
2004      if ( handle==NULL ) {
2005    
2006        yyerror2("cannot read regex match file (%s)", ms->match_path);
2007    
2008        return;
2009      }
2010      
2011      while (!feof(handle)) {
2012        linenumber++;
2013        
2014        if (! fgets(buf, 2048, handle)) {
2015    
2016          continue;
2017          
2018        }
2019    
2020        if (strlen(buf)==0 || buf[0]=='\n') {
2021    
2022          continue;
2023    
2024        }
2025    
2026        if(buf[strlen(buf)-1]=='\n') {
2027    
2028          buf[strlen(buf)-1]=0;
2029          
2030        }
2031    
2032        ms->match_string= xstrdup(buf);
2033        addmatch(ms, actionnumber, linenumber);
2034      }
2035    
2036      fclose(handle);
2037    
2038    }
2039    
2040  /*  /*
2041   * Set Uid object in the current service   * Set Uid object in the current service

Legend:
Removed from v.1.209  
changed lines
  Added in v.1.210

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