X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=loadcfg.c;h=334f07f860cc0a620c400c0854f0bfe0401cc45e;hb=71e1ccf869288acf3d482f1931ea747aaea3f255;hp=260f921460dc426cc844555c04e9dde5d9db83a8;hpb=eb7d670180a9e22a4a1581c5b29825a5ece9d18f;p=privoxy.git diff --git a/loadcfg.c b/loadcfg.c index 260f9214..334f07f8 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.64 2007/05/21 10:44:08 fabiankeil Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.68 2007/10/19 16:32:34 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,22 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.64 2007/05/21 10:44:08 fabiankeil * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.68 2007/10/19 16:32:34 fabiankeil + * Plug memory leak introduced with my last commit. + * + * Revision 1.67 2007/10/14 14:12:41 fabiankeil + * When in daemon mode, close stderr after the configuration file has been + * parsed the first time. If logfile isn't set, stop logging. Fixes BR#897436. + * + * Revision 1.66 2007/08/05 14:02:09 fabiankeil + * #1763173 from Stefan Huehner: declare unload_configfile() static. + * + * Revision 1.65 2007/07/21 11:51:36 fabiankeil + * As Hal noticed, checking dispatch_cgi() as the last cruncher + * looks like a bug if CGI requests are blocked unintentionally, + * so don't do it unless the user enabled the new config option + * "allow-cgi-request-crunching". + * * Revision 1.64 2007/05/21 10:44:08 fabiankeil * - Use strlcpy() instead of strcpy(). * - Stop treating actions files special. Expect a complete file name @@ -549,7 +565,7 @@ static void savearg(char *command, char *argument, struct configuration_spec * c * Returns : N/A * *********************************************************************/ -void unload_configfile (void * data) +static void unload_configfile (void * data) { struct configuration_spec * config = (struct configuration_spec *)data; struct forward_spec *cur_fwd = config->forward; @@ -655,6 +671,9 @@ void unload_current_config_file(void) * * Description : Load the config file and all parameters. * + * XXX: more than thousand lines long + * and thus in serious need of refactoring. + * * Parameters : None * * Returns : The configuration_spec, or NULL on error. @@ -670,6 +689,7 @@ struct configuration_spec * load_config(void) struct file_list *fs; unsigned long linenum = 0; int i; + char *logfile = NULL; if ( !check_file_changed(current_configfile, configfile, &fs)) { @@ -1285,8 +1305,14 @@ struct configuration_spec * load_config(void) * In logdir by default * *************************************************************************/ case hash_logfile : - freez(config->logfile); - config->logfile = no_daemon ? NULL : make_path(config->logdir, arg); + if (!no_daemon) + { + logfile = make_path(config->logdir, arg); + if (NULL == logfile) + { + log_error(LOG_LEVEL_FATAL, "Out of memory while creating logfile path"); + } + } continue; /* ************************************************************************* @@ -1587,13 +1613,28 @@ struct configuration_spec * load_config(void) fclose(configfp); + set_debug_level(config->debug); + + freez(config->logfile); + + if (!no_daemon) + { + if (NULL != logfile) + { + config->logfile = logfile; + init_error_log(Argv[0], config->logfile); + } + else + { + disable_logging(); + } + } + if (NULL == config->proxy_args) { log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args"); } - init_error_log(Argv[0], config->logfile, config->debug); - if (config->actions_file[0]) { add_loader(load_actions_file, config);