samba-vscan/openantivirus vscan-oav.c, 1.37.2.9, 1.37.2.10

Rainer Link <[email protected]> Sun, 20 May 2007 17:23:36 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/openantivirus
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12652/openantivirus

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


Index: vscan-oav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/openantivirus/vscan-oav.c,v
retrieving revision 1.37.2.9
retrieving revision 1.37.2.10
diff -u -d -r1.37.2.9 -r1.37.2.10
--- vscan-oav.c	10 Apr 2005 15:22:53 -0000	1.37.2.9
+++ vscan-oav.c	20 May 2007 17:23:34 -0000	1.37.2.10
@@ -88,7 +88,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)
@@ -127,9 +129,13 @@
 	       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));
-	  DEBUG(0, ("configuration file is: %s\n", config_file));
+	 #endif
+	  DEBUG(3, ("configuration file is: %s\n", config_file));
 	  retval = pm_process(config_file, do_section, do_parameter);
 
 	  /* FIXME: this is lame! */
@@ -151,7 +157,9 @@
         /* initialise file regexp */
         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);
@@ -159,7 +167,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)
@@ -171,7 +181,9 @@
         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);
@@ -179,7 +191,9 @@
 }
 
 
-#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)
@@ -194,7 +208,11 @@
 	int rc;
 
 	/* Assemble complete file path */
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+	pstrcpy(filepath, handle->conn->connectpath);
+#else
 	pstrcpy(filepath, conn->connectpath);
+#endif
 	pstrcat(filepath, "/");
 	pstrcat(filepath, fname);
 
@@ -204,14 +222,19 @@
         if ( !vscan_config.common.scan_on_open ) {
 		/* we should use vscan_syslog instead of DEBUG here ... */
                 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)
+		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);
 #endif				
         }
 
-#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 */ 
+		return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
         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
@@ -219,7 +242,9 @@
 		return default_vfs_ops.open(conn, fname, flags, mode);
 #endif
 	else if ( S_ISDIR(stat_buf.st_mode) ) 	/* is it a directory? */
-#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);
@@ -227,7 +252,9 @@
 	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 */
-#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);
@@ -239,7 +266,9 @@
 	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);
-#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);
@@ -257,7 +286,11 @@
                 } else if ( sockfd >= 0 ) {
 			               
 			/* get client IP */
-			safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1);
+			#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);
@@ -282,7 +315,9 @@
 				vscan_oav_end(sockfd);
 				
 				/* grant access */
-#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);
@@ -319,8 +354,10 @@
 				/* close socket */
 				vscan_oav_end(sockfd);
 				/* do action ... */
+#if (SMB_VFS_INTERFACE_VERSION >= 21)
+				rc = 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);
 				
-#if (SMB_VFS_INTERFACE_VERSION >= 6)
+#elif (SMB_VFS_INTERFACE_VERSION >= 6)
 				rc = 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
 				rc = 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);
@@ -342,7 +379,9 @@
 		vscan_oav_end(sockfd);
 
 	}
-#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);


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