1 const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.133 2012/10/21 12:32:21 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_remote_toggle 2979744683U /* "enable-remote-toggle" */
136 #define hash_enable_remote_http_toggle 110543988U /* "enable-remote-http-toggle" */
137 #define hash_enforce_blocks 1862427469U /* "enforce-blocks" */
138 #define hash_filterfile 250887266U /* "filterfile" */
139 #define hash_forward 2029845U /* "forward" */
140 #define hash_forward_socks4 3963965521U /* "forward-socks4" */
141 #define hash_forward_socks4a 2639958518U /* "forward-socks4a" */
142 #define hash_forward_socks5 3963965522U /* "forward-socks5" */
143 #define hash_forwarded_connect_retries 101465292U /* "forwarded-connect-retries" */
144 #define hash_handle_as_empty_returns_ok 1444873247U /* "handle-as-empty-doc-returns-ok" */
145 #define hash_hostname 10308071U /* "hostname" */
146 #define hash_keep_alive_timeout 3878599515U /* "keep-alive-timeout" */
147 #define hash_listen_address 1255650842U /* "listen-address" */
148 #define hash_logdir 422889U /* "logdir" */
149 #define hash_logfile 2114766U /* "logfile" */
150 #define hash_max_client_connections 3595884446U /* "max-client-connections" */
151 #define hash_permit_access 3587953268U /* "permit-access" */
152 #define hash_proxy_info_url 3903079059U /* "proxy-info-url" */
153 #define hash_single_threaded 4250084780U /* "single-threaded" */
154 #define hash_socket_timeout 1809001761U /* "socket-timeout" */
155 #define hash_split_large_cgi_forms 671658948U /* "split-large-cgi-forms" */
156 #define hash_suppress_blocklists 1948693308U /* "suppress-blocklists" */
157 #define hash_templdir 11067889U /* "templdir" */
158 #define hash_tolerate_pipelining 1360286620U /* "tolerate-pipelining" */
159 #define hash_toggle 447966U /* "toggle" */
160 #define hash_trust_info_url 430331967U /* "trust-info-url" */
161 #define hash_trustfile 56494766U /* "trustfile" */
162 #define hash_usermanual 1416668518U /* "user-manual" */
163 #define hash_activity_animation 1817904738U /* "activity-animation" */
164 #define hash_close_button_minimizes 3651284693U /* "close-button-minimizes" */
165 #define hash_hide_console 2048809870U /* "hide-console" */
166 #define hash_log_buffer_size 2918070425U /* "log-buffer-size" */
167 #define hash_log_font_name 2866730124U /* "log-font-name" */
168 #define hash_log_font_size 2866731014U /* "log-font-size" */
169 #define hash_log_highlight_messages 4032101240U /* "log-highlight-messages" */
170 #define hash_log_max_lines 2868344173U /* "log-max-lines" */
171 #define hash_log_messages 2291744899U /* "log-messages" */
172 #define hash_show_on_task_bar 215410365U /* "show-on-task-bar" */
175 static void savearg(char *command, char *argument, struct configuration_spec * config);
177 /*********************************************************************
179 * Function : unload_configfile
181 * Description : Free the config structure and all components.
184 * 1 : data: struct configuration_spec to unload
188 *********************************************************************/
189 static void unload_configfile (void * data)
191 struct configuration_spec * config = (struct configuration_spec *)data;
192 struct forward_spec *cur_fwd = config->forward;
196 struct access_control_list *cur_acl = config->acl;
198 while (cur_acl != NULL)
200 struct access_control_list * next_acl = cur_acl->next;
205 #endif /* def FEATURE_ACL */
207 while (cur_fwd != NULL)
209 struct forward_spec * next_fwd = cur_fwd->next;
210 free_url_spec(cur_fwd->url);
212 freez(cur_fwd->gateway_host);
213 freez(cur_fwd->forward_host);
217 config->forward = NULL;
219 freez(config->confdir);
220 freez(config->logdir);
221 freez(config->templdir);
222 freez(config->hostname);
224 for (i = 0; i < MAX_LISTENING_SOCKETS; i++)
226 freez(config->haddr[i]);
228 freez(config->logfile);
230 for (i = 0; i < MAX_AF_FILES; i++)
232 freez(config->actions_file_short[i]);
233 freez(config->actions_file[i]);
234 freez(config->re_filterfile_short[i]);
235 freez(config->re_filterfile[i]);
238 list_remove_all(config->ordered_client_headers);
240 freez(config->admin_address);
241 freez(config->proxy_info_url);
242 freez(config->proxy_args);
243 freez(config->usermanual);
246 freez(config->trustfile);
247 list_remove_all(config->trust_info);
248 #endif /* def FEATURE_TRUST */
254 #ifdef FEATURE_GRACEFUL_TERMINATION
255 /*********************************************************************
257 * Function : unload_current_config_file
259 * Description : Unloads current config file - reset to state at
260 * beginning of program.
266 *********************************************************************/
267 void unload_current_config_file(void)
269 if (current_configfile)
271 current_configfile->unloader = unload_configfile;
272 current_configfile = NULL;
278 /*********************************************************************
280 * Function : parse_toggle_value
282 * Description : Parse the value of a directive that can only be
283 * enabled or disabled. Terminates with a fatal error
284 * if the value is NULL or something other than 0 or 1.
287 * 1 : name: The name of the directive. Used for log messages.
288 * 2 : value: The value to parse
291 * Returns : The numerical toggle state
293 *********************************************************************/
294 static int parse_toggle_state(const char *name, const char *value)
297 assert(name != NULL);
298 assert(value != NULL);
300 if ((value == NULL) || (*value == '\0'))
302 log_error(LOG_LEVEL_FATAL, "Directive %s used without argument", name);
305 toggle_state = atoi(value);
308 * Also check the length as atoi() doesn't mind
309 * garbage after a valid integer, but we do.
311 if (((toggle_state != 0) && (toggle_state != 1)) || (strlen(value) != 1))
313 log_error(LOG_LEVEL_FATAL,
314 "Directive %s used with invalid argument '%s'. Use either '0' or '1'.",
323 /*********************************************************************
325 * Function : parse_client_header_order
327 * Description : Parse the value of the header-order directive
330 * 1 : ordered_header_list: List to insert the ordered
332 * 2 : ordered_headers: The ordered header names separated
338 *********************************************************************/
339 static void parse_client_header_order(struct list *ordered_header_list, const char *ordered_headers)
341 char *original_headers_copy;
344 int number_of_headers;
347 assert(ordered_header_list != NULL);
348 assert(ordered_headers != NULL);
350 if (ordered_headers == NULL)
352 log_error(LOG_LEVEL_FATAL, "header-order used without argument");
356 * XXX: This estimate is guaranteed to be high enough as we
357 * let ssplit() ignore empty fields, but also a bit wasteful.
358 * The same hack is used in get_last_url() so it looks like
359 * a real solution is needed.
361 max_segments = strlen(ordered_headers) / 2;
362 if (max_segments == 0)
366 vector = malloc_or_die(max_segments * sizeof(char *));
368 original_headers_copy = strdup_or_die(ordered_headers);
370 number_of_headers = ssplit(original_headers_copy, "\t ", vector, max_segments);
371 if (number_of_headers == -1)
373 log_error(LOG_LEVEL_FATAL, "Failed to split ordered headers");
376 for (i = 0; i < number_of_headers; i++)
378 if (JB_ERR_OK != enlist(ordered_header_list, vector[i]))
380 log_error(LOG_LEVEL_FATAL,
381 "Failed to enlist ordered header: %s", vector[i]);
386 freez(original_headers_copy);
393 /*********************************************************************
395 * Function : load_config
397 * Description : Load the config file and all parameters.
399 * XXX: more than thousand lines long
400 * and thus in serious need of refactoring.
404 * Returns : The configuration_spec, or NULL on error.
406 *********************************************************************/
407 struct configuration_spec * load_config(void)
411 FILE *configfp = NULL;
412 struct configuration_spec * config = NULL;
413 struct client_state * fake_csp;
414 struct file_list *fs;
415 unsigned long linenum = 0;
417 char *logfile = NULL;
419 if (!check_file_changed(current_configfile, configfile, &fs))
421 /* No need to load */
422 return ((struct configuration_spec *)current_configfile->f);
426 log_error(LOG_LEVEL_FATAL,
427 "can't check configuration file '%s': %E", configfile);
431 if (NULL != current_configfile)
433 log_error(LOG_LEVEL_INFO, "Reloading configuration file '%s'", configfile);
436 #ifdef FEATURE_TOGGLE
437 global_toggle_state = 1;
438 #endif /* def FEATURE_TOGGLE */
440 fs->f = config = (struct configuration_spec *)zalloc(sizeof(*config));
446 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
451 * This is backwards from how it's usually done.
452 * Following the usual pattern, "fs" would be stored in a member
453 * variable in "csp", and then we'd access "config" from "fs->f",
454 * using a cast. However, "config" is used so often that a
455 * cast each time would be very ugly, and the extra indirection
456 * would waste CPU cycles. Therefore we store "config" in
457 * "csp->config", and "fs" in "csp->config->config_file_list".
459 config->config_file_list = fs;
464 config->multi_threaded = 1;
465 config->buffer_limit = 4096 * 1024;
466 config->usermanual = strdup(USER_MANUAL_URL);
467 config->proxy_args = strdup("");
468 config->forwarded_connect_retries = 0;
469 config->max_client_connections = 0;
470 config->socket_timeout = 300; /* XXX: Should be a macro. */
471 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
472 config->default_server_timeout = 0;
473 config->keep_alive_timeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
474 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
475 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
477 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
478 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
479 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
480 config->feature_flags &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
481 #ifdef FEATURE_COMPRESSION
482 config->feature_flags &= ~RUNTIME_FEATURE_COMPRESSION;
484 * XXX: Run some benchmarks to see if there are better default values.
486 config->compression_level = 1;
488 config->feature_flags &= ~RUNTIME_FEATURE_TOLERATE_PIPELINING;
490 configfp = fopen(configfile, "r");
491 if (NULL == configfp)
493 log_error(LOG_LEVEL_FATAL,
494 "can't open configuration file '%s': %E", configfile);
495 /* Never get here - LOG_LEVEL_FATAL causes program exit */
498 while (read_config_line(configfp, &linenum, &buf) != NULL)
500 char cmd[BUFFER_SIZE];
501 char arg[BUFFER_SIZE];
502 char tmp[BUFFER_SIZE];
504 struct access_control_list *cur_acl;
505 #endif /* def FEATURE_ACL */
506 struct forward_spec *cur_fwd;
509 unsigned int directive_hash;
511 strlcpy(tmp, buf, sizeof(tmp));
513 /* Copy command (i.e. up to space or tab) into cmd */
516 while (*p && (*p != ' ') && (*p != '\t'))
522 /* Skip over the whitespace in buf */
523 while (*p && ((*p == ' ') || (*p == '\t')))
528 /* Copy the argument into arg */
529 if (strlcpy(arg, p, sizeof(arg)) >= sizeof(arg))
531 log_error(LOG_LEVEL_FATAL, "Config line too long: %s", buf);
534 /* Should never happen, but check this anyway */
541 /* Make sure the command field is lower case */
542 for (p = cmd; *p; p++)
544 if (privoxy_isupper(*p))
546 *p = (char)privoxy_tolower(*p);
550 directive_hash = hash_string(cmd);
551 switch (directive_hash)
553 /* *************************************************************************
554 * actionsfile actions-file-name
555 * In confdir by default
556 * *************************************************************************/
557 case hash_actions_file :
559 while ((i < MAX_AF_FILES) && (NULL != config->actions_file[i]))
564 if (i >= MAX_AF_FILES)
566 log_error(LOG_LEVEL_FATAL, "Too many 'actionsfile' directives in config file - limit is %d.\n"
567 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
570 config->actions_file_short[i] = strdup(arg);
571 config->actions_file[i] = make_path(config->confdir, arg);
574 /* *************************************************************************
575 * accept-intercepted-requests
576 * *************************************************************************/
577 case hash_accept_intercepted_requests:
578 if (parse_toggle_state(cmd, arg) == 1)
580 config->feature_flags |= RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
584 config->feature_flags &= ~RUNTIME_FEATURE_ACCEPT_INTERCEPTED_REQUESTS;
588 /* *************************************************************************
589 * admin-address email-address
590 * *************************************************************************/
591 case hash_admin_address :
592 freez(config->admin_address);
593 config->admin_address = strdup(arg);
596 /* *************************************************************************
597 * allow-cgi-request-crunching
598 * *************************************************************************/
599 case hash_allow_cgi_request_crunching:
600 if (parse_toggle_state(cmd, arg) == 1)
602 config->feature_flags |= RUNTIME_FEATURE_CGI_CRUNCHING;
606 config->feature_flags &= ~RUNTIME_FEATURE_CGI_CRUNCHING;
610 /* *************************************************************************
612 * *************************************************************************/
613 case hash_buffer_limit :
614 config->buffer_limit = (size_t)(1024 * atoi(arg));
617 /* *************************************************************************
618 * client-header-order header-1 header-2 ... header-n
619 * *************************************************************************/
620 case hash_client_header_order:
621 list_remove_all(config->ordered_client_headers);
622 parse_client_header_order(config->ordered_client_headers, arg);
625 /* *************************************************************************
626 * confdir directory-name
627 * *************************************************************************/
629 freez(config->confdir);
630 config->confdir = make_path(NULL, arg);
633 /* *************************************************************************
634 * compression-level 0-9
635 * *************************************************************************/
636 #ifdef FEATURE_COMPRESSION
637 case hash_compression_level :
640 int compression_level = atoi(arg);
641 if (-1 <= compression_level && compression_level <= 9)
643 config->compression_level = compression_level;;
647 log_error(LOG_LEVEL_FATAL,
648 "Invalid compression-level value: %s", arg);
653 log_error(LOG_LEVEL_FATAL,
654 "Invalid compression-level directive. Compression value missing");
659 /* *************************************************************************
660 * connection-sharing (0|1)
661 * *************************************************************************/
662 #ifdef FEATURE_CONNECTION_SHARING
663 case hash_connection_sharing :
664 if (parse_toggle_state(cmd, arg) == 1)
666 config->feature_flags |= RUNTIME_FEATURE_CONNECTION_SHARING;
670 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
675 /* *************************************************************************
677 * Specifies debug level, multiple values are ORed together.
678 * *************************************************************************/
680 config->debug |= atoi(arg);
683 /* *************************************************************************
684 * default-server-timeout timeout
685 * *************************************************************************/
686 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
687 case hash_default_server_timeout :
690 int timeout = atoi(arg);
693 config->default_server_timeout = (unsigned int)timeout;
697 log_error(LOG_LEVEL_FATAL,
698 "Invalid default-server-timeout value: %s", arg);
704 /* *************************************************************************
705 * deny-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
706 * *************************************************************************/
708 case hash_deny_access:
709 strlcpy(tmp, arg, sizeof(tmp));
710 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
712 if ((vec_count != 1) && (vec_count != 2))
714 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
715 "deny-access directive in configuration file.");
716 string_append(&config->proxy_args,
717 "<br>\nWARNING: Wrong number of parameters for "
718 "deny-access directive in configuration file.<br><br>\n");
722 /* allocate a new node */
723 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
727 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
728 /* Never get here - LOG_LEVEL_FATAL causes program exit */
731 cur_acl->action = ACL_DENY;
733 if (acl_addr(vec[0], cur_acl->src) < 0)
735 log_error(LOG_LEVEL_ERROR, "Invalid source address, port or netmask "
736 "for deny-access directive in configuration file: \"%s\"", vec[0]);
737 string_append(&config->proxy_args,
738 "<br>\nWARNING: Invalid source address, port or netmask "
739 "for deny-access directive in configuration file: \"");
740 string_append(&config->proxy_args,
742 string_append(&config->proxy_args,
749 if (acl_addr(vec[1], cur_acl->dst) < 0)
751 log_error(LOG_LEVEL_ERROR, "Invalid destination address, port or netmask "
752 "for deny-access directive in configuration file: \"%s\"", vec[1]);
753 string_append(&config->proxy_args,
754 "<br>\nWARNING: Invalid destination address, port or netmask "
755 "for deny-access directive in configuration file: \"");
756 string_append(&config->proxy_args,
758 string_append(&config->proxy_args,
767 cur_acl->wildcard_dst = 1;
769 #endif /* def HAVE_RFC2553 */
772 * Add it to the list. Note we reverse the list to get the
773 * behaviour the user expects. With both the ACL and
774 * actions file, the last match wins. However, the internal
775 * implementations are different: The actions file is stored
776 * in the same order as the file, and scanned completely.
777 * With the ACL, we reverse the order as we load it, then
778 * when we scan it we stop as soon as we get a match.
780 cur_acl->next = config->acl;
781 config->acl = cur_acl;
784 #endif /* def FEATURE_ACL */
786 /* *************************************************************************
787 * enable-edit-actions 0|1
788 * *************************************************************************/
789 #ifdef FEATURE_CGI_EDIT_ACTIONS
790 case hash_enable_edit_actions:
791 if (parse_toggle_state(cmd, arg) == 1)
793 config->feature_flags |= RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
797 config->feature_flags &= ~RUNTIME_FEATURE_CGI_EDIT_ACTIONS;
800 #endif /* def FEATURE_CGI_EDIT_ACTIONS */
802 /* *************************************************************************
803 * enable-compression 0|1
804 * *************************************************************************/
805 #ifdef FEATURE_COMPRESSION
806 case hash_enable_compression:
807 if (parse_toggle_state(cmd, arg) == 1)
809 config->feature_flags |= RUNTIME_FEATURE_COMPRESSION;
813 config->feature_flags &= ~RUNTIME_FEATURE_COMPRESSION;
816 #endif /* def FEATURE_COMPRESSION */
819 /* *************************************************************************
820 * enable-remote-toggle 0|1
821 * *************************************************************************/
822 #ifdef FEATURE_TOGGLE
823 case hash_enable_remote_toggle:
824 if (parse_toggle_state(cmd, arg) == 1)
826 config->feature_flags |= RUNTIME_FEATURE_CGI_TOGGLE;
830 config->feature_flags &= ~RUNTIME_FEATURE_CGI_TOGGLE;
833 #endif /* def FEATURE_TOGGLE */
835 /* *************************************************************************
836 * enable-remote-http-toggle 0|1
837 * *************************************************************************/
838 case hash_enable_remote_http_toggle:
839 if (parse_toggle_state(cmd, arg) == 1)
841 config->feature_flags |= RUNTIME_FEATURE_HTTP_TOGGLE;
845 config->feature_flags &= ~RUNTIME_FEATURE_HTTP_TOGGLE;
849 /* *************************************************************************
851 * *************************************************************************/
852 case hash_enforce_blocks:
853 #ifdef FEATURE_FORCE_LOAD
854 if (parse_toggle_state(cmd, arg) == 1)
856 config->feature_flags |= RUNTIME_FEATURE_ENFORCE_BLOCKS;
860 config->feature_flags &= ~RUNTIME_FEATURE_ENFORCE_BLOCKS;
863 log_error(LOG_LEVEL_ERROR, "Ignoring directive 'enforce-blocks'. "
864 "FEATURE_FORCE_LOAD is disabled, blocks will always be enforced.");
865 #endif /* def FEATURE_FORCE_LOAD */
868 /* *************************************************************************
869 * filterfile file-name
870 * In confdir by default.
871 * *************************************************************************/
872 case hash_filterfile :
874 while ((i < MAX_AF_FILES) && (NULL != config->re_filterfile[i]))
879 if (i >= MAX_AF_FILES)
881 log_error(LOG_LEVEL_FATAL, "Too many 'filterfile' directives in config file - limit is %d.\n"
882 "(You can increase this limit by changing MAX_AF_FILES in project.h and recompiling).",
885 config->re_filterfile_short[i] = strdup(arg);
886 config->re_filterfile[i] = make_path(config->confdir, arg);
890 /* *************************************************************************
891 * forward url-pattern (.|http-proxy-host[:port])
892 * *************************************************************************/
894 strlcpy(tmp, arg, sizeof(tmp));
895 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
899 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for forward "
900 "directive in configuration file.");
901 string_append(&config->proxy_args,
902 "<br>\nWARNING: Wrong number of parameters for "
903 "forward directive in configuration file.");
907 /* allocate a new node */
908 cur_fwd = zalloc(sizeof(*cur_fwd));
911 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
912 /* Never get here - LOG_LEVEL_FATAL causes program exit */
916 cur_fwd->type = SOCKS_NONE;
918 /* Save the URL pattern */
919 if (create_url_spec(cur_fwd->url, vec[0]))
921 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward "
922 "directive in configuration file.");
923 string_append(&config->proxy_args,
924 "<br>\nWARNING: Bad URL specifier for "
925 "forward directive in configuration file.");
929 /* Parse the parent HTTP proxy host:port */
932 if (strcmp(p, ".") != 0)
934 cur_fwd->forward_port = 8000;
935 parse_forwarder_address(p, &cur_fwd->forward_host,
936 &cur_fwd->forward_port);
940 cur_fwd->next = config->forward;
941 config->forward = cur_fwd;
945 /* *************************************************************************
946 * forward-socks4 url-pattern socks-proxy[:port] (.|http-proxy[:port])
947 * *************************************************************************/
948 case hash_forward_socks4:
949 strlcpy(tmp, arg, sizeof(tmp));
950 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
954 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
955 "forward-socks4 directive in configuration file.");
956 string_append(&config->proxy_args,
957 "<br>\nWARNING: Wrong number of parameters for "
958 "forward-socks4 directive in configuration file.");
962 /* allocate a new node */
963 cur_fwd = zalloc(sizeof(*cur_fwd));
966 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
967 /* Never get here - LOG_LEVEL_FATAL causes program exit */
971 cur_fwd->type = SOCKS_4;
973 /* Save the URL pattern */
974 if (create_url_spec(cur_fwd->url, vec[0]))
976 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4 "
977 "directive in configuration file.");
978 string_append(&config->proxy_args,
979 "<br>\nWARNING: Bad URL specifier for "
980 "forward-socks4 directive in configuration file.");
984 /* Parse the SOCKS proxy host[:port] */
987 /* XXX: This check looks like a bug. */
988 if (strcmp(p, ".") != 0)
990 cur_fwd->gateway_port = 1080;
991 parse_forwarder_address(p, &cur_fwd->gateway_host,
992 &cur_fwd->gateway_port);
995 /* Parse the parent HTTP proxy host[:port] */
998 if (strcmp(p, ".") != 0)
1000 cur_fwd->forward_port = 8000;
1001 parse_forwarder_address(p, &cur_fwd->forward_host,
1002 &cur_fwd->forward_port);
1006 cur_fwd->next = config->forward;
1007 config->forward = cur_fwd;
1011 /* *************************************************************************
1012 * forward-socks4a url-pattern socks-proxy[:port] (.|http-proxy[:port])
1013 * *************************************************************************/
1014 case hash_forward_socks4a:
1015 case hash_forward_socks5:
1016 strlcpy(tmp, arg, sizeof(tmp));
1017 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
1021 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1022 "forward-socks4a directive in configuration file.");
1023 string_append(&config->proxy_args,
1024 "<br>\nWARNING: Wrong number of parameters for "
1025 "forward-socks4a directive in configuration file.");
1029 /* allocate a new node */
1030 cur_fwd = zalloc(sizeof(*cur_fwd));
1031 if (cur_fwd == NULL)
1033 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1034 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1038 if (directive_hash == hash_forward_socks4a)
1040 cur_fwd->type = SOCKS_4A;
1044 cur_fwd->type = SOCKS_5;
1047 /* Save the URL pattern */
1048 if (create_url_spec(cur_fwd->url, vec[0]))
1050 log_error(LOG_LEVEL_ERROR, "Bad URL specifier for forward-socks4a "
1051 "directive in configuration file.");
1052 string_append(&config->proxy_args,
1053 "<br>\nWARNING: Bad URL specifier for "
1054 "forward-socks4a directive in configuration file.");
1058 /* Parse the SOCKS proxy host[:port] */
1061 cur_fwd->gateway_port = 1080;
1062 parse_forwarder_address(p, &cur_fwd->gateway_host,
1063 &cur_fwd->gateway_port);
1065 /* Parse the parent HTTP proxy host[:port] */
1068 if (strcmp(p, ".") != 0)
1070 cur_fwd->forward_port = 8000;
1071 parse_forwarder_address(p, &cur_fwd->forward_host,
1072 &cur_fwd->forward_port);
1076 cur_fwd->next = config->forward;
1077 config->forward = cur_fwd;
1081 /* *************************************************************************
1082 * forwarded-connect-retries n
1083 * *************************************************************************/
1084 case hash_forwarded_connect_retries :
1085 config->forwarded_connect_retries = atoi(arg);
1088 /* *************************************************************************
1089 * handle-as-empty-doc-returns-ok 0|1
1091 * Workaround for firefox hanging on blocked javascript pages.
1092 * Block with the "+handle-as-empty-document" flag and set the
1093 * "handle-as-empty-doc-returns-ok" run-time config flag so that
1094 * Privoxy returns a 200/OK status instead of a 403/Forbidden status
1095 * to the browser for blocked pages.
1096 ***************************************************************************/
1097 case hash_handle_as_empty_returns_ok:
1098 if (parse_toggle_state(cmd, arg) == 1)
1100 config->feature_flags |= RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
1104 config->feature_flags &= ~RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK;
1108 /* *************************************************************************
1109 * hostname hostname-to-show-on-cgi-pages
1110 * *************************************************************************/
1111 case hash_hostname :
1112 freez(config->hostname);
1113 config->hostname = strdup(arg);
1114 if (NULL == config->hostname)
1116 log_error(LOG_LEVEL_FATAL, "Out of memory saving hostname.");
1120 /* *************************************************************************
1121 * keep-alive-timeout timeout
1122 * *************************************************************************/
1123 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
1124 case hash_keep_alive_timeout :
1127 int timeout = atoi(arg);
1130 config->feature_flags |= RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1131 config->keep_alive_timeout = (unsigned int)timeout;
1135 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1141 /* *************************************************************************
1142 * listen-address [ip][:port]
1143 * *************************************************************************/
1144 case hash_listen_address :
1146 while ((i < MAX_LISTENING_SOCKETS) && (NULL != config->haddr[i]))
1151 if (i >= MAX_LISTENING_SOCKETS)
1153 log_error(LOG_LEVEL_FATAL, "Too many 'listen-address' directives in config file - limit is %d.\n"
1154 "(You can increase this limit by changing MAX_LISTENING_SOCKETS in project.h and recompiling).",
1155 MAX_LISTENING_SOCKETS);
1157 config->haddr[i] = strdup(arg);
1158 if (NULL == config->haddr[i])
1160 log_error(LOG_LEVEL_FATAL, "Out of memory while copying listening address");
1164 /* *************************************************************************
1165 * logdir directory-name
1166 * *************************************************************************/
1168 freez(config->logdir);
1169 config->logdir = make_path(NULL, arg);
1172 /* *************************************************************************
1173 * logfile log-file-name
1174 * In logdir by default
1175 * *************************************************************************/
1179 logfile = make_path(config->logdir, arg);
1180 if (NULL == logfile)
1182 log_error(LOG_LEVEL_FATAL, "Out of memory while creating logfile path");
1187 /* *************************************************************************
1188 * max-client-connections number
1189 * *************************************************************************/
1190 case hash_max_client_connections :
1193 int max_client_connections = atoi(arg);
1194 if (0 <= max_client_connections)
1196 config->max_client_connections = max_client_connections;
1201 /* *************************************************************************
1202 * permit-access source-ip[/significant-bits] [dest-ip[/significant-bits]]
1203 * *************************************************************************/
1205 case hash_permit_access:
1206 strlcpy(tmp, arg, sizeof(tmp));
1207 vec_count = ssplit(tmp, " \t", vec, SZ(vec));
1209 if ((vec_count != 1) && (vec_count != 2))
1211 log_error(LOG_LEVEL_ERROR, "Wrong number of parameters for "
1212 "permit-access directive in configuration file.");
1213 string_append(&config->proxy_args,
1214 "<br>\nWARNING: Wrong number of parameters for "
1215 "permit-access directive in configuration file.<br><br>\n");
1220 /* allocate a new node */
1221 cur_acl = (struct access_control_list *) zalloc(sizeof(*cur_acl));
1223 if (cur_acl == NULL)
1225 log_error(LOG_LEVEL_FATAL, "can't allocate memory for configuration");
1226 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1229 cur_acl->action = ACL_PERMIT;
1231 if (acl_addr(vec[0], cur_acl->src) < 0)
1233 log_error(LOG_LEVEL_ERROR, "Invalid source address, port or netmask "
1234 "for permit-access directive in configuration file: \"%s\"", vec[0]);
1235 string_append(&config->proxy_args,
1236 "<br>\nWARNING: Invalid source address, port or netmask for "
1237 "permit-access directive in configuration file: \"");
1238 string_append(&config->proxy_args,
1240 string_append(&config->proxy_args,
1247 if (acl_addr(vec[1], cur_acl->dst) < 0)
1249 log_error(LOG_LEVEL_ERROR, "Invalid destination address, port or netmask "
1250 "for permit-access directive in configuration file: \"%s\"", vec[1]);
1251 string_append(&config->proxy_args,
1252 "<br>\nWARNING: Invalid destination address, port or netmask for "
1253 "permit-access directive in configuration file: \"");
1254 string_append(&config->proxy_args,
1256 string_append(&config->proxy_args,
1265 cur_acl->wildcard_dst = 1;
1267 #endif /* def HAVE_RFC2553 */
1270 * Add it to the list. Note we reverse the list to get the
1271 * behaviour the user expects. With both the ACL and
1272 * actions file, the last match wins. However, the internal
1273 * implementations are different: The actions file is stored
1274 * in the same order as the file, and scanned completely.
1275 * With the ACL, we reverse the order as we load it, then
1276 * when we scan it we stop as soon as we get a match.
1278 cur_acl->next = config->acl;
1279 config->acl = cur_acl;
1282 #endif /* def FEATURE_ACL */
1284 /* *************************************************************************
1285 * proxy-info-url url
1286 * *************************************************************************/
1287 case hash_proxy_info_url :
1288 freez(config->proxy_info_url);
1289 config->proxy_info_url = strdup(arg);
1292 /* *************************************************************************
1294 * *************************************************************************/
1295 case hash_single_threaded :
1296 config->multi_threaded = 0;
1299 /* *************************************************************************
1300 * socket-timeout numer_of_seconds
1301 * *************************************************************************/
1302 case hash_socket_timeout :
1305 int socket_timeout = atoi(arg);
1306 if (0 <= socket_timeout)
1308 config->socket_timeout = socket_timeout;
1312 log_error(LOG_LEVEL_FATAL,
1313 "Invalid socket-timeout: '%s'", arg);
1318 /* *************************************************************************
1319 * split-large-cgi-forms
1320 * *************************************************************************/
1321 case hash_split_large_cgi_forms :
1322 if (parse_toggle_state(cmd, arg) == 1)
1324 config->feature_flags |= RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1328 config->feature_flags &= ~RUNTIME_FEATURE_SPLIT_LARGE_FORMS;
1332 /* *************************************************************************
1333 * templdir directory-name
1334 * *************************************************************************/
1335 case hash_templdir :
1336 freez(config->templdir);
1337 config->templdir = make_path(NULL, arg);
1340 /* *************************************************************************
1341 * tolerate-pipelining (0|1)
1342 * *************************************************************************/
1343 case hash_tolerate_pipelining :
1344 if (parse_toggle_state(cmd, arg) == 1)
1346 config->feature_flags |= RUNTIME_FEATURE_TOLERATE_PIPELINING;
1350 config->feature_flags &= ~RUNTIME_FEATURE_TOLERATE_PIPELINING;
1354 /* *************************************************************************
1356 * *************************************************************************/
1357 #ifdef FEATURE_TOGGLE
1359 global_toggle_state = parse_toggle_state(cmd, arg);
1361 #endif /* def FEATURE_TOGGLE */
1363 /* *************************************************************************
1364 * trust-info-url url
1365 * *************************************************************************/
1366 #ifdef FEATURE_TRUST
1367 case hash_trust_info_url :
1368 enlist(config->trust_info, arg);
1370 #endif /* def FEATURE_TRUST */
1372 /* *************************************************************************
1373 * trustfile filename
1374 * (In confdir by default.)
1375 * *************************************************************************/
1376 #ifdef FEATURE_TRUST
1377 case hash_trustfile :
1378 freez(config->trustfile);
1379 config->trustfile = make_path(config->confdir, arg);
1381 #endif /* def FEATURE_TRUST */
1383 /* *************************************************************************
1385 * *************************************************************************/
1386 case hash_usermanual :
1388 * XXX: If this isn't the first config directive, the
1389 * show-status page links to the website documentation
1390 * for the directives that were already parsed. Lame.
1392 freez(config->usermanual);
1393 config->usermanual = strdup(arg);
1396 /* *************************************************************************
1397 * Win32 Console options:
1398 * *************************************************************************/
1400 /* *************************************************************************
1402 * *************************************************************************/
1404 case hash_hide_console :
1407 #endif /*def _WIN_CONSOLE*/
1410 /* *************************************************************************
1411 * Win32 GUI options:
1412 * *************************************************************************/
1414 #if defined(_WIN32) && ! defined(_WIN_CONSOLE)
1415 /* *************************************************************************
1416 * activity-animation (0|1)
1417 * *************************************************************************/
1418 case hash_activity_animation :
1419 g_bShowActivityAnimation = parse_toggle_state(cmd, arg);
1422 /* *************************************************************************
1423 * close-button-minimizes (0|1)
1424 * *************************************************************************/
1425 case hash_close_button_minimizes :
1426 g_bCloseHidesWindow = parse_toggle_state(cmd, arg);
1429 /* *************************************************************************
1430 * log-buffer-size (0|1)
1431 * *************************************************************************/
1432 case hash_log_buffer_size :
1433 g_bLimitBufferSize = parse_toggle_state(cmd, arg);
1436 /* *************************************************************************
1437 * log-font-name fontname
1438 * *************************************************************************/
1439 case hash_log_font_name :
1440 if (strlcpy(g_szFontFaceName, arg,
1441 sizeof(g_szFontFaceName)) >= sizeof(g_szFontFaceName))
1443 log_error(LOG_LEVEL_FATAL,
1444 "log-font-name argument '%s' is longer than %u characters.",
1445 arg, sizeof(g_szFontFaceName)-1);
1449 /* *************************************************************************
1451 * *************************************************************************/
1452 case hash_log_font_size :
1453 g_nFontSize = atoi(arg);
1456 /* *************************************************************************
1457 * log-highlight-messages (0|1)
1458 * *************************************************************************/
1459 case hash_log_highlight_messages :
1460 g_bHighlightMessages = parse_toggle_state(cmd, arg);
1463 /* *************************************************************************
1465 * *************************************************************************/
1466 case hash_log_max_lines :
1467 g_nMaxBufferLines = atoi(arg);
1470 /* *************************************************************************
1471 * log-messages (0|1)
1472 * *************************************************************************/
1473 case hash_log_messages :
1474 g_bLogMessages = parse_toggle_state(cmd, arg);
1477 /* *************************************************************************
1478 * show-on-task-bar (0|1)
1479 * *************************************************************************/
1480 case hash_show_on_task_bar :
1481 g_bShowOnTaskBar = parse_toggle_state(cmd, arg);
1484 #endif /* defined(_WIN32) && ! defined(_WIN_CONSOLE) */
1487 /* *************************************************************************
1488 * Warnings about unsupported features
1489 * *************************************************************************/
1491 case hash_deny_access:
1492 #endif /* ndef FEATURE_ACL */
1493 #ifndef FEATURE_CGI_EDIT_ACTIONS
1494 case hash_enable_edit_actions:
1495 #endif /* ndef FEATURE_CGI_EDIT_ACTIONS */
1496 #ifndef FEATURE_TOGGLE
1497 case hash_enable_remote_toggle:
1498 #endif /* ndef FEATURE_TOGGLE */
1500 case hash_permit_access:
1501 #endif /* ndef FEATURE_ACL */
1502 #ifndef FEATURE_TOGGLE
1504 #endif /* ndef FEATURE_TOGGLE */
1505 #ifndef FEATURE_TRUST
1506 case hash_trustfile :
1507 case hash_trust_info_url :
1508 #endif /* ndef FEATURE_TRUST */
1510 #ifndef _WIN_CONSOLE
1511 case hash_hide_console :
1512 #endif /* ndef _WIN_CONSOLE */
1514 #if defined(_WIN_CONSOLE) || ! defined(_WIN32)
1515 case hash_activity_animation :
1516 case hash_close_button_minimizes :
1517 case hash_log_buffer_size :
1518 case hash_log_font_name :
1519 case hash_log_font_size :
1520 case hash_log_highlight_messages :
1521 case hash_log_max_lines :
1522 case hash_log_messages :
1523 case hash_show_on_task_bar :
1524 #endif /* defined(_WIN_CONSOLE) || ! defined(_WIN32) */
1525 /* These warnings are annoying - so hide them. -- Jon */
1526 /* log_error(LOG_LEVEL_INFO, "Unsupported directive \"%s\" ignored.", cmd); */
1529 /* *************************************************************************/
1531 /* *************************************************************************/
1533 * I decided that I liked this better as a warning than an
1534 * error. To change back to an error, just change log level
1535 * to LOG_LEVEL_FATAL.
1537 log_error(LOG_LEVEL_ERROR, "Ignoring unrecognized directive "
1538 "'%s' (%uU) in line %lu in configuration file (%s).",
1539 buf, directive_hash, linenum, configfile);
1540 string_append(&config->proxy_args,
1541 " <strong class='warning'>Warning: Ignoring unrecognized directive:</strong>");
1544 /* *************************************************************************/
1545 } /* end switch(hash_string(cmd)) */
1547 /* Save the argument for the show-status page. */
1548 savearg(cmd, arg, config);
1550 } /* end while (read_config_line(...)) */
1554 set_debug_level(config->debug);
1556 freez(config->logfile);
1560 if (NULL != logfile)
1562 config->logfile = logfile;
1563 init_error_log(Argv[0], config->logfile);
1571 #ifdef FEATURE_CONNECTION_KEEP_ALIVE
1572 if (config->default_server_timeout > config->keep_alive_timeout)
1574 log_error(LOG_LEVEL_ERROR,
1575 "Reducing the default-server-timeout from %d to the keep-alive-timeout %d.",
1576 config->default_server_timeout, config->keep_alive_timeout);
1577 config->default_server_timeout = config->keep_alive_timeout;
1579 #endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
1581 #ifdef FEATURE_CONNECTION_SHARING
1582 if (config->feature_flags & RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE)
1584 if (config->multi_threaded)
1586 set_keep_alive_timeout(config->keep_alive_timeout);
1591 * While we could use keep-alive without multiple threads
1592 * if we didn't bother with enforcing the connection timeout,
1593 * that might make Tor users sad, even though they shouldn't
1594 * enable the single-threaded option anyway.
1596 * XXX: We could still use Proxy-Connection: keep-alive.
1598 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_KEEP_ALIVE;
1599 log_error(LOG_LEVEL_ERROR,
1600 "Config option single-threaded disables connection keep-alive.");
1603 else if ((config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING))
1605 log_error(LOG_LEVEL_ERROR, "Config option connection-sharing "
1606 "has no effect if keep-alive-timeout isn't set.");
1607 config->feature_flags &= ~RUNTIME_FEATURE_CONNECTION_SHARING;
1609 #endif /* def FEATURE_CONNECTION_SHARING */
1611 if (NULL == config->proxy_args)
1613 log_error(LOG_LEVEL_FATAL, "Out of memory loading config - insufficient memory for config->proxy_args");
1616 if (config->re_filterfile[0])
1618 add_loader(load_re_filterfiles, config);
1621 if (config->actions_file[0])
1623 add_loader(load_action_files, config);
1626 #ifdef FEATURE_TRUST
1627 if (config->trustfile)
1629 add_loader(load_trustfile, config);
1631 #endif /* def FEATURE_TRUST */
1633 if (NULL == config->haddr[0])
1635 config->haddr[0] = strdup(HADDR_DEFAULT);
1636 if (NULL == config->haddr[0])
1638 log_error(LOG_LEVEL_FATAL, "Out of memory while copying default listening address");
1642 for (i = 0; i < MAX_LISTENING_SOCKETS && NULL != config->haddr[i]; i++)
1644 if ((*config->haddr[i] == '[')
1645 && (NULL != (p = strchr(config->haddr[i], ']')))
1647 && (0 < (config->hport[i] = atoi(p + 2))))
1650 memmove((void *)config->haddr[i], config->haddr[i] + 1,
1651 (size_t)(p - config->haddr[i]));
1653 else if (NULL != (p = strchr(config->haddr[i], ':'))
1654 && (0 < (config->hport[i] = atoi(p + 1))))
1660 log_error(LOG_LEVEL_FATAL, "invalid bind port spec %s", config->haddr[i]);
1661 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1663 if (*config->haddr[i] == '\0')
1666 * Only the port specified. We stored it in config->hport[i]
1667 * and don't need its text representation anymore.
1668 * Use config->hport[i] == 0 to iterate listening addresses since
1671 freez(config->haddr[i]);
1676 * Want to run all the loaders once now.
1678 * Need to set up a fake csp, so they can get to the config.
1680 fake_csp = (struct client_state *) zalloc (sizeof(*fake_csp));
1681 fake_csp->config = config;
1683 if (run_loader(fake_csp))
1686 log_error(LOG_LEVEL_FATAL, "A loader failed while loading config file. Exiting.");
1687 /* Never get here - LOG_LEVEL_FATAL causes program exit */
1691 /* FIXME: this is a kludge for win32 */
1692 #if defined(_WIN32) && !defined (_WIN_CONSOLE)
1694 g_default_actions_file = config->actions_file[1]; /* FIXME Hope this is default.action */
1695 g_user_actions_file = config->actions_file[2]; /* FIXME Hope this is user.action */
1696 g_default_filterfile = config->re_filterfile[0]; /* FIXME Hope this is default.filter */
1697 g_user_filterfile = config->re_filterfile[1]; /* FIXME Hope this is user.filter */
1699 #ifdef FEATURE_TRUST
1700 g_trustfile = config->trustfile;
1701 #endif /* def FEATURE_TRUST */
1704 #endif /* defined(_WIN32) && !defined (_WIN_CONSOLE) */
1705 /* FIXME: end kludge */
1708 config->need_bind = 1;
1710 if (current_configfile)
1712 struct configuration_spec * oldcfg = (struct configuration_spec *)
1713 current_configfile->f;
1715 * Check if config->haddr[i],hport[i] == oldcfg->haddr[i],hport[i]
1717 * The following could be written more compactly as a single,
1718 * (unreadably long) if statement.
1720 config->need_bind = 0;
1722 for (i = 0; i < MAX_LISTENING_SOCKETS; i++)
1724 if (config->hport[i] != oldcfg->hport[i])
1726 config->need_bind = 1;
1728 else if (config->haddr[i] == NULL)
1730 if (oldcfg->haddr[i] != NULL)
1732 config->need_bind = 1;
1735 else if (oldcfg->haddr[i] == NULL)
1737 config->need_bind = 1;
1739 else if (0 != strcmp(config->haddr[i], oldcfg->haddr[i]))
1741 config->need_bind = 1;
1745 current_configfile->unloader = unload_configfile;
1748 fs->next = files->next;
1751 current_configfile = fs;
1757 /*********************************************************************
1759 * Function : savearg
1761 * Description : Called from `load_config'. It saves each non-empty
1762 * and non-comment line from config into
1763 * config->proxy_args. This is used to create the
1764 * show-proxy-args page. On error, frees
1765 * config->proxy_args and sets it to NULL
1768 * 1 : command = config setting that was found
1769 * 2 : argument = the setting's argument (if any)
1770 * 3 : config = Configuration to save into.
1774 *********************************************************************/
1775 static void savearg(char *command, char *argument, struct configuration_spec * config)
1784 * Add config option name embedded in
1785 * link to its section in the user-manual
1787 buf = strdup("\n<a href=\"");
1788 if (!strncmpic(config->usermanual, "file://", 7) ||
1789 !strncmpic(config->usermanual, "http", 4))
1791 string_append(&buf, config->usermanual);
1795 string_append(&buf, "http://" CGI_SITE_2_HOST "/user-manual/");
1797 string_append(&buf, CONFIG_HELP_PREFIX);
1798 string_join (&buf, string_toupper(command));
1799 string_append(&buf, "\">");
1800 string_append(&buf, command);
1801 string_append(&buf, "</a> ");
1805 freez(config->proxy_args);
1809 if ((NULL != argument) && ('\0' != *argument))
1811 s = html_encode(argument);
1815 freez(config->proxy_args);
1819 if (strncmpic(argument, "http://", 7) == 0)
1821 string_append(&buf, "<a href=\"");
1822 string_append(&buf, s);
1823 string_append(&buf, "\">");
1824 string_join (&buf, s);
1825 string_append(&buf, "</a>");
1829 string_join (&buf, s);
1833 string_append(&buf, "<br>");
1834 string_join(&config->proxy_args, buf);