1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.57 2006/12/21 12:57:48 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.57 2006/12/21 12:57:48 fabiankeil
39 * Add config option "split-large-forms"
40 * to work around the browser bug reported
43 * Revision 1.56 2006/12/17 17:04:51 fabiankeil
44 * Move the <br> in the generated HTML for the config
45 * options from the beginning of the string to its end.
46 * Keeps the white space in balance.
48 * Revision 1.55 2006/11/28 15:31:52 fabiankeil
49 * Fix memory leak in case of config file reloads.
51 * Revision 1.54 2006/10/21 16:04:22 fabiankeil
52 * Modified kludge for win32 to make ming32 menu
53 * "Options/Edit Filters" (sort of) work again.
54 * Same limitations as for the action files apply.
57 * Revision 1.53 2006/09/06 18:45:03 fabiankeil
58 * Incorporate modified version of Roland Rosenfeld's patch to
59 * optionally access the user-manual via Privoxy. Closes patch 679075.
61 * Formatting changed to Privoxy style, added call to
62 * cgi_error_no_template if the requested file doesn't
63 * exist and modified check whether or not Privoxy itself
64 * should serve the manual. Should work cross-platform now.
66 * Revision 1.52 2006/09/06 10:43:32 fabiankeil
67 * Added config option enable-remote-http-toggle
68 * to specify if Privoxy should recognize special
69 * headers (currently only X-Filter) to change its
70 * behaviour. Disabled by default.
72 * Revision 1.51 2006/09/06 09:23:37 fabiankeil
73 * Make number of retries in case of forwarded-connect problems
74 * a config file option (forwarded-connect-retries) and use 0 as
77 * Revision 1.50 2006/07/18 14:48:46 david__schmidt
78 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
79 * with what was really the latest development (the v_3_0_branch branch)
81 * Revision 1.48.2.7 2006/02/02 17:29:16 david__schmidt
82 * Don't forget to malloc space for the null terminator...
84 * Revision 1.48.2.6 2006/01/29 23:10:56 david__schmidt
85 * Multiple filter file support
87 * Revision 1.48.2.5 2003/05/08 15:17:25 oes
88 * Closed two memory leaks; hopefully the last remaining ones
89 * (in the main execution paths, anyway).
91 * Revision 1.48.2.4 2003/04/11 12:06:14 oes
92 * Addressed bug #719435
93 * - Extraneous filterfile directives now logged as errors
94 * - This and unrecnonised directives now really obvious on status page
96 * Revision 1.48.2.3 2003/03/11 11:53:59 oes
97 * Cosmetic: Renamed cryptic variable
99 * Revision 1.48.2.2 2002/11/12 16:28:20 oes
100 * Move unrelated variable declaration out of #ifdef FEATURE_ACL; fixes bug #636655
102 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
103 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
105 * Revision 1.48 2002/05/14 21:30:38 oes
106 * savearg now uses own linking code instead of (now special-cased) add_help_link
108 * Revision 1.47 2002/05/12 21:36:29 jongfoster
109 * Correcting function comments
111 * Revision 1.46 2002/04/26 12:55:14 oes
112 * - New option "user-manual", defaults to our site
113 * via project.h #define
114 * - savearg now embeds option names in help links
116 * Revision 1.45 2002/04/24 02:11:54 oes
117 * Jon's multiple AF patch: Allow up to MAX_AF_FILES actionsfile options
119 * Revision 1.44 2002/04/08 20:37:13 swa
122 * Revision 1.43 2002/04/08 20:36:50 swa
125 * Revision 1.42 2002/04/05 15:50:15 oes
126 * fix for invalid HTML proxy_args
128 * Revision 1.41 2002/03/31 17:19:00 jongfoster
129 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
131 * Revision 1.40 2002/03/26 22:29:55 swa
132 * we have a new homepage!
134 * Revision 1.39 2002/03/24 13:25:43 swa
135 * name change related issues
137 * Revision 1.38 2002/03/24 13:05:48 jongfoster
138 * Renaming re_filterfile to filterfile
140 * Revision 1.37 2002/03/16 23:54:06 jongfoster
141 * Adding graceful termination feature, to help look for memory leaks.
142 * If you enable this (which, by design, has to be done by hand
143 * editing config.h) and then go to http://i.j.b/die, then the program
144 * will exit cleanly after the *next* request. It should free all the
145 * memory that was used.
147 * Revision 1.36 2002/03/13 00:27:05 jongfoster
150 * Revision 1.35 2002/03/07 03:52:44 oes
151 * Set logging to tty for --no-daemon mode
153 * Revision 1.34 2002/03/06 23:14:35 jongfoster
154 * Trivial cosmetic changes to make function comments easier to find.
156 * Revision 1.33 2002/03/05 04:52:42 oes
157 * Deleted non-errlog debugging code
159 * Revision 1.32 2002/03/04 18:24:53 oes
160 * Re-enabled output of unknown config directive hash
162 * Revision 1.31 2002/03/03 15:07:20 oes
163 * Re-enabled automatic config reloading
165 * Revision 1.30 2002/01/22 23:31:43 jongfoster
166 * Replacing strsav() with string_append()
168 * Revision 1.29 2002/01/17 21:02:30 jongfoster
169 * Moving all our URL and URL pattern parsing code to urlmatch.c.
171 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
173 * Revision 1.28 2001/12/30 14:07:32 steudten
174 * - Add signal handling (unix)
175 * - Add SIGHUP handler (unix)
176 * - Add creation of pidfile (unix)
177 * - Add action 'top' in rc file (RH)
178 * - Add entry 'SIGNALS' to manpage
179 * - Add exit message to logfile (unix)
181 * Revision 1.27 2001/11/07 00:02:13 steudten
182 * Add line number in error output for lineparsing for
183 * actionsfile and configfile.
184 * Special handling for CLF added.
186 * Revision 1.26 2001/11/05 21:41:43 steudten
187 * Add changes to be a real daemon just for unix os.
188 * (change cwd to /, detach from controlling tty, set
189 * process group and session leader to the own process.
191 * Add some fatal-error log message for failed malloc().
192 * Add '-d' if compiled with 'configure --with-debug' to
193 * enable debug output.
195 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
196 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
197 * threads to call select() simultaneously. So, it's time to do a real, live,
198 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
199 * (native). Both versions will work, but using __OS2__ offers multi-threading.
201 * Revision 1.24 2001/10/23 21:40:30 jongfoster
202 * Added support for enable-edit-actions and enable-remote-toggle config
205 * Revision 1.23 2001/10/07 15:36:00 oes
206 * Introduced new config option "buffer-limit"
208 * Revision 1.22 2001/09/22 16:36:59 jongfoster
209 * Removing unused parameter fs from read_config_line()
211 * Revision 1.21 2001/09/16 17:10:43 jongfoster
212 * Moving function savearg() here, since it was the only thing left in
215 * Revision 1.20 2001/07/30 22:08:36 jongfoster
216 * Tidying up #defines:
217 * - All feature #defines are now of the form FEATURE_xxx
218 * - Permanently turned off WIN_GUI_EDIT
219 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
221 * Revision 1.19 2001/07/15 17:45:16 jongfoster
222 * Removing some unused #includes
224 * Revision 1.18 2001/07/13 14:01:14 oes
225 * - Removed all #ifdef PCRS
226 * - Removed vim-settings
228 * Revision 1.17 2001/06/29 13:31:03 oes
229 * - Improved comments
230 * - Fixed (actionsfile) and sorted hashes
231 * - Introduced admin_address and proxy-info-url
232 * as config parameters
233 * - Renamed config->proxy_args_invocation (which didn't have
234 * the invocation but the options!) to config->proxy_args
235 * - Various adaptions
236 * - Removed logentry from cancelled commit
238 * Revision 1.16 2001/06/09 10:55:28 jongfoster
239 * Changing BUFSIZ ==> BUFFER_SIZE
241 * Revision 1.15 2001/06/07 23:13:40 jongfoster
242 * Merging ACL and forward files into config file.
243 * Cosmetic: Sorting config file options alphabetically.
244 * Cosmetic: Adding brief syntax comments to config file options.
246 * Revision 1.14 2001/06/07 14:46:25 joergs
247 * Missing make_path() added for re_filterfile.
249 * Revision 1.13 2001/06/05 22:33:54 jongfoster
251 * Fixed minor memory leak.
252 * Also now uses make_path to prepend the pathnames.
254 * Revision 1.12 2001/06/05 20:04:09 jongfoster
255 * Now uses _snprintf() in place of snprintf() under Win32.
257 * Revision 1.11 2001/06/04 18:31:58 swa
258 * files are now prefixed with either `confdir' or `logdir'.
259 * `make redhat-dist' replaces both entries confdir and logdir
262 * Revision 1.10 2001/06/03 19:11:54 oes
263 * introduced confdir option
265 * Revision 1.9 2001/06/01 20:06:24 jongfoster
266 * Removed support for "tinygif" option - moved to actions file.
268 * Revision 1.8 2001/05/31 21:27:13 jongfoster
269 * Removed many options from the config file and into the
270 * "actions" file: add_forwarded, suppress_vanilla_wafer,
271 * wafer, add_header, user_agent, referer, from
272 * Also globally replaced "permission" with "action".
274 * Revision 1.7 2001/05/29 09:50:24 jongfoster
275 * Unified blocklist/imagelist/permissionslist.
276 * File format is still under discussion, but the internal changes
279 * Also modified interceptor behaviour:
280 * - We now intercept all URLs beginning with one of the following
281 * prefixes (and *only* these prefixes):
283 * * http://ijbswa.sf.net/config/
284 * * http://ijbswa.sourceforge.net/config/
285 * - New interceptors "home page" - go to http://i.j.b/ to see it.
286 * - Internal changes so that intercepted and fast redirect pages
287 * are not replaced with an image.
288 * - Interceptors now have the option to send a binary page direct
289 * to the client. (i.e. ijb-send-banner uses this)
290 * - Implemented show-url-info interceptor. (Which is why I needed
291 * the above interceptors changes - a typical URL is
292 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
293 * The previous mechanism would not have intercepted that, and
294 * if it had been intercepted then it then it would have replaced
297 * Revision 1.6 2001/05/26 00:28:36 jongfoster
298 * Automatic reloading of config file.
299 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
300 * Most of the global variables have been moved to a new
301 * struct configuration_spec, accessed through csp->config->globalname
302 * Most of the globals remaining are used by the Win32 GUI.
304 * Revision 1.5 2001/05/25 22:34:30 jongfoster
307 * Revision 1.4 2001/05/22 18:46:04 oes
309 * - Enabled filtering banners by size rather than URL
310 * by adding patterns that replace all standard banner
311 * sizes with the "Junkbuster" gif to the re_filterfile
313 * - Enabled filtering WebBugs by providing a pattern
314 * which kills all 1x1 images
316 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
317 * which is selected by the (nonstandard and therefore
318 * capital) letter 'U' in the option string.
319 * It causes the quantifiers to be ungreedy by default.
320 * Appending a ? turns back to greedy (!).
322 * - Added a new interceptor ijb-send-banner, which
323 * sends back the "Junkbuster" gif. Without imagelist or
324 * MSIE detection support, or if tinygif = 1, or the
325 * URL isn't recognized as an imageurl, a lame HTML
326 * explanation is sent instead.
328 * - Added new feature, which permits blocking remote
329 * script redirects and firing back a local redirect
331 * The feature is conditionally compiled, i.e. it
332 * can be disabled with --disable-fast-redirects,
333 * plus it must be activated by a "fast-redirects"
334 * line in the config file, has its own log level
335 * and of course wants to be displayed by show-proxy-args
336 * Note: Boy, all the #ifdefs in 1001 locations and
337 * all the fumbling with configure.in and acconfig.h
338 * were *way* more work than the feature itself :-(
340 * - Because a generic redirect template was needed for
341 * this, tinygif = 3 now uses the same.
343 * - Moved GIFs, and other static HTTP response templates
348 * - Removed some >400 CRs again (Jon, you really worked
351 * Revision 1.3 2001/05/20 01:21:20 jongfoster
352 * Version 2.9.4 checkin.
353 * - Merged popupfile and cookiefile, and added control over PCRS
354 * filtering, in new "permissionsfile".
355 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
356 * file error you now get a message box (in the Win32 GUI) rather
357 * than the program exiting with no explanation.
358 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
360 * - Removed tabs from "config"
361 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
362 * - Bumped up version number.
364 * Revision 1.2 2001/05/17 23:01:01 oes
365 * - Cleaned CRLF's from the sources and related files
367 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
368 * Initial import of version 2.9.3 source tree
371 *********************************************************************/
377 #include <sys/types.h>
391 # include <windows.h>
394 # ifndef _WIN_CONSOLE
396 # endif /* ndef _WIN_CONSOLE */
398 /* VC++ has "_snprintf", not "snprintf" */
399 #define snprintf _snprintf
401 #else /* ifndef _WIN32 */
405 # include <sys/wait.h>
407 # include <sys/time.h>
408 # include <sys/stat.h>
418 #include "miscutil.h"
422 #include "urlmatch.h"
425 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
428 * Fix a problem with Solaris. There should be no effect on other
430 * Solaris's isspace() is a macro which uses it's argument directly
431 * as an array index. Therefore we need to make sure that high-bit
432 * characters generate +ve values, and ideally we also want to make
433 * the argument match the declared parameter type of "int".
435 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
436 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
438 #ifdef FEATURE_TOGGLE
439 /* Privoxy is enabled by default. */
440 int global_toggle_state = 1;
441 #endif /* def FEATURE_TOGGLE */
443 /* The filename of the configfile */
444 const char *configfile = NULL;
447 * CGI functions will later need access to the invocation args,
448 * so we will make argc and argv global.
451 const char **Argv = NULL;
453 static struct file_list *current_configfile = NULL;
457 * This takes the "cryptic" hash of each keyword and aliases them to
458 * something a little more readable. This also makes changing the
459 * hash values easier if they should change or the hash algorthm changes.
460 * Use the included "hash" program to find out what the hash will be
461 * for any string supplied on the command line. (Or just put it in the
462 * config file and read the number from the error message in the log).
464 * Please keep this list sorted alphabetically (but with the Windows
465 * console and GUI specific options last).
468 #define hash_actions_file 1196306641ul /* "actionsfile" */
469 #define hash_admin_address 4112573064ul /* "admin-address" */
470 #define hash_buffer_limit 1881726070ul /* "buffer-limit */
471 #define hash_confdir 1978389ul /* "confdir" */
472 #define hash_debug 78263ul /* "debug" */
473 #define hash_deny_access 1227333715ul /* "deny-access" */
474 #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */
475 #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */
476 #define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */
477 #define hash_filterfile 250887266ul /* "filterfile" */
478 #define hash_forward 2029845ul /* "forward" */
479 #define hash_forward_socks4 3963965521ul /* "forward-socks4" */
480 #define hash_forward_socks4a 2639958518ul /* "forward-socks4a" */
481 #define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
482 #define hash_jarfile 2046641ul /* "jarfile" */
483 #define hash_listen_address 1255650842ul /* "listen-address" */
484 #define hash_logdir 422889ul /* "logdir" */
485 #define hash_logfile 2114766ul /* "logfile" */
486 #define hash_permit_access 3587953268ul /* "permit-access" */
487 #define hash_proxy_info_url 3903079059ul /* "proxy-info-url" */
488 #define hash_single_threaded 4250084780ul /* "single-threaded" */
489 #define hash_split_large_cgi_forms 671658948ul /* "split-large-cgi-forms" */
490 #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */
491 #define hash_toggle 447966ul /* "toggle" */
492 #define hash_trust_info_url 430331967ul /* "trust-info-url" */
493 #define hash_trustfile 56494766ul /* "trustfile" */
494 #define hash_usermanual 1416668518ul /* "user-manual" */
495 #define hash_activity_animation 1817904738ul /* "activity-animation" */
496 #define hash_close_button_minimizes 3651284693ul /* "close-button-minimizes" */
497 #define hash_hide_console 2048809870ul /* "hide-console" */
498 #define hash_log_buffer_size 2918070425ul /* "log-buffer-size" */
499 #define hash_log_font_name 2866730124ul /* "log-font-name" */
500 #define hash_log_font_size 2866731014ul /* "log-font-size" */
501 #define hash_log_highlight_messages 4032101240ul /* "log-highlight-messages" */
502 #define hash_log_max_lines 2868344173ul /* "log-max-lines" */
503 #define hash_log_messages 2291744899ul /* "log-messages" */
504 #define hash_show_on_task_bar 215410365ul /* "show-on-task-bar" */
507 static void savearg(char *command, char *argument, struct configuration_spec * config);
509 /*********************************************************************
511 * Function : unload_configfile
513 * Description : Free the config structure and all components.
516 * 1 : data: struct configuration_spec to unload
520 *********************************************************************/
521 void unload_configfile (void * data)
523 struct configuration_spec * config = (struct configuration_spec *)data;
524 struct forward_spec *cur_fwd = config->forward;
528 struct access_control_list *cur_acl = config->acl;
530 while (cur_acl != NULL)
532 struct access_control_list * next_acl = cur_acl->next;
537 #endif /* def FEATURE_ACL */
539 while (cur_fwd != NULL)
541 struct forward_spec * next_fwd = cur_fwd->next;
542 free_url_spec(cur_fwd->url);
544 freez(cur_fwd->gateway_host);
545 freez(cur_fwd->forward_host);
549 config->forward = NULL;
551 #ifdef FEATURE_COOKIE_JAR
552 if ( NULL != config->jar )
554 fclose( config->jar );
557 #endif /* def FEATURE_COOKIE_JAR */
559 freez(config->confdir);
560 freez(config->logdir);
562 freez(config->haddr);
563 freez(config->logfile);
565 for (i = 0; i < MAX_AF_FILES; i++)
567 freez(config->actions_file_short[i]);
568 freez(config->actions_file[i]);
569 freez(config->re_filterfile_short[i]);
570 freez(config->re_filterfile[i]);
573 freez(config->admin_address);
574 freez(config->proxy_info_url);
575 freez(config->proxy_args);
576 freez(config->usermanual);
578 #ifdef FEATURE_COOKIE_JAR
579 freez(config->jarfile);
580 #endif /* def FEATURE_COOKIE_JAR */
583 freez(config->trustfile);
584 list_remove_all(config->trust_info);
585 #endif /* def FEATURE_TRUST */
587 for (i = 0; i < MAX_AF_FILES; i++)
589 freez(config->re_filterfile[i]);
596 #ifdef FEATURE_GRACEFUL_TERMINATION
597 /*********************************************************************
599 * Function : unload_current_config_file
601 * Description : Unloads current config file - reset to state at
602 * beginning of program.
608 *********************************************************************/
609 void unload_current_config_file(void)
611 if (current_configfile)
613 current_configfile->unloader = unload_configfile;
614 current_configfile = NULL;
620 /*********************************************************************
622 * Function : load_config
624 * Description : Load the config file and all parameters.
628 * Returns : The configuration_spec, or NULL on error.
630 *********************************************************************/
631 struct configuration_spec * load_config(void)
633 char buf[BUFFER_SIZE];
635 FILE *configfp = NULL;
636 struct configuration_spec * config = NULL;
637 struct client_state * fake_csp;
638 struct file_list *fs;
639 unsigned long linenum = 0;
642 if ( !check_file_changed(current_configfile, configfile, &fs))
644 /* No need to load */
645 return ((struct configuration_spec *)current_configfile->f);
649 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
653 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
655 #ifdef FEATURE_TOGGLE
656 global_toggle_state = 1;
657 #endif /* def FEATURE_TOGGLE */
659 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
665 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
666 /* Never get here - LOG_LEVEL_FATAL causes program exit */
670 * This is backwards from how it's usually done.
671 * Following the usual pattern, "fs" would be stored in a member
672 * variable in "csp", and then we'd access "config" from "fs->f",
673 * using a cast. However, "config" is used so often that a
674 * cast each time would be very ugly, and the extra indirection
675 * would waste CPU cycles. Therefore we store "config" in
676 * "csp->config", and "fs" in "csp->config->config_file_list".
678 config->config_file_list = fs;
683 config->multi_threaded = 1;
684 config->hport = HADDR_PORT;
685 config->buffer_limit = 4096 * 1024;
686 config->usermanual = strdup(USER_MANUAL_URL);
687 config->proxy_args = strdup("");
688 config->forwarded_connect_retries = 0;
689 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
690 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
692 if ((configfp = fopen(configfile, "r")) == NULL)
694 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
696 /* Never get here - LOG_LEVEL_FATAL causes program exit */
699 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
701 char cmd[BUFFER_SIZE];
702 char arg[BUFFER_SIZE];
703 char tmp[BUFFER_SIZE];
705 struct access_control_list *cur_acl;
706 #endif /* def FEATURE_ACL */
707 struct forward_spec *cur_fwd;
713 /* Copy command (i.e. up to space or tab) into cmd */
716 while (*p && (*p != ' ') && (*p != '\t'))
722 /* Skip over the whitespace in buf */
723 while (*p && ((*p == ' ') || (*p == '\t')))
728 /* Copy the argument into arg */
731 /* Should never happen, but check this anyway */
737 /* Make sure the command field is lower case */
742 *p = (char)ijb_tolower(*p);
746 /* Save the argument for show-proxy-args */
747 savearg(cmd, arg, config);
750 switch( hash_string( cmd ) )
752 /* *************************************************************************
753 * actionsfile actions-file-name
754 * In confdir by default
755 * *************************************************************************/
756 case hash_actions_file :
758 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
763 if (i >= MAX_AF_FILES)
765 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
766 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
769 config->actions_file_short[i] = strdup(arg);
770 p = malloc(strlen(arg) + sizeof(".action"));
773 log_error(LOG_LEVEL_FATAL, "Out of memory");
776 strcat(p, ".action");
777 config->actions_file[i] = make_path(config->confdir, p);
781 /* *************************************************************************
782 * admin-address email-address
783 * *************************************************************************/
784 case hash_admin_address :
785 freez(config->admin_address);
786 config->admin_address = strdup(arg);
789 /* *************************************************************************
791 * *************************************************************************/
792 case hash_buffer_limit :
793 config->buffer_limit = (size_t)(1024 * atoi(arg));
796 /* *************************************************************************
797 * confdir directory-name
798 * *************************************************************************/
800 freez(config->confdir);
801 config->confdir = make_path( NULL, arg);
804 /* *************************************************************************
806 * Specifies debug level, multiple values are ORed together.
807 * *************************************************************************/
809 config->debug |= atoi(arg);
812 /* *************************************************************************
813 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
814 * *************************************************************************/
816 case hash_deny_access:
817 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
819 if ((vec_count != 1) && (vec_count != 2))
821 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
822 "deny-access directive in configuration file.");
823 string_append(&config->proxy_args,
824 "<br>\nWARNING: Wrong number of parameters for "
825 "deny-access directive in configuration file.<br><br>\n");
829 /* allocate a new node */
830 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
834 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
835 /* Never get here - LOG_LEVEL_FATAL causes program exit */
838 cur_acl->action = ACL_DENY;
840 if (acl_addr(vec[0], cur_acl->src) < 0)
842 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
843 "directive in configuration file: \"%s\"", vec[0]);
844 string_append(&config->proxy_args,
845 "<br>\nWARNING: Invalid source IP for deny-access directive"
846 " in configuration file: \"");
847 string_append(&config->proxy_args,
849 string_append(&config->proxy_args,
856 if (acl_addr(vec[1], cur_acl->dst) < 0)
858 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
859 "directive in configuration file: \"%s\"", vec[0]);
860 string_append(&config->proxy_args,
861 "<br>\nWARNING: Invalid destination IP for deny-access directive"
862 " in configuration file: \"");
863 string_append(&config->proxy_args,
865 string_append(&config->proxy_args,
873 * Add it to the list. Note we reverse the list to get the
874 * behaviour the user expects. With both the ACL and
875 * actions file, the last match wins. However, the internal
876 * implementations are different: The actions file is stored
877 * in the same order as the file, and scanned completely.
878 * With the ACL, we reverse the order as we load it, then
879 * when we scan it we stop as soon as we get a match.
881 cur_acl->next = config->acl;
882 config->acl = cur_acl;
885 #endif /* def FEATURE_ACL */
887 /* *************************************************************************
888 * enable-edit-actions 0|1
889 * *************************************************************************/
890 #ifdef FEATURE_CGI_EDIT_ACTIONS
891 case hash_enable_edit_actions:
892 if ((*arg != '\0') && (0 != atoi(arg)))
894 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
898 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
901 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
903 /* *************************************************************************
904 * enable-remote-toggle 0|1
905 * *************************************************************************/
906 #ifdef FEATURE_CGI_EDIT_ACTIONS
907 case hash_enable_remote_toggle:
908 if ((*arg != '\0') && (0 != atoi(arg)))
910 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
914 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
917 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
919 /* *************************************************************************
920 * enable-remote-http-toggle 0|1
921 * *************************************************************************/
922 case hash_enable_remote_http_toggle:
923 if ((*arg != '\0') && (0 != atoi(arg)))
925 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
929 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
933 /* *************************************************************************
934 * filterfile file-name
935 * In confdir by default.
936 * *************************************************************************/
937 case hash_filterfile :
939 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
944 if (i >= MAX_AF_FILES)
946 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
947 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
950 config->re_filterfile_short[i] = strdup(arg);
951 p = malloc(strlen(arg) + 1);
954 log_error(LOG_LEVEL_FATAL, "Out of memory");
957 config->re_filterfile[i] = make_path(config->confdir, p);
961 /* *************************************************************************
962 * forward url-pattern (.|http-proxy-host[:port])
963 * *************************************************************************/
965 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
969 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
970 "directive in configuration file.");
971 string_append(&config->proxy_args,
972 "<br>\nWARNING: Wrong number of parameters for "
973 "forward directive in configuration file.");
977 /* allocate a new node */
978 cur_fwd = zalloc(sizeof(*cur_fwd));
981 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
982 /* Never get here - LOG_LEVEL_FATAL causes program exit */
986 cur_fwd->type = SOCKS_NONE;
988 /* Save the URL pattern */
989 if (create_url_spec(cur_fwd->url, vec[0]))
991 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
992 "directive in configuration file.");
993 string_append(&config->proxy_args,
994 "<br>\nWARNING: Bad URL specifier for "
995 "forward directive in configuration file.");
999 /* Parse the parent HTTP proxy host:port */
1002 if (strcmp(p, ".") != 0)
1004 cur_fwd->forward_host = strdup(p);
1006 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1009 cur_fwd->forward_port = atoi(p);
1012 if (cur_fwd->forward_port <= 0)
1014 cur_fwd->forward_port = 8000;
1019 cur_fwd->next = config->forward;
1020 config->forward = cur_fwd;
1024 /* *************************************************************************
1025 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
1026 * *************************************************************************/
1027 case hash_forward_socks4:
1028 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1032 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1033 "forward-socks4 directive in configuration file.");
1034 string_append(&config->proxy_args,
1035 "<br>\nWARNING: Wrong number of parameters for "
1036 "forward-socks4 directive in configuration file.");
1040 /* allocate a new node */
1041 cur_fwd = zalloc(sizeof(*cur_fwd));
1042 if (cur_fwd == NULL)
1044 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1045 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1049 cur_fwd->type = SOCKS_4;
1051 /* Save the URL pattern */
1052 if (create_url_spec(cur_fwd->url, vec[0]))
1054 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
1055 "directive in configuration file.");
1056 string_append(&config->proxy_args,
1057 "<br>\nWARNING: Bad URL specifier for "
1058 "forward-socks4 directive in configuration file.");
1062 /* Parse the SOCKS proxy host[:port] */
1065 if (strcmp(p, ".") != 0)
1067 cur_fwd->gateway_host = strdup(p);
1069 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1072 cur_fwd->gateway_port = atoi(p);
1074 if (cur_fwd->gateway_port <= 0)
1076 cur_fwd->gateway_port = 1080;
1080 /* Parse the parent HTTP proxy host[:port] */
1083 if (strcmp(p, ".") != 0)
1085 cur_fwd->forward_host = strdup(p);
1087 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1090 cur_fwd->forward_port = atoi(p);
1093 if (cur_fwd->forward_port <= 0)
1095 cur_fwd->forward_port = 8000;
1100 cur_fwd->next = config->forward;
1101 config->forward = cur_fwd;
1105 /* *************************************************************************
1106 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1107 * *************************************************************************/
1108 case hash_forward_socks4a:
1109 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1113 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1114 "forward-socks4a directive in configuration file.");
1115 string_append(&config->proxy_args,
1116 "<br>\nWARNING: Wrong number of parameters for "
1117 "forward-socks4a directive in configuration file.");
1121 /* allocate a new node */
1122 cur_fwd = zalloc(sizeof(*cur_fwd));
1123 if (cur_fwd == NULL)
1125 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1126 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1130 cur_fwd->type = SOCKS_4A;
1132 /* Save the URL pattern */
1133 if (create_url_spec(cur_fwd->url, vec[0]))
1135 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1136 "directive in configuration file.");
1137 string_append(&config->proxy_args,
1138 "<br>\nWARNING: Bad URL specifier for "
1139 "forward-socks4a directive in configuration file.");
1143 /* Parse the SOCKS proxy host[:port] */
1146 cur_fwd->gateway_host = strdup(p);
1148 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1151 cur_fwd->gateway_port = atoi(p);
1153 if (cur_fwd->gateway_port <= 0)
1155 cur_fwd->gateway_port = 1080;
1158 /* Parse the parent HTTP proxy host[:port] */
1161 if (strcmp(p, ".") != 0)
1163 cur_fwd->forward_host = strdup(p);
1165 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1168 cur_fwd->forward_port = atoi(p);
1171 if (cur_fwd->forward_port <= 0)
1173 cur_fwd->forward_port = 8000;
1178 cur_fwd->next = config->forward;
1179 config->forward = cur_fwd;
1183 /* *************************************************************************
1184 * forwarded-connect-retries n
1185 * *************************************************************************/
1186 case hash_forwarded_connect_retries :
1187 config->forwarded_connect_retries = atoi(arg);
1190 /* *************************************************************************
1191 * jarfile jar-file-name
1192 * In logdir by default
1193 * *************************************************************************/
1194 #ifdef FEATURE_COOKIE_JAR
1196 freez(config->jarfile);
1197 config->jarfile = make_path(config->logdir, arg);
1199 #endif /* def FEATURE_COOKIE_JAR */
1201 /* *************************************************************************
1202 * listen-address [ip][:port]
1203 * *************************************************************************/
1204 case hash_listen_address :
1205 freez(config->haddr);
1206 config->haddr = strdup(arg);
1209 /* *************************************************************************
1210 * logdir directory-name
1211 * *************************************************************************/
1213 freez(config->logdir);
1214 config->logdir = make_path(NULL, arg);
1217 /* *************************************************************************
1218 * logfile log-file-name
1219 * In logdir by default
1220 * *************************************************************************/
1222 freez(config->logfile);
1223 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1226 /* *************************************************************************
1227 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1228 * *************************************************************************/
1230 case hash_permit_access:
1231 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1233 if ((vec_count != 1) && (vec_count != 2))
1235 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1236 "permit-access directive in configuration file.");
1237 string_append(&config->proxy_args,
1238 "<br>\nWARNING: Wrong number of parameters for "
1239 "permit-access directive in configuration file.<br><br>\n");
1244 /* allocate a new node */
1245 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1247 if (cur_acl == NULL)
1249 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1250 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1253 cur_acl->action = ACL_PERMIT;
1255 if (acl_addr(vec[0], cur_acl->src) < 0)
1257 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1258 "directive in configuration file: \"%s\"", vec[0]);
1259 string_append(&config->proxy_args,
1260 "<br>\nWARNING: Invalid source IP for permit-access directive"
1261 " in configuration file: \"");
1262 string_append(&config->proxy_args,
1264 string_append(&config->proxy_args,
1271 if (acl_addr(vec[1], cur_acl->dst) < 0)
1273 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1274 "permit-access directive in configuration file: \"%s\"",
1276 string_append(&config->proxy_args,
1277 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1278 " in configuration file: \"");
1279 string_append(&config->proxy_args,
1281 string_append(&config->proxy_args,
1289 * Add it to the list. Note we reverse the list to get the
1290 * behaviour the user expects. With both the ACL and
1291 * actions file, the last match wins. However, the internal
1292 * implementations are different: The actions file is stored
1293 * in the same order as the file, and scanned completely.
1294 * With the ACL, we reverse the order as we load it, then
1295 * when we scan it we stop as soon as we get a match.
1297 cur_acl->next = config->acl;
1298 config->acl = cur_acl;
1301 #endif /* def FEATURE_ACL */
1303 /* *************************************************************************
1304 * proxy-info-url url
1305 * *************************************************************************/
1306 case hash_proxy_info_url :
1307 freez(config->proxy_info_url);
1308 config->proxy_info_url = strdup(arg);
1311 /* *************************************************************************
1313 * *************************************************************************/
1314 case hash_single_threaded :
1315 config->multi_threaded = 0;
1318 /* *************************************************************************
1319 * split-large-cgi-forms
1320 * *************************************************************************/
1321 case hash_split_large_cgi_forms :
1322 if ((*arg != '\0') && (0 != atoi(arg)))
1324 config->feature_flags |= RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1328 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1332 /* *************************************************************************
1334 * *************************************************************************/
1335 #ifdef FEATURE_TOGGLE
1337 global_toggle_state = atoi(arg);
1339 #endif /* def FEATURE_TOGGLE */
1341 /* *************************************************************************
1342 * trust-info-url url
1343 * *************************************************************************/
1344 #ifdef FEATURE_TRUST
1345 case hash_trust_info_url :
1346 enlist(config->trust_info, arg);
1348 #endif /* def FEATURE_TRUST */
1350 /* *************************************************************************
1351 * trustfile filename
1352 * (In confdir by default.)
1353 * *************************************************************************/
1354 #ifdef FEATURE_TRUST
1355 case hash_trustfile :
1356 freez(config->trustfile);
1357 config->trustfile = make_path(config->confdir, arg);
1359 #endif /* def FEATURE_TRUST */
1361 /* *************************************************************************
1363 * *************************************************************************/
1364 case hash_usermanual :
1365 freez(config->usermanual);
1366 config->usermanual = strdup(arg);
1369 /* *************************************************************************
1370 * Win32 Console options:
1371 * *************************************************************************/
1373 /* *************************************************************************
1375 * *************************************************************************/
1377 case hash_hide_console :
1380 #endif /*def _WIN_CONSOLE*/
1383 /* *************************************************************************
1384 * Win32 GUI options:
1385 * *************************************************************************/
1387 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1388 /* *************************************************************************
1389 * activity-animation (0|1)
1390 * *************************************************************************/
1391 case hash_activity_animation :
1392 g_bShowActivityAnimation = atoi(arg);
1395 /* *************************************************************************
1396 * close-button-minimizes (0|1)
1397 * *************************************************************************/
1398 case hash_close_button_minimizes :
1399 g_bCloseHidesWindow = atoi(arg);
1402 /* *************************************************************************
1403 * log-buffer-size (0|1)
1404 * *************************************************************************/
1405 case hash_log_buffer_size :
1406 g_bLimitBufferSize = atoi(arg);
1409 /* *************************************************************************
1410 * log-font-name fontnane
1411 * *************************************************************************/
1412 case hash_log_font_name :
1413 strcpy( g_szFontFaceName, arg );
1416 /* *************************************************************************
1418 * *************************************************************************/
1419 case hash_log_font_size :
1420 g_nFontSize = atoi(arg);
1423 /* *************************************************************************
1424 * log-highlight-messages (0|1)
1425 * *************************************************************************/
1426 case hash_log_highlight_messages :
1427 g_bHighlightMessages = atoi(arg);
1430 /* *************************************************************************
1432 * *************************************************************************/
1433 case hash_log_max_lines :
1434 g_nMaxBufferLines = atoi(arg);
1437 /* *************************************************************************
1438 * log-messages (0|1)
1439 * *************************************************************************/
1440 case hash_log_messages :
1441 g_bLogMessages = atoi(arg);
1444 /* *************************************************************************
1445 * show-on-task-bar (0|1)
1446 * *************************************************************************/
1447 case hash_show_on_task_bar :
1448 g_bShowOnTaskBar = atoi(arg);
1451 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1454 /* *************************************************************************
1455 * Warnings about unsupported features
1456 * *************************************************************************/
1458 case hash_deny_access:
1459 #endif /* ndef FEATURE_ACL */
1460 #ifndef FEATURE_CGI_EDIT_ACTIONS
1461 case hash_enable_edit_actions:
1462 case hash_enable_remote_toggle:
1463 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1464 #ifndef FEATURE_COOKIE_JAR
1466 #endif /* ndef FEATURE_COOKIE_JAR */
1468 case hash_permit_access:
1469 #endif /* ndef FEATURE_ACL */
1470 #ifndef FEATURE_TOGGLE
1472 #endif /* ndef FEATURE_TOGGLE */
1473 #ifndef FEATURE_TRUST
1474 case hash_trustfile :
1475 case hash_trust_info_url :
1476 #endif /* ndef FEATURE_TRUST */
1478 #ifndef _WIN_CONSOLE
1479 case hash_hide_console :
1480 #endif /* ndef _WIN_CONSOLE */
1482 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1483 case hash_activity_animation :
1484 case hash_close_button_minimizes :
1485 case hash_log_buffer_size :
1486 case hash_log_font_name :
1487 case hash_log_font_size :
1488 case hash_log_highlight_messages :
1489 case hash_log_max_lines :
1490 case hash_log_messages :
1491 case hash_show_on_task_bar :
1492 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1493 /* These warnings are annoying - so hide them. -- Jon */
1494 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1497 /* *************************************************************************/
1499 /* *************************************************************************/
1501 * I decided that I liked this better as a warning than an
1502 * error. To change back to an error, just change log level
1503 * to LOG_LEVEL_FATAL.
1505 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive '%s' (%luul) in line %lu "
1506 "in configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1507 string_append(&config->proxy_args,
1508 " <b><font color=\"red\">WARNING: unrecognized directive, ignored</font></b>");
1511 /* *************************************************************************/
1512 } /* end switch( hash_string(cmd) ) */
1513 } /* end while ( read_config_line(...) ) */
1517 if (NULL == config->proxy_args)
1519 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1522 init_error_log(Argv[0], config->logfile, config->debug);
1524 if (config->actions_file[0])
1526 add_loader(load_actions_file, config);
1529 if (config->re_filterfile)
1531 add_loader(load_re_filterfile, config);
1534 #ifdef FEATURE_TRUST
1535 if (config->trustfile)
1537 add_loader(load_trustfile, config);
1539 #endif /* def FEATURE_TRUST */
1541 #ifdef FEATURE_COOKIE_JAR
1542 if ( NULL != config->jarfile )
1544 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1546 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1547 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1549 setbuf(config->jar, NULL);
1551 #endif /* def FEATURE_COOKIE_JAR */
1553 if ( NULL == config->haddr )
1555 config->haddr = strdup( HADDR_DEFAULT );
1558 if ( NULL != config->haddr )
1560 if (NULL != (p = strchr(config->haddr, ':')))
1565 config->hport = atoi(p);
1569 if (config->hport <= 0)
1572 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1573 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1575 if (*config->haddr == '\0')
1577 config->haddr = NULL;
1582 * Want to run all the loaders once now.
1584 * Need to set up a fake csp, so they can get to the config.
1586 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1587 fake_csp->config = config;
1589 if (run_loader(fake_csp))
1592 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1593 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1597 /* FIXME: this is a kludge for win32 */
1598 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1600 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1601 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1602 g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1604 #ifdef FEATURE_TRUST
1605 g_trustfile = config->trustfile;
1606 #endif /* def FEATURE_TRUST */
1609 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1610 /* FIXME: end kludge */
1613 config->need_bind = 1;
1615 if (current_configfile)
1617 struct configuration_spec * oldcfg = (struct configuration_spec *)
1618 current_configfile->f;
1620 * Check if config->haddr,hport == oldcfg->haddr,hport
1622 * The following could be written more compactly as a single,
1623 * (unreadably long) if statement.
1625 config->need_bind = 0;
1626 if (config->hport != oldcfg->hport)
1628 config->need_bind = 1;
1630 else if (config->haddr == NULL)
1632 if (oldcfg->haddr != NULL)
1634 config->need_bind = 1;
1637 else if (oldcfg->haddr == NULL)
1639 config->need_bind = 1;
1641 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1643 config->need_bind = 1;
1646 current_configfile->unloader = unload_configfile;
1649 fs->next = files->next;
1652 current_configfile = fs;
1658 /*********************************************************************
1660 * Function : savearg
1662 * Description : Called from `load_config'. It saves each non-empty
1663 * and non-comment line from config into
1664 * config->proxy_args. This is used to create the
1665 * show-proxy-args page. On error, frees
1666 * config->proxy_args and sets it to NULL
1669 * 1 : command = config setting that was found
1670 * 2 : argument = the setting's argument (if any)
1671 * 3 : config = Configuration to save into.
1675 *********************************************************************/
1676 static void savearg(char *command, char *argument, struct configuration_spec * config)
1686 * Add config option name embedded in
1687 * link to it's section in the user-manual
1689 buf = strdup("\n<a href=\"");
1690 if (!strncmpic(config->usermanual, "file://", 7) ||
1691 !strncmpic(config->usermanual, "http", 4))
1693 string_append(&buf, config->usermanual);
1697 string_append(&buf, "http://");
1698 string_append(&buf, CGI_SITE_2_HOST);
1699 string_append(&buf, "/user-manual/");
1701 string_append(&buf, CONFIG_HELP_PREFIX);
1702 string_join (&buf, string_toupper(command));
1703 string_append(&buf, "\">");
1704 string_append(&buf, command);
1705 string_append(&buf, "</a> ");
1709 freez(config->proxy_args);
1713 if ( (NULL != argument) && ('\0' != *argument) )
1715 s = html_encode(argument);
1719 freez(config->proxy_args);
1723 if (strncmpic(argument, "http://", 7) == 0)
1725 string_append(&buf, "<a href=\"");
1726 string_append(&buf, s);
1727 string_append(&buf, "\">");
1728 string_join (&buf, s);
1729 string_append(&buf, "</a>");
1733 string_join (&buf, s);
1737 string_append(&buf, "<br>");
1738 string_join(&config->proxy_args, buf);