1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.58 2006/12/31 14:24:29 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.58 2006/12/31 14:24:29 fabiankeil
39 * Fix gcc43 compiler warnings.
41 * Revision 1.57 2006/12/21 12:57:48 fabiankeil
42 * Add config option "split-large-forms"
43 * to work around the browser bug reported
46 * Revision 1.56 2006/12/17 17:04:51 fabiankeil
47 * Move the <br> in the generated HTML for the config
48 * options from the beginning of the string to its end.
49 * Keeps the white space in balance.
51 * Revision 1.55 2006/11/28 15:31:52 fabiankeil
52 * Fix memory leak in case of config file reloads.
54 * Revision 1.54 2006/10/21 16:04:22 fabiankeil
55 * Modified kludge for win32 to make ming32 menu
56 * "Options/Edit Filters" (sort of) work again.
57 * Same limitations as for the action files apply.
60 * Revision 1.53 2006/09/06 18:45:03 fabiankeil
61 * Incorporate modified version of Roland Rosenfeld's patch to
62 * optionally access the user-manual via Privoxy. Closes patch 679075.
64 * Formatting changed to Privoxy style, added call to
65 * cgi_error_no_template if the requested file doesn't
66 * exist and modified check whether or not Privoxy itself
67 * should serve the manual. Should work cross-platform now.
69 * Revision 1.52 2006/09/06 10:43:32 fabiankeil
70 * Added config option enable-remote-http-toggle
71 * to specify if Privoxy should recognize special
72 * headers (currently only X-Filter) to change its
73 * behaviour. Disabled by default.
75 * Revision 1.51 2006/09/06 09:23:37 fabiankeil
76 * Make number of retries in case of forwarded-connect problems
77 * a config file option (forwarded-connect-retries) and use 0 as
80 * Revision 1.50 2006/07/18 14:48:46 david__schmidt
81 * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch)
82 * with what was really the latest development (the v_3_0_branch branch)
84 * Revision 1.48.2.7 2006/02/02 17:29:16 david__schmidt
85 * Don't forget to malloc space for the null terminator...
87 * Revision 1.48.2.6 2006/01/29 23:10:56 david__schmidt
88 * Multiple filter file support
90 * Revision 1.48.2.5 2003/05/08 15:17:25 oes
91 * Closed two memory leaks; hopefully the last remaining ones
92 * (in the main execution paths, anyway).
94 * Revision 1.48.2.4 2003/04/11 12:06:14 oes
95 * Addressed bug #719435
96 * - Extraneous filterfile directives now logged as errors
97 * - This and unrecnonised directives now really obvious on status page
99 * Revision 1.48.2.3 2003/03/11 11:53:59 oes
100 * Cosmetic: Renamed cryptic variable
102 * Revision 1.48.2.2 2002/11/12 16:28:20 oes
103 * Move unrelated variable declaration out of #ifdef FEATURE_ACL; fixes bug #636655
105 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
106 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
108 * Revision 1.48 2002/05/14 21:30:38 oes
109 * savearg now uses own linking code instead of (now special-cased) add_help_link
111 * Revision 1.47 2002/05/12 21:36:29 jongfoster
112 * Correcting function comments
114 * Revision 1.46 2002/04/26 12:55:14 oes
115 * - New option "user-manual", defaults to our site
116 * via project.h #define
117 * - savearg now embeds option names in help links
119 * Revision 1.45 2002/04/24 02:11:54 oes
120 * Jon's multiple AF patch: Allow up to MAX_AF_FILES actionsfile options
122 * Revision 1.44 2002/04/08 20:37:13 swa
125 * Revision 1.43 2002/04/08 20:36:50 swa
128 * Revision 1.42 2002/04/05 15:50:15 oes
129 * fix for invalid HTML proxy_args
131 * Revision 1.41 2002/03/31 17:19:00 jongfoster
132 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
134 * Revision 1.40 2002/03/26 22:29:55 swa
135 * we have a new homepage!
137 * Revision 1.39 2002/03/24 13:25:43 swa
138 * name change related issues
140 * Revision 1.38 2002/03/24 13:05:48 jongfoster
141 * Renaming re_filterfile to filterfile
143 * Revision 1.37 2002/03/16 23:54:06 jongfoster
144 * Adding graceful termination feature, to help look for memory leaks.
145 * If you enable this (which, by design, has to be done by hand
146 * editing config.h) and then go to http://i.j.b/die, then the program
147 * will exit cleanly after the *next* request. It should free all the
148 * memory that was used.
150 * Revision 1.36 2002/03/13 00:27:05 jongfoster
153 * Revision 1.35 2002/03/07 03:52:44 oes
154 * Set logging to tty for --no-daemon mode
156 * Revision 1.34 2002/03/06 23:14:35 jongfoster
157 * Trivial cosmetic changes to make function comments easier to find.
159 * Revision 1.33 2002/03/05 04:52:42 oes
160 * Deleted non-errlog debugging code
162 * Revision 1.32 2002/03/04 18:24:53 oes
163 * Re-enabled output of unknown config directive hash
165 * Revision 1.31 2002/03/03 15:07:20 oes
166 * Re-enabled automatic config reloading
168 * Revision 1.30 2002/01/22 23:31:43 jongfoster
169 * Replacing strsav() with string_append()
171 * Revision 1.29 2002/01/17 21:02:30 jongfoster
172 * Moving all our URL and URL pattern parsing code to urlmatch.c.
174 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
176 * Revision 1.28 2001/12/30 14:07:32 steudten
177 * - Add signal handling (unix)
178 * - Add SIGHUP handler (unix)
179 * - Add creation of pidfile (unix)
180 * - Add action 'top' in rc file (RH)
181 * - Add entry 'SIGNALS' to manpage
182 * - Add exit message to logfile (unix)
184 * Revision 1.27 2001/11/07 00:02:13 steudten
185 * Add line number in error output for lineparsing for
186 * actionsfile and configfile.
187 * Special handling for CLF added.
189 * Revision 1.26 2001/11/05 21:41:43 steudten
190 * Add changes to be a real daemon just for unix os.
191 * (change cwd to /, detach from controlling tty, set
192 * process group and session leader to the own process.
194 * Add some fatal-error log message for failed malloc().
195 * Add '-d' if compiled with 'configure --with-debug' to
196 * enable debug output.
198 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
199 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
200 * threads to call select() simultaneously. So, it's time to do a real, live,
201 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
202 * (native). Both versions will work, but using __OS2__ offers multi-threading.
204 * Revision 1.24 2001/10/23 21:40:30 jongfoster
205 * Added support for enable-edit-actions and enable-remote-toggle config
208 * Revision 1.23 2001/10/07 15:36:00 oes
209 * Introduced new config option "buffer-limit"
211 * Revision 1.22 2001/09/22 16:36:59 jongfoster
212 * Removing unused parameter fs from read_config_line()
214 * Revision 1.21 2001/09/16 17:10:43 jongfoster
215 * Moving function savearg() here, since it was the only thing left in
218 * Revision 1.20 2001/07/30 22:08:36 jongfoster
219 * Tidying up #defines:
220 * - All feature #defines are now of the form FEATURE_xxx
221 * - Permanently turned off WIN_GUI_EDIT
222 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
224 * Revision 1.19 2001/07/15 17:45:16 jongfoster
225 * Removing some unused #includes
227 * Revision 1.18 2001/07/13 14:01:14 oes
228 * - Removed all #ifdef PCRS
229 * - Removed vim-settings
231 * Revision 1.17 2001/06/29 13:31:03 oes
232 * - Improved comments
233 * - Fixed (actionsfile) and sorted hashes
234 * - Introduced admin_address and proxy-info-url
235 * as config parameters
236 * - Renamed config->proxy_args_invocation (which didn't have
237 * the invocation but the options!) to config->proxy_args
238 * - Various adaptions
239 * - Removed logentry from cancelled commit
241 * Revision 1.16 2001/06/09 10:55:28 jongfoster
242 * Changing BUFSIZ ==> BUFFER_SIZE
244 * Revision 1.15 2001/06/07 23:13:40 jongfoster
245 * Merging ACL and forward files into config file.
246 * Cosmetic: Sorting config file options alphabetically.
247 * Cosmetic: Adding brief syntax comments to config file options.
249 * Revision 1.14 2001/06/07 14:46:25 joergs
250 * Missing make_path() added for re_filterfile.
252 * Revision 1.13 2001/06/05 22:33:54 jongfoster
254 * Fixed minor memory leak.
255 * Also now uses make_path to prepend the pathnames.
257 * Revision 1.12 2001/06/05 20:04:09 jongfoster
258 * Now uses _snprintf() in place of snprintf() under Win32.
260 * Revision 1.11 2001/06/04 18:31:58 swa
261 * files are now prefixed with either `confdir' or `logdir'.
262 * `make redhat-dist' replaces both entries confdir and logdir
265 * Revision 1.10 2001/06/03 19:11:54 oes
266 * introduced confdir option
268 * Revision 1.9 2001/06/01 20:06:24 jongfoster
269 * Removed support for "tinygif" option - moved to actions file.
271 * Revision 1.8 2001/05/31 21:27:13 jongfoster
272 * Removed many options from the config file and into the
273 * "actions" file: add_forwarded, suppress_vanilla_wafer,
274 * wafer, add_header, user_agent, referer, from
275 * Also globally replaced "permission" with "action".
277 * Revision 1.7 2001/05/29 09:50:24 jongfoster
278 * Unified blocklist/imagelist/permissionslist.
279 * File format is still under discussion, but the internal changes
282 * Also modified interceptor behaviour:
283 * - We now intercept all URLs beginning with one of the following
284 * prefixes (and *only* these prefixes):
286 * * http://ijbswa.sf.net/config/
287 * * http://ijbswa.sourceforge.net/config/
288 * - New interceptors "home page" - go to http://i.j.b/ to see it.
289 * - Internal changes so that intercepted and fast redirect pages
290 * are not replaced with an image.
291 * - Interceptors now have the option to send a binary page direct
292 * to the client. (i.e. ijb-send-banner uses this)
293 * - Implemented show-url-info interceptor. (Which is why I needed
294 * the above interceptors changes - a typical URL is
295 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
296 * The previous mechanism would not have intercepted that, and
297 * if it had been intercepted then it then it would have replaced
300 * Revision 1.6 2001/05/26 00:28:36 jongfoster
301 * Automatic reloading of config file.
302 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
303 * Most of the global variables have been moved to a new
304 * struct configuration_spec, accessed through csp->config->globalname
305 * Most of the globals remaining are used by the Win32 GUI.
307 * Revision 1.5 2001/05/25 22:34:30 jongfoster
310 * Revision 1.4 2001/05/22 18:46:04 oes
312 * - Enabled filtering banners by size rather than URL
313 * by adding patterns that replace all standard banner
314 * sizes with the "Junkbuster" gif to the re_filterfile
316 * - Enabled filtering WebBugs by providing a pattern
317 * which kills all 1x1 images
319 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
320 * which is selected by the (nonstandard and therefore
321 * capital) letter 'U' in the option string.
322 * It causes the quantifiers to be ungreedy by default.
323 * Appending a ? turns back to greedy (!).
325 * - Added a new interceptor ijb-send-banner, which
326 * sends back the "Junkbuster" gif. Without imagelist or
327 * MSIE detection support, or if tinygif = 1, or the
328 * URL isn't recognized as an imageurl, a lame HTML
329 * explanation is sent instead.
331 * - Added new feature, which permits blocking remote
332 * script redirects and firing back a local redirect
334 * The feature is conditionally compiled, i.e. it
335 * can be disabled with --disable-fast-redirects,
336 * plus it must be activated by a "fast-redirects"
337 * line in the config file, has its own log level
338 * and of course wants to be displayed by show-proxy-args
339 * Note: Boy, all the #ifdefs in 1001 locations and
340 * all the fumbling with configure.in and acconfig.h
341 * were *way* more work than the feature itself :-(
343 * - Because a generic redirect template was needed for
344 * this, tinygif = 3 now uses the same.
346 * - Moved GIFs, and other static HTTP response templates
351 * - Removed some >400 CRs again (Jon, you really worked
354 * Revision 1.3 2001/05/20 01:21:20 jongfoster
355 * Version 2.9.4 checkin.
356 * - Merged popupfile and cookiefile, and added control over PCRS
357 * filtering, in new "permissionsfile".
358 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
359 * file error you now get a message box (in the Win32 GUI) rather
360 * than the program exiting with no explanation.
361 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
363 * - Removed tabs from "config"
364 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
365 * - Bumped up version number.
367 * Revision 1.2 2001/05/17 23:01:01 oes
368 * - Cleaned CRLF's from the sources and related files
370 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
371 * Initial import of version 2.9.3 source tree
374 *********************************************************************/
380 #include <sys/types.h>
394 # include <windows.h>
397 # ifndef _WIN_CONSOLE
399 # endif /* ndef _WIN_CONSOLE */
401 /* VC++ has "_snprintf", not "snprintf" */
402 #define snprintf _snprintf
404 #else /* ifndef _WIN32 */
408 # include <sys/wait.h>
410 # include <sys/time.h>
411 # include <sys/stat.h>
421 #include "miscutil.h"
425 #include "urlmatch.h"
428 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
431 * Fix a problem with Solaris. There should be no effect on other
433 * Solaris's isspace() is a macro which uses it's argument directly
434 * as an array index. Therefore we need to make sure that high-bit
435 * characters generate +ve values, and ideally we also want to make
436 * the argument match the declared parameter type of "int".
438 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
439 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
441 #ifdef FEATURE_TOGGLE
442 /* Privoxy is enabled by default. */
443 int global_toggle_state = 1;
444 #endif /* def FEATURE_TOGGLE */
446 /* The filename of the configfile */
447 const char *configfile = NULL;
450 * CGI functions will later need access to the invocation args,
451 * so we will make argc and argv global.
454 const char **Argv = NULL;
456 static struct file_list *current_configfile = NULL;
460 * This takes the "cryptic" hash of each keyword and aliases them to
461 * something a little more readable. This also makes changing the
462 * hash values easier if they should change or the hash algorthm changes.
463 * Use the included "hash" program to find out what the hash will be
464 * for any string supplied on the command line. (Or just put it in the
465 * config file and read the number from the error message in the log).
467 * Please keep this list sorted alphabetically (but with the Windows
468 * console and GUI specific options last).
471 #define hash_actions_file 1196306641ul /* "actionsfile" */
472 #define hash_accept_intercepted_requests 1513024973ul /* "accept-intercepted-requests" */
473 #define hash_admin_address 4112573064ul /* "admin-address" */
474 #define hash_buffer_limit 1881726070ul /* "buffer-limit */
475 #define hash_confdir 1978389ul /* "confdir" */
476 #define hash_debug 78263ul /* "debug" */
477 #define hash_deny_access 1227333715ul /* "deny-access" */
478 #define hash_enable_edit_actions 2517097536ul /* "enable-edit-actions" */
479 #define hash_enable_remote_toggle 2979744683ul /* "enable-remote-toggle" */
480 #define hash_enable_remote_http_toggle 110543988ul /* "enable-remote-http-toggle" */
481 #define hash_filterfile 250887266ul /* "filterfile" */
482 #define hash_forward 2029845ul /* "forward" */
483 #define hash_forward_socks4 3963965521ul /* "forward-socks4" */
484 #define hash_forward_socks4a 2639958518ul /* "forward-socks4a" */
485 #define hash_forwarded_connect_retries 101465292ul /* "forwarded-connect-retries" */
486 #define hash_jarfile 2046641ul /* "jarfile" */
487 #define hash_listen_address 1255650842ul /* "listen-address" */
488 #define hash_logdir 422889ul /* "logdir" */
489 #define hash_logfile 2114766ul /* "logfile" */
490 #define hash_permit_access 3587953268ul /* "permit-access" */
491 #define hash_proxy_info_url 3903079059ul /* "proxy-info-url" */
492 #define hash_single_threaded 4250084780ul /* "single-threaded" */
493 #define hash_split_large_cgi_forms 671658948ul /* "split-large-cgi-forms" */
494 #define hash_suppress_blocklists 1948693308ul /* "suppress-blocklists" */
495 #define hash_toggle 447966ul /* "toggle" */
496 #define hash_trust_info_url 430331967ul /* "trust-info-url" */
497 #define hash_trustfile 56494766ul /* "trustfile" */
498 #define hash_usermanual 1416668518ul /* "user-manual" */
499 #define hash_activity_animation 1817904738ul /* "activity-animation" */
500 #define hash_close_button_minimizes 3651284693ul /* "close-button-minimizes" */
501 #define hash_hide_console 2048809870ul /* "hide-console" */
502 #define hash_log_buffer_size 2918070425ul /* "log-buffer-size" */
503 #define hash_log_font_name 2866730124ul /* "log-font-name" */
504 #define hash_log_font_size 2866731014ul /* "log-font-size" */
505 #define hash_log_highlight_messages 4032101240ul /* "log-highlight-messages" */
506 #define hash_log_max_lines 2868344173ul /* "log-max-lines" */
507 #define hash_log_messages 2291744899ul /* "log-messages" */
508 #define hash_show_on_task_bar 215410365ul /* "show-on-task-bar" */
511 static void savearg(char *command, char *argument, struct configuration_spec * config);
513 /*********************************************************************
515 * Function : unload_configfile
517 * Description : Free the config structure and all components.
520 * 1 : data: struct configuration_spec to unload
524 *********************************************************************/
525 void unload_configfile (void * data)
527 struct configuration_spec * config = (struct configuration_spec *)data;
528 struct forward_spec *cur_fwd = config->forward;
532 struct access_control_list *cur_acl = config->acl;
534 while (cur_acl != NULL)
536 struct access_control_list * next_acl = cur_acl->next;
541 #endif /* def FEATURE_ACL */
543 while (cur_fwd != NULL)
545 struct forward_spec * next_fwd = cur_fwd->next;
546 free_url_spec(cur_fwd->url);
548 freez(cur_fwd->gateway_host);
549 freez(cur_fwd->forward_host);
553 config->forward = NULL;
555 #ifdef FEATURE_COOKIE_JAR
556 if ( NULL != config->jar )
558 fclose( config->jar );
561 #endif /* def FEATURE_COOKIE_JAR */
563 freez(config->confdir);
564 freez(config->logdir);
566 freez(config->haddr);
567 freez(config->logfile);
569 for (i = 0; i < MAX_AF_FILES; i++)
571 freez(config->actions_file_short[i]);
572 freez(config->actions_file[i]);
573 freez(config->re_filterfile_short[i]);
574 freez(config->re_filterfile[i]);
577 freez(config->admin_address);
578 freez(config->proxy_info_url);
579 freez(config->proxy_args);
580 freez(config->usermanual);
582 #ifdef FEATURE_COOKIE_JAR
583 freez(config->jarfile);
584 #endif /* def FEATURE_COOKIE_JAR */
587 freez(config->trustfile);
588 list_remove_all(config->trust_info);
589 #endif /* def FEATURE_TRUST */
591 for (i = 0; i < MAX_AF_FILES; i++)
593 freez(config->re_filterfile[i]);
600 #ifdef FEATURE_GRACEFUL_TERMINATION
601 /*********************************************************************
603 * Function : unload_current_config_file
605 * Description : Unloads current config file - reset to state at
606 * beginning of program.
612 *********************************************************************/
613 void unload_current_config_file(void)
615 if (current_configfile)
617 current_configfile->unloader = unload_configfile;
618 current_configfile = NULL;
624 /*********************************************************************
626 * Function : load_config
628 * Description : Load the config file and all parameters.
632 * Returns : The configuration_spec, or NULL on error.
634 *********************************************************************/
635 struct configuration_spec * load_config(void)
637 char buf[BUFFER_SIZE];
639 FILE *configfp = NULL;
640 struct configuration_spec * config = NULL;
641 struct client_state * fake_csp;
642 struct file_list *fs;
643 unsigned long linenum = 0;
646 if ( !check_file_changed(current_configfile, configfile, &fs))
648 /* No need to load */
649 return ((struct configuration_spec *)current_configfile->f);
653 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
657 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
659 #ifdef FEATURE_TOGGLE
660 global_toggle_state = 1;
661 #endif /* def FEATURE_TOGGLE */
663 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
669 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
670 /* Never get here - LOG_LEVEL_FATAL causes program exit */
674 * This is backwards from how it's usually done.
675 * Following the usual pattern, "fs" would be stored in a member
676 * variable in "csp", and then we'd access "config" from "fs->f",
677 * using a cast. However, "config" is used so often that a
678 * cast each time would be very ugly, and the extra indirection
679 * would waste CPU cycles. Therefore we store "config" in
680 * "csp->config", and "fs" in "csp->config->config_file_list".
682 config->config_file_list = fs;
687 config->multi_threaded = 1;
688 config->hport = HADDR_PORT;
689 config->buffer_limit = 4096 * 1024;
690 config->usermanual = strdup(USER_MANUAL_URL);
691 config->proxy_args = strdup("");
692 config->forwarded_connect_retries = 0;
693 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
694 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
695 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
697 if ((configfp = fopen(configfile, "r")) == NULL)
699 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
701 /* Never get here - LOG_LEVEL_FATAL causes program exit */
704 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
706 char cmd[BUFFER_SIZE];
707 char arg[BUFFER_SIZE];
708 char tmp[BUFFER_SIZE];
710 struct access_control_list *cur_acl;
711 #endif /* def FEATURE_ACL */
712 struct forward_spec *cur_fwd;
718 /* Copy command (i.e. up to space or tab) into cmd */
721 while (*p && (*p != ' ') && (*p != '\t'))
727 /* Skip over the whitespace in buf */
728 while (*p && ((*p == ' ') || (*p == '\t')))
733 /* Copy the argument into arg */
736 /* Should never happen, but check this anyway */
742 /* Make sure the command field is lower case */
747 *p = (char)ijb_tolower(*p);
751 /* Save the argument for show-proxy-args */
752 savearg(cmd, arg, config);
755 switch( hash_string( cmd ) )
757 /* *************************************************************************
758 * actionsfile actions-file-name
759 * In confdir by default
760 * *************************************************************************/
761 case hash_actions_file :
763 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
768 if (i >= MAX_AF_FILES)
770 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
771 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
774 config->actions_file_short[i] = strdup(arg);
775 p = malloc(strlen(arg) + sizeof(".action"));
778 log_error(LOG_LEVEL_FATAL, "Out of memory");
781 strcat(p, ".action");
782 config->actions_file[i] = make_path(config->confdir, p);
785 /* *************************************************************************
786 * accept-intercepted-requests
787 * *************************************************************************/
788 case hash_accept_intercepted_requests:
789 if ((*arg != '\0') && (0 != atoi(arg)))
791 config->feature_flags |= RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
795 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
799 /* *************************************************************************
800 * admin-address email-address
801 * *************************************************************************/
802 case hash_admin_address :
803 freez(config->admin_address);
804 config->admin_address = strdup(arg);
807 /* *************************************************************************
809 * *************************************************************************/
810 case hash_buffer_limit :
811 config->buffer_limit = (size_t)(1024 * atoi(arg));
814 /* *************************************************************************
815 * confdir directory-name
816 * *************************************************************************/
818 freez(config->confdir);
819 config->confdir = make_path( NULL, arg);
822 /* *************************************************************************
824 * Specifies debug level, multiple values are ORed together.
825 * *************************************************************************/
827 config->debug |= atoi(arg);
830 /* *************************************************************************
831 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
832 * *************************************************************************/
834 case hash_deny_access:
835 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
837 if ((vec_count != 1) && (vec_count != 2))
839 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
840 "deny-access directive in configuration file.");
841 string_append(&config->proxy_args,
842 "<br>\nWARNING: Wrong number of parameters for "
843 "deny-access directive in configuration file.<br><br>\n");
847 /* allocate a new node */
848 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
852 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
853 /* Never get here - LOG_LEVEL_FATAL causes program exit */
856 cur_acl->action = ACL_DENY;
858 if (acl_addr(vec[0], cur_acl->src) < 0)
860 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
861 "directive in configuration file: \"%s\"", vec[0]);
862 string_append(&config->proxy_args,
863 "<br>\nWARNING: Invalid source IP for deny-access directive"
864 " in configuration file: \"");
865 string_append(&config->proxy_args,
867 string_append(&config->proxy_args,
874 if (acl_addr(vec[1], cur_acl->dst) < 0)
876 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
877 "directive in configuration file: \"%s\"", vec[0]);
878 string_append(&config->proxy_args,
879 "<br>\nWARNING: Invalid destination IP for deny-access directive"
880 " in configuration file: \"");
881 string_append(&config->proxy_args,
883 string_append(&config->proxy_args,
891 * Add it to the list. Note we reverse the list to get the
892 * behaviour the user expects. With both the ACL and
893 * actions file, the last match wins. However, the internal
894 * implementations are different: The actions file is stored
895 * in the same order as the file, and scanned completely.
896 * With the ACL, we reverse the order as we load it, then
897 * when we scan it we stop as soon as we get a match.
899 cur_acl->next = config->acl;
900 config->acl = cur_acl;
903 #endif /* def FEATURE_ACL */
905 /* *************************************************************************
906 * enable-edit-actions 0|1
907 * *************************************************************************/
908 #ifdef FEATURE_CGI_EDIT_ACTIONS
909 case hash_enable_edit_actions:
910 if ((*arg != '\0') && (0 != atoi(arg)))
912 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
916 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
919 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
921 /* *************************************************************************
922 * enable-remote-toggle 0|1
923 * *************************************************************************/
924 #ifdef FEATURE_CGI_EDIT_ACTIONS
925 case hash_enable_remote_toggle:
926 if ((*arg != '\0') && (0 != atoi(arg)))
928 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
932 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
935 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
937 /* *************************************************************************
938 * enable-remote-http-toggle 0|1
939 * *************************************************************************/
940 case hash_enable_remote_http_toggle:
941 if ((*arg != '\0') && (0 != atoi(arg)))
943 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
947 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
951 /* *************************************************************************
952 * filterfile file-name
953 * In confdir by default.
954 * *************************************************************************/
955 case hash_filterfile :
957 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
962 if (i >= MAX_AF_FILES)
964 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
965 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
968 config->re_filterfile_short[i] = strdup(arg);
969 p = malloc(strlen(arg) + 1);
972 log_error(LOG_LEVEL_FATAL, "Out of memory");
975 config->re_filterfile[i] = make_path(config->confdir, p);
979 /* *************************************************************************
980 * forward url-pattern (.|http-proxy-host[:port])
981 * *************************************************************************/
983 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
987 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
988 "directive in configuration file.");
989 string_append(&config->proxy_args,
990 "<br>\nWARNING: Wrong number of parameters for "
991 "forward directive in configuration file.");
995 /* allocate a new node */
996 cur_fwd = zalloc(sizeof(*cur_fwd));
999 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1000 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1004 cur_fwd->type = SOCKS_NONE;
1006 /* Save the URL pattern */
1007 if (create_url_spec(cur_fwd->url, vec[0]))
1009 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
1010 "directive in configuration file.");
1011 string_append(&config->proxy_args,
1012 "<br>\nWARNING: Bad URL specifier for "
1013 "forward directive in configuration file.");
1017 /* Parse the parent HTTP proxy host:port */
1020 if (strcmp(p, ".") != 0)
1022 cur_fwd->forward_host = strdup(p);
1024 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1027 cur_fwd->forward_port = atoi(p);
1030 if (cur_fwd->forward_port <= 0)
1032 cur_fwd->forward_port = 8000;
1037 cur_fwd->next = config->forward;
1038 config->forward = cur_fwd;
1042 /* *************************************************************************
1043 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
1044 * *************************************************************************/
1045 case hash_forward_socks4:
1046 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1050 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1051 "forward-socks4 directive in configuration file.");
1052 string_append(&config->proxy_args,
1053 "<br>\nWARNING: Wrong number of parameters for "
1054 "forward-socks4 directive in configuration file.");
1058 /* allocate a new node */
1059 cur_fwd = zalloc(sizeof(*cur_fwd));
1060 if (cur_fwd == NULL)
1062 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1063 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1067 cur_fwd->type = SOCKS_4;
1069 /* Save the URL pattern */
1070 if (create_url_spec(cur_fwd->url, vec[0]))
1072 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
1073 "directive in configuration file.");
1074 string_append(&config->proxy_args,
1075 "<br>\nWARNING: Bad URL specifier for "
1076 "forward-socks4 directive in configuration file.");
1080 /* Parse the SOCKS proxy host[:port] */
1083 if (strcmp(p, ".") != 0)
1085 cur_fwd->gateway_host = strdup(p);
1087 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1090 cur_fwd->gateway_port = atoi(p);
1092 if (cur_fwd->gateway_port <= 0)
1094 cur_fwd->gateway_port = 1080;
1098 /* Parse the parent HTTP proxy host[:port] */
1101 if (strcmp(p, ".") != 0)
1103 cur_fwd->forward_host = strdup(p);
1105 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1108 cur_fwd->forward_port = atoi(p);
1111 if (cur_fwd->forward_port <= 0)
1113 cur_fwd->forward_port = 8000;
1118 cur_fwd->next = config->forward;
1119 config->forward = cur_fwd;
1123 /* *************************************************************************
1124 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1125 * *************************************************************************/
1126 case hash_forward_socks4a:
1127 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1131 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1132 "forward-socks4a directive in configuration file.");
1133 string_append(&config->proxy_args,
1134 "<br>\nWARNING: Wrong number of parameters for "
1135 "forward-socks4a directive in configuration file.");
1139 /* allocate a new node */
1140 cur_fwd = zalloc(sizeof(*cur_fwd));
1141 if (cur_fwd == NULL)
1143 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1144 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1148 cur_fwd->type = SOCKS_4A;
1150 /* Save the URL pattern */
1151 if (create_url_spec(cur_fwd->url, vec[0]))
1153 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1154 "directive in configuration file.");
1155 string_append(&config->proxy_args,
1156 "<br>\nWARNING: Bad URL specifier for "
1157 "forward-socks4a directive in configuration file.");
1161 /* Parse the SOCKS proxy host[:port] */
1164 cur_fwd->gateway_host = strdup(p);
1166 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1169 cur_fwd->gateway_port = atoi(p);
1171 if (cur_fwd->gateway_port <= 0)
1173 cur_fwd->gateway_port = 1080;
1176 /* Parse the parent HTTP proxy host[:port] */
1179 if (strcmp(p, ".") != 0)
1181 cur_fwd->forward_host = strdup(p);
1183 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1186 cur_fwd->forward_port = atoi(p);
1189 if (cur_fwd->forward_port <= 0)
1191 cur_fwd->forward_port = 8000;
1196 cur_fwd->next = config->forward;
1197 config->forward = cur_fwd;
1201 /* *************************************************************************
1202 * forwarded-connect-retries n
1203 * *************************************************************************/
1204 case hash_forwarded_connect_retries :
1205 config->forwarded_connect_retries = atoi(arg);
1208 /* *************************************************************************
1209 * jarfile jar-file-name
1210 * In logdir by default
1211 * *************************************************************************/
1212 #ifdef FEATURE_COOKIE_JAR
1214 freez(config->jarfile);
1215 config->jarfile = make_path(config->logdir, arg);
1217 #endif /* def FEATURE_COOKIE_JAR */
1219 /* *************************************************************************
1220 * listen-address [ip][:port]
1221 * *************************************************************************/
1222 case hash_listen_address :
1223 freez(config->haddr);
1224 config->haddr = strdup(arg);
1227 /* *************************************************************************
1228 * logdir directory-name
1229 * *************************************************************************/
1231 freez(config->logdir);
1232 config->logdir = make_path(NULL, arg);
1235 /* *************************************************************************
1236 * logfile log-file-name
1237 * In logdir by default
1238 * *************************************************************************/
1240 freez(config->logfile);
1241 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1244 /* *************************************************************************
1245 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1246 * *************************************************************************/
1248 case hash_permit_access:
1249 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1251 if ((vec_count != 1) && (vec_count != 2))
1253 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1254 "permit-access directive in configuration file.");
1255 string_append(&config->proxy_args,
1256 "<br>\nWARNING: Wrong number of parameters for "
1257 "permit-access directive in configuration file.<br><br>\n");
1262 /* allocate a new node */
1263 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1265 if (cur_acl == NULL)
1267 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1268 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1271 cur_acl->action = ACL_PERMIT;
1273 if (acl_addr(vec[0], cur_acl->src) < 0)
1275 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1276 "directive in configuration file: \"%s\"", vec[0]);
1277 string_append(&config->proxy_args,
1278 "<br>\nWARNING: Invalid source IP for permit-access directive"
1279 " in configuration file: \"");
1280 string_append(&config->proxy_args,
1282 string_append(&config->proxy_args,
1289 if (acl_addr(vec[1], cur_acl->dst) < 0)
1291 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1292 "permit-access directive in configuration file: \"%s\"",
1294 string_append(&config->proxy_args,
1295 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1296 " in configuration file: \"");
1297 string_append(&config->proxy_args,
1299 string_append(&config->proxy_args,
1307 * Add it to the list. Note we reverse the list to get the
1308 * behaviour the user expects. With both the ACL and
1309 * actions file, the last match wins. However, the internal
1310 * implementations are different: The actions file is stored
1311 * in the same order as the file, and scanned completely.
1312 * With the ACL, we reverse the order as we load it, then
1313 * when we scan it we stop as soon as we get a match.
1315 cur_acl->next = config->acl;
1316 config->acl = cur_acl;
1319 #endif /* def FEATURE_ACL */
1321 /* *************************************************************************
1322 * proxy-info-url url
1323 * *************************************************************************/
1324 case hash_proxy_info_url :
1325 freez(config->proxy_info_url);
1326 config->proxy_info_url = strdup(arg);
1329 /* *************************************************************************
1331 * *************************************************************************/
1332 case hash_single_threaded :
1333 config->multi_threaded = 0;
1336 /* *************************************************************************
1337 * split-large-cgi-forms
1338 * *************************************************************************/
1339 case hash_split_large_cgi_forms :
1340 if ((*arg != '\0') && (0 != atoi(arg)))
1342 config->feature_flags |= RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1346 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1350 /* *************************************************************************
1352 * *************************************************************************/
1353 #ifdef FEATURE_TOGGLE
1355 global_toggle_state = atoi(arg);
1357 #endif /* def FEATURE_TOGGLE */
1359 /* *************************************************************************
1360 * trust-info-url url
1361 * *************************************************************************/
1362 #ifdef FEATURE_TRUST
1363 case hash_trust_info_url :
1364 enlist(config->trust_info, arg);
1366 #endif /* def FEATURE_TRUST */
1368 /* *************************************************************************
1369 * trustfile filename
1370 * (In confdir by default.)
1371 * *************************************************************************/
1372 #ifdef FEATURE_TRUST
1373 case hash_trustfile :
1374 freez(config->trustfile);
1375 config->trustfile = make_path(config->confdir, arg);
1377 #endif /* def FEATURE_TRUST */
1379 /* *************************************************************************
1381 * *************************************************************************/
1382 case hash_usermanual :
1383 freez(config->usermanual);
1384 config->usermanual = strdup(arg);
1387 /* *************************************************************************
1388 * Win32 Console options:
1389 * *************************************************************************/
1391 /* *************************************************************************
1393 * *************************************************************************/
1395 case hash_hide_console :
1398 #endif /*def _WIN_CONSOLE*/
1401 /* *************************************************************************
1402 * Win32 GUI options:
1403 * *************************************************************************/
1405 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1406 /* *************************************************************************
1407 * activity-animation (0|1)
1408 * *************************************************************************/
1409 case hash_activity_animation :
1410 g_bShowActivityAnimation = atoi(arg);
1413 /* *************************************************************************
1414 * close-button-minimizes (0|1)
1415 * *************************************************************************/
1416 case hash_close_button_minimizes :
1417 g_bCloseHidesWindow = atoi(arg);
1420 /* *************************************************************************
1421 * log-buffer-size (0|1)
1422 * *************************************************************************/
1423 case hash_log_buffer_size :
1424 g_bLimitBufferSize = atoi(arg);
1427 /* *************************************************************************
1428 * log-font-name fontnane
1429 * *************************************************************************/
1430 case hash_log_font_name :
1431 strcpy( g_szFontFaceName, arg );
1434 /* *************************************************************************
1436 * *************************************************************************/
1437 case hash_log_font_size :
1438 g_nFontSize = atoi(arg);
1441 /* *************************************************************************
1442 * log-highlight-messages (0|1)
1443 * *************************************************************************/
1444 case hash_log_highlight_messages :
1445 g_bHighlightMessages = atoi(arg);
1448 /* *************************************************************************
1450 * *************************************************************************/
1451 case hash_log_max_lines :
1452 g_nMaxBufferLines = atoi(arg);
1455 /* *************************************************************************
1456 * log-messages (0|1)
1457 * *************************************************************************/
1458 case hash_log_messages :
1459 g_bLogMessages = atoi(arg);
1462 /* *************************************************************************
1463 * show-on-task-bar (0|1)
1464 * *************************************************************************/
1465 case hash_show_on_task_bar :
1466 g_bShowOnTaskBar = atoi(arg);
1469 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1472 /* *************************************************************************
1473 * Warnings about unsupported features
1474 * *************************************************************************/
1476 case hash_deny_access:
1477 #endif /* ndef FEATURE_ACL */
1478 #ifndef FEATURE_CGI_EDIT_ACTIONS
1479 case hash_enable_edit_actions:
1480 case hash_enable_remote_toggle:
1481 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1482 #ifndef FEATURE_COOKIE_JAR
1484 #endif /* ndef FEATURE_COOKIE_JAR */
1486 case hash_permit_access:
1487 #endif /* ndef FEATURE_ACL */
1488 #ifndef FEATURE_TOGGLE
1490 #endif /* ndef FEATURE_TOGGLE */
1491 #ifndef FEATURE_TRUST
1492 case hash_trustfile :
1493 case hash_trust_info_url :
1494 #endif /* ndef FEATURE_TRUST */
1496 #ifndef _WIN_CONSOLE
1497 case hash_hide_console :
1498 #endif /* ndef _WIN_CONSOLE */
1500 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1501 case hash_activity_animation :
1502 case hash_close_button_minimizes :
1503 case hash_log_buffer_size :
1504 case hash_log_font_name :
1505 case hash_log_font_size :
1506 case hash_log_highlight_messages :
1507 case hash_log_max_lines :
1508 case hash_log_messages :
1509 case hash_show_on_task_bar :
1510 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1511 /* These warnings are annoying - so hide them. -- Jon */
1512 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1515 /* *************************************************************************/
1517 /* *************************************************************************/
1519 * I decided that I liked this better as a warning than an
1520 * error. To change back to an error, just change log level
1521 * to LOG_LEVEL_FATAL.
1523 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive '%s' (%luul) in line %lu "
1524 "in configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1525 string_append(&config->proxy_args,
1526 " <b><font color=\"red\">WARNING: unrecognized directive, ignored</font></b>");
1529 /* *************************************************************************/
1530 } /* end switch( hash_string(cmd) ) */
1531 } /* end while ( read_config_line(...) ) */
1535 if (NULL == config->proxy_args)
1537 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1540 init_error_log(Argv[0], config->logfile, config->debug);
1542 if (config->actions_file[0])
1544 add_loader(load_actions_file, config);
1547 if (config->re_filterfile)
1549 add_loader(load_re_filterfile, config);
1552 #ifdef FEATURE_TRUST
1553 if (config->trustfile)
1555 add_loader(load_trustfile, config);
1557 #endif /* def FEATURE_TRUST */
1559 #ifdef FEATURE_COOKIE_JAR
1560 if ( NULL != config->jarfile )
1562 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1564 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1565 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1567 setbuf(config->jar, NULL);
1569 #endif /* def FEATURE_COOKIE_JAR */
1571 if ( NULL == config->haddr )
1573 config->haddr = strdup( HADDR_DEFAULT );
1576 if ( NULL != config->haddr )
1578 if (NULL != (p = strchr(config->haddr, ':')))
1583 config->hport = atoi(p);
1587 if (config->hport <= 0)
1590 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1591 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1593 if (*config->haddr == '\0')
1595 config->haddr = NULL;
1600 * Want to run all the loaders once now.
1602 * Need to set up a fake csp, so they can get to the config.
1604 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1605 fake_csp->config = config;
1607 if (run_loader(fake_csp))
1610 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1611 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1615 /* FIXME: this is a kludge for win32 */
1616 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1618 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1619 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1620 g_re_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1622 #ifdef FEATURE_TRUST
1623 g_trustfile = config->trustfile;
1624 #endif /* def FEATURE_TRUST */
1627 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1628 /* FIXME: end kludge */
1631 config->need_bind = 1;
1633 if (current_configfile)
1635 struct configuration_spec * oldcfg = (struct configuration_spec *)
1636 current_configfile->f;
1638 * Check if config->haddr,hport == oldcfg->haddr,hport
1640 * The following could be written more compactly as a single,
1641 * (unreadably long) if statement.
1643 config->need_bind = 0;
1644 if (config->hport != oldcfg->hport)
1646 config->need_bind = 1;
1648 else if (config->haddr == NULL)
1650 if (oldcfg->haddr != NULL)
1652 config->need_bind = 1;
1655 else if (oldcfg->haddr == NULL)
1657 config->need_bind = 1;
1659 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1661 config->need_bind = 1;
1664 current_configfile->unloader = unload_configfile;
1667 fs->next = files->next;
1670 current_configfile = fs;
1676 /*********************************************************************
1678 * Function : savearg
1680 * Description : Called from `load_config'. It saves each non-empty
1681 * and non-comment line from config into
1682 * config->proxy_args. This is used to create the
1683 * show-proxy-args page. On error, frees
1684 * config->proxy_args and sets it to NULL
1687 * 1 : command = config setting that was found
1688 * 2 : argument = the setting's argument (if any)
1689 * 3 : config = Configuration to save into.
1693 *********************************************************************/
1694 static void savearg(char *command, char *argument, struct configuration_spec * config)
1704 * Add config option name embedded in
1705 * link to it's section in the user-manual
1707 buf = strdup("\n<a href=\"");
1708 if (!strncmpic(config->usermanual, "file://", 7) ||
1709 !strncmpic(config->usermanual, "http", 4))
1711 string_append(&buf, config->usermanual);
1715 string_append(&buf, "http://");
1716 string_append(&buf, CGI_SITE_2_HOST);
1717 string_append(&buf, "/user-manual/");
1719 string_append(&buf, CONFIG_HELP_PREFIX);
1720 string_join (&buf, string_toupper(command));
1721 string_append(&buf, "\">");
1722 string_append(&buf, command);
1723 string_append(&buf, "</a> ");
1727 freez(config->proxy_args);
1731 if ( (NULL != argument) && ('\0' != *argument) )
1733 s = html_encode(argument);
1737 freez(config->proxy_args);
1741 if (strncmpic(argument, "http://", 7) == 0)
1743 string_append(&buf, "<a href=\"");
1744 string_append(&buf, s);
1745 string_append(&buf, "\">");
1746 string_join (&buf, s);
1747 string_append(&buf, "</a>");
1751 string_join (&buf, s);
1755 string_append(&buf, "<br>");
1756 string_join(&config->proxy_args, buf);