X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=loadcfg.c;h=1e6dc57d38defb004e8b0caff2ff02c7cac07734;hp=39c556668ab7df05daf5d0c7f4e0f191165b14d6;hb=3b1aa5679211bfdff57aa46cad375ed988ed385a;hpb=2a7b6004587d0b734ab12d87f9f7805e7329a6e9 diff --git a/loadcfg.c b/loadcfg.c index 39c55666..1e6dc57d 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,4 +1,4 @@ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.65 2007/07/21 11:51:36 fabiankeil Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.67 2007/10/14 14:12:41 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -35,6 +35,13 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.65 2007/07/21 11:51:36 fabiankeil * * Revisions : * $Log: loadcfg.c,v $ + * 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, @@ -661,6 +668,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. @@ -676,6 +686,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)) { @@ -1291,8 +1302,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; /* ************************************************************************* @@ -1593,13 +1610,31 @@ 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; + log_error(LOG_LEVEL_INFO, + "Switching to daemon mode. Log messages will be written to: %s", config->logfile); + init_error_log(Argv[0], config->logfile); + } + else + { + log_error(LOG_LEVEL_INFO, "No logfile configured while in daemon mode. Logging disabled."); + 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);