samba3-vscan/clamav vscan-clamav.c,1.2,1.3

Rainer Link <[email protected]> Mon, 25 Jul 2005 14:12:14 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba3-vscan/clamav
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27235

Modified Files:
	vscan-clamav.c 
Log Message:
some changes in logic


Index: vscan-clamav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba3-vscan/clamav/vscan-clamav.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vscan-clamav.c	23 Jul 2005 14:47:45 -0000	1.2
+++ vscan-clamav.c	25 Jul 2005 14:12:11 -0000	1.3
@@ -241,100 +241,95 @@
 	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);
+
+		/* 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);
 	} else
 	{
 		char client_ip[CLIENT_IP_SIZE];
 		int must_be_checked;
 
 		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);
-
-			/* 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);
-                }
-		else {
-                        /* ok, we must check the file */
-			int retval;
+                /* ok, we must check the file */
+		int retval;
 
 #ifdef LIBCLAMAV
-			retval = vscan_clamav_lib_scanfile(filepath, client_ip);
+		retval = vscan_clamav_lib_scanfile(filepath, client_ip);
 #else	/* LIBCLAMAV	*/
-			int sockfd;
+		int sockfd;
 
-			/* open socket */
-			sockfd = vscan_clamav_init();
-	                if ( sockfd == VSCAN_SCAN_ERROR ) {
-				if( vscan_config.common.deny_access_on_error ) {
-		                        /* an error occured - can not communicate to daemon - deny access */
-					vscan_syslog("ERROR: can not communicate to daemon - access denied");
-					errno = EACCES;
-					return -1;
-				}
-				vscan_syslog("ERROR: can not communicate to daemon - Not scanned!");
-				retval = 3;	/* Access allowed, not scanned */
-			} else
-			{
-				/* scan file */
-				retval = vscan_clamav_scanfile(sockfd, filepath, client_ip);
-				vscan_clamav_end(sockfd);
+		/* open socket */
+		sockfd = vscan_clamav_init();
+                if ( sockfd == VSCAN_SCAN_ERROR ) {
+			if( vscan_config.common.deny_access_on_error ) {
+	                        /* an error occured - can not communicate to daemon - deny access */
+				vscan_syslog("ERROR: can not communicate to daemon - access denied");
+				errno = EACCES;
+				return -1;
 			}
+			vscan_syslog("ERROR: can not communicate to daemon - Not scanned!");
+			retval = 3;	/* Access allowed, not scanned */
+		} else
+		{
+			/* scan file */
+			retval = vscan_clamav_scanfile(sockfd, filepath, client_ip);
+			vscan_clamav_end(sockfd);
+		}
 #endif 
-			if ( retval == VSCAN_SCAN_OK ) {
-                                /* file is clean, add to lrufiles */
-                                lrufiles_add(filepath, stat_buf.st_mtime, False);
-			}
-			else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
-				/* virus found */
-				/* do action ... */
-				vscan_do_infected_file_action(handle, conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
+		if ( retval == VSCAN_SCAN_OK ) {
+			/* file is clean, add to lrufiles */
+			lrufiles_add(filepath, stat_buf.st_mtime, False);
+		}
+		else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
+			/* virus found */
+			/* do action ... */
+			vscan_do_infected_file_action(handle, conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
 
-                                /* add/update file. mark file as infected! */
-                                lrufiles_add(filepath, stat_buf.st_mtime, True);
+                        /* add/update file. mark file as infected! */
+			lrufiles_add(filepath, stat_buf.st_mtime, True);
 
-				/* virus found, deny acces */
-				errno = EACCES; 
-				return -1;
-			}
-			else if ( retval == VSCAN_SCAN_MINOR_ERROR ) {
-				/* to be safe, remove file from lrufiles */
-				lrufiles_delete(filepath);
+			/* virus found, deny acces */
+			errno = EACCES; 
+			return -1;
+		}
+		else if ( retval == VSCAN_SCAN_MINOR_ERROR ) {
+			/* to be safe, remove file from lrufiles */
+			lrufiles_delete(filepath);
 
-				if( vscan_config.common.deny_access_on_minor_error ) {
-					/* a minor error occured - deny access */
-					vscan_syslog("ERROR: daemon failed with a minor error - access to file %s denied", fname);
+			if( vscan_config.common.deny_access_on_minor_error ) {
+				/* a minor error occured - deny access */
+				vscan_syslog("ERROR: daemon failed with a minor error - access to file %s denied", fname);
 
-					/* deny access */
-					errno = EACCES;
-					return -1;
-				}
-				/* a minor error occured - Not scanned */
-				vscan_syslog("ERROR: daemon failed with a minor error - file %s Not scanned!", fname);
-                        } else if ( retval == VSCAN_SCAN_ERROR ) {
-				/* to be safe, remove file from lrufiles */
-				lrufiles_delete(filepath);
+				/* deny access */
+				errno = EACCES;
+				return -1;
+			}
+			/* a minor error occured - Not scanned */
+			vscan_syslog("ERROR: daemon failed with a minor error - file %s Not scanned!", fname);
+		} else if ( retval == VSCAN_SCAN_ERROR ) {
+			/* to be safe, remove file from lrufiles */
+			lrufiles_delete(filepath);
 
-				if( vscan_config.common.deny_access_on_error ) {
-					/* an error occured - can not communicate to daemon - deny access */
-					vscan_syslog("ERROR: can not communicate to clamd - access to file %s denied", fname);
+			if ( vscan_config.common.deny_access_on_error ) {
+				/* an error occured - can not communicate to daemon - deny access */
+				vscan_syslog("ERROR: can not communicate to clamd - access to file %s denied", fname);
 
-					/* deny access */
-					errno = EACCES;
-					return -1;
-				}
-				/* an error occured - can not communicate to daemon - Not scanned */
-				vscan_syslog("ERROR: can not communicate to clamd - file %s Not scanned!", fname);
-			}
+				/* deny access */
+				errno = EACCES;
+				return -1;
+			}<t_%9>
+			/* an error occured - can not communicate to daemon - Not scanned */
+			vscan_syslog("ERROR: can not communicate to clamd - file %s Not scanned!", fname);
 		}
 	}
 	return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
@@ -344,7 +339,7 @@
 {
 	SMB_STRUCT_STAT stat_buf;
 	pstring filepath;
-        int retval = 0, rv = 0;
+        int retval = 0;
 	char client_ip[CLIENT_IP_SIZE];
 
         /* First close the file */
@@ -384,7 +379,6 @@
 		} else {
 			vscan_syslog("ERROR: File %s not readable or an error occured", fsp->fsp_name);
 		}
-		rv = 3; /* FIXME: due to code re-org this should no longer be needed */
 	}
 	else {
 		safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);



-------------------------------------------------------
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