samba-vscan/trend vscan-trend.c,1.47.2.4,1.47.2.5
Rainer Link <[email protected]> Tue, 28 Sep 2004 18:14:31 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/samba-vscan/trend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7720/trend
Modified Files:
Tag: VSCAN_0_3
vscan-trend.c
Log Message:
updated to use the new global configuration parsing module
Index: vscan-trend.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/trend/vscan-trend.c,v
retrieving revision 1.47.2.4
retrieving revision 1.47.2.5
diff -u -d -r1.47.2.4 -r1.47.2.5
--- vscan-trend.c 28 Sep 2004 15:54:37 -0000 1.47.2.4
+++ vscan-trend.c 28 Sep 2004 18:14:29 -0000 1.47.2.5
@@ -50,6 +50,8 @@
BOOL verbose_file_logging; /* log ever file access */
BOOL send_warning_message; /* send a warning message using the windows
messenger service? */
+fstring trophie_socket_name; /* name of Trophie socket */
+
/* module version */
static const char module_id[]=VSCAN_MODULE_STR" "SAMBA_VSCAN_VERSION_STR;
@@ -64,7 +66,6 @@
DEBUG(3, ("trophie socket name is %s\n", trophie_socket_name));
} else
DEBUG(3, ("unknown parameter: %s\n", param));
- }
}
return True;
@@ -87,6 +88,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;
@@ -102,96 +107,37 @@
/* set default value for configuration files */
fstrcpy(config_file, PARAMCONF);
- /* set default value for max file size */
- max_size = VSCAN_MAX_SIZE;
-
- /* set default value for file logging */
- verbose_file_logging = VSCAN_VERBOSE_FILE_LOGGING;
-
- /* set default value for scan on open() */
- scan_on_open = VSCAN_SCAN_ON_OPEN;
-
- /* set default value for scan on close() */
- scan_on_close = VSCAN_SCAN_ON_CLOSE;
-
- /* set default value for deny access on error */
- deny_access_on_error = VSCAN_DENY_ACCESS_ON_ERROR;
-
- /* set default value for deny access on minor error */
- deny_access_on_minor_error = VSCAN_DENY_ACCESS_ON_MINOR_ERROR;
-
- /* set default value for send warning message */
- send_warning_message = VSCAN_SEND_WARNING_MESSAGE;
-
- /* set default value for infected file action */
- infected_file_action = VSCAN_INFECTED_FILE_ACTION;
-
- /* set default value for quarantine directory */
- fstrcpy(quarantine_dir, VSCAN_QUARANTINE_DIRECTORY);
-
- /* set default value for quarantine prefix */
- fstrcpy(quarantine_prefix, VSCAN_QUARANTINE_PREFIX);
+ /* set default values */
+ set_common_default_settings(&vscan_config);
/* name of Trophie socket */
fstrcpy(trophie_socket_name, TROPHIE_SOCKET_NAME);
- /* set default value for maximum lrufile entries */
- max_lrufiles = VSCAN_MAX_LRUFILES;
-
- /* time after an entry is considered as expired */
- lrufiles_invalidate_time = VSCAN_LRUFILES_INVALIDATE_TIME;
-
- /* file type exclude ist */
- pstrcpy(exclude_file_types, VSCAN_FT_EXCLUDE_LIST);
-
vscan_syslog("INFO: connect to service %s by user %s",
svc, user);
- /* FIXME: what's this statement for??? */
- vscan_trend_init();
-
-
#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)*/
+ fstrcpy(config_file, get_configuration_file(conn, VSCAN_MODULE_STR, PARAMCONF));
+ DEBUG(0, ("configuration file is: %s\n", config_file));
+
retval = pm_process(config_file, do_section, do_parameter);
DEBUG(10, ("pm_process returned %d\n", retval));
+
+ /* FIXME: this is lame! */
+ verbose_file_logging = vscan_config.common.verbose_file_logging;
+ send_warning_message = vscan_config.common.send_warning_message;
+
if (!retval) vscan_syslog("ERROR: could not parse configuration file '%s'. File not found or not read-able. Using compiled-in defaults", config_file);
#endif
/* initialise lrufiles list */
DEBUG(5, ("init lrufiles list\n"));
- lrufiles_init(max_lrufiles, lrufiles_invalidate_time);
+ lrufiles_init(vscan_config.common.max_lrufiles, vscan_config.common.lrufiles_invalidate_time);
/* initialise filetype */
DEBUG(5, ("init file type\n"));
- filetype_init(0, exclude_file_types);
+ filetype_init(0, vscan_config.common.exclude_file_types);
@@ -245,7 +191,7 @@
/* scan files while opening? */
- if ( !scan_on_open ) {
+ 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)
return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
@@ -267,7 +213,7 @@
#else
return default_vfs_ops.open(conn, fname, flags, mode);
#endif
- else if ( ( stat_buf.st_size > max_size ) && ( max_size > 0 ) ) /* file is too large */
+ 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)
@@ -288,7 +234,7 @@
/* open socket */
sockfd = vscan_trend_init();
- if ( sockfd == -1 && deny_access_on_error ) {
+ if ( sockfd == -1 && vscan_config.common.deny_access_on_error ) {
/* an error occured - can not communicate to daemon - deny access */
vscan_syslog("ERROR: can not communicate to daemon - access denied");
errno = EACCES;
@@ -303,7 +249,7 @@
if ( must_be_checked == VSCAN_LRU_DENY_ACCESS ) {
/* file has already been checked and marked as infected */
/* deny access */
- if ( verbose_file_logging )
+ if ( vscan_config.common.verbose_file_logging )
vscan_syslog("File '%s' has already been scanned and marked as infected. Not scanned any more. Access denied", filepath);
/* close socket */
@@ -314,7 +260,7 @@
return -1;
} else if ( must_be_checked == VSCAN_LRU_GRANT_ACCESS ) {
/* file has already been checked, not marked as infected and not modified */
- if ( verbose_file_logging )
+ if ( vscan_config.common.verbose_file_logging )
vscan_syslog("File '%s' has already been scanned, not marked as infected and not modified. Not scanned anymore. Access granted", filepath);
/* close socket */
@@ -331,7 +277,7 @@
/* scan file */
retval = vscan_trend_scanfile(sockfd, filepath, client_ip);
- if ( retval == VSCAN_SCAN_MINOR_ERROR && 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_trend_end(sockfd);
@@ -342,7 +288,7 @@
/* deny access */
errno = EACCES;
return -1;
- } else if ( retval == VSCAN_SCAN_ERROR && deny_access_on_error ) {
+ } else if ( retval == VSCAN_SCAN_ERROR && vscan_config.common.deny_access_on_error ) {
/* an error occured - can not communicate to daemon - deny access */
vscan_syslog("ERROR: can not communicate to daemon - access to file %s denied", fname);
vscan_trend_end(sockfd);
@@ -361,9 +307,9 @@
/* do action ... */
#if (SMB_VFS_INTERFACE_VERSION >= 6)
- rc = vscan_do_infected_file_action(handle, conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
+ 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, quarantine_dir, quarantine_prefix, infected_file_action);
+ rc = vscan_do_infected_file_action(&default_vfs_ops, conn, filepath, vscan_config.comoon.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
#endif
/* add/update file. mark file as infected! */
@@ -407,7 +353,7 @@
retval = default_vfs_ops.close(fsp, fd);
#endif
- if ( !scan_on_close ) {
+ if ( !vscan_config.common.scan_on_close ) {
DEBUG(3, ("samba-vscan - close: File '%s' not scanned as scan_on_close is not set\n", fsp->fsp_name));
return retval;
}
@@ -424,7 +370,7 @@
if ( !fsp->modified ) {
- if ( verbose_file_logging )
+ if ( vscan_config.common.verbose_file_logging )
vscan_syslog("INFO: file %s was not modified - not scanned", filepath);
return retval;
@@ -432,7 +378,7 @@
/* don't scan files which are in the list of exclude file types */
if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
- if ( verbose_file_logging )
+ if ( vscan_config.common.verbose_file_logging )
vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);
return retval;
}
@@ -449,9 +395,9 @@
if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
/* virus was found */
#if (SMB_VFS_INTERFACE_VERSION >= 6)
- rc = vscan_do_infected_file_action(handle, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
+ rc = vscan_do_infected_file_action(handle, fsp->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, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
+ rc = vscan_do_infected_file_action(&default_vfs_ops, fsp->conn, filepath, vscan_config.common.quarantine_dir, vscan_config.common.quarantine_prefix, vscan_config.common.infected_file_action);
#endif
}
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl