samba-vscan/openantivirus vscan-oav.c,1.37.2.5,1.37.2.6

Rainer Link <[email protected]> Sun, 26 Sep 2004 16:20:21 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/openantivirus
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23231/openantivirus

Modified Files:
      Tag: VSCAN_0_3
	vscan-oav.c 
Log Message:
some more code re-org; move parsing of configuration to a dedicated
module


Index: vscan-oav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/openantivirus/vscan-oav.c,v
retrieving revision 1.37.2.5
retrieving revision 1.37.2.6
diff -u -d -r1.37.2.5 -r1.37.2.6
--- vscan-oav.c	25 Sep 2004 12:27:07 -0000	1.37.2.5
+++ vscan-oav.c	26 Sep 2004 16:20:19 -0000	1.37.2.6
@@ -43,10 +43,6 @@
 
 #define VSCAN_MODULE_STR "vscan-oav"
 
-fstring config_file;            /* location of config file, either
-                                   PARAMCONF or as set via vfs options
-                                */
-
 vscan_config_struct vscan_config; /* contains the vscan module configuration */
 
 BOOL verbose_file_logging;
@@ -98,6 +94,10 @@
 static int vscan_connect(struct connection_struct *conn, PROTOTYPE_CONST char *svc, PROTOTYPE_CONST char *user)
 #endif
 {
+	fstring config_file;            /* location of config file, either
+        	                           PARAMCONF or as set via vfs options
+                	                */
+
 	#if (SAMBA_VERSION_MAJOR==2 && SAMBA_VERSION_RELEASE>=4) || SAMBA_VERSION_MAJOR==3
 	 #if !(SMB_VFS_INTERFACE_VERSION >= 6)
           pstring opts_str;
@@ -113,37 +113,9 @@
         /* set default value for configuration files */
         fstrcpy(config_file, PARAMCONF);
 
-        /* set default value for max file size */
-        vscan_config.common.max_size = VSCAN_MAX_SIZE;
-
-        /* set default value for file logging */
-        vscan_config.common.verbose_file_logging = VSCAN_VERBOSE_FILE_LOGGING;
-	verbose_file_logging = VSCAN_VERBOSE_FILE_LOGGING;
-
-        /* set default value for scan on open() */
-        vscan_config.common.scan_on_open = VSCAN_SCAN_ON_OPEN;
-
-        /* set default value for scan on close() */
-        vscan_config.common.scan_on_close = VSCAN_SCAN_ON_CLOSE;
-
-        /* set default value for deny access on error */
-        vscan_config.common.deny_access_on_error = VSCAN_DENY_ACCESS_ON_ERROR;
-
-	/* set default value for deny access on minor error */
-	vscan_config.common.deny_access_on_minor_error = VSCAN_DENY_ACCESS_ON_MINOR_ERROR;
- 
-	/* set default value for send warning message */
-	vscan_config.common.send_warning_message = VSCAN_SEND_WARNING_MESSAGE;
-        send_warning_message = VSCAN_SEND_WARNING_MESSAGE;
-
-        /* set default value for infected file action */
-        vscan_config.common.infected_file_action = VSCAN_INFECTED_FILE_ACTION;
-
-        /* set default value for quarantine directory */
-        fstrcpy(vscan_config.common.quarantine_dir, VSCAN_QUARANTINE_DIRECTORY);
-
-        /* set default value for quarantine prefix */
-        fstrcpy(vscan_config.common.quarantine_prefix, VSCAN_QUARANTINE_PREFIX);
+	/* set default values */
+	set_common_default_settings(&vscan_config);
+	DEBUG(0, ("max size: %d\n", vscan_config.common.max_size));
 
         /* set default value for OAV ScannerDaemon IP */
         fstrcpy(oav_ip, VSCAN_OAV_IP);
@@ -151,48 +123,14 @@
         /* set default value for OAV ScannerDaemon port */
         oav_port = VSCAN_OAV_PORT;
 
-        /* set default value for maximum lrufile entries */
-        vscan_config.common.max_lrufiles = VSCAN_MAX_LRUFILES;
-
-        /* time after an entry is considered as expired */
-        vscan_config.common.lrufiles_invalidate_time = VSCAN_LRUFILES_INVALIDATE_TIME;
-
-	/* file type exclude ist */
-	pstrcpy(vscan_config.common.exclude_file_types, VSCAN_FT_EXCLUDE_LIST);	
-
 	vscan_syslog("INFO: connect to service %s by user %s", 
 	       svc, user);
 
 	#if (SAMBA_VERSION_MAJOR==2 && SAMBA_VERSION_RELEASE>=4) || SAMBA_VERSION_MAJOR==3
-	 #if (SMB_VFS_INTERFACE_VERSION >= 6)
-	  fstrcpy(config_file, lp_parm_const_string(SNUM(conn),VSCAN_MODULE_STR,"config-file",PARAMCONF));
-	 #else
-          pstrcpy(opts_str, (const char*) lp_vfs_options(SNUM(conn)));
-          if( !*opts_str ) {
-                DEBUG(3, ("samba-vscan: no configuration file set - using default value (%s).\n", lp_vfs_options(SNUM(conn))));
-          } else {
-                p = opts_str;
-                if ( next_token(&p, config_file, "=", sizeof(config_file)) ) {
-                        trim_string(config_file, " ", " ");
-                        if ( !strequal("config-file", config_file) ) {
-                                DEBUG(3, ("samba-vscan - connect: options %s is not config-file\n", config_file));
-                                /* setting default value */
-                                fstrcpy(config_file, PARAMCONF);
-
-                        } else {
-                                if ( !next_token(&p, config_file," \n",sizeof(config_file)) ) {
-                                        DEBUG(3, ("samba-vscan - connect: no option after config-file=\n"));
-                                        /* setting default value */
-                                        fstrcpy(config_file, PARAMCONF);
-                                } else {
-                                        trim_string(config_file, " ", " ");
-                                        DEBUG(3, ("samba-vscan - connect: config file name is %s\n", config_file));
-                                }
-                        }
-                }
-          }
-	  #endif /*  #if (SMB_VFS_INTERFACE_VERSION >= 6)*/
-          retval = pm_process(config_file, do_section, do_parameter);
+          
+	  fstrcpy(config_file, get_configuration_file(conn, VSCAN_MODULE_STR));
+	  DEBUG(0, ("configuration file is: %s\n", config_file));
+	  retval = pm_process(config_file, do_section, do_parameter);
 
 	  /* FIXME: this is lame! */
 	  verbose_file_logging = vscan_config.common.verbose_file_logging;
@@ -348,7 +286,7 @@
 
 			/* scan file */
 			retval = vscan_oav_scanfile(sockfd, filepath, client_ip);
-			if ( retval == VSCAN_SCAN_MINOR_ERORR && vscan_config.common.deny_access_on_minor_error ) {
+			if ( retval == VSCAN_SCAN_MINOR_ERROR && vscan_config.common.deny_access_on_minor_error ) {
 				/* a minor error occured - deny access */
 				vscan_syslog("ERROR: daemon failed with a minor error - access to file %s denied", fname);
 				vscan_oav_end(sockfd);



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