1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 2.4 2002/12/28 03:58:19 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.4 2002/12/28 03:58:19 david__schmidt
39 * Initial drop of dashboard instrumentation - enabled with
40 * --enable-activity-console
42 * Revision 2.3 2002/09/19 03:48:29 iwanttokeepanon
43 * 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!
45 * Revision 2.2 2002/09/04 15:48:33 oes
46 * Synced with the stable branch:
47 * Revision 1.48.2.1 2002/08/21 17:58:05 oes
48 * Temp kludge to let user and default action file be edited through win32 GUI (FR 592080)
50 * Revision 2.1 2002/06/04 17:22:36 jongfoster
53 * Revision 2.0 2002/06/04 14:34:21 jongfoster
54 * Moving source files to src/
56 * Revision 1.48 2002/05/14 21:30:38 oes
57 * savearg now uses own linking code instead of (now special-cased) add_help_link
59 * Revision 1.47 2002/05/12 21:36:29 jongfoster
60 * Correcting function comments
62 * Revision 1.46 2002/04/26 12:55:14 oes
63 * - New option "user-manual", defaults to our site
64 * via project.h #define
65 * - savearg now embeds option names in help links
67 * Revision 1.45 2002/04/24 02:11:54 oes
68 * Jon's multiple AF patch: Allow up to MAX_ACTION_FILES actionsfile options
70 * Revision 1.44 2002/04/08 20:37:13 swa
73 * Revision 1.43 2002/04/08 20:36:50 swa
76 * Revision 1.42 2002/04/05 15:50:15 oes
77 * fix for invalid HTML proxy_args
79 * Revision 1.41 2002/03/31 17:19:00 jongfoster
80 * Win32 only: Enabling STRICT to fix a VC++ compile warning.
82 * Revision 1.40 2002/03/26 22:29:55 swa
83 * we have a new homepage!
85 * Revision 1.39 2002/03/24 13:25:43 swa
86 * name change related issues
88 * Revision 1.38 2002/03/24 13:05:48 jongfoster
89 * Renaming re_filterfile to filterfile
91 * Revision 1.37 2002/03/16 23:54:06 jongfoster
92 * Adding graceful termination feature, to help look for memory leaks.
93 * If you enable this (which, by design, has to be done by hand
94 * editing config.h) and then go to http://i.j.b/die, then the program
95 * will exit cleanly after the *next* request. It should free all the
96 * memory that was used.
98 * Revision 1.36 2002/03/13 00:27:05 jongfoster
101 * Revision 1.35 2002/03/07 03:52:44 oes
102 * Set logging to tty for --no-daemon mode
104 * Revision 1.34 2002/03/06 23:14:35 jongfoster
105 * Trivial cosmetic changes to make function comments easier to find.
107 * Revision 1.33 2002/03/05 04:52:42 oes
108 * Deleted non-errlog debugging code
110 * Revision 1.32 2002/03/04 18:24:53 oes
111 * Re-enabled output of unknown config directive hash
113 * Revision 1.31 2002/03/03 15:07:20 oes
114 * Re-enabled automatic config reloading
116 * Revision 1.30 2002/01/22 23:31:43 jongfoster
117 * Replacing strsav() with string_append()
119 * Revision 1.29 2002/01/17 21:02:30 jongfoster
120 * Moving all our URL and URL pattern parsing code to urlmatch.c.
122 * Renaming free_url to free_url_spec, since it frees a struct url_spec.
124 * Revision 1.28 2001/12/30 14:07:32 steudten
125 * - Add signal handling (unix)
126 * - Add SIGHUP handler (unix)
127 * - Add creation of pidfile (unix)
128 * - Add action 'top' in rc file (RH)
129 * - Add entry 'SIGNALS' to manpage
130 * - Add exit message to logfile (unix)
132 * Revision 1.27 2001/11/07 00:02:13 steudten
133 * Add line number in error output for lineparsing for
134 * actionsfile and configfile.
135 * Special handling for CLF added.
137 * Revision 1.26 2001/11/05 21:41:43 steudten
138 * Add changes to be a real daemon just for unix os.
139 * (change cwd to /, detach from controlling tty, set
140 * process group and session leader to the own process.
142 * Add some fatal-error log message for failed malloc().
143 * Add '-d' if compiled with 'configure --with-debug' to
144 * enable debug output.
146 * Revision 1.25 2001/10/25 03:40:48 david__schmidt
147 * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple
148 * threads to call select() simultaneously. So, it's time to do a real, live,
149 * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__
150 * (native). Both versions will work, but using __OS2__ offers multi-threading.
152 * Revision 1.24 2001/10/23 21:40:30 jongfoster
153 * Added support for enable-edit-actions and enable-remote-toggle config
156 * Revision 1.23 2001/10/07 15:36:00 oes
157 * Introduced new config option "buffer-limit"
159 * Revision 1.22 2001/09/22 16:36:59 jongfoster
160 * Removing unused parameter fs from read_config_line()
162 * Revision 1.21 2001/09/16 17:10:43 jongfoster
163 * Moving function savearg() here, since it was the only thing left in
166 * Revision 1.20 2001/07/30 22:08:36 jongfoster
167 * Tidying up #defines:
168 * - All feature #defines are now of the form FEATURE_xxx
169 * - Permanently turned off WIN_GUI_EDIT
170 * - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
172 * Revision 1.19 2001/07/15 17:45:16 jongfoster
173 * Removing some unused #includes
175 * Revision 1.18 2001/07/13 14:01:14 oes
176 * - Removed all #ifdef PCRS
177 * - Removed vim-settings
179 * Revision 1.17 2001/06/29 13:31:03 oes
180 * - Improved comments
181 * - Fixed (actionsfile) and sorted hashes
182 * - Introduced admin_address and proxy-info-url
183 * as config parameters
184 * - Renamed config->proxy_args_invocation (which didn't have
185 * the invocation but the options!) to config->proxy_args
186 * - Various adaptions
187 * - Removed logentry from cancelled commit
189 * Revision 1.16 2001/06/09 10:55:28 jongfoster
190 * Changing BUFSIZ ==> BUFFER_SIZE
192 * Revision 1.15 2001/06/07 23:13:40 jongfoster
193 * Merging ACL and forward files into config file.
194 * Cosmetic: Sorting config file options alphabetically.
195 * Cosmetic: Adding brief syntax comments to config file options.
197 * Revision 1.14 2001/06/07 14:46:25 joergs
198 * Missing make_path() added for re_filterfile.
200 * Revision 1.13 2001/06/05 22:33:54 jongfoster
202 * Fixed minor memory leak.
203 * Also now uses make_path to prepend the pathnames.
205 * Revision 1.12 2001/06/05 20:04:09 jongfoster
206 * Now uses _snprintf() in place of snprintf() under Win32.
208 * Revision 1.11 2001/06/04 18:31:58 swa
209 * files are now prefixed with either `confdir' or `logdir'.
210 * `make redhat-dist' replaces both entries confdir and logdir
213 * Revision 1.10 2001/06/03 19:11:54 oes
214 * introduced confdir option
216 * Revision 1.9 2001/06/01 20:06:24 jongfoster
217 * Removed support for "tinygif" option - moved to actions file.
219 * Revision 1.8 2001/05/31 21:27:13 jongfoster
220 * Removed many options from the config file and into the
221 * "actions" file: add_forwarded, suppress_vanilla_wafer,
222 * wafer, add_header, user_agent, referer, from
223 * Also globally replaced "permission" with "action".
225 * Revision 1.7 2001/05/29 09:50:24 jongfoster
226 * Unified blocklist/imagelist/permissionslist.
227 * File format is still under discussion, but the internal changes
230 * Also modified interceptor behaviour:
231 * - We now intercept all URLs beginning with one of the following
232 * prefixes (and *only* these prefixes):
234 * * http://ijbswa.sf.net/config/
235 * * http://ijbswa.sourceforge.net/config/
236 * - New interceptors "home page" - go to http://i.j.b/ to see it.
237 * - Internal changes so that intercepted and fast redirect pages
238 * are not replaced with an image.
239 * - Interceptors now have the option to send a binary page direct
240 * to the client. (i.e. ijb-send-banner uses this)
241 * - Implemented show-url-info interceptor. (Which is why I needed
242 * the above interceptors changes - a typical URL is
243 * "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
244 * The previous mechanism would not have intercepted that, and
245 * if it had been intercepted then it then it would have replaced
248 * Revision 1.6 2001/05/26 00:28:36 jongfoster
249 * Automatic reloading of config file.
250 * Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
251 * Most of the global variables have been moved to a new
252 * struct configuration_spec, accessed through csp->config->globalname
253 * Most of the globals remaining are used by the Win32 GUI.
255 * Revision 1.5 2001/05/25 22:34:30 jongfoster
258 * Revision 1.4 2001/05/22 18:46:04 oes
260 * - Enabled filtering banners by size rather than URL
261 * by adding patterns that replace all standard banner
262 * sizes with the "Junkbuster" gif to the re_filterfile
264 * - Enabled filtering WebBugs by providing a pattern
265 * which kills all 1x1 images
267 * - Added support for PCRE_UNGREEDY behaviour to pcrs,
268 * which is selected by the (nonstandard and therefore
269 * capital) letter 'U' in the option string.
270 * It causes the quantifiers to be ungreedy by default.
271 * Appending a ? turns back to greedy (!).
273 * - Added a new interceptor ijb-send-banner, which
274 * sends back the "Junkbuster" gif. Without imagelist or
275 * MSIE detection support, or if tinygif = 1, or the
276 * URL isn't recognized as an imageurl, a lame HTML
277 * explanation is sent instead.
279 * - Added new feature, which permits blocking remote
280 * script redirects and firing back a local redirect
282 * The feature is conditionally compiled, i.e. it
283 * can be disabled with --disable-fast-redirects,
284 * plus it must be activated by a "fast-redirects"
285 * line in the config file, has its own log level
286 * and of course wants to be displayed by show-proxy-args
287 * Note: Boy, all the #ifdefs in 1001 locations and
288 * all the fumbling with configure.in and acconfig.h
289 * were *way* more work than the feature itself :-(
291 * - Because a generic redirect template was needed for
292 * this, tinygif = 3 now uses the same.
294 * - Moved GIFs, and other static HTTP response templates
299 * - Removed some >400 CRs again (Jon, you really worked
302 * Revision 1.3 2001/05/20 01:21:20 jongfoster
303 * Version 2.9.4 checkin.
304 * - Merged popupfile and cookiefile, and added control over PCRS
305 * filtering, in new "permissionsfile".
306 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
307 * file error you now get a message box (in the Win32 GUI) rather
308 * than the program exiting with no explanation.
309 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
311 * - Removed tabs from "config"
312 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
313 * - Bumped up version number.
315 * Revision 1.2 2001/05/17 23:01:01 oes
316 * - Cleaned CRLF's from the sources and related files
318 * Revision 1.1.1.1 2001/05/15 13:58:58 oes
319 * Initial import of version 2.9.3 source tree
322 *********************************************************************/
328 #include <sys/types.h>
342 # include <windows.h>
345 # ifndef _WIN_CONSOLE
347 # endif /* ndef _WIN_CONSOLE */
349 /* VC++ has "_snprintf", not "snprintf" */
350 #define snprintf _snprintf
352 #else /* ifndef _WIN32 */
356 # include <sys/wait.h>
358 # include <sys/time.h>
359 # include <sys/stat.h>
369 #include "miscutil.h"
373 #include "urlmatch.h"
376 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
379 * Fix a problem with Solaris. There should be no effect on other
381 * Solaris's isspace() is a macro which uses it's argument directly
382 * as an array index. Therefore we need to make sure that high-bit
383 * characters generate +ve values, and ideally we also want to make
384 * the argument match the declared parameter type of "int".
386 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
387 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
389 #ifdef FEATURE_TOGGLE
391 * Indicates if Privoxy is currently enabled.
393 int g_bToggleIJB = 1; /* Privoxy is enabled by default. */
394 #endif /* def FEATURE_TOGGLE */
397 * The filename of the config file
399 const char *configfile = NULL;
402 * Global argument count, so that CGI functions can access the
408 * Global argument list, so that CGI functions can access the
411 const char **Argv = NULL;
414 * The configuration file which is currently loaded.
416 static struct file_list *current_configfile = NULL;
420 * This takes the "cryptic" hash of each keyword and aliases them to
421 * something a little more readable. This also makes changing the
422 * hash values easier if they should change or the hash algorthm changes.
423 * Use the included "hash" program to find out what the hash will be
424 * for any string supplied on the command line. (Or just put it in the
425 * config file and read the number from the error message in the log).
427 * Please keep this list sorted alphabetically (but with the Windows
428 * console and GUI specific options last).
431 #define hash_actions_file 1196306641ul /**< "actionsfile" */
432 #define hash_activity_console_address 18904208ul /**< "activity-console-address" */
433 #define hash_activity_console_update_freq 3442780376ul /**< "activity-console-update-freq" */
434 #define hash_admin_address 4112573064ul /**< "admin-address" */
435 #define hash_buffer_limit 1881726070ul /**< "buffer-limit */
436 #define hash_confdir 1978389ul /**< "confdir" */
437 #define hash_debug 78263ul /**< "debug" */
438 #define hash_deny_access 1227333715ul /**< "deny-access" */
439 #define hash_enable_edit_actions 2517097536ul /**< "enable-edit-actions" */
440 #define hash_enable_remote_toggle 2979744683ul /**< "enable-remote-toggle" */
441 #define hash_filterfile 250887266ul /**< "filterfile" */
442 #define hash_forward 2029845ul /**< "forward" */
443 #define hash_forward_socks4 3963965521ul /**< "forward-socks4" */
444 #define hash_forward_socks4a 2639958518ul /**< "forward-socks4a" */
445 #define hash_image_blocker_custom_file 2863352327ul /**< "image-blocker-custom-file" */
446 #define hash_jarfile 2046641ul /**< "jarfile" */
447 #define hash_listen_address 1255650842ul /**< "listen-address" */
448 #define hash_logdir 422889ul /**< "logdir" */
449 #define hash_logfile 2114766ul /**< "logfile" */
450 #define hash_permit_access 3587953268ul /**< "permit-access" */
451 #define hash_proxy_info_url 3903079059ul /**< "proxy-info-url" */
452 #define hash_single_threaded 4250084780ul /**< "single-threaded" */
453 #define hash_suppress_blocklists 1948693308ul /**< "suppress-blocklists" */
454 #define hash_toggle 447966ul /**< "toggle" */
455 #define hash_trust_info_url 430331967ul /**< "trust-info-url" */
456 #define hash_trustfile 56494766ul /**< "trustfile" */
457 #define hash_usermanual 1416668518ul /**< "user-manual" */
459 #define hash_activity_animation 1817904738ul /**< "activity-animation" */
460 #define hash_close_button_minimizes 3651284693ul /**< "close-button-minimizes" */
461 #define hash_hide_console 2048809870ul /**< "hide-console" */
462 #define hash_log_buffer_size 2918070425ul /**< "log-buffer-size" */
463 #define hash_log_font_name 2866730124ul /**< "log-font-name" */
464 #define hash_log_font_size 2866731014ul /**< "log-font-size" */
465 #define hash_log_highlight_messages 4032101240ul /**< "log-highlight-messages" */
466 #define hash_log_max_lines 2868344173ul /**< "log-max-lines" */
467 #define hash_log_messages 2291744899ul /**< "log-messages" */
468 #define hash_show_on_task_bar 215410365ul /**< "show-on-task-bar" */
470 static void savearg(char *command, char *argument, struct configuration_spec * config);
472 /*********************************************************************
474 * Function : unload_configfile
476 * Description : Free the config structure and all components.
479 * 1 : data: struct configuration_spec to unload
483 *********************************************************************/
484 void unload_configfile (void * data)
486 struct configuration_spec * config = (struct configuration_spec *)data;
487 struct forward_spec *cur_fwd = config->forward;
490 struct access_control_list *cur_acl = config->acl;
492 while (cur_acl != NULL)
494 struct access_control_list * next_acl = cur_acl->next;
499 #endif /* def FEATURE_ACL */
501 while (cur_fwd != NULL)
503 struct forward_spec * next_fwd = cur_fwd->next;
504 free_url_spec(cur_fwd->url);
506 freez(cur_fwd->gateway_host);
507 freez(cur_fwd->forward_host);
511 config->forward = NULL;
513 #ifdef FEATURE_COOKIE_JAR
514 if ( NULL != config->jar )
516 fclose( config->jar );
519 #endif /* def FEATURE_COOKIE_JAR */
521 freez(config->confdir);
522 freez(config->logdir);
524 freez(config->haddr);
525 freez(config->logfile);
527 for (i = 0; i < MAX_ACTION_FILES; i++)
529 freez(config->actions_file_short[i]);
530 freez(config->actions_file[i]);
533 freez(config->admin_address);
534 freez(config->proxy_info_url);
535 freez(config->proxy_args);
536 freez(config->usermanual);
538 #ifdef FEATURE_COOKIE_JAR
539 freez(config->jarfile);
540 #endif /* def FEATURE_COOKIE_JAR */
542 freez(config->re_filterfile);
544 freez(config->image_blocker_data);
545 freez(config->image_blocker_format);
549 #ifdef FEATURE_GRACEFUL_TERMINATION
550 /*********************************************************************
552 * Function : unload_current_config_file
554 * Description : Unloads current config file - reset to state at
555 * beginning of program.
561 *********************************************************************/
562 void unload_current_config_file(void)
564 if (current_configfile)
566 current_configfile->unloader = unload_configfile;
567 current_configfile = NULL;
573 /*********************************************************************
575 * Function : load_config
577 * Description : Load the config file and all parameters.
581 * Returns : The configuration_spec, or NULL on error.
583 *********************************************************************/
584 struct configuration_spec * load_config(void)
586 char buf[BUFFER_SIZE];
587 char *p, *q, *image_buf, *image_path;
588 FILE *configfp = NULL,
590 struct configuration_spec * config = NULL;
591 struct client_state * fake_csp;
592 struct file_list *fs;
593 struct stat statbuf[1];
594 unsigned long linenum = 0;
595 int i, file_size, bytes_read;
597 if ( !check_file_changed(current_configfile, configfile, &fs))
599 /* No need to load */
600 return ((struct configuration_spec *)current_configfile->f);
604 log_error(LOG_LEVEL_FATAL, "can't check configuration file '%s': %E",
608 log_error(LOG_LEVEL_INFO, "loading configuration file '%s':", configfile);
610 #ifdef FEATURE_TOGGLE
612 #endif /* def FEATURE_TOGGLE */
614 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
620 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
621 /* Never get here - LOG_LEVEL_FATAL causes program exit */
625 * This is backwards from how it's usually done.
626 * Following the usual pattern, "fs" would be stored in a member
627 * variable in "csp", and then we'd access "config" from "fs->f",
628 * using a cast. However, "config" is used so often that a
629 * cast each time would be very ugly, and the extra indirection
630 * would waste CPU cycles. Therefore we store "config" in
631 * "csp->config", and "fs" in "csp->config->config_file_list".
633 config->config_file_list = fs;
638 config->multi_threaded = 1;
639 config->hport = HADDR_PORT;
640 config->buffer_limit = 4096 * 1024;
641 config->usermanual = strdup(USER_MANUAL_URL);
642 config->proxy_args = strdup("");
643 #ifdef FEATURE_ACTIVITY_CONSOLE
644 config->activity_port = ACTIVTY_ADDR_PORT;
645 config->activity_freq = 5;
646 #endif /* def FEATURE_ACTIVITY_CONSOLE */
648 if ((configfp = fopen(configfile, "r")) == NULL)
650 log_error(LOG_LEVEL_FATAL, "can't open configuration file '%s': %E",
652 /* Never get here - LOG_LEVEL_FATAL causes program exit */
655 while (read_config_line(buf, sizeof(buf), configfp, &linenum) != NULL)
657 char cmd[BUFFER_SIZE];
658 char arg[BUFFER_SIZE];
659 char tmp[BUFFER_SIZE];
661 struct access_control_list *cur_acl;
662 #endif /* def FEATURE_ACL */
663 struct forward_spec *cur_fwd;
669 /* Copy command (i.e. up to space or tab) into cmd */
672 while (*p && (*p != ' ') && (*p != '\t'))
678 /* Skip over the whitespace in buf */
679 while (*p && ((*p == ' ') || (*p == '\t')))
684 /* Copy the argument into arg */
687 /* Should never happen, but check this anyway */
693 /* Make sure the command field is lower case */
698 *p = ijb_tolower(*p);
702 /* Save the argument for show-proxy-args */
703 savearg(cmd, arg, config);
706 switch( hash_string( cmd ) )
708 /* *************************************************************************
709 * actionsfile actions-file-name
710 * In confdir by default
711 * *************************************************************************/
712 case hash_actions_file :
714 while ((i < MAX_ACTION_FILES) && (NULL != config->actions_file[i]))
719 if (i >= MAX_ACTION_FILES)
721 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
722 "(You can increase this limit by changing MAX_ACTION_FILES in project.h and recompiling).",
725 config->actions_file_short[i] = strdup(arg);
726 p = malloc(strlen(arg) + sizeof(".action"));
729 log_error(LOG_LEVEL_FATAL, "Out of memory");
732 strcat(p, ".action");
733 config->actions_file[i] = make_path(config->confdir, p);
737 /* *************************************************************************
738 * activity-console-address [ip][:port]
739 * *************************************************************************/
740 #ifdef FEATURE_ACTIVITY_CONSOLE
741 case hash_activity_console_address :
742 freez(config->activity_address);
743 config->activity_address = strdup(arg);
745 #endif /* def FEATURE_ACTIVITY_CONSOLE */
747 /* *************************************************************************
748 * activity-console-update-freq
749 * *************************************************************************/
750 #ifdef FEATURE_ACTIVITY_CONSOLE
751 case hash_activity_console_update_freq :
752 config->activity_freq = atoi(arg);
753 if (config->activity_freq < 1)
754 config->activity_freq = 5;
756 #endif /* def FEATURE_ACTIVITY_CONSOLE */
758 /* *************************************************************************
759 * admin-address email-address
760 * *************************************************************************/
761 case hash_admin_address :
762 freez(config->admin_address);
763 config->admin_address = strdup(arg);
766 /* *************************************************************************
768 * *************************************************************************/
769 case hash_buffer_limit :
770 config->buffer_limit = (size_t) 1024 * atoi(arg);
773 /* *************************************************************************
774 * confdir directory-name
775 * *************************************************************************/
777 freez(config->confdir);
778 config->confdir = make_path( NULL, arg);
781 /* *************************************************************************
783 * Specifies debug level, multiple values are ORed together.
784 * *************************************************************************/
786 config->debug |= atoi(arg);
789 /* *************************************************************************
790 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
791 * *************************************************************************/
793 case hash_deny_access:
794 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
796 if ((vec_count != 1) && (vec_count != 2))
798 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
799 "deny-access directive in configuration file.");
800 string_append(&config->proxy_args,
801 "<br>\nWARNING: Wrong number of parameters for "
802 "deny-access directive in configuration file.<br><br>\n");
806 /* allocate a new node */
807 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
811 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
812 /* Never get here - LOG_LEVEL_FATAL causes program exit */
815 cur_acl->action = ACL_DENY;
817 if (acl_addr(vec[0], cur_acl->src) < 0)
819 log_error(LOG_LEVEL_ERROR, "Invalid source IP for deny-access "
820 "directive in configuration file: \"%s\"", vec[0]);
821 string_append(&config->proxy_args,
822 "<br>\nWARNING: Invalid source IP for deny-access directive"
823 " in configuration file: \"");
824 string_append(&config->proxy_args,
826 string_append(&config->proxy_args,
833 if (acl_addr(vec[1], cur_acl->dst) < 0)
835 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for deny-access "
836 "directive in configuration file: \"%s\"", vec[0]);
837 string_append(&config->proxy_args,
838 "<br>\nWARNING: Invalid destination IP for deny-access directive"
839 " in configuration file: \"");
840 string_append(&config->proxy_args,
842 string_append(&config->proxy_args,
850 * Add it to the list. Note we reverse the list to get the
851 * behaviour the user expects. With both the ACL and
852 * actions file, the last match wins. However, the internal
853 * implementations are different: The actions file is stored
854 * in the same order as the file, and scanned completely.
855 * With the ACL, we reverse the order as we load it, then
856 * when we scan it we stop as soon as we get a match.
858 cur_acl->next = config->acl;
859 config->acl = cur_acl;
862 #endif /* def FEATURE_ACL */
864 /* *************************************************************************
865 * enable-edit-actions 0|1
866 * *************************************************************************/
867 #ifdef FEATURE_CGI_EDIT_ACTIONS
868 case hash_enable_edit_actions:
869 if ((*arg != '\0') && (0 != atoi(arg)))
871 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
875 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
878 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
880 /* *************************************************************************
881 * enable-remote-toggle 0|1
882 * *************************************************************************/
883 #ifdef FEATURE_CGI_EDIT_ACTIONS
884 case hash_enable_remote_toggle:
885 if ((*arg != '\0') && (0 != atoi(arg)))
887 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
891 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
894 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
896 /* *************************************************************************
897 * forward url-pattern (.|http-proxy-host[:port])
898 * *************************************************************************/
900 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
904 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
905 "directive in configuration file.");
906 string_append(&config->proxy_args,
907 "<br>\nWARNING: Wrong number of parameters for "
908 "forward directive in configuration file.");
912 /* allocate a new node */
913 cur_fwd = zalloc(sizeof(*cur_fwd));
916 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
917 /* Never get here - LOG_LEVEL_FATAL causes program exit */
921 cur_fwd->type = SOCKS_NONE;
923 /* Save the URL pattern */
924 if (create_url_spec(cur_fwd->url, vec[0]))
926 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
927 "directive in configuration file.");
928 string_append(&config->proxy_args,
929 "<br>\nWARNING: Bad URL specifier for "
930 "forward directive in configuration file.");
934 /* Parse the parent HTTP proxy host:port */
937 if (strcmp(p, ".") != 0)
939 cur_fwd->forward_host = strdup(p);
941 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
944 cur_fwd->forward_port = atoi(p);
947 if (cur_fwd->forward_port <= 0)
949 cur_fwd->forward_port = 8000;
954 cur_fwd->next = config->forward;
955 config->forward = cur_fwd;
959 /* *************************************************************************
960 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
961 * *************************************************************************/
962 case hash_forward_socks4:
963 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
967 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
968 "forward-socks4 directive in configuration file.");
969 string_append(&config->proxy_args,
970 "<br>\nWARNING: Wrong number of parameters for "
971 "forward-socks4 directive in configuration file.");
975 /* allocate a new node */
976 cur_fwd = zalloc(sizeof(*cur_fwd));
979 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
980 /* Never get here - LOG_LEVEL_FATAL causes program exit */
984 cur_fwd->type = SOCKS_4;
986 /* Save the URL pattern */
987 if (create_url_spec(cur_fwd->url, vec[0]))
989 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
990 "directive in configuration file.");
991 string_append(&config->proxy_args,
992 "<br>\nWARNING: Bad URL specifier for "
993 "forward-socks4 directive in configuration file.");
997 /* Parse the SOCKS proxy host[:port] */
1000 if (strcmp(p, ".") != 0)
1002 cur_fwd->gateway_host = strdup(p);
1004 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1007 cur_fwd->gateway_port = atoi(p);
1009 if (cur_fwd->gateway_port <= 0)
1011 cur_fwd->gateway_port = 1080;
1015 /* Parse the parent HTTP proxy host[:port] */
1018 if (strcmp(p, ".") != 0)
1020 cur_fwd->forward_host = strdup(p);
1022 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1025 cur_fwd->forward_port = atoi(p);
1028 if (cur_fwd->forward_port <= 0)
1030 cur_fwd->forward_port = 8000;
1035 cur_fwd->next = config->forward;
1036 config->forward = cur_fwd;
1040 /* *************************************************************************
1041 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1042 * *************************************************************************/
1043 case hash_forward_socks4a:
1044 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1048 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1049 "forward-socks4a directive in configuration file.");
1050 string_append(&config->proxy_args,
1051 "<br>\nWARNING: Wrong number of parameters for "
1052 "forward-socks4a directive in configuration file.");
1056 /* allocate a new node */
1057 cur_fwd = zalloc(sizeof(*cur_fwd));
1058 if (cur_fwd == NULL)
1060 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1061 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1065 cur_fwd->type = SOCKS_4A;
1067 /* Save the URL pattern */
1068 if (create_url_spec(cur_fwd->url, vec[0]))
1070 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1071 "directive in configuration file.");
1072 string_append(&config->proxy_args,
1073 "<br>\nWARNING: Bad URL specifier for "
1074 "forward-socks4a directive in configuration file.");
1078 /* Parse the SOCKS proxy host[:port] */
1081 cur_fwd->gateway_host = strdup(p);
1083 if (NULL != (p = strchr(cur_fwd->gateway_host, ':')))
1086 cur_fwd->gateway_port = atoi(p);
1088 if (cur_fwd->gateway_port <= 0)
1090 cur_fwd->gateway_port = 1080;
1093 /* Parse the parent HTTP proxy host[:port] */
1096 if (strcmp(p, ".") != 0)
1098 cur_fwd->forward_host = strdup(p);
1100 if (NULL != (p = strchr(cur_fwd->forward_host, ':')))
1103 cur_fwd->forward_port = atoi(p);
1106 if (cur_fwd->forward_port <= 0)
1108 cur_fwd->forward_port = 8000;
1113 cur_fwd->next = config->forward;
1114 config->forward = cur_fwd;
1118 /* *************************************************************************
1119 * jarfile jar-file-name
1120 * In logdir by default
1121 * *************************************************************************/
1122 #ifdef FEATURE_COOKIE_JAR
1124 freez(config->jarfile);
1125 config->jarfile = make_path(config->logdir, arg);
1127 #endif /* def FEATURE_COOKIE_JAR */
1129 /* *************************************************************************
1130 * listen-address [ip][:port]
1131 * *************************************************************************/
1132 case hash_listen_address :
1133 freez(config->haddr);
1134 config->haddr = strdup(arg);
1137 /* *************************************************************************
1138 * logdir directory-name
1139 * *************************************************************************/
1141 freez(config->logdir);
1142 config->logdir = make_path(NULL, arg);
1145 /* *************************************************************************
1146 * logfile log-file-name
1147 * In logdir by default
1148 * *************************************************************************/
1150 freez(config->logfile);
1151 config->logfile = no_daemon ? NULL : make_path(config->logdir, arg);
1154 /* *************************************************************************
1155 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1156 * *************************************************************************/
1158 case hash_permit_access:
1159 vec_count = ssplit(arg, " \t", vec, SZ(vec), 1, 1);
1161 if ((vec_count != 1) && (vec_count != 2))
1163 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1164 "permit-access directive in configuration file.");
1165 string_append(&config->proxy_args,
1166 "<br>\nWARNING: Wrong number of parameters for "
1167 "permit-access directive in configuration file.<br><br>\n");
1172 /* allocate a new node */
1173 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1175 if (cur_acl == NULL)
1177 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1178 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1181 cur_acl->action = ACL_PERMIT;
1183 if (acl_addr(vec[0], cur_acl->src) < 0)
1185 log_error(LOG_LEVEL_ERROR, "Invalid source IP for permit-access "
1186 "directive in configuration file: \"%s\"", vec[0]);
1187 string_append(&config->proxy_args,
1188 "<br>\nWARNING: Invalid source IP for permit-access directive"
1189 " in configuration file: \"");
1190 string_append(&config->proxy_args,
1192 string_append(&config->proxy_args,
1199 if (acl_addr(vec[1], cur_acl->dst) < 0)
1201 log_error(LOG_LEVEL_ERROR, "Invalid destination IP for "
1202 "permit-access directive in configuration file: \"%s\"",
1204 string_append(&config->proxy_args,
1205 "<br>\nWARNING: Invalid destination IP for permit-access directive"
1206 " in configuration file: \"");
1207 string_append(&config->proxy_args,
1209 string_append(&config->proxy_args,
1217 * Add it to the list. Note we reverse the list to get the
1218 * behaviour the user expects. With both the ACL and
1219 * actions file, the last match wins. However, the internal
1220 * implementations are different: The actions file is stored
1221 * in the same order as the file, and scanned completely.
1222 * With the ACL, we reverse the order as we load it, then
1223 * when we scan it we stop as soon as we get a match.
1225 cur_acl->next = config->acl;
1226 config->acl = cur_acl;
1229 #endif /* def FEATURE_ACL */
1231 /* *************************************************************************
1232 * proxy-info-url url
1233 * *************************************************************************/
1234 case hash_proxy_info_url :
1235 freez(config->proxy_info_url);
1236 config->proxy_info_url = strdup(arg);
1239 /* *************************************************************************
1240 * re_filterfile file-name
1241 * In confdir by default.
1242 * *************************************************************************/
1243 case hash_filterfile :
1244 freez(config->re_filterfile);
1245 config->re_filterfile = make_path(config->confdir, arg);
1248 /* *************************************************************************
1250 * *************************************************************************/
1251 case hash_single_threaded :
1252 config->multi_threaded = 0;
1255 /* *************************************************************************
1257 * *************************************************************************/
1258 #ifdef FEATURE_TOGGLE
1260 g_bToggleIJB = atoi(arg);
1262 #endif /* def FEATURE_TOGGLE */
1264 /* *************************************************************************
1265 * trust-info-url url
1266 * *************************************************************************/
1267 #ifdef FEATURE_TRUST
1268 case hash_trust_info_url :
1269 enlist(config->trust_info, arg);
1271 #endif /* def FEATURE_TRUST */
1273 /* *************************************************************************
1274 * trustfile filename
1275 * (In confdir by default.)
1276 * *************************************************************************/
1277 #ifdef FEATURE_TRUST
1278 case hash_trustfile :
1279 freez(config->trustfile);
1280 config->trustfile = make_path(config->confdir, arg);
1282 #endif /* def FEATURE_TRUST */
1284 /* *************************************************************************
1286 * *************************************************************************/
1287 case hash_usermanual :
1288 freez(config->usermanual);
1289 config->usermanual = strdup(arg);
1292 /* *************************************************************************
1293 * Win32 Console options:
1294 * *************************************************************************/
1296 /* *************************************************************************
1298 * *************************************************************************/
1300 case hash_hide_console :
1303 #endif /*def _WIN_CONSOLE*/
1306 /* *************************************************************************
1307 * Win32 GUI options:
1308 * *************************************************************************/
1310 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1311 /* *************************************************************************
1312 * activity-animation (0|1)
1313 * *************************************************************************/
1314 case hash_activity_animation :
1315 g_bShowActivityAnimation = atoi(arg);
1318 /* *************************************************************************
1319 * close-button-minimizes (0|1)
1320 * *************************************************************************/
1321 case hash_close_button_minimizes :
1322 g_bCloseHidesWindow = atoi(arg);
1325 /* *************************************************************************
1326 * log-buffer-size (0|1)
1327 * *************************************************************************/
1328 case hash_log_buffer_size :
1329 g_bLimitBufferSize = atoi(arg);
1332 /* *************************************************************************
1333 * log-font-name fontnane
1334 * *************************************************************************/
1335 case hash_log_font_name :
1336 strcpy( g_szFontFaceName, arg );
1339 /* *************************************************************************
1341 * *************************************************************************/
1342 case hash_log_font_size :
1343 g_nFontSize = atoi(arg);
1346 /* *************************************************************************
1347 * log-highlight-messages (0|1)
1348 * *************************************************************************/
1349 case hash_log_highlight_messages :
1350 g_bHighlightMessages = atoi(arg);
1353 /* *************************************************************************
1355 * *************************************************************************/
1356 case hash_log_max_lines :
1357 g_nMaxBufferLines = atoi(arg);
1360 /* *************************************************************************
1361 * log-messages (0|1)
1362 * *************************************************************************/
1363 case hash_log_messages :
1364 g_bLogMessages = atoi(arg);
1367 /* *************************************************************************
1368 * show-on-task-bar (0|1)
1369 * *************************************************************************/
1370 case hash_show_on_task_bar :
1371 g_bShowOnTaskBar = atoi(arg);
1374 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1376 /* *************************************************************************
1377 * image-blocker-custom-file
1378 * *************************************************************************/
1379 case hash_image_blocker_custom_file :
1380 freez(config->image_blocker_data);
1381 freez(config->image_blocker_format);
1382 config->image_blocker_length = 0;
1383 image_path = make_path(config->confdir, arg);
1386 * Load up the custom image bitmap file
1388 if (NULL == (imagefp = fopen(image_path, "rb")))
1391 * If we can't open the user's requested image, complain
1393 log_error(LOG_LEVEL_ERROR, "Unable to load custom blocker image: %s.", image_path);
1397 if (stat(image_path, statbuf) == 0)
1399 file_size = statbuf->st_size;
1400 image_buf = zalloc(file_size);
1401 if (image_buf != NULL)
1403 bytes_read = fread(image_buf,1,file_size,imagefp);
1406 config->image_blocker_data = image_buf;
1407 config->image_blocker_length = file_size;
1409 * Ensure we can look into files for file signatures
1414 * Snoop into the binary data for a filetype signature
1416 if (memcmp(image_buf,"GIF",3) == 0)
1417 config->image_blocker_format = IMAGE_MIMETYPE_GIF;
1418 else if (memcmp(&image_buf[6],"JFIF",4) == 0)
1419 config->image_blocker_format = IMAGE_MIMETYPE_JPG;
1420 else if (memcmp(&image_buf[1],"PNG",3) == 0)
1421 config->image_blocker_format = IMAGE_MIMETYPE_PNG;
1424 log_error(LOG_LEVEL_ERROR, "Unsupported custom image file type.");
1425 freez(config->image_blocker_data);
1429 freez(config->image_blocker_data);
1433 log_error(LOG_LEVEL_ERROR, "Unable to read custom blocker image: %s", image_path, bytes_read, file_size);
1435 config->image_blocker_length = 0;
1439 log_error(LOG_LEVEL_ERROR, "Unable to allocate memory for custom blocker image: %s.", image_path);
1442 log_error(LOG_LEVEL_ERROR, "Unable to get statistics on custom blocker image file: %s", image_path);
1446 * If our load failed for some reason, just give the default
1447 * checkerboard pattern
1449 if (config->image_blocker_data == NULL)
1451 log_error(LOG_LEVEL_ERROR, "Custom blocker image processing failed; defaulting to \"pattern\".");
1452 config->image_blocker_data = (char*)image_pattern_data;
1453 config->image_blocker_length = image_pattern_length;
1454 config->image_blocker_format = BUILTIN_IMAGE_MIMETYPE;
1458 /* *************************************************************************
1459 * Warnings about unsupported features
1460 * *************************************************************************/
1462 case hash_deny_access:
1463 #endif /* ndef FEATURE_ACL */
1464 #ifndef FEATURE_CGI_EDIT_ACTIONS
1465 case hash_enable_edit_actions:
1466 case hash_enable_remote_toggle:
1467 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
1468 #ifndef FEATURE_COOKIE_JAR
1470 #endif /* ndef FEATURE_COOKIE_JAR */
1472 case hash_permit_access:
1473 #endif /* ndef FEATURE_ACL */
1474 #ifndef FEATURE_TOGGLE
1476 #endif /* ndef FEATURE_TOGGLE */
1477 #ifndef FEATURE_TRUST
1478 case hash_trustfile :
1479 case hash_trust_info_url :
1480 #endif /* ndef FEATURE_TRUST */
1482 #ifndef _WIN_CONSOLE
1483 case hash_hide_console :
1484 #endif /* ndef _WIN_CONSOLE */
1486 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1487 case hash_activity_animation :
1488 case hash_close_button_minimizes :
1489 case hash_log_buffer_size :
1490 case hash_log_font_name :
1491 case hash_log_font_size :
1492 case hash_log_highlight_messages :
1493 case hash_log_max_lines :
1494 case hash_log_messages :
1495 case hash_show_on_task_bar :
1496 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1497 /* These warnings are annoying - so hide them. -- Jon */
1498 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1501 /* *************************************************************************/
1503 /* *************************************************************************/
1505 * I decided that I liked this better as a warning than an
1506 * error. To change back to an error, just change log level
1507 * to LOG_LEVEL_FATAL.
1509 log_error(LOG_LEVEL_ERROR, "Unrecognized directive '%s' (%luul) in line %lu in "
1510 "configuration file (%s).", buf, hash_string(cmd), linenum, configfile);
1511 string_append(&config->proxy_args, "<br>\nWARNING: unrecognized directive : ");
1512 string_append(&config->proxy_args, buf);
1513 string_append(&config->proxy_args, "<br><br>\n");
1516 /* *************************************************************************/
1517 } /* end switch( hash_string(cmd) ) */
1518 } /* end while ( read_config_line(...) ) */
1522 if (NULL == config->proxy_args)
1524 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1527 init_error_log(Argv[0], config->logfile, config->debug);
1529 if (config->actions_file[0])
1531 add_loader(load_actions_file, config);
1534 if (config->re_filterfile)
1536 add_loader(load_re_filterfile, config);
1539 #ifdef FEATURE_TRUST
1540 if (config->trustfile)
1542 add_loader(load_trustfile, config);
1544 #endif /* def FEATURE_TRUST */
1546 #ifdef FEATURE_COOKIE_JAR
1547 if ( NULL != config->jarfile )
1549 if ( NULL == (config->jar = fopen(config->jarfile, "a")) )
1551 log_error(LOG_LEVEL_FATAL, "can't open jarfile '%s': %E", config->jarfile);
1552 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1554 setbuf(config->jar, NULL);
1556 #endif /* def FEATURE_COOKIE_JAR */
1558 #ifdef FEATURE_ACTIVITY_CONSOLE
1559 if ( NULL == config->activity_address )
1561 config->activity_address = strdup( ACTIVTY_ADDR_DEFAULT );
1564 if ( NULL != config->activity_address )
1566 if (NULL != (p = strchr(config->activity_address, ':')))
1571 config->activity_port = atoi(p);
1575 if (config->activity_port <= 0)
1578 log_error(LOG_LEVEL_ERROR, "invalid activity port spec %s", config->activity_address);
1580 if (*config->activity_address == '\0')
1582 config->activity_address = NULL;
1585 log_error(LOG_LEVEL_INFO, "Sending statistics updates to %s, port %d.", config->activity_address, config->activity_port);
1586 #endif /* def FEATURE_ACTIVITY_CONSOLE */
1588 if ( NULL == config->haddr )
1590 config->haddr = strdup( HADDR_DEFAULT );
1593 if ( NULL != config->haddr )
1595 if (NULL != (p = strchr(config->haddr, ':')))
1600 config->hport = atoi(p);
1604 if (config->hport <= 0)
1607 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr);
1608 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1610 if (*config->haddr == '\0')
1612 config->haddr = NULL;
1617 * Want to run all the loaders once now.
1619 * Need to set up a fake csp, so they can get to the config.
1621 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1622 fake_csp->config = config;
1624 if (run_loader(fake_csp))
1627 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1628 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1632 /* FIXME: this is a kludge for win32 */
1633 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1635 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1636 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1637 g_re_filterfile = config->re_filterfile;
1639 #ifdef FEATURE_TRUST
1640 g_trustfile = config->trustfile;
1641 #endif /* def FEATURE_TRUST */
1644 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1645 /* FIXME: end kludge */
1648 config->need_bind = 1;
1650 if (current_configfile)
1652 struct configuration_spec * oldcfg = (struct configuration_spec *)
1653 current_configfile->f;
1655 * Check if config->haddr,hport == oldcfg->haddr,hport
1657 * The following could be written more compactly as a single,
1658 * (unreadably long) if statement.
1660 config->need_bind = 0;
1661 if (config->hport != oldcfg->hport)
1663 config->need_bind = 1;
1665 else if (config->haddr == NULL)
1667 if (oldcfg->haddr != NULL)
1669 config->need_bind = 1;
1672 else if (oldcfg->haddr == NULL)
1674 config->need_bind = 1;
1676 else if (0 != strcmp(config->haddr, oldcfg->haddr))
1678 config->need_bind = 1;
1681 current_configfile->unloader = unload_configfile;
1684 fs->next = files->next;
1687 current_configfile = fs;
1693 /*********************************************************************
1695 * Function : savearg
1697 * Description : Called from `load_config'. It saves each non-empty
1698 * and non-comment line from config into
1699 * config->proxy_args. This is used to create the
1700 * show-proxy-args page. On error, frees
1701 * config->proxy_args and sets it to NULL
1704 * 1 : command = config setting that was found
1705 * 2 : argument = the setting's argument (if any)
1706 * 3 : config = Configuration to save into.
1710 *********************************************************************/
1711 static void savearg(char *command, char *argument, struct configuration_spec * config)
1721 * Add config option name embedded in
1722 * link to it's section in the user-manual
1724 buf = strdup("<a href=\"");
1725 string_append(&buf, config->usermanual);
1726 string_append(&buf, CONFIG_HELP_PREFIX);
1727 string_join (&buf, string_toupper(command));
1728 string_append(&buf, "\">");
1729 string_append(&buf, command);
1730 string_append(&buf, "</a> ");
1734 freez(config->proxy_args);
1738 if ( (NULL != argument) && ('\0' != *argument) )
1740 s = html_encode(argument);
1744 freez(config->proxy_args);
1748 if (strncmpic(argument, "http://", 7) == 0)
1750 string_append(&buf, "<a href=\"");
1751 string_append(&buf, s);
1752 string_append(&buf, "\">");
1753 string_join (&buf, s);
1754 string_append(&buf, "</a>");
1758 string_join (&buf, s);
1762 string_append(&buf, "<br>\n");
1764 string_join(&config->proxy_args, buf);