samba-vscan/global vscan-filetype.c,1.3.2.9,1.3.2.10 vscan-parameter.c,1.1.2.1,1.1.2.2

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

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


Index: vscan-filetype.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/global/vscan-filetype.c,v
retrieving revision 1.3.2.9
retrieving revision 1.3.2.10
diff -u -d -r1.3.2.9 -r1.3.2.10
--- vscan-filetype.c	24 Sep 2004 21:42:20 -0000	1.3.2.9
+++ vscan-filetype.c	26 Sep 2004 16:20:18 -0000	1.3.2.10
@@ -34,7 +34,8 @@
 
 /** 
  * initialise libmagic and load magic
- * @params flags	flags for libmagic, see man libmagic
+ * @param flags		flags for libmagic, see man libmagic
+ * @param exclude_list  list of file types to exclude
  *
 */
 

Index: vscan-parameter.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/global/Attic/vscan-parameter.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- vscan-parameter.c	2 May 2004 19:45:31 -0000	1.1.2.1
+++ vscan-parameter.c	26 Sep 2004 16:20:18 -0000	1.1.2.2
@@ -17,6 +17,136 @@
 
 #include "vscan-global.h"
 
+/**
+ * set default values for common parameters
+ *
+ * @param vscan_config	structure containing common parameters
+ *
+*/
+
+
+void set_common_default_settings(vscan_config_struct *vscan_config)
+{
+	DEBUG(0, ("set_common_default_settings\n"));
+
+        /* set default value for max file size */
+        vscan_config->common.max_size = VSCAN_MAX_SIZE;
+	DEBUG(0, ("default max size: %d\n", vscan_config->common.max_size));
+
+        /* set default value for file logging */
+        vscan_config->common.verbose_file_logging = VSCAN_VERBOSE_FILE_LOGGING;
+	DEBUG(0, ("default verbose logging: %d\n", vscan_config->common.verbose_file_logging));
+
+        /* set default value for scan on open() */
+        vscan_config->common.scan_on_open = VSCAN_SCAN_ON_OPEN;
+	DEBUG(0, ("default scan on open: %d\n", vscan_config->common.scan_on_open));
+
+        /* set default value for scan on close() */
+        vscan_config->common.scan_on_close = VSCAN_SCAN_ON_CLOSE;
+	DEBUG(0, ("default value for scan on close: %d\n", vscan_config->common.scan_on_close));
+
+        /* set default value for deny access on error */
+        vscan_config->common.deny_access_on_error = VSCAN_DENY_ACCESS_ON_ERROR;
+	DEBUG(0, ("default value for deny access on error: %d\n", vscan_config->common.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;
+	DEBUG(0, ("default value for deny access on minor error: %d\n", vscan_config->common.deny_access_on_minor_error)); 
+
+        /* set default value for send warning message */
+        vscan_config->common.send_warning_message = VSCAN_SEND_WARNING_MESSAGE;
+	DEBUG(0, ("default value send warning message: %d\n", vscan_config->common.send_warning_message));
+
+        /* set default value for infected file action */
+        vscan_config->common.infected_file_action = VSCAN_INFECTED_FILE_ACTION;
+	DEBUG(0, ("default value infected file action: %d\n", vscan_config->common.infected_file_action));
+
+        /* set default value for quarantine directory */
+        fstrcpy(vscan_config->common.quarantine_dir, VSCAN_QUARANTINE_DIRECTORY);
+	DEBUG(0, ("default value quarantine directory: %s\n", vscan_config->common.quarantine_dir));
+
+        /* set default value for quarantine prefix */
+        fstrcpy(vscan_config->common.quarantine_prefix, VSCAN_QUARANTINE_PREFIX);
+
+        /* 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);
+
+}
+
+/** 
+ * get name of configuration file
+ *
+ * @param conn		pointer to connection
+ * @param module_name	name of samba-vscan module
+ * @param paramconf	name of default configuration file
+ * @return The correct configuration file
+ *
+*/
+/* FIXME: should we use const here? Should we use **conn instead? */
+
+#if (SMB_VFS_INTERFACE_VERSION >= 6)
+const char* get_configuration_file(connection_struct *conn, fstring module_name)
+#else
+const char* get_configuration_file(struct connection_struct *conn, fstring module_name)
+#endif
+{
+	static fstring config_file;
+
+        #if (SAMBA_VERSION_MAJOR==2 && SAMBA_VERSION_RELEASE>=4) || SAMBA_VERSION_MAJOR==3
+         #if !(SMB_VFS_INTERFACE_VERSION >= 6)
+          pstring opts_str;
+          PROTOTYPE_CONST char *p;
+         #endif
+        #endif
+
+         #if (SMB_VFS_INTERFACE_VERSION >= 6)
+          fstrcpy(config_file, lp_parm_const_string(SNUM(conn),module_name,"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)*/
+	return config_file;
+}
+
+
+
+/**
+ * parsing common parameters and values from config file
+ *
+ * @param vscan_config	containing common parameters
+ * @param param		the parameter
+ * @param value		the value
+ *
+*/
+
 BOOL do_common_parameter(vscan_config_struct *vscan_config, const char *param, const char *value)
 {
 	/* we assume we handled a common parameter */



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