1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.136 2013/03/01 17:39:05 fabiankeil Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
6 * Purpose : Loads settings from the configuration file into
7 * global variables. This file contains both the
8 * routine to load the configuration and the global
9 * variables it writes to.
11 * Copyright : Written by and Copyright (C) 2001-2009 the
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.
36 *********************************************************************/
42 #include <sys/types.h>
61 # endif /* ndef _WIN_CONSOLE */
63 #else /* ifndef _WIN32 */
67 # include <sys/wait.h>
69 # include <sys/time.h>
70 # include <sys/stat.h>
89 const char loadcfg_h_rcs[] = LOADCFG_H_VERSION;
92 /* Privoxy is enabled by default. */
93 int global_toggle_state = 1;
94 #endif /* def FEATURE_TOGGLE */
96 /* The filename of the configfile */
97 const char *configfile = NULL;
100 * CGI functions will later need access to the invocation args,
101 * so we will make argc and argv global.
104 char * const * Argv = NULL;
106 static struct file_list *current_configfile = NULL;
110 * This takes the "cryptic" hash of each keyword and aliases them to
111 * something a little more readable. This also makes changing the
112 * hash values easier if they should change or the hash algorthm changes.
113 * Use the included "hash" program to find out what the hash will be
114 * for any string supplied on the command line. (Or just put it in the
115 * config file and read the number from the error message in the log).
117 * Please keep this list sorted alphabetically (but with the Windows
118 * console and GUI specific options last).
121 #define hash_actions_file 1196306641U /* "actionsfile" */
122 #define hash_accept_intercepted_requests 1513024973U /* "accept-intercepted-requests" */
123 #define hash_admin_address 4112573064U /* "admin-address" */
124 #define hash_allow_cgi_request_crunching 258915987U /* "allow-cgi-request-crunching" */
125 #define hash_buffer_limit 1881726070U /* "buffer-limit */
126 #define hash_client_header_order 2701453514U /* "client-header-order" */
127 #define hash_compression_level 2464423563U /* "compression-level" */
128 #define hash_confdir 1978389U /* "confdir" */
129 #define hash_connection_sharing 1348841265U /* "connection-sharing" */
130 #define hash_debug 78263U /* "debug" */
131 #define hash_default_server_timeout 2530089913U /* "default-server-timeout" */
132 #define hash_deny_access 1227333715U /* "deny-access" */
133 #define hash_enable_edit_actions 2517097536U /* "enable-edit-actions" */
134 #define hash_enable_compression 3943696946U /* "enable-compression" */
135 #define hash_enable_proxy_authentication_forwarding 4040610791U /* enable-proxy-authentication-forwarding */
136 #define hash_enable_remote_toggle 2979744683U /* "enable-remote-toggle" */
137 #define hash_enable_remote_http_toggle 110543988U /* "enable-remote-http-toggle" */
138 #define hash_enforce_blocks 1862427469U /* "enforce-blocks" */
139 #define hash_filterfile 250887266U /* "filterfile" */
140 #define hash_forward 2029845U /* "forward" */
141 #define hash_forward_socks4 3963965521U /* "forward-socks4" */
142 #define hash_forward_socks4a 2639958518U /* "forward-socks4a" */
143 #define hash_forward_socks5 3963965522U /* "forward-socks5" */
144 #define hash_forward_socks5t 2639958542U /* "forward-socks5t" */
145 #define hash_forwarded_connect_retries 101465292U /* "forwarded-connect-retries" */
146 #define hash_handle_as_empty_returns_ok 1444873247U /* "handle-as-empty-doc-returns-ok" */
147 #define hash_hostname 10308071U /* "hostname" */
148 #define hash_keep_alive_timeout 3878599515U /* "keep-alive-timeout" */
149 #define hash_listen_address 1255650842U /* "listen-address" */
150 #define hash_logdir 422889U /* "logdir" */
151 #define hash_logfile 2114766U /* "logfile" */
152 #define hash_max_client_connections 3595884446U /* "max-client-connections" */
153 #define hash_permit_access 3587953268U /* "permit-access" */
154 #define hash_proxy_info_url 3903079059U /* "proxy-info-url" */
155 #define hash_single_threaded 4250084780U /* "single-threaded" */
156 #define hash_socket_timeout 1809001761U /* "socket-timeout" */
157 #define hash_split_large_cgi_forms 671658948U /* "split-large-cgi-forms" */
158 #define hash_suppress_blocklists 1948693308U /* "suppress-blocklists" */
159 #define hash_templdir 11067889U /* "templdir" */
160 #define hash_tolerate_pipelining 1360286620U /* "tolerate-pipelining" */
161 #define hash_toggle 447966U /* "toggle" */
162 #define hash_trust_info_url 430331967U /* "trust-info-url" */
163 #define hash_trustfile 56494766U /* "trustfile" */
164 #define hash_usermanual 1416668518U /* "user-manual" */
165 #define hash_activity_animation 1817904738U /* "activity-animation" */
166 #define hash_close_button_minimizes 3651284693U /* "close-button-minimizes" */
167 #define hash_hide_console 2048809870U /* "hide-console" */
168 #define hash_log_buffer_size 2918070425U /* "log-buffer-size" */
169 #define hash_log_font_name 2866730124U /* "log-font-name" */
170 #define hash_log_font_size 2866731014U /* "log-font-size" */
171 #define hash_log_highlight_messages 4032101240U /* "log-highlight-messages" */
172 #define hash_log_max_lines 2868344173U /* "log-max-lines" */
173 #define hash_log_messages 2291744899U /* "log-messages" */
174 #define hash_show_on_task_bar 215410365U /* "show-on-task-bar" */
177 static void savearg(char *command, char *argument, struct configuration_spec * config);
179 /*********************************************************************
181 * Function : unload_configfile
183 * Description : Free the config structure and all components.
186 * 1 : data: struct configuration_spec to unload
190 *********************************************************************/
191 static void unload_configfile (void * data)
193 struct configuration_spec * config = (struct configuration_spec *)data;
194 struct forward_spec *cur_fwd = config->forward;
198 struct access_control_list *cur_acl = config->acl;
200 while (cur_acl != NULL)
202 struct access_control_list * next_acl = cur_acl->next;
207 #endif /* def FEATURE_ACL */
209 while (cur_fwd != NULL)
211 struct forward_spec * next_fwd = cur_fwd->next;
212 free_url_spec(cur_fwd->url);
214 freez(cur_fwd->gateway_host);
215 freez(cur_fwd->forward_host);
219 config->forward = NULL;
221 freez(config->confdir);
222 freez(config->logdir);
223 freez(config->templdir);
224 freez(config->hostname);
226 for (i = 0; i < MAX_LISTENING_SOCKETS; i++)
228 freez(config->haddr[i]);
230 freez(config->logfile);
232 for (i = 0; i < MAX_AF_FILES; i++)
234 freez(config->actions_file_short[i]);
235 freez(config->actions_file[i]);
236 freez(config->re_filterfile_short[i]);
237 freez(config->re_filterfile[i]);
240 list_remove_all(config->ordered_client_headers);
242 freez(config->admin_address);
243 freez(config->proxy_info_url);
244 freez(config->proxy_args);
245 freez(config->usermanual);
248 freez(config->trustfile);
249 list_remove_all(config->trust_info);
250 #endif /* def FEATURE_TRUST */
256 #ifdef FEATURE_GRACEFUL_TERMINATION
257 /*********************************************************************
259 * Function : unload_current_config_file
261 * Description : Unloads current config file - reset to state at
262 * beginning of program.
268 *********************************************************************/
269 void unload_current_config_file(void)
271 if (current_configfile)
273 current_configfile->unloader = unload_configfile;
274 current_configfile = NULL;
280 /*********************************************************************
282 * Function : parse_toggle_value
284 * Description : Parse the value of a directive that can only be
285 * enabled or disabled. Terminates with a fatal error
286 * if the value is NULL or something other than 0 or 1.
289 * 1 : name: The name of the directive. Used for log messages.
290 * 2 : value: The value to parse
293 * Returns : The numerical toggle state
295 *********************************************************************/
296 static int parse_toggle_state(const char *name, const char *value)
299 assert(name != NULL);
300 assert(value != NULL);
302 if ((value == NULL) || (*value == '\0'))
304 log_error(LOG_LEVEL_FATAL, "Directive %s used without argument", name);
307 toggle_state = atoi(value);
310 * Also check the length as atoi() doesn't mind
311 * garbage after a valid integer, but we do.
313 if (((toggle_state != 0) && (toggle_state != 1)) || (strlen(value) != 1))
315 log_error(LOG_LEVEL_FATAL,
316 "Directive %s used with invalid argument '%s'. Use either '0' or '1'.",
325 /*********************************************************************
327 * Function : parse_client_header_order
329 * Description : Parse the value of the header-order directive
332 * 1 : ordered_header_list: List to insert the ordered
334 * 2 : ordered_headers: The ordered header names separated
340 *********************************************************************/
341 static void parse_client_header_order(struct list *ordered_header_list, const char *ordered_headers)
343 char *original_headers_copy;
346 int number_of_headers;
349 assert(ordered_header_list != NULL);
350 assert(ordered_headers != NULL);
352 if (ordered_headers == NULL)
354 log_error(LOG_LEVEL_FATAL, "header-order used without argument");
358 * XXX: This estimate is guaranteed to be high enough as we
359 * let ssplit() ignore empty fields, but also a bit wasteful.
360 * The same hack is used in get_last_url() so it looks like
361 * a real solution is needed.
363 max_segments = strlen(ordered_headers) / 2;
364 if (max_segments == 0)
368 vector = malloc_or_die(max_segments * sizeof(char *));
370 original_headers_copy = strdup_or_die(ordered_headers);
372 number_of_headers = ssplit(original_headers_copy, "\t ", vector, max_segments);
373 if (number_of_headers == -1)
375 log_error(LOG_LEVEL_FATAL, "Failed to split ordered headers");
378 for (i = 0; i < number_of_headers; i++)
380 if (JB_ERR_OK != enlist(ordered_header_list, vector[i]))
382 log_error(LOG_LEVEL_FATAL,
383 "Failed to enlist ordered header: %s", vector[i]);
388 freez(original_headers_copy);
395 /*********************************************************************
397 * Function : load_config
399 * Description : Load the config file and all parameters.
401 * XXX: more than thousand lines long
402 * and thus in serious need of refactoring.
406 * Returns : The configuration_spec, or NULL on error.
408 *********************************************************************/
409 struct configuration_spec * load_config(void)
413 FILE *configfp = NULL;
414 struct configuration_spec * config = NULL;
415 struct client_state * fake_csp;
416 struct file_list *fs;
417 unsigned long linenum = 0;
419 char *logfile = NULL;
421 if (!check_file_changed(current_configfile, configfile, &fs))
423 /* No need to load */
424 return ((struct configuration_spec *)current_configfile->f);
428 log_error(LOG_LEVEL_FATAL,
429 "can't check configuration file '%s': %E", configfile);
433 if (NULL != current_configfile)
435 log_error(LOG_LEVEL_INFO, "Reloading configuration file '%s'", configfile);
438 #ifdef FEATURE_TOGGLE
439 global_toggle_state = 1;
440 #endif /* def FEATURE_TOGGLE */
442 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
448 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
453 * This is backwards from how it's usually done.
454 * Following the usual pattern, "fs" would be stored in a member
455 * variable in "csp", and then we'd access "config" from "fs->f",
456 * using a cast. However, "config" is used so often that a
457 * cast each time would be very ugly, and the extra indirection
458 * would waste CPU cycles. Therefore we store "config" in
459 * "csp->config", and "fs" in "csp->config->config_file_list".
461 config->config_file_list = fs;
466 config->multi_threaded = 1;
467 config->buffer_limit = 4096 * 1024;
468 config->usermanual = strdup(USER_MANUAL_URL);
469 config->proxy_args = strdup("");
470 config->forwarded_connect_retries = 0;
472 * 128 client sockets ought to be enough for everybody who can't
473 * be bothered to read the documentation to figure out how to
474 * increase the limit.
476 config->max_client_connections = 128;
477 config->socket_timeout = 300; /* XXX: Should be a macro. */
478 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
479 config->default_server_timeout = 0;
480 config->keep_alive_timeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
481 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
482 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
484 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
485 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
486 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
487 config->feature_flags &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
488 config->feature_flags &= ~RUNTIME_FEATURE_FORWARD_PROXY_AUTHENTICATION_HEADERS;
489 #ifdef FEATURE_COMPRESSION
490 config->feature_flags &= ~RUNTIME_FEATURE_COMPRESSION;
492 * XXX: Run some benchmarks to see if there are better default values.
494 config->compression_level = 1;
496 config->feature_flags &= ~RUNTIME_FEATURE_TOLERATE_PIPELINING;
498 configfp = fopen(configfile, "r");
499 if (NULL == configfp)
501 log_error(LOG_LEVEL_FATAL,
502 "can't open configuration file '%s': %E", configfile);
503 /* Never get here - LOG_LEVEL_FATAL causes program exit */
506 while (read_config_line(configfp, &linenum, &buf) != NULL)
508 char cmd[BUFFER_SIZE];
509 char arg[BUFFER_SIZE];
510 char tmp[BUFFER_SIZE];
512 struct access_control_list *cur_acl;
513 #endif /* def FEATURE_ACL */
514 struct forward_spec *cur_fwd;
517 unsigned int directive_hash;
519 strlcpy(tmp, buf, sizeof(tmp));
521 /* Copy command (i.e. up to space or tab) into cmd */
524 while (*p && (*p != ' ') && (*p != '\t'))
530 /* Skip over the whitespace in buf */
531 while (*p && ((*p == ' ') || (*p == '\t')))
536 /* Copy the argument into arg */
537 if (strlcpy(arg, p, sizeof(arg)) >= sizeof(arg))
539 log_error(LOG_LEVEL_FATAL, "Config line too long: %s", buf);
542 /* Should never happen, but check this anyway */
549 /* Make sure the command field is lower case */
550 for (p = cmd; *p; p++)
552 if (privoxy_isupper(*p))
554 *p = (char)privoxy_tolower(*p);
558 directive_hash = hash_string(cmd);
559 switch (directive_hash)
561 /* *************************************************************************
562 * actionsfile actions-file-name
563 * In confdir by default
564 * *************************************************************************/
565 case hash_actions_file :
567 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
572 if (i >= MAX_AF_FILES)
574 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
575 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
578 config->actions_file_short[i] = strdup(arg);
579 config->actions_file[i] = make_path(config->confdir, arg);
582 /* *************************************************************************
583 * accept-intercepted-requests
584 * *************************************************************************/
585 case hash_accept_intercepted_requests:
586 if (parse_toggle_state(cmd, arg) == 1)
588 config->feature_flags |= RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
592 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
596 /* *************************************************************************
597 * admin-address email-address
598 * *************************************************************************/
599 case hash_admin_address :
600 freez(config->admin_address);
601 config->admin_address = strdup(arg);
604 /* *************************************************************************
605 * allow-cgi-request-crunching
606 * *************************************************************************/
607 case hash_allow_cgi_request_crunching:
608 if (parse_toggle_state(cmd, arg) == 1)
610 config->feature_flags |= RUNTIME_FEATURE_CGI_CRUNCHING;
614 config->feature_flags &= ~RUNTIME_FEATURE_CGI_CRUNCHING;
618 /* *************************************************************************
620 * *************************************************************************/
621 case hash_buffer_limit :
622 config->buffer_limit = (size_t)(1024 * atoi(arg));
625 /* *************************************************************************
626 * client-header-order header-1 header-2 ... header-n
627 * *************************************************************************/
628 case hash_client_header_order:
629 list_remove_all(config->ordered_client_headers);
630 parse_client_header_order(config->ordered_client_headers, arg);
633 /* *************************************************************************
634 * confdir directory-name
635 * *************************************************************************/
637 freez(config->confdir);
638 config->confdir = make_path(NULL, arg);
641 /* *************************************************************************
642 * compression-level 0-9
643 * *************************************************************************/
644 #ifdef FEATURE_COMPRESSION
645 case hash_compression_level :
648 int compression_level = atoi(arg);
649 if (-1 <= compression_level && compression_level <= 9)
651 config->compression_level = compression_level;;
655 log_error(LOG_LEVEL_FATAL,
656 "Invalid compression-level value: %s", arg);
661 log_error(LOG_LEVEL_FATAL,
662 "Invalid compression-level directive. Compression value missing");
667 /* *************************************************************************
668 * connection-sharing (0|1)
669 * *************************************************************************/
670 #ifdef FEATURE_CONNECTION_SHARING
671 case hash_connection_sharing :
672 if (parse_toggle_state(cmd, arg) == 1)
674 config->feature_flags |= RUNTIME_FEATURE_CONNECTION_SHARING;
678 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
683 /* *************************************************************************
685 * Specifies debug level, multiple values are ORed together.
686 * *************************************************************************/
688 config->debug |= atoi(arg);
691 /* *************************************************************************
692 * default-server-timeout timeout
693 * *************************************************************************/
694 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
695 case hash_default_server_timeout :
698 int timeout = atoi(arg);
701 config->default_server_timeout = (unsigned int)timeout;
705 log_error(LOG_LEVEL_FATAL,
706 "Invalid default-server-timeout value: %s", arg);
712 /* *************************************************************************
713 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
714 * *************************************************************************/
716 case hash_deny_access:
717 strlcpy(tmp, arg, sizeof(tmp));
718 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
720 if ((vec_count != 1) && (vec_count != 2))
722 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
723 "deny-access directive in configuration file.");
724 string_append(&config->proxy_args,
725 "<br>\nWARNING: Wrong number of parameters for "
726 "deny-access directive in configuration file.<br><br>\n");
730 /* allocate a new node */
731 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
735 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
736 /* Never get here - LOG_LEVEL_FATAL causes program exit */
739 cur_acl->action = ACL_DENY;
741 if (acl_addr(vec[0], cur_acl->src) < 0)
743 log_error(LOG_LEVEL_ERROR, "Invalid source address, port or netmask "
744 "for deny-access directive in configuration file: \"%s\"", vec[0]);
745 string_append(&config->proxy_args,
746 "<br>\nWARNING: Invalid source address, port or netmask "
747 "for deny-access directive in configuration file: \"");
748 string_append(&config->proxy_args,
750 string_append(&config->proxy_args,
757 if (acl_addr(vec[1], cur_acl->dst) < 0)
759 log_error(LOG_LEVEL_ERROR, "Invalid destination address, port or netmask "
760 "for deny-access directive in configuration file: \"%s\"", vec[1]);
761 string_append(&config->proxy_args,
762 "<br>\nWARNING: Invalid destination address, port or netmask "
763 "for deny-access directive in configuration file: \"");
764 string_append(&config->proxy_args,
766 string_append(&config->proxy_args,
775 cur_acl->wildcard_dst = 1;
777 #endif /* def HAVE_RFC2553 */
780 * Add it to the list. Note we reverse the list to get the
781 * behaviour the user expects. With both the ACL and
782 * actions file, the last match wins. However, the internal
783 * implementations are different: The actions file is stored
784 * in the same order as the file, and scanned completely.
785 * With the ACL, we reverse the order as we load it, then
786 * when we scan it we stop as soon as we get a match.
788 cur_acl->next = config->acl;
789 config->acl = cur_acl;
792 #endif /* def FEATURE_ACL */
794 /* *************************************************************************
795 * enable-edit-actions 0|1
796 * *************************************************************************/
797 #ifdef FEATURE_CGI_EDIT_ACTIONS
798 case hash_enable_edit_actions:
799 if (parse_toggle_state(cmd, arg) == 1)
801 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
805 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
808 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
810 /* *************************************************************************
811 * enable-compression 0|1
812 * *************************************************************************/
813 #ifdef FEATURE_COMPRESSION
814 case hash_enable_compression:
815 if (parse_toggle_state(cmd, arg) == 1)
817 config->feature_flags |= RUNTIME_FEATURE_COMPRESSION;
821 config->feature_flags &= ~RUNTIME_FEATURE_COMPRESSION;
824 #endif /* def FEATURE_COMPRESSION */
826 /* *************************************************************************
827 * enable-proxy-authentication-forwarding 0|1
828 * *************************************************************************/
829 case hash_enable_proxy_authentication_forwarding:
830 if (parse_toggle_state(cmd, arg) == 1)
832 config->feature_flags |= RUNTIME_FEATURE_FORWARD_PROXY_AUTHENTICATION_HEADERS;
836 config->feature_flags &= ~RUNTIME_FEATURE_FORWARD_PROXY_AUTHENTICATION_HEADERS;
840 /* *************************************************************************
841 * enable-remote-toggle 0|1
842 * *************************************************************************/
843 #ifdef FEATURE_TOGGLE
844 case hash_enable_remote_toggle:
845 if (parse_toggle_state(cmd, arg) == 1)
847 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
851 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
854 #endif /* def FEATURE_TOGGLE */
856 /* *************************************************************************
857 * enable-remote-http-toggle 0|1
858 * *************************************************************************/
859 case hash_enable_remote_http_toggle:
860 if (parse_toggle_state(cmd, arg) == 1)
862 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
866 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
870 /* *************************************************************************
872 * *************************************************************************/
873 case hash_enforce_blocks:
874 #ifdef FEATURE_FORCE_LOAD
875 if (parse_toggle_state(cmd, arg) == 1)
877 config->feature_flags |= RUNTIME_FEATURE_ENFORCE_BLOCKS;
881 config->feature_flags &= ~RUNTIME_FEATURE_ENFORCE_BLOCKS;
884 log_error(LOG_LEVEL_ERROR, "Ignoring directive 'enforce-blocks'. "
885 "FEATURE_FORCE_LOAD is disabled, blocks will always be enforced.");
886 #endif /* def FEATURE_FORCE_LOAD */
889 /* *************************************************************************
890 * filterfile file-name
891 * In confdir by default.
892 * *************************************************************************/
893 case hash_filterfile :
895 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
900 if (i >= MAX_AF_FILES)
902 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
903 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
906 config->re_filterfile_short[i] = strdup(arg);
907 config->re_filterfile[i] = make_path(config->confdir, arg);
911 /* *************************************************************************
912 * forward url-pattern (.|http-proxy-host[:port])
913 * *************************************************************************/
915 strlcpy(tmp, arg, sizeof(tmp));
916 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
920 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
921 "directive in configuration file.");
922 string_append(&config->proxy_args,
923 "<br>\nWARNING: Wrong number of parameters for "
924 "forward directive in configuration file.");
928 /* allocate a new node */
929 cur_fwd = zalloc(sizeof(*cur_fwd));
932 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
933 /* Never get here - LOG_LEVEL_FATAL causes program exit */
937 cur_fwd->type = SOCKS_NONE;
939 /* Save the URL pattern */
940 if (create_url_spec(cur_fwd->url, vec[0]))
942 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
943 "directive in configuration file.");
944 string_append(&config->proxy_args,
945 "<br>\nWARNING: Bad URL specifier for "
946 "forward directive in configuration file.");
950 /* Parse the parent HTTP proxy host:port */
953 if (strcmp(p, ".") != 0)
955 cur_fwd->forward_port = 8000;
956 parse_forwarder_address(p, &cur_fwd->forward_host,
957 &cur_fwd->forward_port);
961 cur_fwd->next = config->forward;
962 config->forward = cur_fwd;
966 /* *************************************************************************
967 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
968 * *************************************************************************/
969 case hash_forward_socks4:
970 strlcpy(tmp, arg, sizeof(tmp));
971 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
975 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
976 "forward-socks4 directive in configuration file.");
977 string_append(&config->proxy_args,
978 "<br>\nWARNING: Wrong number of parameters for "
979 "forward-socks4 directive in configuration file.");
983 /* allocate a new node */
984 cur_fwd = zalloc(sizeof(*cur_fwd));
987 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
988 /* Never get here - LOG_LEVEL_FATAL causes program exit */
992 cur_fwd->type = SOCKS_4;
994 /* Save the URL pattern */
995 if (create_url_spec(cur_fwd->url, vec[0]))
997 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
998 "directive in configuration file.");
999 string_append(&config->proxy_args,
1000 "<br>\nWARNING: Bad URL specifier for "
1001 "forward-socks4 directive in configuration file.");
1005 /* Parse the SOCKS proxy host[:port] */
1008 /* XXX: This check looks like a bug. */
1009 if (strcmp(p, ".") != 0)
1011 cur_fwd->gateway_port = 1080;
1012 parse_forwarder_address(p, &cur_fwd->gateway_host,
1013 &cur_fwd->gateway_port);
1016 /* Parse the parent HTTP proxy host[:port] */
1019 if (strcmp(p, ".") != 0)
1021 cur_fwd->forward_port = 8000;
1022 parse_forwarder_address(p, &cur_fwd->forward_host,
1023 &cur_fwd->forward_port);
1027 cur_fwd->next = config->forward;
1028 config->forward = cur_fwd;
1032 /* *************************************************************************
1033 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1034 * *************************************************************************/
1035 case hash_forward_socks4a:
1036 case hash_forward_socks5:
1037 case hash_forward_socks5t:
1038 strlcpy(tmp, arg, sizeof(tmp));
1039 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
1043 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1044 "forward-socks4a directive in configuration file.");
1045 string_append(&config->proxy_args,
1046 "<br>\nWARNING: Wrong number of parameters for "
1047 "forward-socks4a directive in configuration file.");
1051 /* allocate a new node */
1052 cur_fwd = zalloc(sizeof(*cur_fwd));
1053 if (cur_fwd == NULL)
1055 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1056 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1060 if (directive_hash == hash_forward_socks4a)
1062 cur_fwd->type = SOCKS_4A;
1064 else if (directive_hash == hash_forward_socks5)
1066 cur_fwd->type = SOCKS_5;
1070 assert(directive_hash == hash_forward_socks5t);
1071 cur_fwd->type = SOCKS_5T;
1074 /* Save the URL pattern */
1075 if (create_url_spec(cur_fwd->url, vec[0]))
1077 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1078 "directive in configuration file.");
1079 string_append(&config->proxy_args,
1080 "<br>\nWARNING: Bad URL specifier for "
1081 "forward-socks4a directive in configuration file.");
1085 /* Parse the SOCKS proxy host[:port] */
1088 cur_fwd->gateway_port = 1080;
1089 parse_forwarder_address(p, &cur_fwd->gateway_host,
1090 &cur_fwd->gateway_port);
1092 /* Parse the parent HTTP proxy host[:port] */
1095 if (strcmp(p, ".") != 0)
1097 cur_fwd->forward_port = 8000;
1098 parse_forwarder_address(p, &cur_fwd->forward_host,
1099 &cur_fwd->forward_port);
1103 cur_fwd->next = config->forward;
1104 config->forward = cur_fwd;
1108 /* *************************************************************************
1109 * forwarded-connect-retries n
1110 * *************************************************************************/
1111 case hash_forwarded_connect_retries :
1112 config->forwarded_connect_retries = atoi(arg);
1115 /* *************************************************************************
1116 * handle-as-empty-doc-returns-ok 0|1
1118 * Workaround for firefox hanging on blocked javascript pages.
1119 * Block with the "+handle-as-empty-document" flag and set the
1120 * "handle-as-empty-doc-returns-ok" run-time config flag so that
1121 * Privoxy returns a 200/OK status instead of a 403/Forbidden status
1122 * to the browser for blocked pages.
1123 ***************************************************************************/
1124 case hash_handle_as_empty_returns_ok:
1125 if (parse_toggle_state(cmd, arg) == 1)
1127 config->feature_flags |= RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
1131 config->feature_flags &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
1135 /* *************************************************************************
1136 * hostname hostname-to-show-on-cgi-pages
1137 * *************************************************************************/
1138 case hash_hostname :
1139 freez(config->hostname);
1140 config->hostname = strdup(arg);
1141 if (NULL == config->hostname)
1143 log_error(LOG_LEVEL_FATAL, "Out of memory saving hostname.");
1147 /* *************************************************************************
1148 * keep-alive-timeout timeout
1149 * *************************************************************************/
1150 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
1151 case hash_keep_alive_timeout :
1154 int timeout = atoi(arg);
1157 config->feature_flags |= RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1158 config->keep_alive_timeout = (unsigned int)timeout;
1162 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1168 /* *************************************************************************
1169 * listen-address [ip][:port]
1170 * *************************************************************************/
1171 case hash_listen_address :
1173 while ((i < MAX_LISTENING_SOCKETS) && (NULL != config->haddr[i]))
1178 if (i >= MAX_LISTENING_SOCKETS)
1180 log_error(LOG_LEVEL_FATAL, "Too many 'listen-address' directives in config file - limit is %d.\n"
1181 "(You can increase this limit by changing MAX_LISTENING_SOCKETS in project.h and recompiling).",
1182 MAX_LISTENING_SOCKETS);
1184 config->haddr[i] = strdup(arg);
1185 if (NULL == config->haddr[i])
1187 log_error(LOG_LEVEL_FATAL, "Out of memory while copying listening address");
1191 /* *************************************************************************
1192 * logdir directory-name
1193 * *************************************************************************/
1195 freez(config->logdir);
1196 config->logdir = make_path(NULL, arg);
1199 /* *************************************************************************
1200 * logfile log-file-name
1201 * In logdir by default
1202 * *************************************************************************/
1206 logfile = make_path(config->logdir, arg);
1207 if (NULL == logfile)
1209 log_error(LOG_LEVEL_FATAL, "Out of memory while creating logfile path");
1214 /* *************************************************************************
1215 * max-client-connections number
1216 * *************************************************************************/
1217 case hash_max_client_connections :
1220 int max_client_connections = atoi(arg);
1221 if (0 <= max_client_connections)
1223 config->max_client_connections = max_client_connections;
1228 /* *************************************************************************
1229 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1230 * *************************************************************************/
1232 case hash_permit_access:
1233 strlcpy(tmp, arg, sizeof(tmp));
1234 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
1236 if ((vec_count != 1) && (vec_count != 2))
1238 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1239 "permit-access directive in configuration file.");
1240 string_append(&config->proxy_args,
1241 "<br>\nWARNING: Wrong number of parameters for "
1242 "permit-access directive in configuration file.<br><br>\n");
1247 /* allocate a new node */
1248 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1250 if (cur_acl == NULL)
1252 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1253 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1256 cur_acl->action = ACL_PERMIT;
1258 if (acl_addr(vec[0], cur_acl->src) < 0)
1260 log_error(LOG_LEVEL_ERROR, "Invalid source address, port or netmask "
1261 "for permit-access directive in configuration file: \"%s\"", vec[0]);
1262 string_append(&config->proxy_args,
1263 "<br>\nWARNING: Invalid source address, port or netmask for "
1264 "permit-access directive in configuration file: \"");
1265 string_append(&config->proxy_args,
1267 string_append(&config->proxy_args,
1274 if (acl_addr(vec[1], cur_acl->dst) < 0)
1276 log_error(LOG_LEVEL_ERROR, "Invalid destination address, port or netmask "
1277 "for permit-access directive in configuration file: \"%s\"", vec[1]);
1278 string_append(&config->proxy_args,
1279 "<br>\nWARNING: Invalid destination address, port or netmask for "
1280 "permit-access directive in configuration file: \"");
1281 string_append(&config->proxy_args,
1283 string_append(&config->proxy_args,
1292 cur_acl->wildcard_dst = 1;
1294 #endif /* def HAVE_RFC2553 */
1297 * Add it to the list. Note we reverse the list to get the
1298 * behaviour the user expects. With both the ACL and
1299 * actions file, the last match wins. However, the internal
1300 * implementations are different: The actions file is stored
1301 * in the same order as the file, and scanned completely.
1302 * With the ACL, we reverse the order as we load it, then
1303 * when we scan it we stop as soon as we get a match.
1305 cur_acl->next = config->acl;
1306 config->acl = cur_acl;
1309 #endif /* def FEATURE_ACL */
1311 /* *************************************************************************
1312 * proxy-info-url url
1313 * *************************************************************************/
1314 case hash_proxy_info_url :
1315 freez(config->proxy_info_url);
1316 config->proxy_info_url = strdup(arg);
1319 /* *************************************************************************
1321 * *************************************************************************/
1322 case hash_single_threaded :
1323 config->multi_threaded = 0;
1326 /* *************************************************************************
1327 * socket-timeout numer_of_seconds
1328 * *************************************************************************/
1329 case hash_socket_timeout :
1332 int socket_timeout = atoi(arg);
1333 if (0 <= socket_timeout)
1335 config->socket_timeout = socket_timeout;
1339 log_error(LOG_LEVEL_FATAL,
1340 "Invalid socket-timeout: '%s'", arg);
1345 /* *************************************************************************
1346 * split-large-cgi-forms
1347 * *************************************************************************/
1348 case hash_split_large_cgi_forms :
1349 if (parse_toggle_state(cmd, arg) == 1)
1351 config->feature_flags |= RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1355 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1359 /* *************************************************************************
1360 * templdir directory-name
1361 * *************************************************************************/
1362 case hash_templdir :
1363 freez(config->templdir);
1364 config->templdir = make_path(NULL, arg);
1367 /* *************************************************************************
1368 * tolerate-pipelining (0|1)
1369 * *************************************************************************/
1370 case hash_tolerate_pipelining :
1371 if (parse_toggle_state(cmd, arg) == 1)
1373 config->feature_flags |= RUNTIME_FEATURE_TOLERATE_PIPELINING;
1377 config->feature_flags &= ~RUNTIME_FEATURE_TOLERATE_PIPELINING;
1381 /* *************************************************************************
1383 * *************************************************************************/
1384 #ifdef FEATURE_TOGGLE
1386 global_toggle_state = parse_toggle_state(cmd, arg);
1388 #endif /* def FEATURE_TOGGLE */
1390 /* *************************************************************************
1391 * trust-info-url url
1392 * *************************************************************************/
1393 #ifdef FEATURE_TRUST
1394 case hash_trust_info_url :
1395 enlist(config->trust_info, arg);
1397 #endif /* def FEATURE_TRUST */
1399 /* *************************************************************************
1400 * trustfile filename
1401 * (In confdir by default.)
1402 * *************************************************************************/
1403 #ifdef FEATURE_TRUST
1404 case hash_trustfile :
1405 freez(config->trustfile);
1406 config->trustfile = make_path(config->confdir, arg);
1408 #endif /* def FEATURE_TRUST */
1410 /* *************************************************************************
1412 * *************************************************************************/
1413 case hash_usermanual :
1415 * XXX: If this isn't the first config directive, the
1416 * show-status page links to the website documentation
1417 * for the directives that were already parsed. Lame.
1419 freez(config->usermanual);
1420 config->usermanual = strdup(arg);
1423 /* *************************************************************************
1424 * Win32 Console options:
1425 * *************************************************************************/
1427 /* *************************************************************************
1429 * *************************************************************************/
1431 case hash_hide_console :
1434 #endif /*def _WIN_CONSOLE*/
1437 /* *************************************************************************
1438 * Win32 GUI options:
1439 * *************************************************************************/
1441 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1442 /* *************************************************************************
1443 * activity-animation (0|1)
1444 * *************************************************************************/
1445 case hash_activity_animation :
1446 g_bShowActivityAnimation = parse_toggle_state(cmd, arg);
1449 /* *************************************************************************
1450 * close-button-minimizes (0|1)
1451 * *************************************************************************/
1452 case hash_close_button_minimizes :
1453 g_bCloseHidesWindow = parse_toggle_state(cmd, arg);
1456 /* *************************************************************************
1457 * log-buffer-size (0|1)
1458 * *************************************************************************/
1459 case hash_log_buffer_size :
1460 g_bLimitBufferSize = parse_toggle_state(cmd, arg);
1463 /* *************************************************************************
1464 * log-font-name fontname
1465 * *************************************************************************/
1466 case hash_log_font_name :
1467 if (strlcpy(g_szFontFaceName, arg,
1468 sizeof(g_szFontFaceName)) >= sizeof(g_szFontFaceName))
1470 log_error(LOG_LEVEL_FATAL,
1471 "log-font-name argument '%s' is longer than %u characters.",
1472 arg, sizeof(g_szFontFaceName)-1);
1476 /* *************************************************************************
1478 * *************************************************************************/
1479 case hash_log_font_size :
1480 g_nFontSize = atoi(arg);
1483 /* *************************************************************************
1484 * log-highlight-messages (0|1)
1485 * *************************************************************************/
1486 case hash_log_highlight_messages :
1487 g_bHighlightMessages = parse_toggle_state(cmd, arg);
1490 /* *************************************************************************
1492 * *************************************************************************/
1493 case hash_log_max_lines :
1494 g_nMaxBufferLines = atoi(arg);
1497 /* *************************************************************************
1498 * log-messages (0|1)
1499 * *************************************************************************/
1500 case hash_log_messages :
1501 g_bLogMessages = parse_toggle_state(cmd, arg);
1504 /* *************************************************************************
1505 * show-on-task-bar (0|1)
1506 * *************************************************************************/
1507 case hash_show_on_task_bar :
1508 g_bShowOnTaskBar = parse_toggle_state(cmd, arg);
1511 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1514 /* *************************************************************************
1515 * Warnings about unsupported features
1516 * *************************************************************************/
1518 case hash_deny_access:
1519 #endif /* ndef FEATURE_ACL */
1520 #ifndef FEATURE_CGI_EDIT_ACTIONS
1521 case hash_enable_edit_actions:
1522 #endif /* ndef FEATURE_CGI_EDIT_ACTIONS */
1523 #ifndef FEATURE_TOGGLE
1524 case hash_enable_remote_toggle:
1525 #endif /* ndef FEATURE_TOGGLE */
1527 case hash_permit_access:
1528 #endif /* ndef FEATURE_ACL */
1529 #ifndef FEATURE_TOGGLE
1531 #endif /* ndef FEATURE_TOGGLE */
1532 #ifndef FEATURE_TRUST
1533 case hash_trustfile :
1534 case hash_trust_info_url :
1535 #endif /* ndef FEATURE_TRUST */
1537 #ifndef _WIN_CONSOLE
1538 case hash_hide_console :
1539 #endif /* ndef _WIN_CONSOLE */
1541 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1542 case hash_activity_animation :
1543 case hash_close_button_minimizes :
1544 case hash_log_buffer_size :
1545 case hash_log_font_name :
1546 case hash_log_font_size :
1547 case hash_log_highlight_messages :
1548 case hash_log_max_lines :
1549 case hash_log_messages :
1550 case hash_show_on_task_bar :
1551 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1552 /* These warnings are annoying - so hide them. -- Jon */
1553 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1556 /* *************************************************************************/
1558 /* *************************************************************************/
1560 * I decided that I liked this better as a warning than an
1561 * error. To change back to an error, just change log level
1562 * to LOG_LEVEL_FATAL.
1564 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive "
1565 "'%s' (%uU) in line %lu in configuration file (%s).",
1566 buf, directive_hash, linenum, configfile);
1567 string_append(&config->proxy_args,
1568 " <strong class='warning'>Warning: Ignoring unrecognized directive:</strong>");
1571 /* *************************************************************************/
1572 } /* end switch(hash_string(cmd)) */
1574 /* Save the argument for the show-status page. */
1575 savearg(cmd, arg, config);
1577 } /* end while (read_config_line(...)) */
1581 set_debug_level(config->debug);
1583 freez(config->logfile);
1587 if (NULL != logfile)
1589 config->logfile = logfile;
1590 init_error_log(Argv[0], config->logfile);
1598 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
1599 if (config->default_server_timeout > config->keep_alive_timeout)
1601 log_error(LOG_LEVEL_ERROR,
1602 "Reducing the default-server-timeout from %d to the keep-alive-timeout %d.",
1603 config->default_server_timeout, config->keep_alive_timeout);
1604 config->default_server_timeout = config->keep_alive_timeout;
1606 #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
1608 #ifdef FEATURE_CONNECTION_SHARING
1609 if (config->feature_flags & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE)
1611 if (config->multi_threaded)
1613 set_keep_alive_timeout(config->keep_alive_timeout);
1618 * While we could use keep-alive without multiple threads
1619 * if we didn't bother with enforcing the connection timeout,
1620 * that might make Tor users sad, even though they shouldn't
1621 * enable the single-threaded option anyway.
1623 * XXX: We could still use Proxy-Connection: keep-alive.
1625 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1626 log_error(LOG_LEVEL_ERROR,
1627 "Config option single-threaded disables connection keep-alive.");
1630 else if ((config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING))
1632 log_error(LOG_LEVEL_ERROR, "Config option connection-sharing "
1633 "has no effect if keep-alive-timeout isn't set.");
1634 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
1636 #endif /* def FEATURE_CONNECTION_SHARING */
1638 if (NULL == config->proxy_args)
1640 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1643 if (config->re_filterfile[0])
1645 add_loader(load_re_filterfiles, config);
1648 if (config->actions_file[0])
1650 add_loader(load_action_files, config);
1653 #ifdef FEATURE_TRUST
1654 if (config->trustfile)
1656 add_loader(load_trustfile, config);
1658 #endif /* def FEATURE_TRUST */
1660 if (NULL == config->haddr[0])
1662 config->haddr[0] = strdup(HADDR_DEFAULT);
1663 if (NULL == config->haddr[0])
1665 log_error(LOG_LEVEL_FATAL, "Out of memory while copying default listening address");
1669 for (i = 0; i < MAX_LISTENING_SOCKETS && NULL != config->haddr[i]; i++)
1671 if ((*config->haddr[i] == '[')
1672 && (NULL != (p = strchr(config->haddr[i], ']')))
1674 && (0 < (config->hport[i] = atoi(p + 2))))
1677 memmove((void *)config->haddr[i], config->haddr[i] + 1,
1678 (size_t)(p - config->haddr[i]));
1680 else if (NULL != (p = strchr(config->haddr[i], ':'))
1681 && (0 < (config->hport[i] = atoi(p + 1))))
1687 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr[i]);
1688 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1690 if (*config->haddr[i] == '\0')
1693 * Only the port specified. We stored it in config->hport[i]
1694 * and don't need its text representation anymore.
1695 * Use config->hport[i] == 0 to iterate listening addresses since
1698 freez(config->haddr[i]);
1703 * Want to run all the loaders once now.
1705 * Need to set up a fake csp, so they can get to the config.
1707 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1708 fake_csp->config = config;
1710 if (run_loader(fake_csp))
1713 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1714 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1718 /* FIXME: this is a kludge for win32 */
1719 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1721 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1722 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1723 g_default_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1724 g_user_filterfile = config->re_filterfile[1]; /* FIXME Hope this is user.filter */
1726 #ifdef FEATURE_TRUST
1727 g_trustfile = config->trustfile;
1728 #endif /* def FEATURE_TRUST */
1731 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1732 /* FIXME: end kludge */
1735 config->need_bind = 1;
1737 if (current_configfile)
1739 struct configuration_spec * oldcfg = (struct configuration_spec *)
1740 current_configfile->f;
1742 * Check if config->haddr[i],hport[i] == oldcfg->haddr[i],hport[i]
1744 * The following could be written more compactly as a single,
1745 * (unreadably long) if statement.
1747 config->need_bind = 0;
1749 for (i = 0; i < MAX_LISTENING_SOCKETS; i++)
1751 if (config->hport[i] != oldcfg->hport[i])
1753 config->need_bind = 1;
1755 else if (config->haddr[i] == NULL)
1757 if (oldcfg->haddr[i] != NULL)
1759 config->need_bind = 1;
1762 else if (oldcfg->haddr[i] == NULL)
1764 config->need_bind = 1;
1766 else if (0 != strcmp(config->haddr[i], oldcfg->haddr[i]))
1768 config->need_bind = 1;
1772 current_configfile->unloader = unload_configfile;
1775 fs->next = files->next;
1778 current_configfile = fs;
1784 /*********************************************************************
1786 * Function : savearg
1788 * Description : Called from `load_config'. It saves each non-empty
1789 * and non-comment line from config into
1790 * config->proxy_args. This is used to create the
1791 * show-proxy-args page. On error, frees
1792 * config->proxy_args and sets it to NULL
1795 * 1 : command = config setting that was found
1796 * 2 : argument = the setting's argument (if any)
1797 * 3 : config = Configuration to save into.
1801 *********************************************************************/
1802 static void savearg(char *command, char *argument, struct configuration_spec * config)
1811 * Add config option name embedded in
1812 * link to its section in the user-manual
1814 buf = strdup("\n<a href=\"");
1815 if (!strncmpic(config->usermanual, "file://", 7) ||
1816 !strncmpic(config->usermanual, "http", 4))
1818 string_append(&buf, config->usermanual);
1822 string_append(&buf, "http://" CGI_SITE_2_HOST "/user-manual/");
1824 string_append(&buf, CONFIG_HELP_PREFIX);
1825 string_join (&buf, string_toupper(command));
1826 string_append(&buf, "\">");
1827 string_append(&buf, command);
1828 string_append(&buf, "</a> ");
1832 freez(config->proxy_args);
1836 if ((NULL != argument) && ('\0' != *argument))
1838 s = html_encode(argument);
1842 freez(config->proxy_args);
1846 if (strncmpic(argument, "http://", 7) == 0)
1848 string_append(&buf, "<a href=\"");
1849 string_append(&buf, s);
1850 string_append(&buf, "\">");
1851 string_join (&buf, s);
1852 string_append(&buf, "</a>");
1856 string_join (&buf, s);
1860 string_append(&buf, "<br>");
1861 string_join(&config->proxy_args, buf);