samba-vscan/clamav vscan-clamav.c,1.1.2.10,1.1.2.11
Rainer Link <[email protected]> Fri, 24 Sep 2004 09:17:33 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/samba-vscan/clamav
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15455/clamav
Modified Files:
Tag: VSCAN_0_3
vscan-clamav.c
Log Message:
update LRU list also on file close. Patch by Helmut, needs to
be "ported" to other modules as well.
Index: vscan-clamav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.c,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -u -d -r1.1.2.10 -r1.1.2.11
--- vscan-clamav.c 10 Sep 2004 09:49:09 -0000 1.1.2.10
+++ vscan-clamav.c 24 Sep 2004 09:17:31 -0000 1.1.2.11
@@ -497,6 +497,7 @@
static int vscan_close(struct files_struct *fsp, int fd)
#endif
{
+ SMB_STRUCT_STAT stat_buf;
pstring filepath;
int retval, rv;
char client_ip[CLIENT_IP_SIZE];
@@ -539,20 +540,36 @@
}
- safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
+#if (SMB_VFS_INTERFACE_VERSION >= 6)
+ if ( (SMB_VFS_NEXT_STAT(handle, handle->conn, fsp->fsp_name, &stat_buf)) != 0 ) { /* an error occured */
+#else
+ if ( (default_vfs_ops.stat(fsp->conn, fsp->fsp_name, &stat_buf)) != 0 ) { /* an error occured */
+#endif
+ if( errno == ENOENT) {
+ if ( 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);
+ }
+ rv = 3;
+ }
+ else {
+ safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
#ifdef LIBCLAMAV
- /* scan only file, do nothing */
- rv = vscan_clamav_lib_scanfile(filepath, client_ip);
-#else /* LIBCLAMAV */
- {
- int sockfd;
- sockfd = vscan_clamav_init();
- /* Errors are written from vscan_clamav_init() */
- if ( sockfd < 0 )
- return retval;
/* scan only file, do nothing */
- rv = vscan_clamav_scanfile(sockfd, filepath, client_ip);
- vscan_clamav_end(sockfd);
+ rv = vscan_clamav_lib_scanfile(filepath, client_ip);
+#else /* LIBCLAMAV */
+ {
+ int sockfd;
+ sockfd = vscan_clamav_init();
+ /* Errors are written from vscan_clamav_init() */
+ if ( sockfd < 0 )
+ return retval;
+ /* scan only file, do nothing */
+ rv = vscan_clamav_scanfile(sockfd, filepath, client_ip);
+ vscan_clamav_end(sockfd);
+ }
}
#endif /* LIBCLAMAV */
@@ -563,7 +580,18 @@
#else
vscan_do_infected_file_action(&default_vfs_ops, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
#endif
+ /* add/update file, mark file as infected! */
+ lrufiles_add(filepath, stat_buf.st_mtime, True);
}
+ else if( rv == 0 ) {
+ /* 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);
+ }
+
return retval;
}
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php