samba-vscan/clamav vscan-clamav.c, 1.1.2.22, 1.1.2.23

Rainer Link <[email protected]> Sat, 19 May 2007 22:29:34 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/clamav
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv673/clamav

Modified Files:
      Tag: VSCAN_0_3
	vscan-clamav.c 
Log Message:
next round of fixes for Samba 3.0.25 (or later)


Index: vscan-clamav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.c,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -d -r1.1.2.22 -r1.1.2.23
--- vscan-clamav.c	10 Apr 2005 19:23:47 -0000	1.1.2.22
+++ vscan-clamav.c	19 May 2007 22:29:32 -0000	1.1.2.23
@@ -116,7 +116,9 @@
 
 /* Implementation of vfs_ops.  */
 
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+static int vscan_connect(vfs_handle_struct *handle,  const char *svc, const char *user)
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 static int vscan_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user)
 #else
 static int vscan_connect(struct connection_struct *conn, PROTOTYPE_CONST char *svc, PROTOTYPE_CONST char *user)
@@ -162,8 +164,11 @@
 	       svc, user);
 
 	#if (SAMBA_VERSION_MAJOR==2 && SAMBA_VERSION_RELEASE>=4) || SAMBA_VERSION_MAJOR==3
-
+	 #if (SMB_VFS_INTERFACE_VERSION >= 21)
+	  fstrcpy(config_file, get_configuration_file(handle->conn, VSCAN_MODULE_STR, PARAMCONF));
+	 #else 
           fstrcpy(config_file, get_configuration_file(conn, VSCAN_MODULE_STR, PARAMCONF));
+	 #endif
           DEBUG(3, ("configuration file is: %s\n", config_file));
 
           retval = pm_process(config_file, do_section, do_parameter);
@@ -193,7 +198,9 @@
         DEBUG(5, ("init file regexp\n"));
 	fileregexp_init(vscan_config.common.exclude_file_regexp);
 
-	#if (SMB_VFS_INTERFACE_VERSION >= 6)
+	#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	 return SMB_VFS_NEXT_CONNCT(handle, svc, user);	
+	#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 	 return SMB_VFS_NEXT_CONNECT(handle, conn, svc, user);
 	#else
 	 return default_vfs_ops.connect(conn, svc, user);
@@ -201,7 +208,9 @@
 
 }
 
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+static void vscan_disconnect(vfs_handle_struct *handle)
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 static void vscan_disconnect(vfs_handle_struct *handle, connection_struct *conn)
 #else/* Samba 3.0 alphaX */
 static void vscan_disconnect(struct connection_struct *conn)
@@ -217,15 +226,18 @@
         lrufiles_destroy_all();
 	filetype_close();
 
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	SMB_VFS_NEXT_DISCONNECT(handle);
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 	SMB_VFS_NEXT_DISCONNECT(handle, conn);
 #else
 	default_vfs_ops.disconnect(conn);
 #endif
 }
 
-
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+static int vscan_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 static int vscan_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode)
 #else
 static int vscan_open(struct connection_struct *conn, PROTOTYPE_CONST char *fname, int flags, mode_t mode)
@@ -235,7 +247,11 @@
 	pstring filepath;
 
 	/* Assemble complete file path */
-	pstrcpy(filepath, conn->connectpath);
+	#if (SMB_VFS_INTERFACE_VERSION >= 21)
+		pstrcpy(filepath, handle->conn->connectpath);
+	#else
+		pstrcpy(filepath, conn->connectpath);
+	#endif
 	pstrcat(filepath, "/");
 	pstrcat(filepath, fname);
 
@@ -244,7 +260,9 @@
         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));
         }
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	if ( (SMB_VFS_NEXT_STAT(handle, fname, &stat_buf)) != 0 ) {    /* an error occured */ 
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 	else if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 ) {    /* an error occured */ 
 #else
 	else if ( (default_vfs_ops.stat(conn, fname, &stat_buf)) != 0 ) {    /* an error occured */ 
@@ -281,7 +299,11 @@
 		char client_ip[CLIENT_IP_SIZE];
 		int must_be_checked;
 
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+		safe_strcpy(client_ip, handle->conn->client_address, CLIENT_IP_SIZE - 1);
+#else		
 		safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1);
+#endif
                 /* 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 ) {
@@ -332,7 +354,9 @@
 			else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
 				/* virus found */
 				/* do action ... */
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+				vscan_do_infected_file_action(handle, handle->conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 				vscan_do_infected_file_action(handle, conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
 #else
 				vscan_do_infected_file_action(&default_vfs_ops, conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
@@ -376,7 +400,9 @@
 			}
 		}
 	}
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 	return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
 #else
 	return default_vfs_ops.open(conn, fname, flags, mode);
@@ -428,7 +454,10 @@
                 if ( vscan_config.common.verbose_file_logging )
                         vscan_syslog("INFO: File '%s' not scanned as file type is on exclude list", filepath);
 	}
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	else if ( (SMB_VFS_NEXT_STAT(handle, fsp->fsp_name, &stat_buf)) != 0 ) {    /* an error occured */ 
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 	else if ( (SMB_VFS_NEXT_STAT(handle, handle->conn, fsp->fsp_name, &stat_buf)) != 0 ) {    /* an error occured */ 
 #else
 	else if ( (default_vfs_ops.stat(fsp->conn, fsp->fsp_name, &stat_buf)) != 0 ) {    /* an error occured */ 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/