The current implementation of --exclude (and --exclude-dir) performs the
pruning AFTER descending/scanning those files.

The problem for us is that one of the areas we scan is via NFS on a
NetApp filer, and upon finding the built-in .snapshot directory (which
holds daily read-only snapshots of this hiearchy), spends the next week
traversing 30+ copies of the same files. --exclude (and --exclude-dir)
doesn't help us as implemented.

Attached is a patch we've been using since 0.75 (this one against
0.86.2) that uses --exclude to prevent traversing into treewalk() if the
regexp is on the list. Thus if we specify "--exclude=.snapshot", that
directory (regardless where) is completely skipped, as well as our
quarantine area. Don't understand why --exclude-dir is needed at all
(this patch doesn't do anything with it, but could simply be tweaked to
use --exclude-dir for this particular section).


It would be desirable to have the functional equivalent of this in the
standard releases.


thanks and regards,
-ericb
--
Transmeta, Corporation


*** clamav-0.86.2/clamscan/treewalk.c.exclude   Sun Jul 24 16:30:17 2005
--- clamav-0.86.2/clamscan/treewalk.c   Wed Sep 14 11:29:30 2005
***************
*** 106,113 ****
  
                    /* stat the file */
                    if(lstat(fname, &statbuf) != -1) {
                        if(S_ISDIR(statbuf.st_mode) && 
!S_ISLNK(statbuf.st_mode) && recursion) {
!                           if(treewalk(fname, root, user, opt, limits, 
options, depth) == 1)
                                scanret++;
                        } else {
                            if(S_ISREG(statbuf.st_mode))
--- 106,128 ----
  
                    /* stat the file */
                    if(lstat(fname, &statbuf) != -1) {
+                       int excludedir = 0;
                        if(S_ISDIR(statbuf.st_mode) && 
!S_ISLNK(statbuf.st_mode) && recursion) {
!                           /* see if this directory is on exclude list */
!                           if(optl(opt, "exclude")) {
!                               struct optnode *optnode;
!                               char *argument = getfirstargl(opt, "exclude", 
&optnode);
!                               while (argument) {
!                                   if(match_regex(fname, argument) == 1) {
!                                       if(!printinfected)
!                                           mprintf("%s: directory 
excluded.\n", fname);
!                                       excludedir = 1;
!                                   }
!                                   argument = getnextargl(&optnode, "exclude");
!                               }
!                           }
! 
!                           if(!excludedir && treewalk(fname, root, user, opt, 
limits, options, depth) == 1)
                                scanret++;
                        } else {
                            if(S_ISREG(statbuf.st_mode))

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html

Reply via email to