1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.5 2003/09/22 00:33:01 david__schmidt Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/src/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 2.5 2003/09/22 00:33:01 david__schmidt
39 * Enable sending a custom 'blocked' image. Shows up as
40 * "image-blocker-custom-file" parameter in config, and
41 * "+set-image-blocker{custom}" in action files.
43 * Revision 2.4 2002/12/28 03:58:19 david__schmidt
44 * Initial drop of dashboard instrumentation - enabled with
45 * --enable-activity-console
47 * Revision 2.3 2002/09/19 03:48:29 iwanttokeepanon
48 * Just moved "int i" up 3 lines in function unload_configfile, out of the "ifdef FEATURE_ACL" clause. I disable ACL and it was not compiling because "int i" was ifdef(d) out. I noticed this in the past, but am just now in a spot where I can change/commit stuff ... long live broadband!
50 * Revision 2.2 2002/09/04 15:48:33 oes
51 * Synced with the stable branch:
52 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
53 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
55 * Revision 2.1 2002/06/04 17:22:36 jongfoster
58 * Revision 2.0 2002/06/04 14:34:21 jongfoster
59 * Moving source files to src/
61 * Revision 1.48 2002/05/14 21:30:38 oes
62 * savearg now uses own linking code instead of (now special-cased) add_help_link
64 * Revision 1.47 2002/05/12 21:36:29 jongfoster
65 * Correcting function comments
67 * Revision 1.46 2002/04/26 12:55:14 oes
68 * - New option "user-manual", defaults to our site
69 * via project.h #define
70 * - savearg now embeds option names in help links
72 * Revision 1.45 2002/04/24 02:11:54 oes
73 * Jon's multiple AF patch: Allow up to MAX_ACTION_FILES actionsfile options
75 * Revision 1.44 2002/04/08 20:37:13 swa
78 * Revision 1.43 2002/04/08 20:36:50 swa
81 * Revision 1.42 2002/04/05 15:50:15 oes
82 * fix for invalid HTML proxy_args
84 * Revision 1.41 2002/03/31 17:19:00 jongfoster
85 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
87 * Revision 1.40 2002/03/26 22:29:55 swa
88 * we have a new homepage!
90 * Revision 1.39 2002/03/24 13:25:43 swa
91 * name change related issues
93 * Revision 1.38 2002/03/24 13:05:48 jongfoster
94 * Renaming re_filterfile to filterfile
96 * Revision 1.37 2002/03/16 23:54:06 jongfoster
97 * Adding graceful termination feature, to help look for memory leaks.
98 * If you enable this (which, by design, has to be done by hand
99 * editing config.h) and then go to http://i.j.b/die, then the program
100 * will exit cleanly after the *next* request. It should free all the
101 * memory that was used.
103 * Revision 1.36 2002/03/13 00:27:05 jongfoster
106 * Revision 1.35 2002/03/07 03:52:44 oes
107 * Set logging to tty for --no-daemon mode
109 * Revision 1.34 2002/03/06 23:14:35 jongfoster
110 * Trivial cosmetic changes to make function comments easier to find.
112 * Revision 1.33 2002/03/05 04:52:42 oes
113 * Deleted non-errlog debugging code
115 * Revision 1.32 2002/03/04 18:24:53 oes
116 * Re-enabled output of unknown config directive hash
118 * Revision 1.31 2002/03/03 15:07:20 oes
119 * Re-enabled automatic config reloading
121 * Revision 1.30 2002/01/22 23:31:43 jongfoster
122 * Replacing strsav() with string_append()
124 * Revision 1.29 2002/01/17 21:02:30 jongfoster
125 * Moving all our URL and URL pattern parsing code to urlmatch.c.
127 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
129 * Revision 1.28 2001/12/30 14:07:32 steudten
130 * - Add signal handling (unix)
131 * - Add SIGHUP handler (unix)
132 * - Add creation of pidfile (unix)
133 * - Add action 'top' in rc file (RH)
134 * - Add entry 'SIGNALS' to manpage
135 * - Add exit message to logfile (unix)
137 * Revision 1.27 2001/11/07 00:02:13 steudten
138 * Add line number in error output for lineparsing for
139 * actionsfile and configfile.
140 * Special handling for CLF added.
142 * Revision 1.26 2001/11/05 21:41:43 steudten
143 * Add changes to be a real daemon just for unix os.
144 * (change cwd to /, detach from controlling tty, set
145 * process group and session leader to the own process.
147 * Add some fatal-error log message for failed malloc().
148 * Add '-d' if compiled with 'configure --with-debug' to
149 * enable debug output.
151 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
152 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
153 * threads to call select() simultaneously. So, it's time to do a real, live,
154 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
155 * (native). Both versions will work, but using __OS2__ offers multi-threading.
157 * Revision 1.24 2001/10/23 21:40:30 jongfoster
158 * Added support for enable-edit-actions and enable-remote-toggle config
161 * Revision 1.23 2001/10/07 15:36:00 oes
162 * Introduced new config option "buffer-limit"
164 * Revision 1.22 2001/09/22 16:36:59 jongfoster
165 * Removing unused parameter fs from read_config_line()
167 * Revision 1.21 2001/09/16 17:10:43 jongfoster
168 * Moving function savearg() here, since it was the only thing left in
171 * Revision 1.20 2001/07/30 22:08:36 jongfoster
172 * Tidying up #defines:
173 * - All feature #defines are now of the form FEATURE_xxx
174 * - Permanently turned off WIN_GUI_EDIT
175 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
177 * Revision 1.19 2001/07/15 17:45:16 jongfoster
178 * Removing some unused #includes
180 * Revision 1.18 2001/07/13 14:01:14 oes
181 * - Removed all #ifdef PCRS
182 * - Removed vim-settings
184 * Revision 1.17 2001/06/29 13:31:03 oes
185 * - Improved comments
186 * - Fixed (actionsfile) and sorted hashes
187 * - Introduced admin_address and proxy-info-url
188 * as config parameters
189 * - Renamed config->proxy_args_invocation (which didn't have
190 * the invocation but the options!) to config->proxy_args
191 * - Various adaptions
192 * - Removed logentry from cancelled commit
194 * Revision 1.16 2001/06/09 10:55:28 jongfoster
195 * Changing BUFSIZ ==> BUFFER_SIZE
197 * Revision 1.15 2001/06/07 23:13:40 jongfoster
198 * Merging ACL and forward files into config file.
199 * Cosmetic: Sorting config file options alphabetically.
200 * Cosmetic: Adding brief syntax comments to config file options.
202 * Revision 1.14 2001/06/07 14:46:25 joergs
203 * Missing make_path() added for re_filterfile.
205 * Revision 1.13 2001/06/05 22:33:54 jongfoster
207 * Fixed minor memory leak.
208 * Also now uses make_path to prepend the pathnames.
210 * Revision 1.12 2001/06/05 20:04:09 jongfoster
211 * Now uses _snprintf() in place of snprintf() under Win32.
213 * Revision 1.11 2001/06/04 18:31:58 swa
214 * files are now prefixed with either `confdir' or `logdir'.
215 * `make redhat-dist' replaces both entries confdir and logdir
218 * Revision 1.10 2001/06/03 19:11:54 oes
219 * introduced confdir option
221 * Revision 1.9 2001/06/01 20:06:24 jongfoster
222 * Removed support for "tinygif" option - moved to actions file.
224 * Revision 1.8 2001/05/31 21:27:13 jongfoster
225 * Removed many options from the config file and into the
226 * "actions" file: add_forwarded, suppress_vanilla_wafer,
227 * wafer, add_header, user_agent, referer, from
228 * Also globally replaced "permission" with "action".
230 * Revision 1.7 2001/05/29 09:50:24 jongfoster
231 * Unified blocklist/imagelist/permissionslist.
232 * File format is still under discussion, but the internal changes
235 * Also modified interceptor behaviour:
236 * - We now intercept all URLs beginning with one of the following
237 * prefixes (and *only* these prefixes):
239 * * http://ijbswa.sf.net/config/
240 * * http://ijbswa.sourceforge.net/config/
241 * - New interceptors "home page" - go to http://i.j.b/ to see it.
242 * - Internal changes so that intercepted and fast redirect pages
243 * are not replaced with an image.
244 * - Interceptors now have the option to send a binary page direct
245 * to the client. (i.e. ijb-send-banner uses this)
246 * - Implemented show-url-info interceptor. (Which is why I needed
247 * the above interceptors changes - a typical URL is
248 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
249 * The previous mechanism would not have intercepted that, and
250 * if it had been intercepted then it then it would have replaced
253 * Revision 1.6 2001/05/26 00:28:36 jongfoster
254 * Automatic reloading of config file.
255 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
256 * Most of the global variables have been moved to a new
257 * struct configuration_spec, accessed through csp->config->globalname
258 * Most of the globals remaining are used by the Win32 GUI.
260 * Revision 1.5 2001/05/25 22:34:30 jongfoster
263 * Revision 1.4 2001/05/22 18:46:04 oes
265 * - Enabled filtering banners by size rather than URL
266 * by adding patterns that replace all standard banner
267 * sizes with the "Junkbuster" gif to the re_filterfile
269 * - Enabled filtering WebBugs by providing a pattern
270 * which kills all 1x1 images
272 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
273 * which is selected by the (nonstandard and therefore
274 * capital) letter 'U' in the option string.
275 * It causes the quantifiers to be ungreedy by default.
276 * Appending a ? turns back to greedy (!).
278 * - Added a new interceptor ijb-send-banner, which
279 * sends back the "Junkbuster" gif. Without imagelist or
280 * MSIE detection support, or if tinygif = 1, or the
281 * URL isn't recognized as an imageurl, a lame HTML
282 * explanation is sent instead.
284 * - Added new feature, which permits blocking remote
285 * script redirects and firing back a local redirect
287 * The feature is conditionally compiled, i.e. it
288 * can be disabled with --disable-fast-redirects,
289 * plus it must be activated by a "fast-redirects"
290 * line in the config file, has its own log level
291 * and of course wants to be displayed by show-proxy-args
292 * Note: Boy, all the #ifdefs in 1001 locations and
293 * all the fumbling with configure.in and acconfig.h
294 * were *way* more work than the feature itself :-(
296 * - Because a generic redirect template was needed for
297 * this, tinygif = 3 now uses the same.
299 * - Moved GIFs, and other static HTTP response templates
304 * - Removed some >400 CRs again (Jon, you really worked
307 * Revision 1.3 2001/05/20 01:21:20 jongfoster
308 * Version 2.9.4 checkin.
309 * - Merged popupfile and cookiefile, and added control over PCRS
310 * filtering, in new "permissionsfile".
311 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
312 * file error you now get a message box (in the Win32 GUI) rather
313 * than the program exiting with no explanation.
314 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
316 * - Removed tabs from "config"
317 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
318 * - Bumped up version number.
320 * Revision 1.2 2001/05/17 23:01:01 oes
321 * - Cleaned CRLF's from the sources and related files
323 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
324 * Initial import of version 2.9.3 source tree
327 *********************************************************************/
333 #include <sys/types.h>
334 #include <sys/stat.h>
348 # include <windows.h>
351 # ifndef _WIN_CONSOLE
353 # endif /* ndef _WIN_CONSOLE */
355 /* VC++ has "_snprintf", not "snprintf" */
356 #define snprintf _snprintf
358 #else /* every platform but _WIN32 */
362 # include <sys/wait.h>
363 #endif /* ndef __OS2__ */
364 # include <sys/time.h>
367 #endif /* ndef _WIN32 */
374 #include "miscutil.h"
378 #include "urlmatch.h"
381 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
384 * Fix a problem with Solaris. There should be no effect on other
386 * Solaris's isspace() is a macro which uses it's argument directly
387 * as an array index. Therefore we need to make sure that high-bit
388 * characters generate +ve values, and ideally we also want to make
389 * the argument match the declared parameter type of "int".
391 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
392 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
394 #ifdef FEATURE_TOGGLE
396 * Indicates if Privoxy is currently enabled.
398 int g_bToggleIJB = 1; /* Privoxy is enabled by default. */
399 #endif /* def FEATURE_TOGGLE */
402 * The filename of the config file
404 const char *configfile = NULL;
407 * Global argument count, so that CGI functions can access the
413 * Global argument list, so that CGI functions can access the
416 const char **Argv = NULL;
419 * The configuration file which is currently loaded.
421 static struct file_list *current_configfile = NULL;
425 * This takes the "cryptic" hash of each keyword and aliases them to
426 * something a little more readable. This also makes changing the
427 * hash values easier if they should change or the hash algorthm changes.
428 * Use the included "hash" program to find out what the hash will be
429 * for any string supplied on the command line. (Or just put it in the
430 * config file and read the number from the error message in the log).
432 * Please keep this list sorted alphabetically (but with the Windows
433 * console and GUI specific options last).
436 #define hash_actions_file 1196306641ul /**< "actionsfile" */
437 #define hash_activity_console_address 18904208ul /**< "activity-console-address" */
438 #define hash_activity_console_update_freq 3442780376ul /**< "activity-console-update-freq" */
439 #define hash_admin_address 4112573064ul /**< "admin-address" */
440 #define hash_buffer_limit 1881726070ul /**< "buffer-limit */
441 #define hash_confdir 1978389ul /**< "confdir" */
442 #define hash_debug 78263ul /**< "debug" */
443 #define hash_deny_access 1227333715ul /**< "deny-access" */
444 #define hash_enable_edit_actions 2517097536ul /**< "enable-edit-actions" */
445 #define hash_enable_remote_toggle 2979744683ul /**< "enable-remote-toggle" */
446 #define hash_filterfile 250887266ul /**< "filterfile" */
447 #define hash_forward 2029845ul /**< "forward" */
448 #define hash_forward_socks4 3963965521ul /**< "forward-socks4" */
449 #define hash_forward_socks4a 2639958518ul /**< "forward-socks4a" */
450 #define hash_image_blocker_custom_file 2863352327ul /**< "image-blocker-custom-file" */
451 #define hash_jarfile 2046641ul /**< "jarfile" */
452 #define hash_listen_address 1255650842ul /**< "listen-address" */
453 #define hash_logdir 422889ul /**< "logdir" */
454 #define hash_logfile 2114766ul /**< "logfile" */
455 #define hash_permit_access 3587953268ul /**< "permit-access" */
456 #define hash_proxy_info_url 3903079059ul /**< "proxy-info-url" */
457 #define hash_single_threaded 4250084780ul /**< "single-threaded" */
458 #define hash_suppress_blocklists 1948693308ul /**< "suppress-blocklists" */
459 #define hash_toggle 447966ul /**< "toggle" */
460 #define hash_trust_info_url 430331967ul /**< "trust-info-url" */
461 #define hash_trustfile 56494766ul /**< "trustfile" */
462 #define hash_usermanual 1416668518ul /**< "user-manual" */
464 #define hash_activity_animation 1817904738ul /**< "activity-animation" */
465 #define hash_close_button_minimizes 3651284693ul /**< "close-button-minimizes" */
466 #define hash_hide_console 2048809870ul /**< "hide-console" */
467 #define hash_log_buffer_size 2918070425ul /**< "log-buffer-size" */
468 #define hash_log_font_name 2866730124ul /**< "log-font-name" */
469 #define hash_log_font_size 2866731014ul /**< "log-font-size" */
470 #define hash_log_highlight_messages 4032101240ul /**< "log-highlight-messages" */
471 #define hash_log_max_lines 2868344173ul /**< "log-max-lines" */
472 #define hash_log_messages 2291744899ul /**< "log-messages" */
473 #define hash_show_on_task_bar 215410365ul /**< "show-on-task-bar" */
475 static void savearg(char *command, char *argument, struct configuration_spec * config);
477 /*********************************************************************
479 * Function : unload_configfile
481 * Description : Free the config structure and all components.
484 * 1 : data: struct configuration_spec to unload
488 *********************************************************************/
489 void unload_configfile (void * data)
491 struct configuration_spec * config = (struct configuration_spec *)data;
492 struct forward_spec *cur_fwd = config->forward;
495 struct access_control_list *cur_acl = config->acl;
497 while (cur_acl != NULL)
499 struct access_control_list * next_acl = cur_acl->next;
504 #endif /* def FEATURE_ACL */
506 while (cur_fwd != NULL)
508 struct forward_spec * next_fwd = cur_fwd->next;
509 free_url_spec(cur_fwd->url);
511 freez(cur_fwd->gateway_host);
512 freez(cur_fwd->forward_host);
516 config->forward = NULL;
518 #ifdef FEATURE_COOKIE_JAR
519 if ( NULL != config->jar )
521 fclose( config->jar );
524 #endif /* def FEATURE_COOKIE_JAR */
526 freez(config->confdir);
527 freez(config->logdir);
529 freez(config->haddr);
530 freez(config->logfile);
532 for (i = 0; i < MAX_ACTION_FILES; i++)
534 freez(config->actions_file_short[i]);
535 freez(config->actions_file[i]);
538 freez(config->admin_address);
539 freez(config->proxy_info_url);
540 freez(config->proxy_args);
541 freez(config->usermanual);
543 #ifdef FEATURE_COOKIE_JAR
544 freez(config->jarfile);
545 #endif /* def FEATURE_COOKIE_JAR */
547 freez(config->re_filterfile);
549 freez(config->image_blocker_data);
550 freez(config->image_blocker_format);
554 #ifdef FEATURE_GRACEFUL_TERMINATION
555 /*********************************************************************
557 * Function : unload_current_config_file
559 * Description : Unloads current config file - reset to state at
560 * beginning of program.
566 *********************************************************************/
567 void unload_current_config_file(void)
569 if (current_configfile)
571 current_configfile->unloader = unload_configfile;
572 current_configfile = NULL;
578 /*********************************************************************
580 * Function : load_config
582 * Description : Load the config file and all parameters.
586 * Returns : The configuration_spec, or NULL on error.
588 *********************************************************************/
589 struct configuration_spec * load_config(void)
591 char buf[BUFFER_SIZE];
592 char *p, *q, *image_buf, *image_path;
593 FILE *configfp = NULL,
595 struct configuration_spec * config = NULL;
596 struct client_state * fake_csp;
597 struct file_list *fs;
598 struct stat statbuf[1];
599 unsigned long linenum = 0;
600 int i, file_size, bytes_read;
602 if ( !check_file_changed(current_configfile, configfile, &fs))
604 /* No need to load */
605 return ((struct configuration_spec *)current_configfile->f);
609 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
613 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
615 #ifdef FEATURE_TOGGLE
617 #endif /* def FEATURE_TOGGLE */
619 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
625 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
626 /* Never get here - LOG_LEVEL_FATAL causes program exit */
630 * This is backwards from how it's usually done.
631 * Following the usual pattern, "fs" would be stored in a member
632 * variable in "csp", and then we'd access "config" from "fs->f",
633 * using a cast. However, "config" is used so often that a
634 * cast each time would be very ugly, and the extra indirection
635 * would waste CPU cycles. Therefore we store "config" in
636 * "csp->config", and "fs" in "csp->config->config_file_list".
638 config->config_file_list = fs;
643 config->multi_threaded = 1;
644 config->hport = HADDR_PORT;
645 config->buffer_limit = 4096 * 1024;
646 config->usermanual = strdup(USER_MANUAL_URL);
647 config->proxy_args = strdup("");
648 #ifdef FEATURE_ACTIVITY_CONSOLE
649 config->activity_port = ACTIVTY_ADDR_PORT;
650 config->activity_freq = 5;
651 #endif /* def FEATURE_ACTIVITY_CONSOLE */
653 if ((configfp = fopen(configfile, "r")) == NULL)
655 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
657 /* Never get here - LOG_LEVEL_FATAL causes program exit */
660 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
662 char cmd[BUFFER_SIZE];
663 char arg[BUFFER_SIZE];
664 char tmp[BUFFER_SIZE];
666 struct access_control_list *cur_acl;
667 #endif /* def FEATURE_ACL */
668 struct forward_spec *cur_fwd;
674 /* Copy command (i.e. up to space or tab) into cmd */
677 while (*p && (*p != ' ') && (*p != '\t'))
683 /* Skip over the whitespace in buf */
684 while (*p && ((*p == ' ') || (*p == '\t')))
689 /* Copy the argument into arg */
692 /* Should never happen, but check this anyway */
698 /* Make sure the command field is lower case */
703 *p = ijb_tolower(*p);
707 /* Save the argument for show-proxy-args */
708 savearg(cmd, arg, config);
711 switch( hash_string( cmd ) )
713 /* *************************************************************************
714 * actionsfile actions-file-name
715 * In confdir by default
716 * *************************************************************************/
717 case hash_actions_file :
719 while ((i < MAX_ACTION_FILES) && (NULL != config->actions_file[i]))
724 if (i >= MAX_ACTION_FILES)
726 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
727 "(You can increase this limit by changing MAX_ACTION_FILES in project.h and recompiling).",
730 config->actions_file_short[i] = strdup(arg);
731 p = malloc(strlen(arg) + sizeof(".action"));
734 log_error(LOG_LEVEL_FATAL, "Out of memory");
737 strcat(p, ".action");
738 config->actions_file[i] = make_path(config->confdir, p);
742 /* *************************************************************************
743 * activity-console-address [ip][:port]
744 * *************************************************************************/
745 #ifdef FEATURE_ACTIVITY_CONSOLE
746 case hash_activity_console_address :
747 freez(config->activity_address);
748 config->activity_address = strdup(arg);
750 #endif /* def FEATURE_ACTIVITY_CONSOLE */
752 /* *************************************************************************
753 * activity-console-update-freq
754 * *************************************************************************/
755 #ifdef FEATURE_ACTIVITY_CONSOLE
756 case hash_activity_console_update_freq :
757 config->activity_freq = atoi(arg);
758 if (config->activity_freq < 1)
759 config->activity_freq = 5;
761 #endif /* def FEATURE_ACTIVITY_CONSOLE */
763 /* *************************************************************************
764 * admin-address email-address
765 * *************************************************************************/
766 case hash_admin_address :
767 freez(config->admin_address);
768 config->admin_address = strdup(arg);
771 /* *************************************************************************
773 * *************************************************************************/
774 case hash_buffer_limit :
775 config->buffer_limit = (size_t) 1024 * atoi(arg);
778 /* *************************************************************************
779 * confdir directory-name
780 * *************************************************************************/
782 freez(config->confdir);
783 config->confdir = make_path( NULL, arg);
786 /* *************************************************************************
788 * Specifies debug level, multiple values are ORed together.
789 * *************************************************************************/
791 config->debug |= atoi(arg);
794 /* *************************************************************************
795 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
796 * *************************************************************************/
798 case hash_deny_access:
799 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
801 if ((vec_count != 1) && (vec_count != 2))
803 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
804 "deny-access directive in configuration file.");
805 string_append(&config->proxy_args,
806 "<br>\nWARNING: Wrong number of parameters for "
807 "deny-access directive in configuration file.<br><br>\n");
811 /* allocate a new node */
812 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
816 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
817 /* Never get here - LOG_LEVEL_FATAL causes program exit */
820 cur_acl->action = ACL_DENY;
822 if (acl_addr(vec[0], cur_acl->src) < 0)
824 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
825 "directive in configuration file: \"%s\"", vec[0]);
826 string_append(&config->proxy_args,
827 "<br>\nWARNING: Invalid source IP for deny-access directive"
828 " in configuration file: \"");
829 string_append(&config->proxy_args,
831 string_append(&config->proxy_args,
838 if (acl_addr(vec[1], cur_acl->dst) < 0)
840 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
841 "directive in configuration file: \"%s\"", vec[0]);
842 string_append(&config->proxy_args,
843 "<br>\nWARNING: Invalid destination IP for deny-access directive"
844 " in configuration file: \"");
845 string_append(&config->proxy_args,
847 string_append(&config->proxy_args,
855 * Add it to the list. Note we reverse the list to get the
856 * behaviour the user expects. With both the ACL and
857 * actions file, the last match wins. However, the internal
858 * implementations are different: The actions file is stored
859 * in the same order as the file, and scanned completely.
860 * With the ACL, we reverse the order as we load it, then
861 * when we scan it we stop as soon as we get a match.
863 cur_acl->next = config->acl;
864 config->acl = cur_acl;
867 #endif /* def FEATURE_ACL */
869 /* *************************************************************************
870 * enable-edit-actions 0|1
871 * *************************************************************************/
872 #ifdef FEATURE_CGI_EDIT_ACTIONS
873 case hash_enable_edit_actions:
874 if ((*arg != '\0') && (0 != atoi(arg)))
876 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
880 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
883 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
885 /* *************************************************************************
886 * enable-remote-toggle 0|1
887 * *************************************************************************/
888 #ifdef FEATURE_CGI_EDIT_ACTIONS
889 case hash_enable_remote_toggle:
890 if ((*arg != '\0') && (0 != atoi(arg)))
892 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
896 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
899 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
901 /* *************************************************************************
902 * forward url-pattern (.|http-proxy-host[:port])
903 * *************************************************************************/
905 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
909 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
910 "directive in configuration file.");
911 string_append(&config->proxy_args,
912 "<br>\nWARNING: Wrong number of parameters for "
913 "forward directive in configuration file.");
917 /* allocate a new node */
918 cur_fwd = zalloc(sizeof(*cur_fwd));
921 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
922 /* Never get here - LOG_LEVEL_FATAL causes program exit */
926 cur_fwd->type = SOCKS_NONE;
928 /* Save the URL pattern */
929 if (create_url_spec(cur_fwd->url, vec[0]))
931 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
932 "directive in configuration file.");
933 string_append(&config->proxy_args,
934 "<br>\nWARNING: Bad URL specifier for "
935 "forward directive in configuration file.");
939 /* Parse the parent HTTP proxy host:port */
942 if (strcmp(p, ".") != 0)
944 cur_fwd->forward_host = strdup(p);
946 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
949 cur_fwd->forward_port = atoi(p);
952 if (cur_fwd->forward_port <= 0)
954 cur_fwd->forward_port = 8000;
959 cur_fwd->next = config->forward;
960 config->forward = cur_fwd;
964 /* *************************************************************************
965 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
966 * *************************************************************************/
967 case hash_forward_socks4:
968 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
972 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
973 "forward-socks4 directive in configuration file.");
974 string_append(&config->proxy_args,
975 "<br>\nWARNING: Wrong number of parameters for "
976 "forward-socks4 directive in configuration file.");
980 /* allocate a new node */
981 cur_fwd = zalloc(sizeof(*cur_fwd));
984 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
985 /* Never get here - LOG_LEVEL_FATAL causes program exit */
989 cur_fwd->type = SOCKS_4;
991 /* Save the URL pattern */
992 if (create_url_spec(cur_fwd->url, vec[0]))
994 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
995 "directive in configuration file.");
996 string_append(&config->proxy_args,
997 "<br>\nWARNING: Bad URL specifier for "
998 "forward-socks4 directive in configuration file.");
1002 /* Parse the SOCKS proxy host[:port] */
1005 if (strcmp(p, ".") != 0)
1007 cur_fwd->gateway_host = strdup(p);
1009 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1012 cur_fwd->gateway_port = atoi(p);
1014 if (cur_fwd->gateway_port <= 0)
1016 cur_fwd->gateway_port = 1080;
1020 /* Parse the parent HTTP proxy host[:port] */
1023 if (strcmp(p, ".") != 0)
1025 cur_fwd->forward_host = strdup(p);
1027 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1030 cur_fwd->forward_port = atoi(p);
1033 if (cur_fwd->forward_port <= 0)
1035 cur_fwd->forward_port = 8000;
1040 cur_fwd->next = config->forward;
1041 config->forward = cur_fwd;
1045 /* *************************************************************************
1046 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1047 * *************************************************************************/
1048 case hash_forward_socks4a:
1049 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1053 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1054 "forward-socks4a directive in configuration file.");
1055 string_append(&config->proxy_args,
1056 "<br>\nWARNING: Wrong number of parameters for "
1057 "forward-socks4a directive in configuration file.");
1061 /* allocate a new node */
1062 cur_fwd = zalloc(sizeof(*cur_fwd));
1063 if (cur_fwd == NULL)
1065 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1066 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1070 cur_fwd->type = SOCKS_4A;
1072 /* Save the URL pattern */
1073 if (create_url_spec(cur_fwd->url, vec[0]))
1075 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1076 "directive in configuration file.");
1077 string_append(&config->proxy_args,
1078 "<br>\nWARNING: Bad URL specifier for "
1079 "forward-socks4a directive in configuration file.");
1083 /* Parse the SOCKS proxy host[:port] */
1086 cur_fwd->gateway_host = strdup(p);
1088 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1091 cur_fwd->gateway_port = atoi(p);
1093 if (cur_fwd->gateway_port <= 0)
1095 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 * jarfile jar-file-name
1125 * In logdir by default
1126 * *************************************************************************/
1127 #ifdef FEATURE_COOKIE_JAR
1129 freez(config->jarfile);
1130 config->jarfile = make_path(config->logdir, arg);
1132 #endif /* def FEATURE_COOKIE_JAR */
1134 /* *************************************************************************
1135 * listen-address [ip][:port]
1136 * *************************************************************************/
1137 case hash_listen_address :
1138 freez(config->haddr);
1139 config->haddr = strdup(arg);
1142 /* *************************************************************************
1143 * logdir directory-name
1144 * *************************************************************************/
1146 freez(config->logdir);
1147 config->logdir = make_path(NULL, arg);
1150 /* *************************************************************************
1151 * logfile log-file-name
1152 * In logdir by default
1153 * *************************************************************************/
1155 freez(config->logfile);
1156 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1159 /* *************************************************************************
1160 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1161 * *************************************************************************/
1163 case hash_permit_access:
1164 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1166 if ((vec_count != 1) && (vec_count != 2))
1168 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1169 "permit-access directive in configuration file.");
1170 string_append(&config->proxy_args,
1171 "<br>\nWARNING: Wrong number of parameters for "
1172 "permit-access directive in configuration file.<br><br>\n");
1177 /* allocate a new node */
1178 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1180 if (cur_acl == NULL)
1182 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1183 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1186 cur_acl->action = ACL_PERMIT;
1188 if (acl_addr(vec[0], cur_acl->src) < 0)
1190 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1191 "directive in configuration file: \"%s\"", vec[0]);
1192 string_append(&config->proxy_args,
1193 "<br>\nWARNING: Invalid source IP for permit-access directive"
1194 " in configuration file: \"");
1195 string_append(&config->proxy_args,
1197 string_append(&config->proxy_args,
1204 if (acl_addr(vec[1], cur_acl->dst) < 0)
1206 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1207 "permit-access directive in configuration file: \"%s\"",
1209 string_append(&config->proxy_args,
1210 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1211 " in configuration file: \"");
1212 string_append(&config->proxy_args,
1214 string_append(&config->proxy_args,
1222 * Add it to the list. Note we reverse the list to get the
1223 * behaviour the user expects. With both the ACL and
1224 * actions file, the last match wins. However, the internal
1225 * implementations are different: The actions file is stored
1226 * in the same order as the file, and scanned completely.
1227 * With the ACL, we reverse the order as we load it, then
1228 * when we scan it we stop as soon as we get a match.
1230 cur_acl->next = config->acl;
1231 config->acl = cur_acl;
1234 #endif /* def FEATURE_ACL */
1236 /* *************************************************************************
1237 * proxy-info-url url
1238 * *************************************************************************/
1239 case hash_proxy_info_url :
1240 freez(config->proxy_info_url);
1241 config->proxy_info_url = strdup(arg);
1244 /* *************************************************************************
1245 * re_filterfile file-name
1246 * In confdir by default.
1247 * *************************************************************************/
1248 case hash_filterfile :
1249 freez(config->re_filterfile);
1250 config->re_filterfile = make_path(config->confdir, arg);
1253 /* *************************************************************************
1255 * *************************************************************************/
1256 case hash_single_threaded :
1257 config->multi_threaded = 0;
1260 /* *************************************************************************
1262 * *************************************************************************/
1263 #ifdef FEATURE_TOGGLE
1265 g_bToggleIJB = atoi(arg);
1267 #endif /* def FEATURE_TOGGLE */
1269 /* *************************************************************************
1270 * trust-info-url url
1271 * *************************************************************************/
1272 #ifdef FEATURE_TRUST
1273 case hash_trust_info_url :
1274 enlist(config->trust_info, arg);
1276 #endif /* def FEATURE_TRUST */
1278 /* *************************************************************************
1279 * trustfile filename
1280 * (In confdir by default.)
1281 * *************************************************************************/
1282 #ifdef FEATURE_TRUST
1283 case hash_trustfile :
1284 freez(config->trustfile);
1285 config->trustfile = make_path(config->confdir, arg);
1287 #endif /* def FEATURE_TRUST */
1289 /* *************************************************************************
1291 * *************************************************************************/
1292 case hash_usermanual :
1293 freez(config->usermanual);
1294 config->usermanual = strdup(arg);
1297 /* *************************************************************************
1298 * Win32 Console options:
1299 * *************************************************************************/
1301 /* *************************************************************************
1303 * *************************************************************************/
1305 case hash_hide_console :
1308 #endif /*def _WIN_CONSOLE*/
1311 /* *************************************************************************
1312 * Win32 GUI options:
1313 * *************************************************************************/
1315 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1316 /* *************************************************************************
1317 * activity-animation (0|1)
1318 * *************************************************************************/
1319 case hash_activity_animation :
1320 g_bShowActivityAnimation = atoi(arg);
1323 /* *************************************************************************
1324 * close-button-minimizes (0|1)
1325 * *************************************************************************/
1326 case hash_close_button_minimizes :
1327 g_bCloseHidesWindow = atoi(arg);
1330 /* *************************************************************************
1331 * log-buffer-size (0|1)
1332 * *************************************************************************/
1333 case hash_log_buffer_size :
1334 g_bLimitBufferSize = atoi(arg);
1337 /* *************************************************************************
1338 * log-font-name fontnane
1339 * *************************************************************************/
1340 case hash_log_font_name :
1341 strcpy( g_szFontFaceName, arg );
1344 /* *************************************************************************
1346 * *************************************************************************/
1347 case hash_log_font_size :
1348 g_nFontSize = atoi(arg);
1351 /* *************************************************************************
1352 * log-highlight-messages (0|1)
1353 * *************************************************************************/
1354 case hash_log_highlight_messages :
1355 g_bHighlightMessages = atoi(arg);
1358 /* *************************************************************************
1360 * *************************************************************************/
1361 case hash_log_max_lines :
1362 g_nMaxBufferLines = atoi(arg);
1365 /* *************************************************************************
1366 * log-messages (0|1)
1367 * *************************************************************************/
1368 case hash_log_messages :
1369 g_bLogMessages = atoi(arg);
1372 /* *************************************************************************
1373 * show-on-task-bar (0|1)
1374 * *************************************************************************/
1375 case hash_show_on_task_bar :
1376 g_bShowOnTaskBar = atoi(arg);
1379 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1381 /* *************************************************************************
1382 * image-blocker-custom-file
1383 * *************************************************************************/
1384 case hash_image_blocker_custom_file :
1385 freez(config->image_blocker_data);
1386 freez(config->image_blocker_format);
1387 config->image_blocker_length = 0;
1388 image_path = make_path(config->confdir, arg);
1391 * Load up the custom image bitmap file
1393 if (NULL == (imagefp = fopen(image_path, "rb")))
1396 * If we can't open the user's requested image, complain
1398 log_error(LOG_LEVEL_ERROR, "Unable to load custom blocker image: %s.", image_path);
1402 if (stat(image_path, statbuf) == 0)
1404 file_size = statbuf->st_size;
1405 image_buf = zalloc(file_size);
1406 if (image_buf != NULL)
1408 bytes_read = fread(image_buf,1,file_size,imagefp);
1411 config->image_blocker_data = image_buf;
1412 config->image_blocker_length = file_size;
1414 * Ensure we can look into files for file signatures
1419 * Snoop into the binary data for a filetype signature
1421 if (memcmp(image_buf,"GIF",3) == 0)
1422 config->image_blocker_format = IMAGE_MIMETYPE_GIF;
1423 else if (memcmp(&image_buf[6],"JFIF",4) == 0)
1424 config->image_blocker_format = IMAGE_MIMETYPE_JPG;
1425 else if (memcmp(&image_buf[1],"PNG",3) == 0)
1426 config->image_blocker_format = IMAGE_MIMETYPE_PNG;
1429 log_error(LOG_LEVEL_ERROR, "Unsupported custom image file type.");
1430 freez(config->image_blocker_data);
1434 freez(config->image_blocker_data);
1438 log_error(LOG_LEVEL_ERROR, "Unable to read custom blocker image: %s", image_path, bytes_read, file_size);
1440 config->image_blocker_length = 0;
1444 log_error(LOG_LEVEL_ERROR, "Unable to allocate memory for custom blocker image: %s.", image_path);
1447 log_error(LOG_LEVEL_ERROR, "Unable to get statistics on custom blocker image file: %s", image_path);
1451 * If our load failed for some reason, just give the default
1452 * checkerboard pattern
1454 if (config->image_blocker_data == NULL)
1456 log_error(LOG_LEVEL_ERROR, "Custom blocker image processing failed; defaulting to \"pattern\".");
1457 config->image_blocker_data = (char*)image_pattern_data;
1458 config->image_blocker_length = image_pattern_length;
1459 config->image_blocker_format = BUILTIN_IMAGE_MIMETYPE;
1463 /* *************************************************************************
1464 * Warnings about unsupported features
1465 * *************************************************************************/
1467 case hash_deny_access:
1468 #endif /* ndef FEATURE_ACL */
1469 #ifndef FEATURE_CGI_EDIT_ACTIONS
1470 case hash_enable_edit_actions:
1471 case hash_enable_remote_toggle:
1472 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1473 #ifndef FEATURE_COOKIE_JAR
1475 #endif /* ndef FEATURE_COOKIE_JAR */
1477 case hash_permit_access:
1478 #endif /* ndef FEATURE_ACL */
1479 #ifndef FEATURE_TOGGLE
1481 #endif /* ndef FEATURE_TOGGLE */
1482 #ifndef FEATURE_TRUST
1483 case hash_trustfile :
1484 case hash_trust_info_url :
1485 #endif /* ndef FEATURE_TRUST */
1487 #ifndef _WIN_CONSOLE
1488 case hash_hide_console :
1489 #endif /* ndef _WIN_CONSOLE */
1491 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1492 case hash_activity_animation :
1493 case hash_close_button_minimizes :
1494 case hash_log_buffer_size :
1495 case hash_log_font_name :
1496 case hash_log_font_size :
1497 case hash_log_highlight_messages :
1498 case hash_log_max_lines :
1499 case hash_log_messages :
1500 case hash_show_on_task_bar :
1501 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1502 /* These warnings are annoying - so hide them. -- Jon */
1503 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1506 /* *************************************************************************/
1508 /* *************************************************************************/
1510 * I decided that I liked this better as a warning than an
1511 * error. To change back to an error, just change log level
1512 * to LOG_LEVEL_FATAL.
1514 log_error(LOG_LEVEL_ERROR, "Unrecognized directive '%s' (%luul) in line %lu in "
1515 "configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1516 string_append(&config->proxy_args, "<br>\nWARNING: unrecognized directive : ");
1517 string_append(&config->proxy_args, buf);
1518 string_append(&config->proxy_args, "<br><br>\n");
1521 /* *************************************************************************/
1522 } /* end switch( hash_string(cmd) ) */
1523 } /* end while ( read_config_line(...) ) */
1527 if (NULL == config->proxy_args)
1529 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1532 init_error_log(Argv[0], config->logfile, config->debug);
1534 if (config->actions_file[0])
1536 add_loader(load_actions_file, config);
1539 if (config->re_filterfile)
1541 add_loader(load_re_filterfile, config);
1544 #ifdef FEATURE_TRUST
1545 if (config->trustfile)
1547 add_loader(load_trustfile, config);
1549 #endif /* def FEATURE_TRUST */
1551 #ifdef FEATURE_COOKIE_JAR
1552 if ( NULL != config->jarfile )
1554 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1556 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1557 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1559 setbuf(config->jar, NULL);
1561 #endif /* def FEATURE_COOKIE_JAR */
1563 #ifdef FEATURE_ACTIVITY_CONSOLE
1564 if ( NULL == config->activity_address )
1566 config->activity_address = strdup( ACTIVTY_ADDR_DEFAULT );
1569 if ( NULL != config->activity_address )
1571 if (NULL != (p = strchr(config->activity_address, ':')))
1576 config->activity_port = atoi(p);
1580 if (config->activity_port <= 0)
1583 log_error(LOG_LEVEL_ERROR, "invalid activity port spec %s", config->activity_address);
1585 if (*config->activity_address == '\0')
1587 config->activity_address = NULL;
1590 log_error(LOG_LEVEL_INFO, "Sending statistics updates to %s, port %d.", config->activity_address, config->activity_port);
1591 #endif /* def FEATURE_ACTIVITY_CONSOLE */
1593 if ( NULL == config->haddr )
1595 config->haddr = strdup( HADDR_DEFAULT );
1598 if ( NULL != config->haddr )
1600 if (NULL != (p = strchr(config->haddr, ':')))
1605 config->hport = atoi(p);
1609 if (config->hport <= 0)
1612 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1613 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1615 if (*config->haddr == '\0')
1617 config->haddr = NULL;
1622 * Want to run all the loaders once now.
1624 * Need to set up a fake csp, so they can get to the config.
1626 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1627 fake_csp->config = config;
1629 if (run_loader(fake_csp))
1632 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1633 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1637 /* FIXME: this is a kludge for win32 */
1638 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1640 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1641 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1642 g_re_filterfile = config->re_filterfile;
1644 #ifdef FEATURE_TRUST
1645 g_trustfile = config->trustfile;
1646 #endif /* def FEATURE_TRUST */
1649 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1650 /* FIXME: end kludge */
1653 config->need_bind = 1;
1655 if (current_configfile)
1657 struct configuration_spec * oldcfg = (struct configuration_spec *)
1658 current_configfile->f;
1660 * Check if config->haddr,hport == oldcfg->haddr,hport
1662 * The following could be written more compactly as a single,
1663 * (unreadably long) if statement.
1665 config->need_bind = 0;
1666 if (config->hport != oldcfg->hport)
1668 config->need_bind = 1;
1670 else if (config->haddr == NULL)
1672 if (oldcfg->haddr != NULL)
1674 config->need_bind = 1;
1677 else if (oldcfg->haddr == NULL)
1679 config->need_bind = 1;
1681 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1683 config->need_bind = 1;
1686 current_configfile->unloader = unload_configfile;
1689 fs->next = files->next;
1692 current_configfile = fs;
1698 /*********************************************************************
1700 * Function : savearg
1702 * Description : Called from `load_config'. It saves each non-empty
1703 * and non-comment line from config into
1704 * config->proxy_args. This is used to create the
1705 * show-proxy-args page. On error, frees
1706 * config->proxy_args and sets it to NULL
1709 * 1 : command = config setting that was found
1710 * 2 : argument = the setting's argument (if any)
1711 * 3 : config = Configuration to save into.
1715 *********************************************************************/
1716 static void savearg(char *command, char *argument, struct configuration_spec * config)
1726 * Add config option name embedded in
1727 * link to it's section in the user-manual
1729 buf = strdup("<a href=\"");
1730 string_append(&buf, config->usermanual);
1731 string_append(&buf, CONFIG_HELP_PREFIX);
1732 string_join (&buf, string_toupper(command));
1733 string_append(&buf, "\">");
1734 string_append(&buf, command);
1735 string_append(&buf, "</a> ");
1739 freez(config->proxy_args);
1743 if ( (NULL != argument) && ('\0' != *argument) )
1745 s = html_encode(argument);
1749 freez(config->proxy_args);
1753 if (strncmpic(argument, "http://", 7) == 0)
1755 string_append(&buf, "<a href=\"");
1756 string_append(&buf, s);
1757 string_append(&buf, "\">");
1758 string_join (&buf, s);
1759 string_append(&buf, "</a>");
1763 string_join (&buf, s);
1767 string_append(&buf, "<br>\n");
1769 string_join(&config->proxy_args, buf);