samba3-vscan/kaspersky vscan-kavp.c,1.4,1.5
Rainer Link <[email protected]> Thu, 28 Jul 2005 10:15:11 +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-serv12787/kaspersky
Modified Files:
vscan-kavp.c
Log Message:
bugfix in kaspersky module
stream-lined vscan_close for all modules
Index: vscan-kavp.c
===================================================================
RCS file: /cvsroot/openantivirus/samba3-vscan/kaspersky/vscan-kavp.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- vscan-kavp.c 27 Jul 2005 18:40:24 -0000 1.4
+++ vscan-kavp.c 28 Jul 2005 10:15:09 -0000 1.5
@@ -157,7 +157,7 @@
static int vscan_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode)
{
- int retval, must_be_checked, rc, sockfd;
+ int retval, must_be_checked, rc;
SMB_STRUCT_STAT stat_buf;
pstring filepath;
char client_ip[CLIENT_IP_SIZE];
@@ -225,7 +225,7 @@
errno = EACCES;
vscan_kavp_end();
return -1;
- } else if ( sockfd >= 0 ) {
+ } else if ( kavp_socket >= 0 ) {
/* get client IP */
safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1);
@@ -285,64 +285,75 @@
static int vscan_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
{
+ SMB_STRUCT_STAT stat_buf;
pstring filepath;
- int retval, rv, rc;
+ int retval = 0, rv = 0, rc = 0;
char client_ip[CLIENT_IP_SIZE];
/* First close the file */
retval = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+ /* get the file name */
+ pstrcpy(filepath, fsp->conn->connectpath);
+ pstrcat(filepath, "/");
+ pstrcat(filepath, fsp->fsp_name);
+
if ( !vscan_config.common.scan_on_close ) {
DEBUG(3, ("samba-vscan - close: File '%s' not scanned as scan_on_close is not set\n", fsp->fsp_name));
- return retval;
}
-
-
- /* get the file name */
- pstrcpy(filepath, fsp->conn->connectpath);
- pstrcat(filepath, "/");
- pstrcat(filepath, fsp->fsp_name);
-
/* Don't scan directorys */
- if ( fsp->is_directory )
- return retval;
-
-
- if ( !fsp->modified ) {
+ else if ( fsp->is_directory )
+ DEBUG(10, ("don't scan directory\n"));
+ /* Don't scan files which have not been modified */
+ else if ( !fsp->modified ) {
if ( vscan_config.common.verbose_file_logging )
vscan_syslog("INFO: file %s was not modified - not scanned", filepath);
- return retval;
}
-
/* dont' scan file which matches exclude regexp */
- if ( fileregexp_skipscan(filepath) == VSCAN_FR_SKIP_SCAN ) {
+ 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);
- return retval;
}
-
/* don't scan files which are in the list of exclude file types */
- if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
+ 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 retval;
+ vscan_syslog("INFO: File '%s' not scanned as file type is on exclude list", filepath);
}
+ else if ( (SMB_VFS_NEXT_STAT(handle, handle->conn, fsp->fsp_name, &stat_buf)) != 0 ) { /* an error occured */
+ if( errno == ENOENT) {
+ if ( vscan_config.common.verbose_file_logging )
+ vscan_syslog("INFO: File %s not found! Not scanned!", fsp->fsp_name);
+ } else {
+ vscan_syslog("ERROR: File %s not readable or an error occured", fsp->fsp_name);
+ }
+ }
+ else {
+ /* scan only file, do nothing */
+ vscan_kavp_init();
+ if ( kavp_socket >= 0 ) {
+ safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
+ rv = vscan_kavp_scanfile(filepath, client_ip);
+ vscan_kavp_end();
+ if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
+ /* virus was found */
+ rc = vscan_do_infected_file_action(handle, fsp->conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
- /* scan only file, do nothing */
-
- vscan_kavp_init();
- if ( kavp_socket >= 0 ) {
- safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
- rv = vscan_kavp_scanfile(filepath, client_ip);
- vscan_kavp_end();
- if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
- /* virus was found */
- rc = vscan_do_infected_file_action(handle, fsp->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);
+ }
+ else if( rv == VSCAN_SCAN_OK ) {
+ /* add/update file, mark file as clean! */
+ lrufiles_add(filepath, stat_buf.st_mtime, False);
+ }
+ else {
+ /* to be save, delete file from lrufiles */
+ lrufiles_delete(filepath);
+ } /* rv */
+ } /* sockfd */
+ } /* pre-scan conditions */
- }
return retval;
}
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September
19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf