From: <re...@us...> - 2003-09-12 07:12:50
|
Update of /cvsroot/openantivirus/samba-vscan/clamav In directory sc8-pr-cvs1:/tmp/cvs-serv12508/clamav Modified Files: Tag: VSCAN_0_3 vscan-clamav.c vscan-clamav.h Log Message: changes for 0.3.5; added skip scanning of files based on file type (currently not well tested) Index: vscan-clamav.c =================================================================== RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- vscan-clamav.c 14 Jul 2003 13:09:15 -0000 1.1.2.1 +++ vscan-clamav.c 12 Sep 2003 07:12:14 -0000 1.1.2.2 @@ -85,6 +85,8 @@ time_t lrufiles_invalidate_time; /* specified the time in seconds after the lifetime of an entry is expired and entry will be invalidated */ +pstring exclude_file_types; /* list of file types which should be excluded from scanning */ + /* module version */ static const char module_id[]=VSCAN_MODULE_STR" "SAMBA_VSCAN_VERSION_STR; @@ -140,8 +142,8 @@ } else if ( StrCaseCmp("clamd socket name", param) == 0) { fstrcpy(clamd_socket_name, value); DEBUG(3, ("clamd socket name is %s\n", clamd_socket_name)); - - + } else if ( StrCaseCmp("exclude file types", param) == 0 ) { + pstrcpy(exclude_file_types, value); } else DEBUG(3, ("unknown parameter: %s\n", param)); @@ -210,6 +212,8 @@ /* time after an entry is considered as expired */ lrufiles_invalidate_time = VSCAN_LRUFILES_INVALIDATE_TIME; + /* file type exclude ist */ + pstrcpy(exclude_file_types, VSCAN_FT_EXCLUDE_LIST); vscan_syslog("INFO: connect to service %s by user %s", svc, user); @@ -252,13 +256,16 @@ DEBUG(5, ("init lrufiles list\n")); lrufiles_init(max_lrufiles, lrufiles_invalidate_time); + /* initialise filetype */ + DEBUG(5, ("init file type\n")); + filetype_init(0, exclude_file_types); - #if (SMB_VFS_INTERFACE_VERSION >= 6) + #if (SMB_VFS_INTERFACE_VERSION >= 6) return SMB_VFS_NEXT_CONNECT(handle, conn, svc, user); - #else + #else return default_vfs_ops.connect(conn, svc, user); - #endif + #endif } @@ -272,6 +279,7 @@ vscan_syslog("INFO: disconnected"); lrufiles_destroy_all(); + filetype_close(); #if (SMB_VFS_INTERFACE_VERSION >= 6) SMB_VFS_NEXT_DISCONNECT(handle, conn); @@ -295,6 +303,11 @@ int rc; + /* Assemble complete file path */ + pstrcpy(filepath, conn->connectpath); + pstrcat(filepath, "/"); + pstrcat(filepath, fname); + /* scan files while opening? */ if ( !scan_on_open ) { @@ -327,7 +340,16 @@ #else return default_vfs_ops.open(conn, fname, flags, mode); #endif - else + else if ( filetype_skipscan(filepath) == 1 ) { + if ( verbose_file_logging ) + vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath); +#if (SMB_VFS_INTERFACE_VERSION >= 6) + return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode); +#else + return default_vfs_ops.open(conn, fname, flags, mode); +#endif + + } else { /* open socket */ sockfd = vscan_clamav_init(); @@ -339,11 +361,6 @@ return -1; } else if ( sockfd >= 0 ) { - /* Assemble complete file path */ - pstrcpy(filepath, conn->connectpath); - pstrcat(filepath, "/"); - pstrcat(filepath, fname); - safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1); /* must file actually be scanned? */ @@ -476,6 +493,14 @@ return retval; } + + /* don't scan files which are in the list of exclude file types */ + if ( filetype_skipscan(filepath) == 1 ) { + if ( verbose_file_logging ) + vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath); + return retval; + } + sockfd = vscan_clamav_init(); if ( sockfd >= 0 ) { Index: vscan-clamav.h =================================================================== RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- vscan-clamav.h 14 Jul 2003 13:09:15 -0000 1.1.2.1 +++ vscan-clamav.h 12 Sep 2003 07:12:15 -0000 1.1.2.2 @@ -72,6 +72,10 @@ /* time after an entry is considered as expired */ #define VSCAN_LRUFILES_INVALIDATE_TIME 5 +/* MIME-types of files to be exluded from scanning; that's an + semi-colon seperated list */ +#define VSCAN_FT_EXCLUDE_LIST "" + /* End Configuration Section */ |