#include "cf.defs.h"#include "cf.extern.h"Go to the source code of this file.
Functions | |
| void | InstallFilter (char *filter) |
| void | InstallFilterTest (char *alias, char *type, char *data) |
| void | CheckFilters () |
| enum filternames | FilterActionsToCode (char *filtertype) |
| int | FilterExists (char *name) |
| time_t | Date2Number (char *string, time_t now) |
| int | ProcessFilter (char *proc, struct Item *filterlist, char **names, int *start, int *end) |
| int | FileObjectFilter (char *file, struct stat *lstatptr, struct Item *filterlist, enum actions context) |
| void | DoFilter (struct Item **attr, char **crit, struct stat *lstatptr, char *filename) |
| void | DoProc (struct Item **attr, char **crit, char **names, char **line) |
| int | FilterTypeMatch (struct stat *lstatptr, char *crit) |
| int | FilterProcMatch (char *name1, char *name2, char *expr, char **names, char **line) |
| int | FilterProcSTimeMatch (char *name1, char *name2, char *fromexpr, char *toexpr, char **names, char **line) |
| int | FilterProcTTimeMatch (char *name1, char *name2, char *fromexpr, char *toexpr, char **names, char **line) |
| int | FilterOwnerMatch (struct stat *lstatptr, char *crit) |
| int | FilterGroupMatch (struct stat *lstatptr, char *crit) |
| int | FilterModeMatch (struct stat *lstatptr, char *crit) |
| int | FilterTimeMatch (time_t stattime, char *from, char *to) |
| int | FilterNameRegexMatch (char *filename, char *crit) |
| int | FilterExecRegexMatch (char *filename, char *crit) |
| int | FilterIsSymLinkTo (char *filename, char *crit) |
| int | FilterExecMatch (char *filename, char *crit) |
| void | GetProcessColumns (char *proc, char **names, int *start, int *end) |
| void | SplitLine (char *proc, struct Item *filterlist, char **names, int *start, int *end, char **line) |
|
|
Definition at line 220 of file filters.c. References Filter::alias, bufsize, cferror, CfLog(), Filter::criteria, Date2Number(), FatalError(), filterfromatime, filterfromctime, filterfrommtime, filterfromsize, filterfromstime, filterfromttime, filterresult, filtertoatime, filtertoctime, filtertomtime, filtertosize, filtertostime, filtertottime, fp, Filter::next, NULL, OUTPUT, snprintf(), VFILTERLIST, and yyerror(). Referenced by main(). 00222 { struct Filter *fp; 00223 time_t t; 00224 00225 if (time(&t) == -1) 00226 { 00227 FatalError("Clock unavailable"); 00228 } 00229 00230 for (fp = VFILTERLIST; fp != NULL; fp = fp->next) 00231 { 00232 if (fp->criteria[filterresult] == NULL) 00233 { 00234 snprintf(OUTPUT,bufsize*2,"No result specified for filter %s",fp->alias); 00235 CfLog(cferror,OUTPUT,""); 00236 FatalError("Consistency error"); 00237 } 00238 00239 if ((fp->criteria[filterfromctime]!=NULL && fp->criteria[filtertoctime]==NULL) || 00240 (fp->criteria[filterfromctime]==NULL && fp->criteria[filtertoctime]!=NULL)) 00241 { 00242 snprintf(OUTPUT,bufsize*2,"Incomplete ctime limit specification of filter %s",fp->alias); 00243 CfLog(cferror,OUTPUT,""); 00244 FatalError("Consistency errors"); 00245 } 00246 00247 if ((fp->criteria[filterfromatime]!=NULL && fp->criteria[filtertoatime]==NULL) || 00248 (fp->criteria[filterfromatime]==NULL && fp->criteria[filtertoatime]!=NULL)) 00249 { 00250 snprintf(OUTPUT,bufsize*2,"Incomplete atime limit specification of filter %s",fp->alias); 00251 CfLog(cferror,OUTPUT,""); 00252 FatalError("Consistency errors"); 00253 } 00254 00255 if ((fp->criteria[filterfrommtime]!=NULL && fp->criteria[filtertomtime]==NULL) || 00256 (fp->criteria[filterfrommtime]==NULL && fp->criteria[filtertomtime]!=NULL)) 00257 { 00258 snprintf(OUTPUT,bufsize*2,"Incomplete mtime limit specification of filter %s",fp->alias); 00259 CfLog(cferror,OUTPUT,""); 00260 FatalError("Consistency errors"); 00261 } 00262 00263 if ((fp->criteria[filterfromstime]!=NULL && fp->criteria[filtertostime]==NULL) || 00264 (fp->criteria[filterfromstime]==NULL && fp->criteria[filtertostime]!=NULL)) 00265 { 00266 snprintf(OUTPUT,bufsize*2,"Incomplete stime limit specification of filter %s",fp->alias); 00267 CfLog(cferror,OUTPUT,""); 00268 FatalError("Consistency errors"); 00269 } 00270 00271 if ((fp->criteria[filterfromttime]!=NULL && fp->criteria[filtertottime]==NULL) || 00272 (fp->criteria[filterfromttime]==NULL && fp->criteria[filtertottime]!=NULL)) 00273 { 00274 snprintf(OUTPUT,bufsize*2,"Incomplete ttime limit specification of filter %s",fp->alias); 00275 CfLog(cferror,OUTPUT,""); 00276 FatalError("Consistency errors"); 00277 } 00278 00279 00280 if ((fp->criteria[filterfromsize]!=NULL && fp->criteria[filtertosize]==NULL) || 00281 (fp->criteria[filterfromsize]==NULL && fp->criteria[filtertosize]!=NULL)) 00282 { 00283 snprintf(OUTPUT,bufsize*2,"Incomplete size limit specification of filter %s",fp->alias); 00284 CfLog(cferror,OUTPUT,""); 00285 FatalError("Consistency errors"); 00286 } 00287 00288 if (fp->criteria[filterfromatime] != NULL) 00289 { 00290 if (Date2Number(fp->criteria[filterfromatime],t) > Date2Number(fp->criteria[filtertoatime],t)) 00291 { 00292 snprintf(OUTPUT,bufsize*2,"To/From atimes silly in filter %s (from > to)",fp->alias); 00293 CfLog(cferror,OUTPUT,""); 00294 FatalError("Consistency errors"); 00295 } 00296 } 00297 00298 if (fp->criteria[filterfromctime] != NULL) 00299 { 00300 if (Date2Number(fp->criteria[filterfromctime],t) > Date2Number(fp->criteria[filtertoctime],t)) 00301 { 00302 snprintf(OUTPUT,bufsize*2,"To/From ctimes silly in filter %s (from > to)",fp->alias); 00303 CfLog(cferror,OUTPUT,""); 00304 FatalError("Consistency errors"); 00305 } 00306 } 00307 00308 if (fp->criteria[filterfrommtime] != NULL) 00309 { 00310 if (Date2Number(fp->criteria[filterfrommtime],t) > Date2Number(fp->criteria[filtertomtime],t)) 00311 { 00312 snprintf(OUTPUT,bufsize*2,"To/From mtimes silly in filter %s (from > to)",fp->alias); 00313 CfLog(cferror,OUTPUT,""); 00314 FatalError("Consistency errors"); 00315 } 00316 } 00317 00318 if (fp->criteria[filterfromstime] != NULL) 00319 { 00320 if (Date2Number(fp->criteria[filterfromstime],t) > Date2Number(fp->criteria[filtertostime],t)) 00321 { 00322 snprintf(OUTPUT,bufsize*2,"To/From stimes silly in filter %s (from > to)",fp->alias); 00323 CfLog(cferror,OUTPUT,""); 00324 FatalError("Consistency errors"); 00325 } 00326 } 00327 00328 if (fp->criteria[filterfromttime] != NULL) 00329 { 00330 if (Date2Number(fp->criteria[filterfromttime],t) > Date2Number(fp->criteria[filtertottime],t)) 00331 { 00332 snprintf(OUTPUT,bufsize*2,"To/From ttimes silly in filter %s (from > to)",fp->alias); 00333 CfLog(cferror,OUTPUT,""); 00334 FatalError("Consistency errors"); 00335 } 00336 if (strncmp(fp->criteria[filterfromttime],"accumulated",strlen("accumulated")) != 0) 00337 { 00338 yyerror("Must use accumulated time in FromTtime"); 00339 } 00340 if (strncmp(fp->criteria[filtertottime],"accumulated",strlen("accumulated")) != 0) 00341 { 00342 yyerror("Must use accumulated time in ToTtime"); 00343 } 00344 } 00345 00346 if (fp->criteria[filterfromsize] != NULL) 00347 { 00348 if (strcmp(fp->criteria[filterfromsize],fp->criteria[filtertosize]) > 0) 00349 { 00350 snprintf(OUTPUT,bufsize*2,"To/From size is silly in filter %s (from > to)",fp->alias); 00351 CfLog(cferror,OUTPUT,""); 00352 FatalError("Consistency errors"); 00353 } 00354 } 00355 00356 } 00357 }
|
|
||||||||||||
|
Definition at line 408 of file filters.c. References CFSTARTTIME, Debug, NULL, and yyerror(). Referenced by CheckFilters(), FilterProcSTimeMatch(), FilterProcTTimeMatch(), FilterTimeMatch(), and InstallFilterTest(). 00415 : "date(1999,2,22,0,0,0)" 00416 FromMtime: "tminus(0,0,2,0,0,0)" 00417 00418 */ 00419 00420 { char type[16],datestr[63]; 00421 int year=-1,month=-1,day=-1,hr=-1,min=-1,sec=-1; 00422 time_t time; 00423 struct tm tmv; 00424 00425 if (string == NULL || strlen (string) == 0) 00426 { 00427 return now; 00428 } 00429 00430 if (strcmp(string,"now") == 0) 00431 { 00432 return now; 00433 } 00434 00435 if (strcmp(string,"inf")==0) 00436 { 00437 return (time_t) (now|0x0FFFFFFF); /* time_t is signed long, assumes 64 bits */ 00438 } 00439 00440 sscanf(string,"%15[^(](%d,%d,%d,%d,%d,%d)",type,&year,&month,&day,&hr,&min,&sec); 00441 00442 if (year*month*day*hr*min*sec < 0) 00443 { 00444 yyerror("Bad relative time specifier, should be type(year,month,day,hr,min,sec)"); 00445 return now; 00446 } 00447 00448 if (strcmp(type,"date")==0) 00449 00450 { 00451 if (year < 1970 || year > 3000) 00452 { 00453 yyerror("Year value is silly (1970-3000)"); 00454 return now; 00455 } 00456 00457 if (month < 1 || month > 12) 00458 { 00459 yyerror("Month value is silly (1-12)"); 00460 return now; 00461 } 00462 00463 if (day < 1 || day > 31) 00464 { 00465 yyerror("Day value is silly (1-31)"); 00466 return now; 00467 } 00468 00469 if (hr > 23) 00470 { 00471 yyerror("Hour value is silly (0-23)"); 00472 return now; 00473 } 00474 00475 if (min > 59) 00476 { 00477 yyerror("Minute value is silly (0-59)"); 00478 return now; 00479 } 00480 00481 if (sec > 59) 00482 { 00483 yyerror("Second value is silly (0-59)"); 00484 return now; 00485 } 00486 00487 Debug("Time is %s or (y=%d,m=%d,d=%d,h=%d,m=%d,s=%d)\n",datestr,year,month,day,hr,min,sec); 00488 00489 tmv.tm_year = year - 1900; 00490 tmv.tm_mon = month -1; 00491 tmv.tm_mday = day; 00492 tmv.tm_hour = hr; 00493 tmv.tm_min = min; 00494 tmv.tm_sec = sec; 00495 tmv.tm_isdst= -1; 00496 00497 if ((time=mktime(&tmv))== -1) 00498 { 00499 yyerror("Illegal time value"); 00500 return now; 00501 } 00502 00503 Debug("Time computed from input was: %s\n",ctime(&time)); 00504 return time; 00505 } 00506 00507 else if (strcmp(type,"tminus")==0) 00508 00509 { 00510 if (year > 30) 00511 { 00512 yyerror("Relative Year value is silly (0-30 year ago)"); 00513 return now; 00514 } 00515 00516 Debug("Time is %s or (y=%d,m=%d,d=%d,h=%d,m=%d,s=%d)\n",datestr,year,month,day,hr,min,sec); 00517 00518 time = CFSTARTTIME; 00519 00520 time -= sec; 00521 time -= min * 60; 00522 time -= hr * 3600; 00523 time -= day * 24 * 3600; 00524 time -= month * 30 * 24 * 3600; 00525 time -= year * 365 * 24 * 3600; 00526 00527 Debug("Total negative offset = %.1f minutes\n",(double)(CFSTARTTIME-time)/60.0); 00528 Debug("Time computed from input was: %s\n",ctime(&time)); 00529 return time; 00530 } 00531 00532 else if (strcmp(type,"accumulated")==0) 00533 00534 { 00535 sscanf(string,"%8[^(](%d,%d,%d,%d,%d,%d)",type,&year,&month,&day,&hr,&min,&sec); 00536 if (year*month*day*hr*min*sec < 0) 00537 { 00538 yyerror("Bad cumulative time specifier, should be type(year,month,day,hr,min,sec)"); 00539 return now; 00540 } 00541 00542 time = 0; 00543 time += sec; 00544 time += min * 60; 00545 time += hr * 3600; 00546 time += day * 24 * 3600; 00547 time += month * 30 * 24 * 3600; 00548 time += year * 365 * 24 * 3600; 00549 return time; 00550 } 00551 00552 yyerror("Illegal time specifier"); 00553 return now; 00554 }
|
|
||||||||||||||||||||
|
Definition at line 678 of file filters.c. References filterexec, FilterExecMatch(), filterexecregex, FilterExecRegexMatch(), filterfromatime, filterfromctime, filterfrommtime, filtergroup, FilterGroupMatch(), FilterIsSymLinkTo(), filtermode, FilterModeMatch(), filternameregex, FilterNameRegexMatch(), filterowner, FilterOwnerMatch(), filtersymlinkto, FilterTimeMatch(), filtertoatime, filtertoctime, filtertomtime, filtertype, FilterTypeMatch(), NULL, PrependItem(), and S_ISLNK. Referenced by FileObjectFilter(). 00684 { 00685 if (crit[filtertype] != NULL) 00686 { 00687 if (FilterTypeMatch(lstatptr,crit[filtertype])) 00688 { 00689 PrependItem(attr,"Type",""); 00690 } 00691 } 00692 00693 if (crit[filterowner] != NULL) 00694 { 00695 if (FilterOwnerMatch(lstatptr,crit[filterowner])) 00696 { 00697 PrependItem(attr,"Owner",""); 00698 } 00699 } 00700 00701 if (crit[filtergroup] != NULL) 00702 { 00703 if (FilterGroupMatch(lstatptr,crit[filtergroup])) 00704 { 00705 PrependItem(attr,"Group",""); 00706 } 00707 } 00708 00709 if (crit[filtermode] != NULL) 00710 { 00711 if (FilterModeMatch(lstatptr,crit[filtermode])) 00712 { 00713 PrependItem(attr,"Mode",""); 00714 } 00715 } 00716 00717 if (crit[filterfromatime] != NULL) 00718 { 00719 if (FilterTimeMatch(lstatptr->st_atime,crit[filterfromatime],crit[filtertoatime])) 00720 { 00721 PrependItem(attr,"Atime",""); 00722 } 00723 } 00724 00725 if (crit[filterfromctime] != NULL) 00726 { 00727 if (FilterTimeMatch(lstatptr->st_ctime,crit[filterfromctime],crit[filtertoctime])) 00728 { 00729 PrependItem(attr,"Ctime",""); 00730 } 00731 } 00732 00733 if (crit[filterfrommtime] != NULL) 00734 { 00735 if (FilterTimeMatch(lstatptr->st_mtime,crit[filterfrommtime],crit[filtertomtime])) 00736 { 00737 PrependItem(attr,"Mtime",""); 00738 } 00739 } 00740 00741 if (crit[filternameregex] != NULL) 00742 { 00743 if (FilterNameRegexMatch(filename,crit[filternameregex])) 00744 { 00745 PrependItem(attr,"NameRegex",""); 00746 } 00747 } 00748 00749 if ((crit[filtersymlinkto] != NULL) && (S_ISLNK(lstatptr->st_mode))) 00750 { 00751 if (FilterIsSymLinkTo(filename,crit[filtersymlinkto])) 00752 { 00753 PrependItem(attr,"IsSymLinkTo",""); 00754 } 00755 } 00756 00757 if (crit[filterexecregex] != NULL) 00758 { 00759 if (FilterExecRegexMatch(filename,crit[filterexecregex])) 00760 { 00761 PrependItem(attr,"ExecRegex",""); 00762 } 00763 } 00764 00765 if (crit[filterexec] != NULL) 00766 { 00767 if (FilterExecMatch(filename,crit[filterexec])) 00768 { 00769 PrependItem(attr,"Exec",""); 00770 } 00771 } 00772 }
|
|
||||||||||||||||||||
|
Definition at line 776 of file filters.c. References filtercmd, filterfromstime, filterfromttime, filterowner, filterpgid, filterpid, filterppid, filterpriority, FilterProcMatch(), FilterProcSTimeMatch(), FilterProcTTimeMatch(), filterrsize, filtersize, filterstatus, filterthreads, filtertostime, filtertottime, filtertty, NULL, and PrependItem(). Referenced by ProcessFilter(). 00781 { 00782 if (crit[filterowner] != NULL) 00783 { 00784 if (FilterProcMatch("UID","USER",crit[filterowner],names,line)) 00785 { 00786 PrependItem(attr,"Owner",""); 00787 } 00788 } 00789 else 00790 { 00791 PrependItem(attr,"Owner",""); 00792 } 00793 00794 if (crit[filterpid] != NULL) 00795 { 00796 if (FilterProcMatch("PID","PID",crit[filterpid],names,line)) 00797 { 00798 PrependItem(attr,"PID",""); 00799 } 00800 } 00801 else 00802 { 00803 PrependItem(attr,"PID",""); 00804 } 00805 00806 if (crit[filterppid] != NULL) 00807 { 00808 if (FilterProcMatch("PPID","PPID",crit[filterppid],names,line)) 00809 { 00810 PrependItem(attr,"PPID",""); 00811 } 00812 } 00813 else 00814 { 00815 PrependItem(attr,"PPID",""); 00816 } 00817 00818 if (crit[filterpgid] != NULL) 00819 { 00820 if (FilterProcMatch("PGID","PGID",crit[filterpgid],names,line)) 00821 { 00822 PrependItem(attr,"PGID",""); 00823 } 00824 } 00825 else 00826 { 00827 PrependItem(attr,"PGID",""); 00828 } 00829 00830 if (crit[filtersize] != NULL) 00831 { 00832 if (FilterProcMatch("SZ","VSZ",crit[filtersize],names,line)) 00833 { 00834 PrependItem(attr,"VSize",""); 00835 } 00836 } 00837 else 00838 { 00839 PrependItem(attr,"VSize",""); 00840 } 00841 00842 if (crit[filterrsize] != NULL) 00843 { 00844 if (FilterProcMatch("RSS","RSS",crit[filterrsize],names,line)) 00845 { 00846 PrependItem(attr,"RSize",""); 00847 } 00848 } 00849 else 00850 { 00851 PrependItem(attr,"RSize",""); 00852 } 00853 00854 if (crit[filterstatus] != NULL) 00855 { 00856 if (FilterProcMatch("S","STAT",crit[filterstatus],names,line)) 00857 { 00858 PrependItem(attr,"Status",""); 00859 } 00860 } 00861 else 00862 { 00863 PrependItem(attr,"Status",""); 00864 } 00865 00866 if (crit[filtercmd] != NULL) 00867 { 00868 if (FilterProcMatch("CMD","COMMAND",crit[filtercmd],names,line)) 00869 { 00870 PrependItem(attr,"Command",""); 00871 } 00872 } 00873 else 00874 { 00875 PrependItem(attr,"Command",""); 00876 } 00877 00878 if (crit[filterfromttime] != NULL) 00879 { 00880 if (FilterProcTTimeMatch("TIME","TIME",crit[filterfromttime],crit[filtertottime],names,line)) 00881 { 00882 PrependItem(attr,"TTime",""); 00883 } 00884 } 00885 else 00886 { 00887 PrependItem(attr,"TTime",""); 00888 } 00889 00890 if (crit[filterfromstime] != NULL) 00891 { 00892 if (FilterProcSTimeMatch("STIME","START",crit[filterfromstime],crit[filtertostime],names,line)) 00893 { 00894 PrependItem(attr,"STime",""); 00895 } 00896 } 00897 else 00898 { 00899 PrependItem(attr,"STime",""); 00900 } 00901 00902 if (crit[filtertty] != NULL) 00903 { 00904 if (FilterProcMatch("TTY","TTY",crit[filtertty],names,line)) 00905 { 00906 PrependItem(attr,"TTY",""); 00907 } 00908 } 00909 else 00910 { 00911 PrependItem(attr,"TTY",""); 00912 } 00913 00914 if (crit[filterpriority] != NULL) 00915 { 00916 if (FilterProcMatch("NI","PRI",crit[filterpriority],names,line)) 00917 { 00918 PrependItem(attr,"Priority",""); 00919 } 00920 } 00921 else 00922 { 00923 PrependItem(attr,"Priority",""); 00924 } 00925 00926 if (crit[filterthreads] != NULL) 00927 { 00928 if (FilterProcMatch("NLWP","NLWP",crit[filterthreads],names,line)) 00929 { 00930 PrependItem(attr,"Threads",""); 00931 } 00932 } 00933 else 00934 { 00935 PrependItem(attr,"Threads",""); 00936 } 00937 }
|
|
||||||||||||||||||||
|
Definition at line 628 of file filters.c. References AddMultipleClasses(), Filter::alias, Filter::criteria, Debug, Filter::defines, DeleteItemList(), DoFilter(), Filter::elsedef, EvaluateORString(), filterresult, fp, IsItemIn(), Filter::next, NULL, strdup(), and VFILTERLIST. Referenced by CheckExistingFile(), DoRecursiveEditFiles(), RecursiveImage(), RecursiveLink(), TidyHomeFile(), TidyParticularFile(), and WrapDoEditFile(). 00635 { struct Item *tests = NULL; 00636 struct Filter *fp; int result = true, tmpres; 00637 00638 Debug("FileObjectFilter(%s)\n",file); 00639 00640 if (filterlist == NULL) 00641 { 00642 return true; 00643 } 00644 00645 for (fp = VFILTERLIST; fp != NULL; fp=fp->next) 00646 { 00647 if (IsItemIn(filterlist,fp->alias)) 00648 { 00649 Debug ("Applying filter %s\n",fp->alias); 00650 00651 if (fp->criteria[filterresult] == NULL) 00652 { 00653 fp->criteria[filterresult] = strdup("Type.Owner.Group.Mode.Ctime.Mtime.Atime.Size.ExecRegex.NameRegex.IsSymLinkTo.Exec"); 00654 } 00655 00656 DoFilter(&tests,fp->criteria,lstatptr,file); 00657 00658 if (tmpres = EvaluateORString(fp->criteria[filterresult],tests)) 00659 { 00660 AddMultipleClasses(fp->defines); 00661 } 00662 else 00663 { 00664 AddMultipleClasses(fp->elsedef); 00665 } 00666 00667 result &= tmpres; 00668 } 00669 } 00670 00671 DeleteItemList(tests); 00672 Debug("Filter result on %s was %d\n",file,result); 00673 return result; 00674 }
|
|
|
Definition at line 361 of file filters.c. References Debug1, i, NoFilter, VFILTERNAMES, and yyerror(). Referenced by InstallFilterTest(). 00365 { int i; 00366 00367 Debug1("FilterActionsToCode(%s)\n",filtertype); 00368 00369 if (filtertype[strlen(filtertype)-1] != ':') 00370 { 00371 yyerror("Syntax error in filter type"); 00372 return NoFilter; 00373 } 00374 00375 filtertype[strlen(filtertype)-1] = '\0'; 00376 00377 for (i = 0; VFILTERNAMES[i] != '\0'; i++) 00378 { 00379 if (strcmp(VFILTERNAMES[i],filtertype) == 0) 00380 { 00381 return (enum filternames) i; 00382 } 00383 } 00384 00385 return (NoFilter); 00386 }
|
|
||||||||||||
|
Definition at line 1358 of file filters.c. References AddMacroValue(), CONTEXTID, Debug, DeleteMacro(), ExpandVarstring(), NULL, ShellCommandReturnsZero(), and VBUFF. Referenced by DoFilter(). 01364 { 01365 AddMacroValue(CONTEXTID,"this",filename); 01366 VBUFF[0] = '\0'; 01367 ExpandVarstring(crit,VBUFF,NULL); 01368 DeleteMacro(CONTEXTID,"this"); 01369 01370 Debug("Executing filter command [%s]\n",VBUFF); 01371 01372 if (ShellCommandReturnsZero(VBUFF)) 01373 { 01374 return true; 01375 } 01376 else 01377 { 01378 return false; 01379 } 01380 }
|
|
||||||||||||
|
Definition at line 1264 of file filters.c. References AddMacroValue(), bufsize, bzero, cferror, CfLog(), cfpclose(), cfpopen(), CfRegcomp(), CONTEXTID, DeleteMacro(), ExpandVarstring(), NULL, OUTPUT, ReadLine(), REG_EXTENDED, regexec(), regfree(), regmatch_t::rm_eo, regmatch_t::rm_so, snprintf(), sp, and VBUFF. Referenced by DoFilter(). 01268 { regex_t rx; 01269 regmatch_t pmatch; 01270 char buffer[bufsize],expr[bufsize],line[bufsize],*sp; 01271 FILE *pp; 01272 01273 AddMacroValue(CONTEXTID,"this",filename); 01274 VBUFF[0] = '\0'; 01275 ExpandVarstring(crit,VBUFF,NULL); 01276 DeleteMacro(CONTEXTID,"this"); 01277 01278 bzero(buffer,bufsize); 01279 bzero(line,bufsize); 01280 bzero(expr,bufsize); 01281 01282 for (sp = VBUFF+strlen(VBUFF)-1; (*sp != '(') && (sp > VBUFF); sp--) 01283 { 01284 } 01285 01286 sscanf(sp+1,"%256[^)]",expr); 01287 strncpy(buffer,VBUFF,(int)(sp-VBUFF)); 01288 01289 if (CfRegcomp(&rx,expr,REG_EXTENDED) != 0) 01290 { 01291 return false; 01292 } 01293 01294 if ((pp = cfpopen(buffer,"r")) == NULL) 01295 { 01296 snprintf(OUTPUT,bufsize*2,"Couldn't open pipe to command %s\n",buffer); 01297 CfLog(cferror,OUTPUT,"cfpopen"); 01298 return false; 01299 } 01300 01301 ReadLine(line,bufsize,pp); /* One buffer only */ 01302 01303 cfpclose(pp); 01304 01305 if (regexec(&rx,line,1,&pmatch,0) == 0) 01306 { 01307 if ((pmatch.rm_so == 0) && (pmatch.rm_eo == strlen(line))) 01308 { 01309 regfree(&rx); 01310 return true; 01311 } 01312 } 01313 01314 regfree(&rx); 01315 return false; 01316 }
|
|
|
Definition at line 390 of file filters.c. References Filter::alias, Filter::next, NULL, and VFILTERLIST. Referenced by InstallFilter(). 00394 { struct Filter *ptr; 00395 00396 for (ptr=VFILTERLIST; ptr != NULL; ptr=ptr->next) 00397 { 00398 if (strcmp(ptr->alias,name) == 0) 00399 { 00400 return true; 00401 } 00402 } 00403 return false; 00404 }
|
|
||||||||||||
|
Definition at line 1173 of file filters.c. References DeleteItemList(), EvaluateORString(), NULL, and PrependItem(). Referenced by DoFilter(). 01178 { struct Item *attrib = NULL; 01179 char buffer[64]; 01180 struct group *gr; 01181 01182 sprintf(buffer,"%d",lstatptr->st_gid); 01183 PrependItem(&attrib,buffer,""); 01184 01185 if ((gr = getgrgid(lstatptr->st_gid)) != NULL) 01186 { 01187 PrependItem(&attrib,gr->gr_name,""); 01188 } 01189 else 01190 { 01191 PrependItem(&attrib,"none",""); 01192 } 01193 01194 if (EvaluateORString(crit,attrib)) 01195 { 01196 DeleteItemList(attrib); 01197 return true; 01198 } 01199 else 01200 { 01201 DeleteItemList(attrib); 01202 return false; 01203 } 01204 }
|
|
||||||||||||
|
Definition at line 1320 of file filters.c. References bufsize, bzero, cferror, CfLog(), CfRegcomp(), OUTPUT, REG_EXTENDED, regexec(), regfree(), regmatch_t::rm_eo, regmatch_t::rm_so, and snprintf(). Referenced by DoFilter(). 01324 { regex_t rx; 01325 regmatch_t pmatch; 01326 char buffer[bufsize]; 01327 01328 if (CfRegcomp(&rx,crit,REG_EXTENDED) != 0) 01329 { 01330 return false; 01331 } 01332 01333 bzero(buffer,bufsize); 01334 01335 if (readlink(filename,buffer,bufsize-1) == -1) 01336 { 01337 snprintf(OUTPUT,bufsize*2,"Unable to read link %s in filter",filename); 01338 CfLog(cferror,OUTPUT,"readlink"); 01339 regfree(&rx); 01340 return false; 01341 } 01342 01343 if (regexec(&rx,buffer,1,&pmatch,0) == 0) 01344 { 01345 if ((pmatch.rm_so == 0) && (pmatch.rm_eo == strlen(buffer))) 01346 { 01347 regfree(&rx); 01348 return true; 01349 } 01350 } 01351 01352 regfree(&rx); 01353 return false; 01354 }
|
|
||||||||||||
|
Definition at line 1208 of file filters.c. References ParseModeString(). Referenced by DoFilter(). 01213 { mode_t plusmask,minusmask; 01214 01215 ParseModeString(crit,&plusmask,&minusmask); 01216 01217 return ((lstatptr->st_mode & plusmask) && !(lstatptr->st_mode & minusmask)); 01218 }
|
|
||||||||||||
|
Definition at line 1237 of file filters.c. References CfRegcomp(), REG_EXTENDED, regexec(), regfree(), regmatch_t::rm_eo, and regmatch_t::rm_so. Referenced by DoFilter(). 01241 { regex_t rx; 01242 regmatch_t pmatch; 01243 01244 if (CfRegcomp(&rx,crit,REG_EXTENDED) != 0) 01245 { 01246 return false; 01247 } 01248 01249 if (regexec(&rx,filename,1,&pmatch,0) == 0) 01250 { 01251 if ((pmatch.rm_so == 0) && (pmatch.rm_eo == strlen(filename))) 01252 { 01253 regfree(&rx); 01254 return true; 01255 } 01256 } 01257 01258 regfree(&rx); 01259 return false; 01260 }
|
|
||||||||||||
|
Definition at line 1138 of file filters.c. References DeleteItemList(), EvaluateORString(), NULL, and PrependItem(). Referenced by DoFilter(). 01143 { struct Item *attrib = NULL; 01144 char buffer[64]; 01145 struct passwd *pw; 01146 01147 sprintf(buffer,"%d",lstatptr->st_uid); 01148 PrependItem(&attrib,buffer,""); 01149 01150 if ((pw = getpwuid(lstatptr->st_uid)) != NULL) 01151 { 01152 PrependItem(&attrib,pw->pw_name,""); 01153 } 01154 else 01155 { 01156 PrependItem(&attrib,"none",""); 01157 } 01158 01159 if (EvaluateORString(crit,attrib)) 01160 { 01161 DeleteItemList(attrib); 01162 return true; 01163 } 01164 else 01165 { 01166 DeleteItemList(attrib); 01167 return false; 01168 } 01169 }
|
|
||||||||||||||||||||||||
|
Definition at line 1004 of file filters.c. References CfRegcomp(), Debug, i, NULL, REG_EXTENDED, regexec(), regfree(), regmatch_t::rm_eo, and regmatch_t::rm_so. Referenced by DoProc(). 01009 { int i; 01010 regex_t rx; 01011 regmatch_t pmatch; 01012 01013 Debug("FilterProcMatch(%s,%s,%s,%s,[%s])\n",name1,name2,expr,names,line); 01014 01015 if (CfRegcomp(&rx,expr,REG_EXTENDED) != 0) 01016 { 01017 return false; 01018 } 01019 01020 for (i = 0; names[i] != NULL; i++) 01021 { 01022 if ((strcmp(names[i],name1) == 0) || (strcmp(names[i],name2) == 0)) 01023 { 01024 Debug("Match (%s) to (%s)\n",expr,line[i]); 01025 if (regexec(&rx,line[i],1,&pmatch,0) == 0) 01026 { 01027 if ((pmatch.rm_so == 0) && (pmatch.rm_eo == strlen(line[i]))) 01028 { 01029 regfree(&rx); 01030 return true; 01031 } 01032 } 01033 01034 regfree(&rx); 01035 return false; 01036 } 01037 } 01038 01039 regfree(&rx); 01040 return false; 01041 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 1045 of file filters.c. References bzero, CFSTARTTIME, Date2Number(), Debug, i, Month2Number(), NULL, snprintf(), strstr(), VDAY, VHR, VMINUTE, VMONTH, and VYEAR. Referenced by DoProc(). 01050 { int i; 01051 time_t fromtime,totime, now = CFSTARTTIME,pstime; 01052 char year[5],month[4],hr[3],min[3],day[3],timestr[256]; 01053 01054 bzero(year,5); 01055 strcpy(year,VYEAR); 01056 bzero(month,4); 01057 strcpy(month,VMONTH); 01058 bzero(day,3); 01059 strcpy(day,VDAY); 01060 bzero(hr,3); 01061 strcpy(hr,VHR); 01062 bzero(min,3); 01063 strcpy(min,VMINUTE); 01064 01065 fromtime = Date2Number(fromexpr,now); 01066 totime = Date2Number(toexpr,now); 01067 01068 for (i = 0; names[i] != NULL; i++) 0106 |