1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.56 2006/12/17 17:04:51 fabiankeil Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
6 * Purpose : Loads settings from the configuration file into
7 * global variables. This file contains both the
8 * routine to load the configuration and the global
9 * variables it writes to.
11 * Copyright : Written by and Copyright (C) 2001 the SourceForge
12 * Privoxy team. http://www.privoxy.org/
14 * Based on the Internet Junkbuster originally written
15 * by and Copyright (C) 1997 Anonymous Coders and
16 * Junkbusters Corporation. http://www.junkbusters.com
18 * This program is free software; you can redistribute it
19 * and/or modify it under the terms of the GNU General
20 * Public License as published by the Free Software
21 * Foundation; either version 2 of the License, or (at
22 * your option) any later version.
24 * This program is distributed in the hope that it will
25 * be useful, but WITHOUT ANY WARRANTY; without even the
26 * implied warranty of MERCHANTABILITY or FITNESS FOR A
27 * PARTICULAR PURPOSE. See the GNU General Public
28 * License for more details.
30 * The GNU General Public License should be included with
31 * this file. If not, you can view it at
32 * http://www.gnu.org/copyleft/gpl.html
33 * or write to the Free Software Foundation, Inc., 59
34 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 * Revision 1.56 2006/12/17 17:04:51 fabiankeil
39 * Move the <br> in the generated HTML for the config
40 * options from the beginning of the string to its end.
41 * Keeps the white space in balance.
43 * Revision 1.55 2006/11/28 15:31:52 fabiankeil
44 * Fix memory leak in case of config file reloads.
46 * Revision 1.54 2006/10/21 16:04:22 fabiankeil
47 * Modified kludge for win32 to make ming32 menu
48 * "Options/Edit Filters" (sort of) work again.
49 * Same limitations as for the action files apply.
52 * Revision 1.53 2006/09/06 18:45:03 fabiankeil
53 * Incorporate modified version of Roland Rosenfeld's patch to
54 * optionally access the user-manual via Privoxy. Closes patch 679075.
56 * Formatting changed to Privoxy style, added call to
57 * cgi_error_no_template if the requested file doesn't
58 * exist and modified check whether or not Privoxy itself
59 * should serve the manual. Should work cross-platform now.
61 * Revision 1.52 2006/09/06 10:43:32 fabiankeil
62 * Added config option enable-remote-http-toggle
63 * to specify if Privoxy should recognize special
64 * headers (currently only X-Filter) to change its
65 * behaviour. Disabled by default.
67 * Revision 1.51 2006/09/06 09:23:37 fabiankeil
68 * Make number of retries in case of forwarded-connect problems
69 * a config file option (forwarded-connect-retries) and use 0 as
72 * Revision 1.50 2006/07/18 14:48:46 david__schmidt
73 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
74 * with what was really the latest development (the v_3_0_branch branch)
76 * Revision 1.48.2.7 2006/02/02 17:29:16 david__schmidt
77 * Don't forget to malloc space for the null terminator...
79 * Revision 1.48.2.6 2006/01/29 23:10:56 david__schmidt
80 * Multiple filter file support
82 * Revision 1.48.2.5 2003/05/08 15:17:25 oes
83 * Closed two memory leaks; hopefully the last remaining ones
84 * (in the main execution paths, anyway).
86 * Revision 1.48.2.4 2003/04/11 12:06:14 oes
87 * Addressed bug #719435
88 * - Extraneous filterfile directives now logged as errors
89 * - This and unrecnonised directives now really obvious on status page
91 * Revision 1.48.2.3 2003/03/11 11:53:59 oes
92 * Cosmetic: Renamed cryptic variable
94 * Revision 1.48.2.2 2002/11/12 16:28:20 oes
95 * Move unrelated variable declaration out of #ifdef FEATURE_ACL; fixes bug #636655
97 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
98 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
100 * Revision 1.48 2002/05/14 21:30:38 oes
101 * savearg now uses own linking code instead of (now special-cased) add_help_link
103 * Revision 1.47 2002/05/12 21:36:29 jongfoster
104 * Correcting function comments
106 * Revision 1.46 2002/04/26 12:55:14 oes
107 * - New option "user-manual", defaults to our site
108 * via project.h #define
109 * - savearg now embeds option names in help links
111 * Revision 1.45 2002/04/24 02:11:54 oes
112 * Jon's multiple AF patch: Allow up to MAX_AF_FILES actionsfile options
114 * Revision 1.44 2002/04/08 20:37:13 swa
117 * Revision 1.43 2002/04/08 20:36:50 swa
120 * Revision 1.42 2002/04/05 15:50:15 oes
121 * fix for invalid HTML proxy_args
123 * Revision 1.41 2002/03/31 17:19:00 jongfoster
124 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
126 * Revision 1.40 2002/03/26 22:29:55 swa
127 * we have a new homepage!
129 * Revision 1.39 2002/03/24 13:25:43 swa
130 * name change related issues
132 * Revision 1.38 2002/03/24 13:05:48 jongfoster
133 * Renaming re_filterfile to filterfile
135 * Revision 1.37 2002/03/16 23:54:06 jongfoster
136 * Adding graceful termination feature, to help look for memory leaks.
137 * If you enable this (which, by design, has to be done by hand
138 * editing config.h) and then go to http://i.j.b/die, then the program
139 * will exit cleanly after the *next* request. It should free all the
140 * memory that was used.
142 * Revision 1.36 2002/03/13 00:27:05 jongfoster
145 * Revision 1.35 2002/03/07 03:52:44 oes
146 * Set logging to tty for --no-daemon mode
148 * Revision 1.34 2002/03/06 23:14:35 jongfoster
149 * Trivial cosmetic changes to make function comments easier to find.
151 * Revision 1.33 2002/03/05 04:52:42 oes
152 * Deleted non-errlog debugging code
154 * Revision 1.32 2002/03/04 18:24:53 oes
155 * Re-enabled output of unknown config directive hash
157 * Revision 1.31 2002/03/03 15:07:20 oes
158 * Re-enabled automatic config reloading
160 * Revision 1.30 2002/01/22 23:31:43 jongfoster
161 * Replacing strsav() with string_append()
163 * Revision 1.29 2002/01/17 21:02:30 jongfoster
164 * Moving all our URL and URL pattern parsing code to urlmatch.c.
166 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
168 * Revision 1.28 2001/12/30 14:07:32 steudten
169 * - Add signal handling (unix)
170 * - Add SIGHUP handler (unix)
171 * - Add creation of pidfile (unix)
172 * - Add action 'top' in rc file (RH)
173 * - Add entry 'SIGNALS' to manpage
174 * - Add exit message to logfile (unix)
176 * Revision 1.27 2001/11/07 00:02:13 steudten
177 * Add line number in error output for lineparsing for
178 * actionsfile and configfile.
179 * Special handling for CLF added.
181 * Revision 1.26 2001/11/05 21:41:43 steudten
182 * Add changes to be a real daemon just for unix os.
183 * (change cwd to /, detach from controlling tty, set
184 * process group and session leader to the own process.
186 * Add some fatal-error log message for failed malloc().
187 * Add '-d' if compiled with 'configure --with-debug' to
188 * enable debug output.
190 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
191 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
192 * threads to call select() simultaneously. So, it's time to do a real, live,
193 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
194 * (native). Both versions will work, but using __OS2__ offers multi-threading.
196 * Revision 1.24 2001/10/23 21:40:30 jongfoster
197 * Added support for enable-edit-actions and enable-remote-toggle config
200 * Revision 1.23 2001/10/07 15:36:00 oes
201 * Introduced new config option "buffer-limit"
203 * Revision 1.22 2001/09/22 16:36:59 jongfoster
204 * Removing unused parameter fs from read_config_line()
206 * Revision 1.21 2001/09/16 17:10:43 jongfoster
207 * Moving function savearg() here, since it was the only thing left in
210 * Revision 1.20 2001/07/30 22:08:36 jongfoster
211 * Tidying up #defines:
212 * - All feature #defines are now of the form FEATURE_xxx
213 * - Permanently turned off WIN_GUI_EDIT
214 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
216 * Revision 1.19 2001/07/15 17:45:16 jongfoster
217 * Removing some unused #includes
219 * Revision 1.18 2001/07/13 14:01:14 oes
220 * - Removed all #ifdef PCRS
221 * - Removed vim-settings
223 * Revision 1.17 2001/06/29 13:31:03 oes
224 * - Improved comments
225 * - Fixed (actionsfile) and sorted hashes
226 * - Introduced admin_address and proxy-info-url
227 * as config parameters
228 * - Renamed config->proxy_args_invocation (which didn't have
229 * the invocation but the options!) to config->proxy_args
230 * - Various adaptions
231 * - Removed logentry from cancelled commit
233 * Revision 1.16 2001/06/09 10:55:28 jongfoster
234 * Changing BUFSIZ ==> BUFFER_SIZE
236 * Revision 1.15 2001/06/07 23:13:40 jongfoster
237 * Merging ACL and forward files into config file.
238 * Cosmetic: Sorting config file options alphabetically.
239 * Cosmetic: Adding brief syntax comments to config file options.
241 * Revision 1.14 2001/06/07 14:46:25 joergs
242 * Missing make_path() added for re_filterfile.
244 * Revision 1.13 2001/06/05 22:33:54 jongfoster
246 * Fixed minor memory leak.
247 * Also now uses make_path to prepend the pathnames.
249 * Revision 1.12 2001/06/05 20:04:09 jongfoster
250 * Now uses _snprintf() in place of snprintf() under Win32.
252 * Revision 1.11 2001/06/04 18:31:58 swa
253 * files are now prefixed with either `confdir' or `logdir'.
254 * `make redhat-dist' replaces both entries confdir and logdir
257 * Revision 1.10 2001/06/03 19:11:54 oes
258 * introduced confdir option
260 * Revision 1.9 2001/06/01 20:06:24 jongfoster
261 * Removed support for "tinygif" option - moved to actions file.
263 * Revision 1.8 2001/05/31 21:27:13 jongfoster
264 * Removed many options from the config file and into the
265 * "actions" file: add_forwarded, suppress_vanilla_wafer,
266 * wafer, add_header, user_agent, referer, from
267 * Also globally replaced "permission" with "action".
269 * Revision 1.7 2001/05/29 09:50:24 jongfoster
270 * Unified blocklist/imagelist/permissionslist.
271 * File format is still under discussion, but the internal changes
274 * Also modified interceptor behaviour:
275 * - We now intercept all URLs beginning with one of the following
276 * prefixes (and *only* these prefixes):
278 * * http://ijbswa.sf.net/config/
279 * * http://ijbswa.sourceforge.net/config/
280 * - New interceptors "home page" - go to http://i.j.b/ to see it.
281 * - Internal changes so that intercepted and fast redirect pages
282 * are not replaced with an image.
283 * - Interceptors now have the option to send a binary page direct
284 * to the client. (i.e. ijb-send-banner uses this)
285 * - Implemented show-url-info interceptor. (Which is why I needed
286 * the above interceptors changes - a typical URL is
287 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
288 * The previous mechanism would not have intercepted that, and
289 * if it had been intercepted then it then it would have replaced
292 * Revision 1.6 2001/05/26 00:28:36 jongfoster
293 * Automatic reloading of config file.
294 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
295 * Most of the global variables have been moved to a new
296 * struct configuration_spec, accessed through csp->config->globalname
297 * Most of the globals remaining are used by the Win32 GUI.
299 * Revision 1.5 2001/05/25 22:34:30 jongfoster
302 * Revision 1.4 2001/05/22 18:46:04 oes
304 * - Enabled filtering banners by size rather than URL
305 * by adding patterns that replace all standard banner
306 * sizes with the "Junkbuster" gif to the re_filterfile
308 * - Enabled filtering WebBugs by providing a pattern
309 * which kills all 1x1 images
311 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
312 * which is selected by the (nonstandard and therefore
313 * capital) letter 'U' in the option string.
314 * It causes the quantifiers to be ungreedy by default.
315 * Appending a ? turns back to greedy (!).
317 * - Added a new interceptor ijb-send-banner, which
318 * sends back the "Junkbuster" gif. Without imagelist or
319 * MSIE detection support, or if tinygif = 1, or the
320 * URL isn't recognized as an imageurl, a lame HTML
321 * explanation is sent instead.
323 * - Added new feature, which permits blocking remote
324 * script redirects and firing back a local redirect
326 * The feature is conditionally compiled, i.e. it
327 * can be disabled with --disable-fast-redirects,
328 * plus it must be activated by a "fast-redirects"
329 * line in the config file, has its own log level
330 * and of course wants to be displayed by show-proxy-args
331 * Note: Boy, all the #ifdefs in 1001 locations and
332 * all the fumbling with configure.in and acconfig.h
333 * were *way* more work than the feature itself :-(
335 * - Because a generic redirect template was needed for
336 * this, tinygif = 3 now uses the same.
338 * - Moved GIFs, and other static HTTP response templates
343 * - Removed some >400 CRs again (Jon, you really worked
346 * Revision 1.3 2001/05/20 01:21:20 jongfoster
347 * Version 2.9.4 checkin.
348 * - Merged popupfile and cookiefile, and added control over PCRS
349 * filtering, in new "permissionsfile".
350 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
351 * file error you now get a message box (in the Win32 GUI) rather
352 * than the program exiting with no explanation.
353 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
355 * - Removed tabs from "config"
356 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
357 * - Bumped up version number.
359 * Revision 1.2 2001/05/17 23:01:01 oes
360 * - Cleaned CRLF's from the sources and related files
362 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
363 * Initial import of version 2.9.3 source tree
366 *********************************************************************/
372 #include <sys/types.h>
386 # include <windows.h>
389 # ifndef _WIN_CONSOLE
391 # endif /* ndef _WIN_CONSOLE */
393 /* VC++ has "_snprintf", not "snprintf" */
394 #define snprintf _snprintf
396 #else /* ifndef _WIN32 */
400 # include <sys/wait.h>
402 # include <sys/time.h>
403 # include <sys/stat.h>
413 #include "miscutil.h"
417 #include "urlmatch.h"
420 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
423 * Fix a problem with Solaris. There should be no effect on other
425 * Solaris's isspace() is a macro which uses it's argument directly
426 * as an array index. Therefore we need to make sure that high-bit
427 * characters generate +ve values, and ideally we also want to make
428 * the argument match the declared parameter type of "int".
430 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
431 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
433 #ifdef FEATURE_TOGGLE
434 /* Privoxy is enabled by default. */
435 int global_toggle_state = 1;
436 #endif /* def FEATURE_TOGGLE */
438 /* The filename of the configfile */
439 const char *configfile = NULL;
442 * CGI functions will later need access to the invocation args,
443 * so we will make argc and argv global.
446 const char **Argv = NULL;
448 static struct file_list *current_configfile = NULL;
452 * This takes the "cryptic" hash of each keyword and aliases them to
453 * something a little more readable. This also makes changing the
454 * hash values easier if they should change or the hash algorthm changes.
455 * Use the included "hash" program to find out what the hash will be
456 * for any string supplied on the command line. (Or just put it in the
457 * config file and read the number from the error message in the log).
459 * Please keep this list sorted alphabetically (but with the Windows
460 * console and GUI specific options last).
463 #define hash_actions_file 1196306641ul /* "actionsfile" */
464 #define hash_admin_address 4112573064ul /* "admin-address" */
465 #define hash_buffer_limit 1881726070ul /* "buffer-limit */
466 #define hash_confdir 1978389ul /* "confdir" */
467 #define hash_debug 78263ul /* "debug" */
468 #define hash_deny_access 1227333715ul /* "deny-access" */
469 #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */
470 #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */
471 #define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */
472 #define hash_filterfile 250887266ul /* "filterfile" */
473 #define hash_forward 2029845ul /* "forward" */
474 #define hash_forward_socks4 3963965521ul /* "forward-socks4" */
475 #define hash_forward_socks4a 2639958518ul /* "forward-socks4a" */
476 #define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
477 #define hash_jarfile 2046641ul /* "jarfile" */
478 #define hash_listen_address 1255650842ul /* "listen-address" */
479 #define hash_logdir 422889ul /* "logdir" */
480 #define hash_logfile 2114766ul /* "logfile" */
481 #define hash_permit_access 3587953268ul /* "permit-access" */
482 #define hash_proxy_info_url 3903079059ul /* "proxy-info-url" */
483 #define hash_single_threaded 4250084780ul /* "single-threaded" */
484 #define hash_split_large_cgi_forms 671658948ul /* "split-large-cgi-forms" */
485 #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */
486 #define hash_toggle 447966ul /* "toggle" */
487 #define hash_trust_info_url 430331967ul /* "trust-info-url" */
488 #define hash_trustfile 56494766ul /* "trustfile" */
489 #define hash_usermanual 1416668518ul /* "user-manual" */
490 #define hash_activity_animation 1817904738ul /* "activity-animation" */
491 #define hash_close_button_minimizes 3651284693ul /* "close-button-minimizes" */
492 #define hash_hide_console 2048809870ul /* "hide-console" */
493 #define hash_log_buffer_size 2918070425ul /* "log-buffer-size" */
494 #define hash_log_font_name 2866730124ul /* "log-font-name" */
495 #define hash_log_font_size 2866731014ul /* "log-font-size" */
496 #define hash_log_highlight_messages 4032101240ul /* "log-highlight-messages" */
497 #define hash_log_max_lines 2868344173ul /* "log-max-lines" */
498 #define hash_log_messages 2291744899ul /* "log-messages" */
499 #define hash_show_on_task_bar 215410365ul /* "show-on-task-bar" */
502 static void savearg(char *command, char *argument, struct configuration_spec * config);
504 /*********************************************************************
506 * Function : unload_configfile
508 * Description : Free the config structure and all components.
511 * 1 : data: struct configuration_spec to unload
515 *********************************************************************/
516 void unload_configfile (void * data)
518 struct configuration_spec * config = (struct configuration_spec *)data;
519 struct forward_spec *cur_fwd = config->forward;
523 struct access_control_list *cur_acl = config->acl;
525 while (cur_acl != NULL)
527 struct access_control_list * next_acl = cur_acl->next;
532 #endif /* def FEATURE_ACL */
534 while (cur_fwd != NULL)
536 struct forward_spec * next_fwd = cur_fwd->next;
537 free_url_spec(cur_fwd->url);
539 freez(cur_fwd->gateway_host);
540 freez(cur_fwd->forward_host);
544 config->forward = NULL;
546 #ifdef FEATURE_COOKIE_JAR
547 if ( NULL != config->jar )
549 fclose( config->jar );
552 #endif /* def FEATURE_COOKIE_JAR */
554 freez(config->confdir);
555 freez(config->logdir);
557 freez(config->haddr);
558 freez(config->logfile);
560 for (i = 0; i < MAX_AF_FILES; i++)
562 freez(config->actions_file_short[i]);
563 freez(config->actions_file[i]);
564 freez(config->re_filterfile_short[i]);
565 freez(config->re_filterfile[i]);
568 freez(config->admin_address);
569 freez(config->proxy_info_url);
570 freez(config->proxy_args);
571 freez(config->usermanual);
573 #ifdef FEATURE_COOKIE_JAR
574 freez(config->jarfile);
575 #endif /* def FEATURE_COOKIE_JAR */
578 freez(config->trustfile);
579 list_remove_all(config->trust_info);
580 #endif /* def FEATURE_TRUST */
582 for (i = 0; i < MAX_AF_FILES; i++)
584 freez(config->re_filterfile[i]);
591 #ifdef FEATURE_GRACEFUL_TERMINATION
592 /*********************************************************************
594 * Function : unload_current_config_file
596 * Description : Unloads current config file - reset to state at
597 * beginning of program.
603 *********************************************************************/
604 void unload_current_config_file(void)
606 if (current_configfile)
608 current_configfile->unloader = unload_configfile;
609 current_configfile = NULL;
615 /*********************************************************************
617 * Function : load_config
619 * Description : Load the config file and all parameters.
623 * Returns : The configuration_spec, or NULL on error.
625 *********************************************************************/
626 struct configuration_spec * load_config(void)
628 char buf[BUFFER_SIZE];
630 FILE *configfp = NULL;
631 struct configuration_spec * config = NULL;
632 struct client_state * fake_csp;
633 struct file_list *fs;
634 unsigned long linenum = 0;
637 if ( !check_file_changed(current_configfile, configfile, &fs))
639 /* No need to load */
640 return ((struct configuration_spec *)current_configfile->f);
644 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
648 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
650 #ifdef FEATURE_TOGGLE
651 global_toggle_state = 1;
652 #endif /* def FEATURE_TOGGLE */
654 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
660 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
661 /* Never get here - LOG_LEVEL_FATAL causes program exit */
665 * This is backwards from how it's usually done.
666 * Following the usual pattern, "fs" would be stored in a member
667 * variable in "csp", and then we'd access "config" from "fs->f",
668 * using a cast. However, "config" is used so often that a
669 * cast each time would be very ugly, and the extra indirection
670 * would waste CPU cycles. Therefore we store "config" in
671 * "csp->config", and "fs" in "csp->config->config_file_list".
673 config->config_file_list = fs;
678 config->multi_threaded = 1;
679 config->hport = HADDR_PORT;
680 config->buffer_limit = 4096 * 1024;
681 config->usermanual = strdup(USER_MANUAL_URL);
682 config->proxy_args = strdup("");
683 config->forwarded_connect_retries = 0;
684 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
685 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
687 if ((configfp = fopen(configfile, "r")) == NULL)
689 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
691 /* Never get here - LOG_LEVEL_FATAL causes program exit */
694 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
696 char cmd[BUFFER_SIZE];
697 char arg[BUFFER_SIZE];
698 char tmp[BUFFER_SIZE];
700 struct access_control_list *cur_acl;
701 #endif /* def FEATURE_ACL */
702 struct forward_spec *cur_fwd;
708 /* Copy command (i.e. up to space or tab) into cmd */
711 while (*p && (*p != ' ') && (*p != '\t'))
717 /* Skip over the whitespace in buf */
718 while (*p && ((*p == ' ') || (*p == '\t')))
723 /* Copy the argument into arg */
726 /* Should never happen, but check this anyway */
732 /* Make sure the command field is lower case */
737 *p = ijb_tolower(*p);
741 /* Save the argument for show-proxy-args */
742 savearg(cmd, arg, config);
745 switch( hash_string( cmd ) )
747 /* *************************************************************************
748 * actionsfile actions-file-name
749 * In confdir by default
750 * *************************************************************************/
751 case hash_actions_file :
753 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
758 if (i >= MAX_AF_FILES)
760 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
761 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
764 config->actions_file_short[i] = strdup(arg);
765 p = malloc(strlen(arg) + sizeof(".action"));
768 log_error(LOG_LEVEL_FATAL, "Out of memory");
771 strcat(p, ".action");
772 config->actions_file[i] = make_path(config->confdir, p);
776 /* *************************************************************************
777 * admin-address email-address
778 * *************************************************************************/
779 case hash_admin_address :
780 freez(config->admin_address);
781 config->admin_address = strdup(arg);
784 /* *************************************************************************
786 * *************************************************************************/
787 case hash_buffer_limit :
788 config->buffer_limit = (size_t) 1024 * atoi(arg);
791 /* *************************************************************************
792 * confdir directory-name
793 * *************************************************************************/
795 freez(config->confdir);
796 config->confdir = make_path( NULL, arg);
799 /* *************************************************************************
801 * Specifies debug level, multiple values are ORed together.
802 * *************************************************************************/
804 config->debug |= atoi(arg);
807 /* *************************************************************************
808 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
809 * *************************************************************************/
811 case hash_deny_access:
812 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
814 if ((vec_count != 1) && (vec_count != 2))
816 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
817 "deny-access directive in configuration file.");
818 string_append(&config->proxy_args,
819 "<br>\nWARNING: Wrong number of parameters for "
820 "deny-access directive in configuration file.<br><br>\n");
824 /* allocate a new node */
825 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
829 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
830 /* Never get here - LOG_LEVEL_FATAL causes program exit */
833 cur_acl->action = ACL_DENY;
835 if (acl_addr(vec[0], cur_acl->src) < 0)
837 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
838 "directive in configuration file: \"%s\"", vec[0]);
839 string_append(&config->proxy_args,
840 "<br>\nWARNING: Invalid source IP for deny-access directive"
841 " in configuration file: \"");
842 string_append(&config->proxy_args,
844 string_append(&config->proxy_args,
851 if (acl_addr(vec[1], cur_acl->dst) < 0)
853 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
854 "directive in configuration file: \"%s\"", vec[0]);
855 string_append(&config->proxy_args,
856 "<br>\nWARNING: Invalid destination IP for deny-access directive"
857 " in configuration file: \"");
858 string_append(&config->proxy_args,
860 string_append(&config->proxy_args,
868 * Add it to the list. Note we reverse the list to get the
869 * behaviour the user expects. With both the ACL and
870 * actions file, the last match wins. However, the internal
871 * implementations are different: The actions file is stored
872 * in the same order as the file, and scanned completely.
873 * With the ACL, we reverse the order as we load it, then
874 * when we scan it we stop as soon as we get a match.
876 cur_acl->next = config->acl;
877 config->acl = cur_acl;
880 #endif /* def FEATURE_ACL */
882 /* *************************************************************************
883 * enable-edit-actions 0|1
884 * *************************************************************************/
885 #ifdef FEATURE_CGI_EDIT_ACTIONS
886 case hash_enable_edit_actions:
887 if ((*arg != '\0') && (0 != atoi(arg)))
889 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
893 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
896 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
898 /* *************************************************************************
899 * enable-remote-toggle 0|1
900 * *************************************************************************/
901 #ifdef FEATURE_CGI_EDIT_ACTIONS
902 case hash_enable_remote_toggle:
903 if ((*arg != '\0') && (0 != atoi(arg)))
905 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
909 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
912 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
914 /* *************************************************************************
915 * enable-remote-http-toggle 0|1
916 * *************************************************************************/
917 case hash_enable_remote_http_toggle:
918 if ((*arg != '\0') && (0 != atoi(arg)))
920 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
924 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
928 /* *************************************************************************
929 * filterfile file-name
930 * In confdir by default.
931 * *************************************************************************/
932 case hash_filterfile :
934 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
939 if (i >= MAX_AF_FILES)
941 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
942 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
945 config->re_filterfile_short[i] = strdup(arg);
946 p = malloc(strlen(arg) + 1);
949 log_error(LOG_LEVEL_FATAL, "Out of memory");
952 config->re_filterfile[i] = make_path(config->confdir, p);
956 /* *************************************************************************
957 * forward url-pattern (.|http-proxy-host[:port])
958 * *************************************************************************/
960 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
964 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
965 "directive in configuration file.");
966 string_append(&config->proxy_args,
967 "<br>\nWARNING: Wrong number of parameters for "
968 "forward directive in configuration file.");
972 /* allocate a new node */
973 cur_fwd = zalloc(sizeof(*cur_fwd));
976 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
977 /* Never get here - LOG_LEVEL_FATAL causes program exit */
981 cur_fwd->type = SOCKS_NONE;
983 /* Save the URL pattern */
984 if (create_url_spec(cur_fwd->url, vec[0]))
986 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
987 "directive in configuration file.");
988 string_append(&config->proxy_args,
989 "<br>\nWARNING: Bad URL specifier for "
990 "forward directive in configuration file.");
994 /* Parse the parent HTTP proxy host:port */
997 if (strcmp(p, ".") != 0)
999 cur_fwd->forward_host = strdup(p);
1001 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1004 cur_fwd->forward_port = atoi(p);
1007 if (cur_fwd->forward_port <= 0)
1009 cur_fwd->forward_port = 8000;
1014 cur_fwd->next = config->forward;
1015 config->forward = cur_fwd;
1019 /* *************************************************************************
1020 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
1021 * *************************************************************************/
1022 case hash_forward_socks4:
1023 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1027 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1028 "forward-socks4 directive in configuration file.");
1029 string_append(&config->proxy_args,
1030 "<br>\nWARNING: Wrong number of parameters for "
1031 "forward-socks4 directive in configuration file.");
1035 /* allocate a new node */
1036 cur_fwd = zalloc(sizeof(*cur_fwd));
1037 if (cur_fwd == NULL)
1039 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1040 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1044 cur_fwd->type = SOCKS_4;
1046 /* Save the URL pattern */
1047 if (create_url_spec(cur_fwd->url, vec[0]))
1049 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
1050 "directive in configuration file.");
1051 string_append(&config->proxy_args,
1052 "<br>\nWARNING: Bad URL specifier for "
1053 "forward-socks4 directive in configuration file.");
1057 /* Parse the SOCKS proxy host[:port] */
1060 if (strcmp(p, ".") != 0)
1062 cur_fwd->gateway_host = strdup(p);
1064 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1067 cur_fwd->gateway_port = atoi(p);
1069 if (cur_fwd->gateway_port <= 0)
1071 cur_fwd->gateway_port = 1080;
1075 /* Parse the parent HTTP proxy host[:port] */
1078 if (strcmp(p, ".") != 0)
1080 cur_fwd->forward_host = strdup(p);
1082 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1085 cur_fwd->forward_port = atoi(p);
1088 if (cur_fwd->forward_port <= 0)
1090 cur_fwd->forward_port = 8000;
1095 cur_fwd->next = config->forward;
1096 config->forward = cur_fwd;
1100 /* *************************************************************************
1101 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1102 * *************************************************************************/
1103 case hash_forward_socks4a:
1104 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1108 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1109 "forward-socks4a directive in configuration file.");
1110 string_append(&config->proxy_args,
1111 "<br>\nWARNING: Wrong number of parameters for "
1112 "forward-socks4a directive in configuration file.");
1116 /* allocate a new node */
1117 cur_fwd = zalloc(sizeof(*cur_fwd));
1118 if (cur_fwd == NULL)
1120 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1121 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1125 cur_fwd->type = SOCKS_4A;
1127 /* Save the URL pattern */
1128 if (create_url_spec(cur_fwd->url, vec[0]))
1130 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1131 "directive in configuration file.");
1132 string_append(&config->proxy_args,
1133 "<br>\nWARNING: Bad URL specifier for "
1134 "forward-socks4a directive in configuration file.");
1138 /* Parse the SOCKS proxy host[:port] */
1141 cur_fwd->gateway_host = strdup(p);
1143 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1146 cur_fwd->gateway_port = atoi(p);
1148 if (cur_fwd->gateway_port <= 0)
1150 cur_fwd->gateway_port = 1080;
1153 /* Parse the parent HTTP proxy host[:port] */
1156 if (strcmp(p, ".") != 0)
1158 cur_fwd->forward_host = strdup(p);
1160 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1163 cur_fwd->forward_port = atoi(p);
1166 if (cur_fwd->forward_port <= 0)
1168 cur_fwd->forward_port = 8000;
1173 cur_fwd->next = config->forward;
1174 config->forward = cur_fwd;
1178 /* *************************************************************************
1179 * forwarded-connect-retries n
1180 * *************************************************************************/
1181 case hash_forwarded_connect_retries :
1182 config->forwarded_connect_retries = atoi(arg);
1185 /* *************************************************************************
1186 * jarfile jar-file-name
1187 * In logdir by default
1188 * *************************************************************************/
1189 #ifdef FEATURE_COOKIE_JAR
1191 freez(config->jarfile);
1192 config->jarfile = make_path(config->logdir, arg);
1194 #endif /* def FEATURE_COOKIE_JAR */
1196 /* *************************************************************************
1197 * listen-address [ip][:port]
1198 * *************************************************************************/
1199 case hash_listen_address :
1200 freez(config->haddr);
1201 config->haddr = strdup(arg);
1204 /* *************************************************************************
1205 * logdir directory-name
1206 * *************************************************************************/
1208 freez(config->logdir);
1209 config->logdir = make_path(NULL, arg);
1212 /* *************************************************************************
1213 * logfile log-file-name
1214 * In logdir by default
1215 * *************************************************************************/
1217 freez(config->logfile);
1218 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1221 /* *************************************************************************
1222 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1223 * *************************************************************************/
1225 case hash_permit_access:
1226 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1228 if ((vec_count != 1) && (vec_count != 2))
1230 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1231 "permit-access directive in configuration file.");
1232 string_append(&config->proxy_args,
1233 "<br>\nWARNING: Wrong number of parameters for "
1234 "permit-access directive in configuration file.<br><br>\n");
1239 /* allocate a new node */
1240 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1242 if (cur_acl == NULL)
1244 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1245 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1248 cur_acl->action = ACL_PERMIT;
1250 if (acl_addr(vec[0], cur_acl->src) < 0)
1252 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1253 "directive in configuration file: \"%s\"", vec[0]);
1254 string_append(&config->proxy_args,
1255 "<br>\nWARNING: Invalid source IP for permit-access directive"
1256 " in configuration file: \"");
1257 string_append(&config->proxy_args,
1259 string_append(&config->proxy_args,
1266 if (acl_addr(vec[1], cur_acl->dst) < 0)
1268 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1269 "permit-access directive in configuration file: \"%s\"",
1271 string_append(&config->proxy_args,
1272 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1273 " in configuration file: \"");
1274 string_append(&config->proxy_args,
1276 string_append(&config->proxy_args,
1284 * Add it to the list. Note we reverse the list to get the
1285 * behaviour the user expects. With both the ACL and
1286 * actions file, the last match wins. However, the internal
1287 * implementations are different: The actions file is stored
1288 * in the same order as the file, and scanned completely.
1289 * With the ACL, we reverse the order as we load it, then
1290 * when we scan it we stop as soon as we get a match.
1292 cur_acl->next = config->acl;
1293 config->acl = cur_acl;
1296 #endif /* def FEATURE_ACL */
1298 /* *************************************************************************
1299 * proxy-info-url url
1300 * *************************************************************************/
1301 case hash_proxy_info_url :
1302 freez(config->proxy_info_url);
1303 config->proxy_info_url = strdup(arg);
1306 /* *************************************************************************
1308 * *************************************************************************/
1309 case hash_single_threaded :
1310 config->multi_threaded = 0;
1313 /* *************************************************************************
1314 * split-large-cgi-forms
1315 * *************************************************************************/
1316 case hash_split_large_cgi_forms :
1317 if ((*arg != '\0') && (0 != atoi(arg)))
1319 config->feature_flags |= RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1323 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1327 /* *************************************************************************
1329 * *************************************************************************/
1330 #ifdef FEATURE_TOGGLE
1332 global_toggle_state = atoi(arg);
1334 #endif /* def FEATURE_TOGGLE */
1336 /* *************************************************************************
1337 * trust-info-url url
1338 * *************************************************************************/
1339 #ifdef FEATURE_TRUST
1340 case hash_trust_info_url :
1341 enlist(config->trust_info, arg);
1343 #endif /* def FEATURE_TRUST */
1345 /* *************************************************************************
1346 * trustfile filename
1347 * (In confdir by default.)
1348 * *************************************************************************/
1349 #ifdef FEATURE_TRUST
1350 case hash_trustfile :
1351 freez(config->trustfile);
1352 config->trustfile = make_path(config->confdir, arg);
1354 #endif /* def FEATURE_TRUST */
1356 /* *************************************************************************
1358 * *************************************************************************/
1359 case hash_usermanual :
1360 freez(config->usermanual);
1361 config->usermanual = strdup(arg);
1364 /* *************************************************************************
1365 * Win32 Console options:
1366 * *************************************************************************/
1368 /* *************************************************************************
1370 * *************************************************************************/
1372 case hash_hide_console :
1375 #endif /*def _WIN_CONSOLE*/
1378 /* *************************************************************************
1379 * Win32 GUI options:
1380 * *************************************************************************/
1382 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1383 /* *************************************************************************
1384 * activity-animation (0|1)
1385 * *************************************************************************/
1386 case hash_activity_animation :
1387 g_bShowActivityAnimation = atoi(arg);
1390 /* *************************************************************************
1391 * close-button-minimizes (0|1)
1392 * *************************************************************************/
1393 case hash_close_button_minimizes :
1394 g_bCloseHidesWindow = atoi(arg);
1397 /* *************************************************************************
1398 * log-buffer-size (0|1)
1399 * *************************************************************************/
1400 case hash_log_buffer_size :
1401 g_bLimitBufferSize = atoi(arg);
1404 /* *************************************************************************
1405 * log-font-name fontnane
1406 * *************************************************************************/
1407 case hash_log_font_name :
1408 strcpy( g_szFontFaceName, arg );
1411 /* *************************************************************************
1413 * *************************************************************************/
1414 case hash_log_font_size :
1415 g_nFontSize = atoi(arg);
1418 /* *************************************************************************
1419 * log-highlight-messages (0|1)
1420 * *************************************************************************/
1421 case hash_log_highlight_messages :
1422 g_bHighlightMessages = atoi(arg);
1425 /* *************************************************************************
1427 * *************************************************************************/
1428 case hash_log_max_lines :
1429 g_nMaxBufferLines = atoi(arg);
1432 /* *************************************************************************
1433 * log-messages (0|1)
1434 * *************************************************************************/
1435 case hash_log_messages :
1436 g_bLogMessages = atoi(arg);
1439 /* *************************************************************************
1440 * show-on-task-bar (0|1)
1441 * *************************************************************************/
1442 case hash_show_on_task_bar :
1443 g_bShowOnTaskBar = atoi(arg);
1446 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1449 /* *************************************************************************
1450 * Warnings about unsupported features
1451 * *************************************************************************/
1453 case hash_deny_access:
1454 #endif /* ndef FEATURE_ACL */
1455 #ifndef FEATURE_CGI_EDIT_ACTIONS
1456 case hash_enable_edit_actions:
1457 case hash_enable_remote_toggle:
1458 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1459 #ifndef FEATURE_COOKIE_JAR
1461 #endif /* ndef FEATURE_COOKIE_JAR */
1463 case hash_permit_access:
1464 #endif /* ndef FEATURE_ACL */
1465 #ifndef FEATURE_TOGGLE
1467 #endif /* ndef FEATURE_TOGGLE */
1468 #ifndef FEATURE_TRUST
1469 case hash_trustfile :
1470 case hash_trust_info_url :
1471 #endif /* ndef FEATURE_TRUST */
1473 #ifndef _WIN_CONSOLE
1474 case hash_hide_console :
1475 #endif /* ndef _WIN_CONSOLE */
1477 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1478 case hash_activity_animation :
1479 case hash_close_button_minimizes :
1480 case hash_log_buffer_size :
1481 case hash_log_font_name :
1482 case hash_log_font_size :
1483 case hash_log_highlight_messages :
1484 case hash_log_max_lines :
1485 case hash_log_messages :
1486 case hash_show_on_task_bar :
1487 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1488 /* These warnings are annoying - so hide them. -- Jon */
1489 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1492 /* *************************************************************************/
1494 /* *************************************************************************/
1496 * I decided that I liked this better as a warning than an
1497 * error. To change back to an error, just change log level
1498 * to LOG_LEVEL_FATAL.
1500 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive '%s' (%luul) in line %lu "
1501 "in configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1502 string_append(&config->proxy_args,
1503 " <b><font color=\"red\">WARNING: unrecognized directive, ignored</font></b>");
1506 /* *************************************************************************/
1507 } /* end switch( hash_string(cmd) ) */
1508 } /* end while ( read_config_line(...) ) */
1512 if (NULL == config->proxy_args)
1514 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1517 init_error_log(Argv[0], config->logfile, config->debug);
1519 if (config->actions_file[0])
1521 add_loader(load_actions_file, config);
1524 if (config->re_filterfile)
1526 add_loader(load_re_filterfile, config);
1529 #ifdef FEATURE_TRUST
1530 if (config->trustfile)
1532 add_loader(load_trustfile, config);
1534 #endif /* def FEATURE_TRUST */
1536 #ifdef FEATURE_COOKIE_JAR
1537 if ( NULL != config->jarfile )
1539 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1541 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1542 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1544 setbuf(config->jar, NULL);
1546 #endif /* def FEATURE_COOKIE_JAR */
1548 if ( NULL == config->haddr )
1550 config->haddr = strdup( HADDR_DEFAULT );
1553 if ( NULL != config->haddr )
1555 if (NULL != (p = strchr(config->haddr, ':')))
1560 config->hport = atoi(p);
1564 if (config->hport <= 0)
1567 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1568 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1570 if (*config->haddr == '\0')
1572 config->haddr = NULL;
1577 * Want to run all the loaders once now.
1579 * Need to set up a fake csp, so they can get to the config.
1581 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1582 fake_csp->config = config;
1584 if (run_loader(fake_csp))
1587 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1588 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1592 /* FIXME: this is a kludge for win32 */
1593 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1595 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1596 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1597 g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1599 #ifdef FEATURE_TRUST
1600 g_trustfile = config->trustfile;
1601 #endif /* def FEATURE_TRUST */
1604 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1605 /* FIXME: end kludge */
1608 config->need_bind = 1;
1610 if (current_configfile)
1612 struct configuration_spec * oldcfg = (struct configuration_spec *)
1613 current_configfile->f;
1615 * Check if config->haddr,hport == oldcfg->haddr,hport
1617 * The following could be written more compactly as a single,
1618 * (unreadably long) if statement.
1620 config->need_bind = 0;
1621 if (config->hport != oldcfg->hport)
1623 config->need_bind = 1;
1625 else if (config->haddr == NULL)
1627 if (oldcfg->haddr != NULL)
1629 config->need_bind = 1;
1632 else if (oldcfg->haddr == NULL)
1634 config->need_bind = 1;
1636 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1638 config->need_bind = 1;
1641 current_configfile->unloader = unload_configfile;
1644 fs->next = files->next;
1647 current_configfile = fs;
1653 /*********************************************************************
1655 * Function : savearg
1657 * Description : Called from `load_config'. It saves each non-empty
1658 * and non-comment line from config into
1659 * config->proxy_args. This is used to create the
1660 * show-proxy-args page. On error, frees
1661 * config->proxy_args and sets it to NULL
1664 * 1 : command = config setting that was found
1665 * 2 : argument = the setting's argument (if any)
1666 * 3 : config = Configuration to save into.
1670 *********************************************************************/
1671 static void savearg(char *command, char *argument, struct configuration_spec * config)
1681 * Add config option name embedded in
1682 * link to it's section in the user-manual
1684 buf = strdup("\n<a href=\"");
1685 if (!strncmpic(config->usermanual, "file://", 7) ||
1686 !strncmpic(config->usermanual, "http", 4))
1688 string_append(&buf, config->usermanual);
1692 string_append(&buf, "http://");
1693 string_append(&buf, CGI_SITE_2_HOST);
1694 string_append(&buf, "/user-manual/");
1696 string_append(&buf, CONFIG_HELP_PREFIX);
1697 string_join (&buf, string_toupper(command));
1698 string_append(&buf, "\">");
1699 string_append(&buf, command);
1700 string_append(&buf, "</a> ");
1704 freez(config->proxy_args);
1708 if ( (NULL != argument) && ('\0' != *argument) )
1710 s = html_encode(argument);
1714 freez(config->proxy_args);
1718 if (strncmpic(argument, "http://", 7) == 0)
1720 string_append(&buf, "<a href=\"");
1721 string_append(&buf, s);
1722 string_append(&buf, "\">");
1723 string_join (&buf, s);
1724 string_append(&buf, "</a>");
1728 string_join (&buf, s);
1732 string_append(&buf, "<br>");
1733 string_join(&config->proxy_args, buf);