samba3-vscan/f-secure vscan-fsav.c,1.2,1.3
Rainer Link <[email protected]> Wed, 27 Jul 2005 18:35:41 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/samba3-vscan/f-secure
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32264/f-secure
Modified Files:
vscan-fsav.c
Log Message:
changed the logic in vscan_open
Index: vscan-fsav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba3-vscan/f-secure/vscan-fsav.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vscan-fsav.c 23 Jul 2005 14:47:45 -0000 1.2
+++ vscan-fsav.c 27 Jul 2005 18:35:34 -0000 1.3
@@ -188,13 +188,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];
- fsav_handle *fsav;
-
- int rc;
+ fsav_handle *fsav = NULL;
/* Assemble complete file path */
@@ -202,28 +200,51 @@
pstrcat(filepath, "/");
pstrcat(filepath, fname);
- /* scan files while opening? */
+ /* 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);
- if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 ) /* an error occured */
- return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
- else if ( S_ISDIR(stat_buf.st_mode) ) /* is it a directory? */
- 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 */
- 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);
- }
- 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);
+ /* 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 {
fsav = fsav_create_handle();
if (fsav) {
@@ -255,40 +276,6 @@
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 handle */
- fsav_free_handle(fsav);
-
- /* 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 handle */
- fsav_free_handle(fsav);
-
- /* grant access */
- return SMB_VFS_NEXT_OPEN(handle, conn,
- fname, flags,
- mode);
- }
/* ok, we must check the file */
/* scan file */
-------------------------------------------------------
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