samba3-vscan/kaspersky vscan-kavp.c,1.2,1.3
Rainer Link <[email protected]> Wed, 27 Jul 2005 18:35:37 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/samba3-vscan/kaspersky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32264/kaspersky
Modified Files:
vscan-kavp.c
Log Message:
changed the logic in vscan_open
Index: vscan-kavp.c
===================================================================
RCS file: /cvsroot/openantivirus/samba3-vscan/kaspersky/vscan-kavp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vscan-kavp.c 23 Jul 2005 14:48:02 -0000 1.2
+++ vscan-kavp.c 27 Jul 2005 18:35:35 -0000 1.3
@@ -157,12 +157,11 @@
static int vscan_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode)
{
- int retval, must_be_checked;
+ int retval, must_be_checked, rc;
SMB_STRUCT_STAT stat_buf;
pstring filepath;
char client_ip[CLIENT_IP_SIZE];
- int rc;
/* Assemble complete file path */
pstrcpy(filepath, conn->connectpath);
@@ -173,74 +172,64 @@
/* scan files while opening? */
if ( !vscan_config.common.scan_on_open ) {
DEBUG(3, ("samba-vscan - open: File '%s' not scanned as scan_on_open is not set\n", fname));
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
}
+ else if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 ) { /* an error occured */
+ if ( errno == ENOENT ) {
+ if ( verbose_file_logging )
+ vscan_syslog("INFO: File %s not found! Not scanned!", fname);
+ }
+ else {
+ vscan_syslog("ERROR: File %s not readable or an error occured", fname);
+ }
+ }
+ else if ( S_ISDIR(stat_buf.st_mode) ) { /* is it a directory? */
+ if ( verbose_file_logging )
+ vscan_syslog("INFO: File %s is a directory! Not scanned!", fname);
+ }
+ else if ( ( stat_buf.st_size > vscan_config.common.max_size ) && ( vscan_config.common.max_size > 0 ) ) { /* file is
+too large */
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File %s is larger than specified maximum file size! Not scanned!", fname);
+ }
+ else if ( stat_buf.st_size == 0 ) { /* do not scan empty files */
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File %s has size zero! Not scanned!", fname);
+ }
+ else if ( fileregexp_skipscan(filepath) == VSCAN_FR_SKIP_SCAN ) {
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File '%s' not scanned as file is machted by exclude regexp", filepath);
+ }
+ else if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
+ if ( verbose_file_logging )
+ vscan_syslog("INFO: File '%s' not scanned as file type is on exclude list", filepath);
+ } else if ( (must_be_checked = lrufiles_must_be_checked(filepath, stat_buf.st_mtime)) == VSCAN_LRU_DENY_ACCESS ) {
+ /* file has already been checked and marked as infected */
+ /* deny access */
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File '%s' has already been scanned and marked as infected. Not scanned any more. Access denied", filepath);
- vscan_kavp_init();
- if ( kavp_socket < 0 && vscan_config.common.deny_access_on_error ) {
+ /* deny access */
+ errno = EACCES;
+ return -1;
+ } else if ( must_be_checked == VSCAN_LRU_GRANT_ACCESS ) {
+ /* file has already been checked, not marked as infected and not modified */
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File '%s' has already been scanned, not marked as infected and not modified. Not scanned anymore. Access granted", filepath);
- /* an error occured - can not communicate to daemon - deny access */
- vscan_syslog("ERROR: can not communicate to daemon - access denied");
- errno = EACCES;
- vscan_kavp_end();
- return -1;
} else {
- if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 ) { /* an error occured */
- vscan_kavp_end();
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- }
- else if ( S_ISDIR(stat_buf.st_mode) ) { /* is it a directory? */
- vscan_kavp_end();
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- }
- else if ( ( stat_buf.st_size > vscan_config.common.max_size ) && ( vscan_config.common.max_size > 0 ) ) { /* file is too large */
- vscan_syslog("INFO: File %s is larger than specified maximum file size! Not scanned!", fname);
- }
- else if ( stat_buf.st_size == 0 ) { /* do not scan empty files */
- vscan_kavp_end();
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- }
- else if ( fileregexp_skipscan(filepath) == VSCAN_FR_SKIP_SCAN ) {
- if ( vscan_config.common.verbose_file_logging )
- vscan_syslog("INFO: file '%s' not scanned as file is machted by exclude regexp", filepath);
- }
+ vscan_kavp_init();
+ if ( kavp_socket < 0 && vscan_config.common.deny_access_on_error ) {
- else if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
- if ( vscan_config.common.verbose_file_logging )
- vscan_syslog("INFO: File '%s' not scanned as file type is on exclude list", filepath);
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- }
+ /* an error occured - can not communicate to daemon - deny access */
+ vscan_syslog("ERROR: can not communicate to daemon - access denied");
+ errno = EACCES;
+ vscan_kavp_end();
+ return -1;
+ } else if ( sockfd >= 0 ) {
- else {
/* get client IP */
safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1);
- /* must file actually be scanned? */
- must_be_checked = lrufiles_must_be_checked(filepath, stat_buf.st_mtime);
- if ( must_be_checked == VSCAN_LRU_DENY_ACCESS ) {
- /* file has already been checked and marked as infected */
- /* deny access */
- if ( vscan_config.common.verbose_file_logging )
- vscan_syslog("INFO: File '%s' has already been scanned and marked as infected. Not scanned any more. Access denied", filepath);
-
- /* close socket */
- vscan_kavp_end();
-
- /* deny access */
- errno = EACCES;
- return -1;
- } else if ( must_be_checked == VSCAN_LRU_GRANT_ACCESS ) {
- /* file has already been checked, not marked as infected and not modified */
- if ( vscan_config.common.verbose_file_logging )
- vscan_syslog("INFO: File '%s' has already been scanned, not marked as infected and not modified. Not scanned anymore. Access granted", filepath);
-
- /* close socket */
- vscan_kavp_end();
-
- /* grant access */
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- }
- /* ok, we must check the file */
/* scan file */
retval = vscan_kavp_scanfile(filepath, client_ip);
@@ -285,11 +274,11 @@
/* file is clean, add to lrufiles */
lrufiles_add(filepath, stat_buf.st_mtime, False);
}
+
+ /* close socket */
+ vsccan_kavp_end();
}
- /* close socket */
- vscan_kavp_end();
-
}
return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
}
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click