]>
Commit | Line | Data |
---|---|---|
30a4f2a8 | 1 | /* |
262a0e14 | 2 | * $Id$ |
30a4f2a8 | 3 | * |
4 | * DEBUG: section 3 Configuration File Parsing | |
5 | * AUTHOR: Harvest Derived | |
6 | * | |
2b6662ba | 7 | * SQUID Web Proxy Cache http://www.squid-cache.org/ |
e25c139f | 8 | * ---------------------------------------------------------- |
30a4f2a8 | 9 | * |
2b6662ba | 10 | * Squid is the result of efforts by numerous individuals from |
11 | * the Internet community; see the CONTRIBUTORS file for full | |
12 | * details. Many organizations have provided support for Squid's | |
13 | * development; see the SPONSORS file for full details. Squid is | |
14 | * Copyrighted (C) 2001 by the Regents of the University of | |
15 | * California; see the COPYRIGHT file for full details. Squid | |
16 | * incorporates software developed and/or copyrighted by other | |
17 | * sources; see the CREDITS file for full details. | |
30a4f2a8 | 18 | * |
19 | * This program is free software; you can redistribute it and/or modify | |
20 | * it under the terms of the GNU General Public License as published by | |
21 | * the Free Software Foundation; either version 2 of the License, or | |
22 | * (at your option) any later version. | |
26ac0430 | 23 | * |
30a4f2a8 | 24 | * This program is distributed in the hope that it will be useful, |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 | * GNU General Public License for more details. | |
26ac0430 | 28 | * |
30a4f2a8 | 29 | * You should have received a copy of the GNU General Public License |
30 | * along with this program; if not, write to the Free Software | |
cbdec147 | 31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
e25c139f | 32 | * |
30a4f2a8 | 33 | */ |
cf5fd929 | 34 | |
44a47c6e | 35 | #include "squid.h" |
154dc884 | 36 | #include "ProtoPort.h" |
75cb38cb | 37 | #include "HttpRequestMethod.h" |
2d2b0bb7 AR |
38 | #include "auth/Config.h" |
39 | #include "auth/Scheme.h" | |
62ee09ca | 40 | #include "CacheManager.h" |
e6ccf245 | 41 | #include "Store.h" |
d3b3ab85 | 42 | #include "SwapDir.h" |
a80a77cf | 43 | #include "ConfigParser.h" |
3ad63615 AR |
44 | #include "acl/Acl.h" |
45 | #include "acl/Gadgets.h" | |
59b2d47f | 46 | #include "StoreFileSystem.h" |
c8f4eac4 | 47 | #include "Parsing.h" |
0eb49b6d | 48 | #include "MemBuf.h" |
d295d770 | 49 | #include "wordlist.h" |
85944c1c | 50 | #include "ip/IpIntercept.h" |
04f87469 | 51 | |
52303a3d | 52 | #if HAVE_GLOB_H |
592a09dc | 53 | #include <glob.h> |
52303a3d | 54 | #endif |
1df370e3 | 55 | |
56 | #if SQUID_SNMP | |
a97cfa48 | 57 | #include "snmp.h" |
1df370e3 | 58 | #endif |
f41735ea | 59 | #if USE_SQUID_ESI |
f99c2cfe | 60 | #include "esi/Parser.h" |
43ae1d95 | 61 | #endif |
090089c4 | 62 | |
62c7f90e AR |
63 | #if USE_ADAPTATION |
64 | #include "adaptation/Config.h" | |
65 | ||
66 | static void parse_adaptation_service_set_type(); | |
62c7f90e | 67 | static void parse_adaptation_access_type(); |
62c7f90e AR |
68 | |
69 | #endif | |
70 | ||
3a69ddf3 | 71 | #if ICAP_CLIENT |
26cc52cb | 72 | #include "adaptation/icap/Config.h" |
3a69ddf3 | 73 | |
26cc52cb AR |
74 | static void parse_icap_service_type(Adaptation::Icap::Config *); |
75 | static void dump_icap_service_type(StoreEntry *, const char *, const Adaptation::Icap::Config &); | |
76 | static void free_icap_service_type(Adaptation::Icap::Config *); | |
c939dc70 AR |
77 | static void parse_icap_class_type(); |
78 | static void parse_icap_access_type(); | |
3a69ddf3 | 79 | |
80 | #endif | |
81 | ||
21a26d31 | 82 | #if USE_ECAP |
1f3c65fc | 83 | #include "adaptation/ecap/Config.h" |
574b508c AR |
84 | static void parse_ecap_service_type(Adaptation::Ecap::Config *); |
85 | static void dump_ecap_service_type(StoreEntry *, const char *, const Adaptation::Ecap::Config &); | |
86 | static void free_ecap_service_type(Adaptation::Ecap::Config *); | |
21a26d31 AR |
87 | #endif |
88 | ||
f5691f9c | 89 | CBDATA_TYPE(peer); |
90 | ||
8813e606 | 91 | static const char *const T_SECOND_STR = "second"; |
92 | static const char *const T_MINUTE_STR = "minute"; | |
93 | static const char *const T_HOUR_STR = "hour"; | |
94 | static const char *const T_DAY_STR = "day"; | |
95 | static const char *const T_WEEK_STR = "week"; | |
96 | static const char *const T_FORTNIGHT_STR = "fortnight"; | |
97 | static const char *const T_MONTH_STR = "month"; | |
98 | static const char *const T_YEAR_STR = "year"; | |
99 | static const char *const T_DECADE_STR = "decade"; | |
aa0a0c7c | 100 | |
9906e724 | 101 | static const char *const B_BYTES_STR = "bytes"; |
102 | static const char *const B_KBYTES_STR = "KB"; | |
103 | static const char *const B_MBYTES_STR = "MB"; | |
104 | static const char *const B_GBYTES_STR = "GB"; | |
105 | ||
4db43fab | 106 | static const char *const list_sep = ", \t\n\r"; |
b0e7d2d5 | 107 | |
7684c4b1 | 108 | static void parse_logformat(logformat ** logformat_definitions); |
109 | static void parse_access_log(customlog ** customlog_definitions); | |
d64bef4c | 110 | static int check_null_access_log(customlog *customlog_definitions); |
111 | ||
7684c4b1 | 112 | static void dump_logformat(StoreEntry * entry, const char *name, logformat * definitions); |
113 | static void dump_access_log(StoreEntry * entry, const char *name, customlog * definitions); | |
114 | static void free_logformat(logformat ** definitions); | |
115 | static void free_access_log(customlog ** definitions); | |
116 | ||
cd748f27 | 117 | static void update_maxobjsize(void); |
f5b8bbc4 | 118 | static void configDoConfigure(void); |
119 | static void parse_refreshpattern(refresh_t **); | |
120 | static int parseTimeUnits(const char *unit); | |
121 | static void parseTimeLine(time_t * tptr, const char *units); | |
59715b38 | 122 | static void parse_ushort(u_short * var); |
f5b8bbc4 | 123 | static void parse_string(char **); |
f5b8bbc4 | 124 | static void default_all(void); |
125 | static void defaults_if_none(void); | |
126 | static int parse_line(char *); | |
127 | static void parseBytesLine(size_t * bptr, const char *units); | |
128 | static size_t parseBytesUnits(const char *unit); | |
f5b8bbc4 | 129 | static void free_all(void); |
94439e4e | 130 | void requirePathnameExists(const char *name, const char *path); |
ed7f5615 | 131 | static OBJH dump_config; |
c26ffae9 | 132 | #if HTTP_VIOLATIONS |
6bccf575 | 133 | static void dump_http_header_access(StoreEntry * entry, const char *name, header_mangler header[]); |
134 | static void parse_http_header_access(header_mangler header[]); | |
135 | static void free_http_header_access(header_mangler header[]); | |
136 | static void dump_http_header_replace(StoreEntry * entry, const char *name, header_mangler header[]); | |
137 | static void parse_http_header_replace(header_mangler * header); | |
138 | static void free_http_header_replace(header_mangler * header); | |
9e8b2f1c | 139 | #endif |
6bccf575 | 140 | static void parse_denyinfo(acl_deny_info_list ** var); |
141 | static void dump_denyinfo(StoreEntry * entry, const char *name, acl_deny_info_list * var); | |
142 | static void free_denyinfo(acl_deny_info_list ** var); | |
e1a88700 | 143 | |
0b0cfcf2 | 144 | #if USE_WCCPv2 |
23f6a720 AJ |
145 | static void parse_IpAddress_list(IpAddress_list **); |
146 | static void dump_IpAddress_list(StoreEntry *, const char *, const IpAddress_list *); | |
147 | static void free_IpAddress_list(IpAddress_list **); | |
0b0cfcf2 | 148 | #if CURRENTLY_UNUSED |
23f6a720 | 149 | static int check_null_IpAddress_list(const IpAddress_list *); |
3f38a55e | 150 | #endif /* CURRENTLY_UNUSED */ |
e1a88700 | 151 | #endif /* USE_WCCPv2 */ |
152 | ||
3f38a55e | 153 | static void parse_http_port_list(http_port_list **); |
154 | static void dump_http_port_list(StoreEntry *, const char *, const http_port_list *); | |
155 | static void free_http_port_list(http_port_list **); | |
e1a88700 | 156 | |
d193a436 | 157 | #if USE_SSL |
158 | static void parse_https_port_list(https_port_list **); | |
159 | static void dump_https_port_list(StoreEntry *, const char *, const https_port_list *); | |
160 | static void free_https_port_list(https_port_list **); | |
161 | #if 0 | |
162 | static int check_null_https_port_list(const https_port_list *); | |
163 | #endif | |
164 | #endif /* USE_SSL */ | |
e1a88700 | 165 | |
ef1955a5 | 166 | static void parse_b_size_t(size_t * var); |
47f6e231 | 167 | static void parse_b_int64_t(int64_t * var); |
270b86af | 168 | |
cfcb6b30 | 169 | static int parseOneConfigFile(const char *file_name, unsigned int depth); |
170 | ||
a385afc3 | 171 | /* |
172 | * LegacyParser is a parser for legacy code that uses the global | |
173 | * approach. This is static so that it is only exposed to cache_cf. | |
174 | * Other modules needing access to a ConfigParser should have it | |
175 | * provided to them in their parserFOO methods. | |
176 | */ | |
177 | static ConfigParser LegacyParser = ConfigParser(); | |
a9f20260 | 178 | |
0e4e0e7d | 179 | void |
0673c0ba | 180 | self_destruct(void) |
090089c4 | 181 | { |
a9f20260 | 182 | LegacyParser.destruct(); |
6b8e7481 | 183 | } |
184 | ||
cd748f27 | 185 | static void |
186 | update_maxobjsize(void) | |
187 | { | |
188 | int i; | |
47f6e231 | 189 | int64_t ms = -1; |
cd748f27 | 190 | |
191 | for (i = 0; i < Config.cacheSwap.n_configured; i++) { | |
c8f4eac4 | 192 | assert (Config.cacheSwap.swapDirs[i].getRaw()); |
62e76326 | 193 | |
c8f4eac4 | 194 | if (dynamic_cast<SwapDir *>(Config.cacheSwap.swapDirs[i].getRaw())-> |
195 | max_objsize > ms) | |
196 | ms = dynamic_cast<SwapDir *>(Config.cacheSwap.swapDirs[i].getRaw())->max_objsize; | |
cd748f27 | 197 | } |
198 | store_maxobjsize = ms; | |
199 | } | |
200 | ||
76b9daa5 | 201 | static void |
202 | SetConfigFilename(char const *file_name, bool is_pipe) | |
203 | { | |
204 | cfg_filename = file_name; | |
205 | ||
206 | char const *token; | |
207 | ||
208 | if (is_pipe) | |
209 | cfg_filename = file_name + 1; | |
210 | else if ((token = strrchr(cfg_filename, '/'))) | |
211 | cfg_filename = token + 1; | |
212 | } | |
213 | ||
130bff33 | 214 | static const char* |
215 | skip_ws(const char* s) | |
216 | { | |
217 | while (xisspace(*s)) | |
218 | ++s; | |
219 | ||
220 | return s; | |
221 | } | |
222 | ||
cfcb6b30 | 223 | static int |
224 | parseManyConfigFiles(char* files, int depth) | |
225 | { | |
226 | int error_count = 0; | |
d7ac36b9 | 227 | char* saveptr = NULL; |
52303a3d | 228 | #if HAVE_GLOB |
592a09dc | 229 | char *path; |
230 | glob_t globbuf; | |
231 | int i; | |
232 | memset(&globbuf, 0, sizeof(globbuf)); | |
233 | for (path = strwordtok(files, &saveptr); path; path = strwordtok(NULL, &saveptr)) { | |
26ac0430 AJ |
234 | if (glob(path, globbuf.gl_pathc ? GLOB_APPEND : 0, NULL, &globbuf) != 0) { |
235 | fatalf("Unable to find configuration file: %s: %s", | |
236 | path, xstrerror()); | |
237 | } | |
238 | } | |
592a09dc | 239 | for (i = 0; i < (int)globbuf.gl_pathc; i++) { |
26ac0430 | 240 | error_count += parseOneConfigFile(globbuf.gl_pathv[i], depth); |
cfcb6b30 | 241 | } |
592a09dc | 242 | globfree(&globbuf); |
52303a3d | 243 | #else |
244 | char* file = strwordtok(files, &saveptr); | |
245 | while (file != NULL) { | |
26ac0430 AJ |
246 | error_count += parseOneConfigFile(file, depth); |
247 | file = strwordtok(NULL, &saveptr); | |
52303a3d | 248 | } |
249 | #endif /* HAVE_GLOB */ | |
cfcb6b30 | 250 | return error_count; |
251 | } | |
252 | ||
253 | static int | |
254 | parseOneConfigFile(const char *file_name, unsigned int depth) | |
2546fcb3 | 255 | { |
270b86af | 256 | FILE *fp = NULL; |
cfcb6b30 | 257 | const char *orig_cfg_filename = cfg_filename; |
258 | const int orig_config_lineno = config_lineno; | |
270b86af | 259 | char *token = NULL; |
81c161d0 | 260 | char *tmp_line = NULL; |
261 | int tmp_line_len = 0; | |
e13ee7ad | 262 | int err_count = 0; |
1741cbad | 263 | int is_pipe = 0; |
cfcb6b30 | 264 | |
265 | debugs(3, 1, "Processing Configuration File: " << file_name << " (depth " << depth << ")"); | |
266 | if (depth > 16) { | |
267 | fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name); | |
268 | return 1; | |
269 | } | |
62e76326 | 270 | |
1741cbad | 271 | if (file_name[0] == '!' || file_name[0] == '|') { |
62e76326 | 272 | fp = popen(file_name + 1, "r"); |
273 | is_pipe = 1; | |
1741cbad | 274 | } else { |
62e76326 | 275 | fp = fopen(file_name, "r"); |
1741cbad | 276 | } |
62e76326 | 277 | |
1741cbad | 278 | if (fp == NULL) |
cfcb6b30 | 279 | fatalf("Unable to open configuration file: %s: %s", file_name, xstrerror()); |
62e76326 | 280 | |
ec4daaa5 | 281 | #ifdef _SQUID_WIN32_ |
62e76326 | 282 | |
c4aefe96 | 283 | setmode(fileno(fp), O_TEXT); |
62e76326 | 284 | |
c4aefe96 | 285 | #endif |
62e76326 | 286 | |
76b9daa5 | 287 | SetConfigFilename(file_name, bool(is_pipe)); |
62e76326 | 288 | |
270b86af | 289 | memset(config_input_line, '\0', BUFSIZ); |
62e76326 | 290 | |
270b86af | 291 | config_lineno = 0; |
62e76326 | 292 | |
270b86af | 293 | while (fgets(config_input_line, BUFSIZ, fp)) { |
62e76326 | 294 | config_lineno++; |
295 | ||
296 | if ((token = strchr(config_input_line, '\n'))) | |
297 | *token = '\0'; | |
298 | ||
d866e2ad | 299 | if ((token = strchr(config_input_line, '\r'))) |
300 | *token = '\0'; | |
301 | ||
62e76326 | 302 | if (strncmp(config_input_line, "#line ", 6) == 0) { |
303 | static char new_file_name[1024]; | |
304 | static char *file; | |
305 | static char new_lineno; | |
306 | token = config_input_line + 6; | |
307 | new_lineno = strtol(token, &file, 0) - 1; | |
308 | ||
309 | if (file == token) | |
310 | continue; /* Not a valid #line directive, may be a comment */ | |
311 | ||
e4755e29 | 312 | while (*file && xisspace((unsigned char) *file)) |
62e76326 | 313 | file++; |
314 | ||
315 | if (*file) { | |
316 | if (*file != '"') | |
317 | continue; /* Not a valid #line directive, may be a comment */ | |
318 | ||
319 | xstrncpy(new_file_name, file + 1, sizeof(new_file_name)); | |
320 | ||
321 | if ((token = strchr(new_file_name, '"'))) | |
322 | *token = '\0'; | |
323 | ||
324 | cfg_filename = new_file_name; | |
62e76326 | 325 | } |
326 | ||
327 | config_lineno = new_lineno; | |
328 | } | |
329 | ||
330 | if (config_input_line[0] == '#') | |
331 | continue; | |
332 | ||
333 | if (config_input_line[0] == '\0') | |
334 | continue; | |
335 | ||
130bff33 | 336 | const char* append = tmp_line_len ? skip_ws(config_input_line) : config_input_line; |
337 | ||
338 | size_t append_len = strlen(append); | |
62e76326 | 339 | |
130bff33 | 340 | tmp_line = (char*)xrealloc(tmp_line, tmp_line_len + append_len + 1); |
81c161d0 | 341 | |
130bff33 | 342 | strcpy(tmp_line + tmp_line_len, append); |
81c161d0 | 343 | |
130bff33 | 344 | tmp_line_len += append_len; |
81c161d0 | 345 | |
346 | if (tmp_line[tmp_line_len-1] == '\\') { | |
bf8fe701 | 347 | debugs(3, 5, "parseConfigFile: tmp_line='" << tmp_line << "'"); |
81c161d0 | 348 | tmp_line[--tmp_line_len] = '\0'; |
349 | continue; | |
350 | } | |
351 | ||
bf8fe701 | 352 | debugs(3, 5, "Processing: '" << tmp_line << "'"); |
62e76326 | 353 | |
26ac0430 | 354 | /* Handle includes here */ |
cfcb6b30 | 355 | if (tmp_line_len >= 9 && strncmp(tmp_line, "include", 7) == 0 && xisspace(tmp_line[7])) { |
356 | err_count += parseManyConfigFiles(tmp_line + 8, depth + 1); | |
26ac0430 | 357 | } else if (!parse_line(tmp_line)) { |
cfcb6b30 | 358 | debugs(3, 0, HERE << cfg_filename << ":" << config_lineno << " unrecognized: '" << tmp_line << "'"); |
26ac0430 AJ |
359 | err_count++; |
360 | } | |
62e76326 | 361 | |
362 | safe_free(tmp_line); | |
81c161d0 | 363 | tmp_line_len = 0; |
364 | ||
270b86af | 365 | } |
62e76326 | 366 | |
1741cbad | 367 | if (is_pipe) { |
62e76326 | 368 | int ret = pclose(fp); |
369 | ||
370 | if (ret != 0) | |
371 | fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name, ret); | |
1741cbad | 372 | } else { |
62e76326 | 373 | fclose(fp); |
1741cbad | 374 | } |
62e76326 | 375 | |
cfcb6b30 | 376 | cfg_filename = orig_cfg_filename; |
377 | config_lineno = orig_config_lineno; | |
378 | ||
379 | return err_count; | |
380 | } | |
381 | ||
382 | int | |
dd9b1081 | 383 | parseConfigFile(const char *file_name) |
cfcb6b30 | 384 | { |
385 | int err_count = 0; | |
dd9b1081 | 386 | CacheManager *manager=CacheManager::GetInstance(); |
cfcb6b30 | 387 | |
388 | configFreeMemory(); | |
389 | ||
390 | default_all(); | |
391 | ||
392 | err_count = parseOneConfigFile(file_name, 0); | |
393 | ||
f0b19334 | 394 | defaults_if_none(); |
f9ad0106 | 395 | |
9c46ca97 | 396 | /* |
397 | * We must call configDoConfigure() before leave_suid() because | |
398 | * configDoConfigure() is where we turn username strings into | |
399 | * uid values. | |
400 | */ | |
401 | configDoConfigure(); | |
402 | ||
f9ad0106 | 403 | if (!Config.chroot_dir) { |
404 | leave_suid(); | |
c642c141 | 405 | setUmask(Config.umask); |
62493678 | 406 | _db_init(Debug::cache_log, Debug::debugOptions); |
f9ad0106 | 407 | enter_suid(); |
408 | } | |
409 | ||
478c4f2f | 410 | if (opt_send_signal == -1) { |
dd9b1081 | 411 | manager->registerAction("config", |
26ac0430 AJ |
412 | "Current Squid Configuration", |
413 | dump_config, | |
414 | 1, 1); | |
478c4f2f | 415 | } |
416 | ||
e13ee7ad | 417 | return err_count; |
f0b19334 | 418 | } |
270b86af | 419 | |
cfcb6b30 | 420 | |
f0b19334 | 421 | static void |
422 | configDoConfigure(void) | |
423 | { | |
f0b19334 | 424 | memset(&Config2, '\0', sizeof(SquidConfig2)); |
7021844c | 425 | /* init memory as early as possible */ |
426 | memConfigure(); | |
270b86af | 427 | /* Sanity checks */ |
62e76326 | 428 | |
5aecb102 | 429 | #if SIZEOF_OFF_T <= 4 |
430 | if (Config.Store.maxObjectSize > 0x7FFF0000) { | |
26ac0430 AJ |
431 | debugs(3, 0, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB"); |
432 | Config.Store.maxObjectSize = 0x7FFF0000; | |
5aecb102 | 433 | } |
434 | #endif | |
c8f4eac4 | 435 | if (0 == Store::Root().maxSize()) |
62e76326 | 436 | /* people might want a zero-sized cache on purpose */ |
437 | (void) 0; | |
c8f4eac4 | 438 | else if (Store::Root().maxSize() < (Config.memMaxSize >> 10)) |
439 | /* This is bogus. folk with NULL caches will want this */ | |
bf8fe701 | 440 | debugs(3, 0, "WARNING cache_mem is larger than total disk cache space!"); |
62e76326 | 441 | |
84f42bac | 442 | if (Config.Announce.period > 0) { |
62e76326 | 443 | Config.onoff.announce = 1; |
84f42bac | 444 | } else if (Config.Announce.period < 1) { |
62e76326 | 445 | Config.Announce.period = 86400 * 365; /* one year */ |
446 | Config.onoff.announce = 0; | |
270b86af | 447 | } |
62e76326 | 448 | |
d3caee79 | 449 | if (Config.onoff.httpd_suppress_version_string) |
450 | visible_appname_string = (char *)appname_string; | |
451 | else | |
7dbca7a4 | 452 | visible_appname_string = (char const *)APP_FULLNAME; |
d3caee79 | 453 | |
6b53c392 | 454 | #if USE_DNSSERVERS |
d3caee79 | 455 | |
f0b19334 | 456 | if (Config.dnsChildren < 1) |
62e76326 | 457 | fatal("No dnsservers allocated"); |
458 | ||
efd900cb | 459 | #endif |
62e76326 | 460 | |
270b86af | 461 | if (Config.Program.redirect) { |
62e76326 | 462 | if (Config.redirectChildren < 1) { |
463 | Config.redirectChildren = 0; | |
464 | wordlistDestroy(&Config.Program.redirect); | |
465 | } | |
fea2e6e0 | 466 | } |
62e76326 | 467 | |
f1dc9b30 | 468 | if (Config.appendDomain) |
62e76326 | 469 | if (*Config.appendDomain != '.') |
470 | fatal("append_domain must begin with a '.'"); | |
471 | ||
270b86af | 472 | if (Config.errHtmlText == NULL) |
62e76326 | 473 | Config.errHtmlText = xstrdup(null_string); |
474 | ||
270b86af | 475 | storeConfigure(); |
62e76326 | 476 | |
52f772de | 477 | snprintf(ThisCache, sizeof(ThisCache), "%s (%s)", |
62e76326 | 478 | uniqueHostname(), |
d3caee79 | 479 | visible_appname_string); |
fbdba7c4 | 480 | |
38a6c74e | 481 | /* |
482 | * the extra space is for loop detection in client_side.c -- we search | |
483 | * for substrings in the Via header. | |
484 | */ | |
52f772de | 485 | snprintf(ThisCache2, sizeof(ThisCache), " %s (%s)", |
62e76326 | 486 | uniqueHostname(), |
d3caee79 | 487 | visible_appname_string); |
62e76326 | 488 | |
270b86af | 489 | if (!Config.udpMaxHitObjsz || Config.udpMaxHitObjsz > SQUID_UDP_SO_SNDBUF) |
62e76326 | 490 | Config.udpMaxHitObjsz = SQUID_UDP_SO_SNDBUF; |
491 | ||
270b86af | 492 | if (Config.appendDomain) |
62e76326 | 493 | Config.appendDomainLen = strlen(Config.appendDomain); |
270b86af | 494 | else |
62e76326 | 495 | Config.appendDomainLen = 0; |
496 | ||
22c653cd | 497 | if (Config.retry.maxtries > 10) |
62e76326 | 498 | fatal("maximum_single_addr_tries cannot be larger than 10"); |
499 | ||
22c653cd | 500 | if (Config.retry.maxtries < 1) { |
bf8fe701 | 501 | debugs(3, 0, "WARNING: resetting 'maximum_single_addr_tries to 1"); |
62e76326 | 502 | Config.retry.maxtries = 1; |
5210854d | 503 | } |
62e76326 | 504 | |
f0b19334 | 505 | requirePathnameExists("MIME Config Table", Config.mimeTablePathname); |
6b53c392 | 506 | #if USE_DNSSERVERS |
62e76326 | 507 | |
f0b19334 | 508 | requirePathnameExists("cache_dns_program", Config.Program.dnsserver); |
efd900cb | 509 | #endif |
a3d0a19d | 510 | #if USE_UNLINKD |
62e76326 | 511 | |
f0b19334 | 512 | requirePathnameExists("unlinkd_program", Config.Program.unlinkd); |
a3d0a19d | 513 | #endif |
62e76326 | 514 | |
f0b19334 | 515 | if (Config.Program.redirect) |
62e76326 | 516 | requirePathnameExists("redirect_program", Config.Program.redirect->key); |
517 | ||
f0b19334 | 518 | requirePathnameExists("Icon Directory", Config.icons.directory); |
62e76326 | 519 | |
26ac0430 | 520 | if (Config.errorDirectory) |
43000484 | 521 | requirePathnameExists("Error Directory", Config.errorDirectory); |
62e76326 | 522 | |
9f60cfdf | 523 | #if HTTP_VIOLATIONS |
62e76326 | 524 | |
9f60cfdf | 525 | { |
62e76326 | 526 | const refresh_t *R; |
527 | ||
26ac0430 | 528 | for (R = Config.Refresh; R; R = R->next) { |
62e76326 | 529 | if (!R->flags.override_expire) |
530 | continue; | |
531 | ||
bf8fe701 | 532 | debugs(22, 1, "WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP"); |
62e76326 | 533 | |
534 | break; | |
535 | } | |
536 | ||
26ac0430 | 537 | for (R = Config.Refresh; R; R = R->next) { |
62e76326 | 538 | if (!R->flags.override_lastmod) |
539 | continue; | |
540 | ||
bf8fe701 | 541 | debugs(22, 1, "WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP"); |
62e76326 | 542 | |
543 | break; | |
544 | } | |
545 | ||
26ac0430 | 546 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 547 | if (!R->flags.reload_into_ims) |
548 | continue; | |
549 | ||
bf8fe701 | 550 | debugs(22, 1, "WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 551 | |
552 | break; | |
553 | } | |
554 | ||
26ac0430 | 555 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 556 | if (!R->flags.ignore_reload) |
557 | continue; | |
558 | ||
bf8fe701 | 559 | debugs(22, 1, "WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 560 | |
561 | break; | |
562 | } | |
563 | ||
26ac0430 | 564 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 565 | if (!R->flags.ignore_no_cache) |
566 | continue; | |
567 | ||
bf8fe701 | 568 | debugs(22, 1, "WARNING: use of 'ignore-no-cache' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 569 | |
570 | break; | |
571 | } | |
572 | ||
26ac0430 | 573 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 574 | if (!R->flags.ignore_no_store) |
575 | continue; | |
576 | ||
bf8fe701 | 577 | debugs(22, 1, "WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 578 | |
579 | break; | |
580 | } | |
581 | ||
4ca08219 AJ |
582 | for (R = Config.Refresh; R; R = R->next) { |
583 | if (!R->flags.ignore_must_revalidate) | |
584 | continue; | |
585 | debugs(22, 1, "WARNING: use of 'ignore-must-revalidate' in 'refresh_pattern' violates HTTP"); | |
586 | break; | |
587 | } | |
588 | ||
26ac0430 | 589 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 590 | if (!R->flags.ignore_private) |
591 | continue; | |
592 | ||
bf8fe701 | 593 | debugs(22, 1, "WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 594 | |
595 | break; | |
596 | } | |
597 | ||
26ac0430 | 598 | for (R = Config.Refresh; R; R = R->next) { |
38f9c547 | 599 | if (!R->flags.ignore_auth) |
600 | continue; | |
601 | ||
bf8fe701 | 602 | debugs(22, 1, "WARNING: use of 'ignore-auth' in 'refresh_pattern' violates HTTP"); |
38f9c547 | 603 | |
604 | break; | |
605 | } | |
606 | ||
9f60cfdf | 607 | } |
c2f5c744 | 608 | #endif |
609 | #if !HTTP_VIOLATIONS | |
610 | Config.onoff.via = 1; | |
611 | #else | |
62e76326 | 612 | |
c2f5c744 | 613 | if (!Config.onoff.via) |
bf8fe701 | 614 | debugs(22, 1, "WARNING: HTTP requires the use of Via"); |
62e76326 | 615 | |
9f60cfdf | 616 | #endif |
62e76326 | 617 | |
ede3296d AJ |
618 | if (aclPurgeMethodInUse(Config.accessList.http)) |
619 | Config2.onoff.enable_purge = 1; | |
62e76326 | 620 | |
4f56514c | 621 | Config2.onoff.mangle_request_headers = httpReqHdrManglersConfigured(); |
5967c0bf | 622 | |
8749fa47 | 623 | if (geteuid() == 0) { |
62e76326 | 624 | if (NULL != Config.effectiveUser) { |
625 | ||
626 | struct passwd *pwd = getpwnam(Config.effectiveUser); | |
627 | ||
5ad8d199 | 628 | if (NULL == pwd) { |
62e76326 | 629 | /* |
630 | * Andres Kroonmaa <andre@online.ee>: | |
631 | * Some getpwnam() implementations (Solaris?) require | |
632 | * an available FD < 256 for opening a FILE* to the | |
633 | * passwd file. | |
634 | * DW: | |
635 | * This should be safe at startup, but might still fail | |
636 | * during reconfigure. | |
637 | */ | |
638 | fatalf("getpwnam failed to find userid for effective user '%s'", | |
639 | Config.effectiveUser); | |
5ad8d199 | 640 | return; |
641 | } | |
62e76326 | 642 | |
643 | Config2.effectiveUserID = pwd->pw_uid; | |
644 | ||
645 | Config2.effectiveGroupID = pwd->pw_gid; | |
08ac5ea7 | 646 | |
cff61cb8 | 647 | #if HAVE_PUTENV |
648 | ||
649 | if (pwd->pw_dir && *pwd->pw_dir) { | |
650 | int len; | |
651 | char *env_str = (char *)xcalloc((len = strlen(pwd->pw_dir) + 6), 1); | |
652 | snprintf(env_str, len, "HOME=%s", pwd->pw_dir); | |
653 | putenv(env_str); | |
654 | } | |
655 | ||
656 | #endif | |
657 | ||
62e76326 | 658 | } |
8749fa47 | 659 | } else { |
62e76326 | 660 | Config2.effectiveUserID = geteuid(); |
661 | Config2.effectiveGroupID = getegid(); | |
d20b1cd0 | 662 | } |
62e76326 | 663 | |
d20b1cd0 | 664 | if (NULL != Config.effectiveGroup) { |
62e76326 | 665 | |
666 | struct group *grp = getgrnam(Config.effectiveGroup); | |
667 | ||
5ad8d199 | 668 | if (NULL == grp) { |
62e76326 | 669 | fatalf("getgrnam failed to find groupid for effective group '%s'", |
670 | Config.effectiveGroup); | |
5ad8d199 | 671 | return; |
672 | } | |
62e76326 | 673 | |
674 | Config2.effectiveGroupID = grp->gr_gid; | |
d20b1cd0 | 675 | } |
62e76326 | 676 | |
985c86bc | 677 | HttpRequestMethod::Configure(Config); |
a7ad6e4e | 678 | #if USE_SSL |
62e76326 | 679 | |
bf8fe701 | 680 | debugs(3, 1, "Initializing https proxy context"); |
f9ad0106 | 681 | |
a82a4fe4 | 682 | Config.ssl_client.sslContext = sslCreateClientContext(Config.ssl_client.cert, Config.ssl_client.key, Config.ssl_client.version, Config.ssl_client.cipher, Config.ssl_client.options, Config.ssl_client.flags, Config.ssl_client.cafile, Config.ssl_client.capath, Config.ssl_client.crlfile); |
f9ad0106 | 683 | |
684 | { | |
685 | ||
686 | peer *p; | |
687 | ||
688 | for (p = Config.peers; p != NULL; p = p->next) { | |
689 | if (p->use_ssl) { | |
bf8fe701 | 690 | debugs(3, 1, "Initializing cache_peer " << p->name << " SSL context"); |
a82a4fe4 | 691 | p->sslContext = sslCreateClientContext(p->sslcert, p->sslkey, p->sslversion, p->sslcipher, p->ssloptions, p->sslflags, p->sslcafile, p->sslcapath, p->sslcrlfile); |
f9ad0106 | 692 | } |
693 | } | |
694 | } | |
695 | ||
154dc884 | 696 | { |
697 | ||
698 | http_port_list *s; | |
699 | ||
700 | for (s = Config.Sockaddr.http; s != NULL; s = (http_port_list *) s->next) { | |
701 | if (!s->cert && !s->key) | |
702 | continue; | |
703 | ||
704 | debugs(3, 1, "Initializing http_port " << s->http.s << " SSL context"); | |
705 | ||
706 | s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext); | |
707 | } | |
708 | } | |
709 | ||
f9ad0106 | 710 | { |
711 | ||
712 | https_port_list *s; | |
713 | ||
b844522c | 714 | for (s = Config.Sockaddr.https; s != NULL; s = (https_port_list *) s->http.next) { |
cc192b50 | 715 | debugs(3, 1, "Initializing https_port " << s->http.s << " SSL context"); |
bf8fe701 | 716 | |
a82a4fe4 | 717 | s->sslContext = sslCreateServerContext(s->cert, s->key, s->version, s->cipher, s->options, s->sslflags, s->clientca, s->cafile, s->capath, s->crlfile, s->dhfile, s->sslcontext); |
f9ad0106 | 718 | } |
719 | } | |
720 | ||
a7ad6e4e | 721 | #endif |
090089c4 | 722 | } |
723 | ||
270b86af | 724 | /* Parse a time specification from the config file. Store the |
f1dc9b30 | 725 | * result in 'tptr', after converting it to 'units' */ |
8203a132 | 726 | static void |
a47b9029 | 727 | parseTimeLine(time_t * tptr, const char *units) |
090089c4 | 728 | { |
729 | char *token; | |
270b86af | 730 | double d; |
f1dc9b30 | 731 | time_t m; |
732 | time_t u; | |
62e76326 | 733 | |
270b86af | 734 | if ((u = parseTimeUnits(units)) == 0) |
62e76326 | 735 | self_destruct(); |
736 | ||
270b86af | 737 | if ((token = strtok(NULL, w_space)) == NULL) |
62e76326 | 738 | self_destruct(); |
739 | ||
5c20d6fa | 740 | d = xatof(token); |
62e76326 | 741 | |
270b86af | 742 | m = u; /* default to 'units' if none specified */ |
62e76326 | 743 | |
10738561 | 744 | if (0 == d) |
62e76326 | 745 | (void) 0; |
10738561 | 746 | else if ((token = strtok(NULL, w_space)) == NULL) |
26ac0430 AJ |
747 | debugs(3, 0, "WARNING: No units on '" << |
748 | config_input_line << "', assuming " << | |
749 | d << " " << units ); | |
9e975e4e | 750 | else if ((m = parseTimeUnits(token)) == 0) |
62e76326 | 751 | self_destruct(); |
752 | ||
e6ccf245 | 753 | *tptr = static_cast<time_t> (m * d / u); |
090089c4 | 754 | } |
755 | ||
270b86af | 756 | static int |
757 | parseTimeUnits(const char *unit) | |
758 | { | |
759 | if (!strncasecmp(unit, T_SECOND_STR, strlen(T_SECOND_STR))) | |
62e76326 | 760 | return 1; |
761 | ||
270b86af | 762 | if (!strncasecmp(unit, T_MINUTE_STR, strlen(T_MINUTE_STR))) |
62e76326 | 763 | return 60; |
764 | ||
270b86af | 765 | if (!strncasecmp(unit, T_HOUR_STR, strlen(T_HOUR_STR))) |
62e76326 | 766 | return 3600; |
767 | ||
270b86af | 768 | if (!strncasecmp(unit, T_DAY_STR, strlen(T_DAY_STR))) |
62e76326 | 769 | return 86400; |
770 | ||
270b86af | 771 | if (!strncasecmp(unit, T_WEEK_STR, strlen(T_WEEK_STR))) |
62e76326 | 772 | return 86400 * 7; |
773 | ||
270b86af | 774 | if (!strncasecmp(unit, T_FORTNIGHT_STR, strlen(T_FORTNIGHT_STR))) |
62e76326 | 775 | return 86400 * 14; |
776 | ||
270b86af | 777 | if (!strncasecmp(unit, T_MONTH_STR, strlen(T_MONTH_STR))) |
62e76326 | 778 | return 86400 * 30; |
779 | ||
270b86af | 780 | if (!strncasecmp(unit, T_YEAR_STR, strlen(T_YEAR_STR))) |
62e76326 | 781 | return static_cast<int>(86400 * 365.2522); |
782 | ||
270b86af | 783 | if (!strncasecmp(unit, T_DECADE_STR, strlen(T_DECADE_STR))) |
62e76326 | 784 | return static_cast<int>(86400 * 365.2522 * 10); |
785 | ||
bf8fe701 | 786 | debugs(3, 1, "parseTimeUnits: unknown time unit '" << unit << "'"); |
62e76326 | 787 | |
270b86af | 788 | return 0; |
789 | } | |
790 | ||
47f6e231 | 791 | static void |
792 | parseBytesLine64(int64_t * bptr, const char *units) | |
793 | { | |
794 | char *token; | |
795 | double d; | |
796 | int64_t m; | |
797 | int64_t u; | |
798 | ||
9eeb8e4b | 799 | if ((u = parseBytesUnits(units)) == 0) { |
47f6e231 | 800 | self_destruct(); |
9eeb8e4b | 801 | return; |
802 | } | |
47f6e231 | 803 | |
9eeb8e4b | 804 | if ((token = strtok(NULL, w_space)) == NULL) { |
47f6e231 | 805 | self_destruct(); |
9eeb8e4b | 806 | return; |
807 | } | |
47f6e231 | 808 | |
809 | if (strcmp(token, "none") == 0 || strcmp(token, "-1") == 0) { | |
bc41416d | 810 | *bptr = -1; |
47f6e231 | 811 | return; |
812 | } | |
813 | ||
814 | d = xatof(token); | |
815 | ||
816 | m = u; /* default to 'units' if none specified */ | |
817 | ||
818 | if (0.0 == d) | |
819 | (void) 0; | |
820 | else if ((token = strtok(NULL, w_space)) == NULL) | |
26ac0430 AJ |
821 | debugs(3, 0, "WARNING: No units on '" << |
822 | config_input_line << "', assuming " << | |
823 | d << " " << units ); | |
9eeb8e4b | 824 | else if ((m = parseBytesUnits(token)) == 0) { |
47f6e231 | 825 | self_destruct(); |
9eeb8e4b | 826 | return; |
827 | } | |
47f6e231 | 828 | |
829 | *bptr = static_cast<int64_t>(m * d / u); | |
830 | ||
831 | if (static_cast<double>(*bptr) * 2 != m * d / u * 2) | |
832 | self_destruct(); | |
833 | } | |
834 | ||
835 | ||
9906e724 | 836 | static void |
9e975e4e | 837 | parseBytesLine(size_t * bptr, const char *units) |
9906e724 | 838 | { |
839 | char *token; | |
840 | double d; | |
47f6e231 | 841 | int m; |
842 | int u; | |
62e76326 | 843 | |
9eeb8e4b | 844 | if ((u = parseBytesUnits(units)) == 0) { |
62e76326 | 845 | self_destruct(); |
9eeb8e4b | 846 | return; |
847 | } | |
62e76326 | 848 | |
9eeb8e4b | 849 | if ((token = strtok(NULL, w_space)) == NULL) { |
62e76326 | 850 | self_destruct(); |
9eeb8e4b | 851 | return; |
852 | } | |
62e76326 | 853 | |
f8ecd7d7 | 854 | if (strcmp(token, "none") == 0 || strcmp(token, "-1") == 0) { |
b2d729e6 | 855 | *bptr = static_cast<size_t>(-1); |
ef1955a5 | 856 | return; |
857 | } | |
858 | ||
5c20d6fa | 859 | d = xatof(token); |
62e76326 | 860 | |
9906e724 | 861 | m = u; /* default to 'units' if none specified */ |
62e76326 | 862 | |
343f47a3 | 863 | if (0.0 == d) |
62e76326 | 864 | (void) 0; |
4860dc1b | 865 | else if ((token = strtok(NULL, w_space)) == NULL) |
26ac0430 AJ |
866 | debugs(3, 0, "WARNING: No units on '" << |
867 | config_input_line << "', assuming " << | |
868 | d << " " << units ); | |
9eeb8e4b | 869 | else if ((m = parseBytesUnits(token)) == 0) { |
62e76326 | 870 | self_destruct(); |
9eeb8e4b | 871 | return; |
872 | } | |
62e76326 | 873 | |
e6ccf245 | 874 | *bptr = static_cast<size_t>(m * d / u); |
347ae7c4 | 875 | |
a69d485c | 876 | if (static_cast<double>(*bptr) * 2 != m * d / u * 2) |
347ae7c4 | 877 | self_destruct(); |
9906e724 | 878 | } |
879 | ||
880 | static size_t | |
881 | parseBytesUnits(const char *unit) | |
882 | { | |
883 | if (!strncasecmp(unit, B_BYTES_STR, strlen(B_BYTES_STR))) | |
62e76326 | 884 | return 1; |
885 | ||
9906e724 | 886 | if (!strncasecmp(unit, B_KBYTES_STR, strlen(B_KBYTES_STR))) |
62e76326 | 887 | return 1 << 10; |
888 | ||
9906e724 | 889 | if (!strncasecmp(unit, B_MBYTES_STR, strlen(B_MBYTES_STR))) |
62e76326 | 890 | return 1 << 20; |
891 | ||
9906e724 | 892 | if (!strncasecmp(unit, B_GBYTES_STR, strlen(B_GBYTES_STR))) |
62e76326 | 893 | return 1 << 30; |
894 | ||
fa37412f | 895 | debugs(3, DBG_CRITICAL, "WARNING: Unknown bytes unit '" << unit << "'"); |
62e76326 | 896 | |
9906e724 | 897 | return 0; |
898 | } | |
899 | ||
270b86af | 900 | /***************************************************************************** |
901 | * Max | |
902 | *****************************************************************************/ | |
903 | ||
8203a132 | 904 | static void |
97427e90 | 905 | dump_acl(StoreEntry * entry, const char *name, ACL * ae) |
090089c4 | 906 | { |
56b63fa1 | 907 | wordlist *w; |
908 | wordlist *v; | |
62e76326 | 909 | |
9ef28b60 | 910 | while (ae != NULL) { |
bf8fe701 | 911 | debugs(3, 3, "dump_acl: " << name << " " << ae->name); |
62e76326 | 912 | storeAppendPrintf(entry, "%s %s %s ", |
913 | name, | |
914 | ae->name, | |
915 | ae->typeString()); | |
6bf4f823 | 916 | v = w = ae->dump(); |
62e76326 | 917 | |
918 | while (v != NULL) { | |
bf8fe701 | 919 | debugs(3, 3, "dump_acl: " << name << " " << ae->name << " " << v->key); |
62e76326 | 920 | storeAppendPrintf(entry, "%s ", v->key); |
921 | v = v->next; | |
922 | } | |
923 | ||
924 | storeAppendPrintf(entry, "\n"); | |
925 | wordlistDestroy(&w); | |
926 | ae = ae->next; | |
56b63fa1 | 927 | } |
090089c4 | 928 | } |
929 | ||
8203a132 | 930 | static void |
97427e90 | 931 | parse_acl(ACL ** ae) |
090089c4 | 932 | { |
a9f20260 | 933 | ACL::ParseAclLine(LegacyParser, ae); |
f1dc9b30 | 934 | } |
935 | ||
936 | static void | |
97427e90 | 937 | free_acl(ACL ** ae) |
f1dc9b30 | 938 | { |
9ef28b60 | 939 | aclDestroyAcls(ae); |
090089c4 | 940 | } |
941 | ||
8203a132 | 942 | static void |
76cd39d7 | 943 | dump_acl_list(StoreEntry * entry, ACLList * head) |
30a4f2a8 | 944 | { |
76cd39d7 | 945 | ACLList *l; |
62e76326 | 946 | |
d6827718 | 947 | for (l = head; l; l = l->next) { |
62e76326 | 948 | storeAppendPrintf(entry, " %s%s", |
949 | l->op ? null_string : "!", | |
950 | l->_acl->name); | |
d6827718 | 951 | } |
952 | } | |
953 | ||
b67e2c8c | 954 | void |
d6827718 | 955 | dump_acl_access(StoreEntry * entry, const char *name, acl_access * head) |
956 | { | |
957 | acl_access *l; | |
62e76326 | 958 | |
d6827718 | 959 | for (l = head; l; l = l->next) { |
62e76326 | 960 | storeAppendPrintf(entry, "%s %s", |
961 | name, | |
962 | l->allow ? "Allow" : "Deny"); | |
963 | dump_acl_list(entry, l->aclList); | |
964 | storeAppendPrintf(entry, "\n"); | |
56b63fa1 | 965 | } |
30a4f2a8 | 966 | } |
090089c4 | 967 | |
8203a132 | 968 | static void |
16300b58 | 969 | parse_acl_access(acl_access ** head) |
090089c4 | 970 | { |
a9f20260 | 971 | aclParseAccessLine(LegacyParser, head); |
090089c4 | 972 | } |
973 | ||
0153d498 | 974 | static void |
16300b58 | 975 | free_acl_access(acl_access ** head) |
0153d498 | 976 | { |
a47b9029 | 977 | aclDestroyAccessList(head); |
0153d498 | 978 | } |
979 | ||
8203a132 | 980 | static void |
ad61a2b4 | 981 | dump_address(StoreEntry * entry, const char *name, IpAddress &addr) |
270b86af | 982 | { |
cc192b50 | 983 | char buf[MAX_IPSTRLEN]; |
984 | storeAppendPrintf(entry, "%s %s\n", name, addr.NtoA(buf,MAX_IPSTRLEN) ); | |
270b86af | 985 | } |
986 | ||
987 | static void | |
ad61a2b4 | 988 | parse_address(IpAddress *addr) |
090089c4 | 989 | { |
270b86af | 990 | char *token = strtok(NULL, w_space); |
991 | ||
9eeb8e4b | 992 | if (!token) { |
62e76326 | 993 | self_destruct(); |
9eeb8e4b | 994 | return; |
995 | } | |
62e76326 | 996 | |
26ac0430 | 997 | if (!strcmp(token,"any_addr")) { |
cc192b50 | 998 | addr->SetAnyAddr(); |
26ac0430 AJ |
999 | (void) 0; |
1000 | } else if ( (!strcmp(token,"no_addr")) || (!strcmp(token,"full_mask")) ) { | |
cc192b50 | 1001 | addr->SetNoAddr(); |
26ac0430 AJ |
1002 | (void) 0; |
1003 | } else | |
cc192b50 | 1004 | *addr = token; |
090089c4 | 1005 | } |
1006 | ||
0153d498 | 1007 | static void |
ad61a2b4 | 1008 | free_address(IpAddress *addr) |
0153d498 | 1009 | { |
cc192b50 | 1010 | addr->SetEmpty(); |
0153d498 | 1011 | } |
1012 | ||
d6827718 | 1013 | CBDATA_TYPE(acl_address); |
1014 | ||
1015 | static void | |
1016 | dump_acl_address(StoreEntry * entry, const char *name, acl_address * head) | |
1017 | { | |
cc192b50 | 1018 | char buf[MAX_IPSTRLEN]; |
d6827718 | 1019 | acl_address *l; |
62e76326 | 1020 | |
d6827718 | 1021 | for (l = head; l; l = l->next) { |
cc192b50 | 1022 | if (!l->addr.IsAnyAddr()) |
1023 | storeAppendPrintf(entry, "%s %s", name, l->addr.NtoA(buf,MAX_IPSTRLEN)); | |
62e76326 | 1024 | else |
1025 | storeAppendPrintf(entry, "%s autoselect", name); | |
1026 | ||
1027 | dump_acl_list(entry, l->aclList); | |
1028 | ||
1029 | storeAppendPrintf(entry, "\n"); | |
d6827718 | 1030 | } |
1031 | } | |
1032 | ||
1033 | static void | |
1034 | freed_acl_address(void *data) | |
1035 | { | |
e6ccf245 | 1036 | acl_address *l = static_cast<acl_address *>(data); |
29b8d8d6 | 1037 | aclDestroyAclList(&l->aclList); |
d6827718 | 1038 | } |
1039 | ||
1040 | static void | |
1041 | parse_acl_address(acl_address ** head) | |
1042 | { | |
1043 | acl_address *l; | |
1044 | acl_address **tail = head; /* sane name below */ | |
1045 | CBDATA_INIT_TYPE_FREECB(acl_address, freed_acl_address); | |
1046 | l = cbdataAlloc(acl_address); | |
1047 | parse_address(&l->addr); | |
a9f20260 | 1048 | aclParseAclList(LegacyParser, &l->aclList); |
62e76326 | 1049 | |
d6827718 | 1050 | while (*tail) |
62e76326 | 1051 | tail = &(*tail)->next; |
1052 | ||
d6827718 | 1053 | *tail = l; |
1054 | } | |
1055 | ||
1056 | static void | |
1057 | free_acl_address(acl_address ** head) | |
1058 | { | |
1059 | while (*head) { | |
62e76326 | 1060 | acl_address *l = *head; |
1061 | *head = l->next; | |
1062 | cbdataFree(l); | |
d6827718 | 1063 | } |
1064 | } | |
1065 | ||
1066 | CBDATA_TYPE(acl_tos); | |
1067 | ||
1068 | static void | |
1069 | dump_acl_tos(StoreEntry * entry, const char *name, acl_tos * head) | |
1070 | { | |
1071 | acl_tos *l; | |
62e76326 | 1072 | |
d6827718 | 1073 | for (l = head; l; l = l->next) { |
62e76326 | 1074 | if (l->tos > 0) |
1075 | storeAppendPrintf(entry, "%s 0x%02X", name, l->tos); | |
1076 | else | |
1077 | storeAppendPrintf(entry, "%s none", name); | |
1078 | ||
1079 | dump_acl_list(entry, l->aclList); | |
1080 | ||
1081 | storeAppendPrintf(entry, "\n"); | |
d6827718 | 1082 | } |
1083 | } | |
1084 | ||
1085 | static void | |
1086 | freed_acl_tos(void *data) | |
1087 | { | |
e6ccf245 | 1088 | acl_tos *l = static_cast<acl_tos *>(data); |
29b8d8d6 | 1089 | aclDestroyAclList(&l->aclList); |
d6827718 | 1090 | } |
1091 | ||
1092 | static void | |
1093 | parse_acl_tos(acl_tos ** head) | |
1094 | { | |
1095 | acl_tos *l; | |
1096 | acl_tos **tail = head; /* sane name below */ | |
1097 | int tos; | |
1098 | char junk; | |
1099 | char *token = strtok(NULL, w_space); | |
62e76326 | 1100 | |
9eeb8e4b | 1101 | if (!token) { |
62e76326 | 1102 | self_destruct(); |
9eeb8e4b | 1103 | return; |
1104 | } | |
62e76326 | 1105 | |
9eeb8e4b | 1106 | if (sscanf(token, "0x%x%c", &tos, &junk) != 1) { |
62e76326 | 1107 | self_destruct(); |
9eeb8e4b | 1108 | return; |
1109 | } | |
62e76326 | 1110 | |
9eeb8e4b | 1111 | if (tos < 0 || tos > 255) { |
62e76326 | 1112 | self_destruct(); |
9eeb8e4b | 1113 | return; |
1114 | } | |
62e76326 | 1115 | |
d6827718 | 1116 | CBDATA_INIT_TYPE_FREECB(acl_tos, freed_acl_tos); |
62e76326 | 1117 | |
d6827718 | 1118 | l = cbdataAlloc(acl_tos); |
62e76326 | 1119 | |
d6827718 | 1120 | l->tos = tos; |
62e76326 | 1121 | |
a9f20260 | 1122 | aclParseAclList(LegacyParser, &l->aclList); |
62e76326 | 1123 | |
d6827718 | 1124 | while (*tail) |
62e76326 | 1125 | tail = &(*tail)->next; |
1126 | ||
d6827718 | 1127 | *tail = l; |
1128 | } | |
1129 | ||
1130 | static void | |
1131 | free_acl_tos(acl_tos ** head) | |
1132 | { | |
1133 | while (*head) { | |
62e76326 | 1134 | acl_tos *l = *head; |
1135 | *head = l->next; | |
1136 | l->next = NULL; | |
1137 | cbdataFree(l); | |
d6827718 | 1138 | } |
1139 | } | |
1140 | ||
ef1955a5 | 1141 | CBDATA_TYPE(acl_size_t); |
1142 | ||
1143 | static void | |
1144 | dump_acl_b_size_t(StoreEntry * entry, const char *name, acl_size_t * head) | |
1145 | { | |
1146 | acl_size_t *l; | |
1147 | ||
1148 | for (l = head; l; l = l->next) { | |
ed013b6c | 1149 | if (l->size != -1) |
ef1955a5 | 1150 | storeAppendPrintf(entry, "%s %d %s\n", name, (int) l->size, B_BYTES_STR); |
1151 | else | |
1152 | storeAppendPrintf(entry, "%s none", name); | |
1153 | ||
1154 | dump_acl_list(entry, l->aclList); | |
1155 | ||
1156 | storeAppendPrintf(entry, "\n"); | |
1157 | } | |
1158 | } | |
1159 | ||
1160 | static void | |
1161 | freed_acl_b_size_t(void *data) | |
1162 | { | |
1163 | acl_size_t *l = static_cast<acl_size_t *>(data); | |
1164 | aclDestroyAclList(&l->aclList); | |
1165 | } | |
1166 | ||
1167 | static void | |
1168 | parse_acl_b_size_t(acl_size_t ** head) | |
1169 | { | |
1170 | acl_size_t *l; | |
1171 | acl_size_t **tail = head; /* sane name below */ | |
1172 | ||
1173 | CBDATA_INIT_TYPE_FREECB(acl_size_t, freed_acl_b_size_t); | |
1174 | ||
1175 | l = cbdataAlloc(acl_size_t); | |
1176 | ||
47f6e231 | 1177 | parse_b_int64_t(&l->size); |
ef1955a5 | 1178 | |
a9f20260 | 1179 | aclParseAclList(LegacyParser, &l->aclList); |
ef1955a5 | 1180 | |
1181 | while (*tail) | |
1182 | tail = &(*tail)->next; | |
1183 | ||
1184 | *tail = l; | |
1185 | } | |
1186 | ||
1187 | static void | |
1188 | free_acl_b_size_t(acl_size_t ** head) | |
1189 | { | |
1190 | while (*head) { | |
1191 | acl_size_t *l = *head; | |
1192 | *head = l->next; | |
1193 | l->next = NULL; | |
1194 | cbdataFree(l); | |
1195 | } | |
1196 | } | |
1197 | ||
59715b38 | 1198 | #if DELAY_POOLS |
1199 | ||
b67e2c8c | 1200 | #include "DelayPools.h" |
1201 | #include "DelayConfig.h" | |
59715b38 | 1202 | /* do nothing - free_delay_pool_count is the magic free function. |
1203 | * this is why delay_pool_count isn't just marked TYPE: ushort | |
1204 | */ | |
1205 | #define free_delay_pool_class(X) | |
1206 | #define free_delay_pool_access(X) | |
1207 | #define free_delay_pool_rates(X) | |
1208 | #define dump_delay_pool_class(X, Y, Z) | |
1209 | #define dump_delay_pool_access(X, Y, Z) | |
1210 | #define dump_delay_pool_rates(X, Y, Z) | |
1211 | ||
1212 | static void | |
b67e2c8c | 1213 | free_delay_pool_count(DelayConfig * cfg) |
59715b38 | 1214 | { |
b67e2c8c | 1215 | cfg->freePoolCount(); |
59715b38 | 1216 | } |
1217 | ||
1218 | static void | |
b67e2c8c | 1219 | dump_delay_pool_count(StoreEntry * entry, const char *name, DelayConfig &cfg) |
59715b38 | 1220 | { |
b67e2c8c | 1221 | cfg.dumpPoolCount (entry, name); |
59715b38 | 1222 | } |
1223 | ||
1224 | static void | |
b67e2c8c | 1225 | parse_delay_pool_count(DelayConfig * cfg) |
59715b38 | 1226 | { |
b67e2c8c | 1227 | cfg->parsePoolCount(); |
59715b38 | 1228 | } |
1229 | ||
1230 | static void | |
b67e2c8c | 1231 | parse_delay_pool_class(DelayConfig * cfg) |
59715b38 | 1232 | { |
b67e2c8c | 1233 | cfg->parsePoolClass(); |
59715b38 | 1234 | } |
1235 | ||
1236 | static void | |
b67e2c8c | 1237 | parse_delay_pool_rates(DelayConfig * cfg) |
59715b38 | 1238 | { |
b67e2c8c | 1239 | cfg->parsePoolRates(); |
59715b38 | 1240 | } |
1241 | ||
1242 | static void | |
b67e2c8c | 1243 | parse_delay_pool_access(DelayConfig * cfg) |
59715b38 | 1244 | { |
a9f20260 | 1245 | cfg->parsePoolAccess(LegacyParser); |
59715b38 | 1246 | } |
62e76326 | 1247 | |
59715b38 | 1248 | #endif |
1249 | ||
c26ffae9 | 1250 | #if HTTP_VIOLATIONS |
97474590 | 1251 | static void |
6bccf575 | 1252 | dump_http_header_access(StoreEntry * entry, const char *name, header_mangler header[]) |
e3dd531e | 1253 | { |
efd900cb | 1254 | int i; |
62e76326 | 1255 | |
6bccf575 | 1256 | for (i = 0; i < HDR_ENUM_END; i++) { |
62e76326 | 1257 | if (header[i].access_list != NULL) { |
1258 | storeAppendPrintf(entry, "%s ", name); | |
1259 | dump_acl_access(entry, httpHeaderNameById(i), | |
1260 | header[i].access_list); | |
1261 | } | |
efd900cb | 1262 | } |
97474590 | 1263 | } |
e3dd531e | 1264 | |
97474590 | 1265 | static void |
6bccf575 | 1266 | parse_http_header_access(header_mangler header[]) |
97474590 | 1267 | { |
6bccf575 | 1268 | int id, i; |
97474590 | 1269 | char *t = NULL; |
62e76326 | 1270 | |
97474590 | 1271 | if ((t = strtok(NULL, w_space)) == NULL) { |
bf8fe701 | 1272 | debugs(3, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
1273 | debugs(3, 0, "parse_http_header_access: missing header name."); | |
62e76326 | 1274 | return; |
97474590 | 1275 | } |
62e76326 | 1276 | |
6bccf575 | 1277 | /* Now lookup index of header. */ |
1278 | id = httpHeaderIdByNameDef(t, strlen(t)); | |
62e76326 | 1279 | |
6bccf575 | 1280 | if (strcmp(t, "All") == 0) |
62e76326 | 1281 | id = HDR_ENUM_END; |
6bccf575 | 1282 | else if (strcmp(t, "Other") == 0) |
62e76326 | 1283 | id = HDR_OTHER; |
6bccf575 | 1284 | else if (id == -1) { |
bf8fe701 | 1285 | debugs(3, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
1286 | debugs(3, 0, "parse_http_header_access: unknown header name '" << t << "'"); | |
62e76326 | 1287 | return; |
97474590 | 1288 | } |
62e76326 | 1289 | |
6bccf575 | 1290 | if (id != HDR_ENUM_END) { |
62e76326 | 1291 | parse_acl_access(&header[id].access_list); |
6bccf575 | 1292 | } else { |
62e76326 | 1293 | char *next_string = t + strlen(t) - 1; |
1294 | *next_string = 'A'; | |
1295 | *(next_string + 1) = ' '; | |
1296 | ||
1297 | for (i = 0; i < HDR_ENUM_END; i++) { | |
1298 | char *new_string = xstrdup(next_string); | |
1299 | strtok(new_string, w_space); | |
1300 | parse_acl_access(&header[i].access_list); | |
1301 | safe_free(new_string); | |
1302 | } | |
97474590 | 1303 | } |
6bccf575 | 1304 | } |
1305 | ||
1306 | static void | |
1307 | free_http_header_access(header_mangler header[]) | |
1308 | { | |
1309 | int i; | |
62e76326 | 1310 | |
6bccf575 | 1311 | for (i = 0; i < HDR_ENUM_END; i++) { |
62e76326 | 1312 | free_acl_access(&header[i].access_list); |
6bccf575 | 1313 | } |
1314 | } | |
1315 | ||
1316 | static void | |
1317 | dump_http_header_replace(StoreEntry * entry, const char *name, header_mangler | |
62e76326 | 1318 | header[]) |
6bccf575 | 1319 | { |
1320 | int i; | |
62e76326 | 1321 | |
6bccf575 | 1322 | for (i = 0; i < HDR_ENUM_END; i++) { |
62e76326 | 1323 | if (NULL == header[i].replacement) |
1324 | continue; | |
1325 | ||
1326 | storeAppendPrintf(entry, "%s %s %s\n", name, httpHeaderNameById(i), | |
1327 | header[i].replacement); | |
97474590 | 1328 | } |
1329 | } | |
e3dd531e | 1330 | |
97474590 | 1331 | static void |
6bccf575 | 1332 | parse_http_header_replace(header_mangler header[]) |
e3dd531e | 1333 | { |
6bccf575 | 1334 | int id, i; |
1335 | char *t = NULL; | |
62e76326 | 1336 | |
6bccf575 | 1337 | if ((t = strtok(NULL, w_space)) == NULL) { |
bf8fe701 | 1338 | debugs(3, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
1339 | debugs(3, 0, "parse_http_header_replace: missing header name."); | |
62e76326 | 1340 | return; |
6bccf575 | 1341 | } |
62e76326 | 1342 | |
6bccf575 | 1343 | /* Now lookup index of header. */ |
1344 | id = httpHeaderIdByNameDef(t, strlen(t)); | |
62e76326 | 1345 | |
6bccf575 | 1346 | if (strcmp(t, "All") == 0) |
62e76326 | 1347 | id = HDR_ENUM_END; |
6bccf575 | 1348 | else if (strcmp(t, "Other") == 0) |
62e76326 | 1349 | id = HDR_OTHER; |
6bccf575 | 1350 | else if (id == -1) { |
bf8fe701 | 1351 | debugs(3, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
1352 | debugs(3, 0, "parse_http_header_replace: unknown header name " << t << "."); | |
1353 | ||
62e76326 | 1354 | return; |
6bccf575 | 1355 | } |
62e76326 | 1356 | |
6bccf575 | 1357 | if (id != HDR_ENUM_END) { |
62e76326 | 1358 | if (header[id].replacement != NULL) |
1359 | safe_free(header[id].replacement); | |
1360 | ||
1361 | header[id].replacement = xstrdup(t + strlen(t) + 1); | |
6bccf575 | 1362 | } else { |
62e76326 | 1363 | for (i = 0; i < HDR_ENUM_END; i++) { |
1364 | if (header[i].replacement != NULL) | |
1365 | safe_free(header[i].replacement); | |
1366 | ||
1367 | header[i].replacement = xstrdup(t + strlen(t) + 1); | |
1368 | } | |
6bccf575 | 1369 | } |
1370 | } | |
1371 | ||
1372 | static void | |
1373 | free_http_header_replace(header_mangler header[]) | |
1374 | { | |
1375 | int i; | |
62e76326 | 1376 | |
6bccf575 | 1377 | for (i = 0; i < HDR_ENUM_END; i++) { |
62e76326 | 1378 | if (header[i].replacement != NULL) |
1379 | safe_free(header[i].replacement); | |
6bccf575 | 1380 | } |
97474590 | 1381 | } |
62e76326 | 1382 | |
9e8b2f1c | 1383 | #endif |
97474590 | 1384 | |
e90100aa | 1385 | static void |
e1f7507e | 1386 | dump_cachedir(StoreEntry * entry, const char *name, SquidConfig::_cacheSwap swap) |
e90100aa | 1387 | { |
f53b06f9 | 1388 | SwapDir *s; |
1389 | int i; | |
d3b3ab85 | 1390 | assert (entry); |
62e76326 | 1391 | |
a7d59104 | 1392 | for (i = 0; i < swap.n_configured; i++) { |
c8f4eac4 | 1393 | s = dynamic_cast<SwapDir *>(swap.swapDirs[i].getRaw()); |
26ac0430 | 1394 | if (!s) continue; |
59b2d47f | 1395 | storeAppendPrintf(entry, "%s %s %s", name, s->type(), s->path); |
62e76326 | 1396 | s->dump(*entry); |
62e76326 | 1397 | storeAppendPrintf(entry, "\n"); |
f53b06f9 | 1398 | } |
1399 | } | |
1400 | ||
53ad48e6 | 1401 | static int |
1402 | check_null_string(char *s) | |
1403 | { | |
1404 | return s == NULL; | |
1405 | } | |
1406 | ||
94439e4e | 1407 | static void |
1408 | parse_authparam(authConfig * config) | |
1409 | { | |
1410 | char *type_str; | |
1411 | char *param_str; | |
94439e4e | 1412 | |
1413 | if ((type_str = strtok(NULL, w_space)) == NULL) | |
62e76326 | 1414 | self_destruct(); |
94439e4e | 1415 | |
1416 | if ((param_str = strtok(NULL, w_space)) == NULL) | |
62e76326 | 1417 | self_destruct(); |
94439e4e | 1418 | |
f5691f9c | 1419 | /* find a configuration for the scheme */ |
1420 | AuthConfig *scheme = AuthConfig::Find (type_str); | |
62e76326 | 1421 | |
f5691f9c | 1422 | if (scheme == NULL) { |
1423 | /* Create a configuration */ | |
1424 | AuthScheme *theScheme; | |
1425 | ||
1426 | if ((theScheme = AuthScheme::Find(type_str)) == NULL) { | |
bf8fe701 | 1427 | debugs(3, 0, "Parsing Config File: Unknown authentication scheme '" << type_str << "'."); |
f5691f9c | 1428 | return; |
62e76326 | 1429 | } |
94439e4e | 1430 | |
f5691f9c | 1431 | config->push_back(theScheme->createConfig()); |
1432 | scheme = config->back(); | |
1433 | assert (scheme); | |
94439e4e | 1434 | } |
62e76326 | 1435 | |
f5691f9c | 1436 | scheme->parse(scheme, config->size(), param_str); |
94439e4e | 1437 | } |
1438 | ||
1439 | static void | |
1440 | free_authparam(authConfig * cfg) | |
1441 | { | |
f5691f9c | 1442 | AuthConfig *scheme; |
94439e4e | 1443 | /* DON'T FREE THESE FOR RECONFIGURE */ |
62e76326 | 1444 | |
94439e4e | 1445 | if (reconfiguring) |
62e76326 | 1446 | return; |
1447 | ||
f5691f9c | 1448 | while (cfg->size()) { |
1449 | scheme = cfg->pop_back(); | |
1450 | scheme->done(); | |
94439e4e | 1451 | } |
94439e4e | 1452 | } |
1453 | ||
1454 | static void | |
1455 | dump_authparam(StoreEntry * entry, const char *name, authConfig cfg) | |
1456 | { | |
f5691f9c | 1457 | for (authConfig::iterator i = cfg.begin(); i != cfg.end(); ++i) |
1458 | (*i)->dump(entry, name, (*i)); | |
94439e4e | 1459 | } |
1460 | ||
59b2d47f | 1461 | /* TODO: just return the object, the # is irrelevant */ |
cd748f27 | 1462 | static int |
1463 | find_fstype(char *type) | |
1464 | { | |
59b2d47f | 1465 | for (size_t i = 0; i < StoreFileSystem::FileSystems().size(); ++i) |
1466 | if (strcasecmp(type, StoreFileSystem::FileSystems().items[i]->type()) == 0) | |
1467 | return (int)i; | |
62e76326 | 1468 | |
cd748f27 | 1469 | return (-1); |
1470 | } | |
1471 | ||
0e4e0e7d | 1472 | static void |
e1f7507e | 1473 | parse_cachedir(SquidConfig::_cacheSwap * swap) |
0e4e0e7d | 1474 | { |
1475 | char *type_str; | |
cd748f27 | 1476 | char *path_str; |
c8f4eac4 | 1477 | RefCount<SwapDir> sd; |
cd748f27 | 1478 | int i; |
1479 | int fs; | |
cd748f27 | 1480 | |
0e4e0e7d | 1481 | if ((type_str = strtok(NULL, w_space)) == NULL) |
62e76326 | 1482 | self_destruct(); |
cd748f27 | 1483 | |
cd748f27 | 1484 | if ((path_str = strtok(NULL, w_space)) == NULL) |
62e76326 | 1485 | self_destruct(); |
cd748f27 | 1486 | |
c9e2e0e8 | 1487 | fs = find_fstype(type_str); |
1488 | ||
1489 | if (fs < 0) | |
1490 | self_destruct(); | |
1491 | ||
1492 | /* reconfigure existing dir */ | |
cd748f27 | 1493 | |
1494 | for (i = 0; i < swap->n_configured; i++) { | |
c8f4eac4 | 1495 | assert (swap->swapDirs[i].getRaw()); |
62e76326 | 1496 | |
2c9e9cba | 1497 | if ((strcasecmp(path_str, dynamic_cast<SwapDir *>(swap->swapDirs[i].getRaw())->path)) == 0) { |
c9e2e0e8 | 1498 | /* this is specific to on-fs Stores. The right |
26ac0430 | 1499 | * way to handle this is probably to have a mapping |
c9e2e0e8 | 1500 | * from paths to stores, and have on-fs stores |
1501 | * register with that, and lookip in that in their | |
1502 | * own setup logic. RBC 20041225. TODO. | |
1503 | */ | |
c8f4eac4 | 1504 | |
1505 | sd = dynamic_cast<SwapDir *>(swap->swapDirs[i].getRaw()); | |
1506 | ||
c9e2e0e8 | 1507 | if (sd->type() != StoreFileSystem::FileSystems().items[fs]->type()) { |
bf8fe701 | 1508 | debugs(3, 0, "ERROR: Can't change type of existing cache_dir " << |
1509 | sd->type() << " " << sd->path << " to " << type_str << ". Restart required"); | |
c9e2e0e8 | 1510 | return; |
1511 | } | |
1512 | ||
62e76326 | 1513 | sd->reconfigure (i, path_str); |
c8f4eac4 | 1514 | |
62e76326 | 1515 | update_maxobjsize(); |
c8f4eac4 | 1516 | |
62e76326 | 1517 | return; |
1518 | } | |
cd748f27 | 1519 | } |
1520 | ||
c9e2e0e8 | 1521 | /* new cache_dir */ |
af6a12ee | 1522 | if (swap->n_configured > 63) { |
2c9e9cba AJ |
1523 | /* 7 bits, signed */ |
1524 | debugs(3, DBG_CRITICAL, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle."); | |
1525 | debugs(3, DBG_CRITICAL, "WARNING: '" << path_str << "' is one to many."); | |
1526 | self_destruct(); | |
1527 | return; | |
1528 | } | |
dc986280 | 1529 | |
cd748f27 | 1530 | allocate_new_swapdir(swap); |
c9e2e0e8 | 1531 | |
59b2d47f | 1532 | swap->swapDirs[swap->n_configured] = StoreFileSystem::FileSystems().items[fs]->createSwapDir(); |
c9e2e0e8 | 1533 | |
c8f4eac4 | 1534 | sd = dynamic_cast<SwapDir *>(swap->swapDirs[swap->n_configured].getRaw()); |
c9e2e0e8 | 1535 | |
8e8d4f30 | 1536 | /* parse the FS parameters and options */ |
d3b3ab85 | 1537 | sd->parse(swap->n_configured, path_str); |
c9e2e0e8 | 1538 | |
d3b3ab85 | 1539 | ++swap->n_configured; |
c9e2e0e8 | 1540 | |
cd748f27 | 1541 | /* Update the max object size */ |
1542 | update_maxobjsize(); | |
752c3b27 | 1543 | } |
1544 | ||
2d72d4fd | 1545 | static const char * |
505e35db | 1546 | peer_type_str(const peer_t type) |
1547 | { | |
1f140227 | 1548 | const char * result; |
1549 | ||
0cdcddb9 | 1550 | switch (type) { |
62e76326 | 1551 | |
505e35db | 1552 | case PEER_PARENT: |
1f140227 | 1553 | result = "parent"; |
62e76326 | 1554 | break; |
1555 | ||
505e35db | 1556 | case PEER_SIBLING: |
1f140227 | 1557 | result = "sibling"; |
62e76326 | 1558 | break; |
1559 | ||
505e35db | 1560 | case PEER_MULTICAST: |
1f140227 | 1561 | result = "multicast"; |
62e76326 | 1562 | break; |
1563 | ||
505e35db | 1564 | default: |
1f140227 | 1565 | result = "unknown"; |
62e76326 | 1566 | break; |
505e35db | 1567 | } |
1f140227 | 1568 | |
1569 | return result; | |
505e35db | 1570 | } |
1571 | ||
f1dc9b30 | 1572 | static void |
a7d59104 | 1573 | dump_peer(StoreEntry * entry, const char *name, peer * p) |
98ffb7e4 | 1574 | { |
505e35db | 1575 | domain_ping *d; |
505e35db | 1576 | domain_type *t; |
1577 | LOCAL_ARRAY(char, xname, 128); | |
62e76326 | 1578 | |
d41de3c1 | 1579 | while (p != NULL) { |
62e76326 | 1580 | storeAppendPrintf(entry, "%s %s %s %d %d", |
1581 | name, | |
1582 | p->host, | |
1583 | neighborTypeStr(p), | |
1584 | p->http_port, | |
1585 | p->icp.port); | |
1586 | dump_peer_options(entry, p); | |
1587 | ||
1588 | for (d = p->peer_domain; d; d = d->next) { | |
1589 | storeAppendPrintf(entry, "cache_peer_domain %s %s%s\n", | |
1590 | p->host, | |
1591 | d->do_ping ? null_string : "!", | |
1592 | d->domain); | |
1593 | } | |
1594 | ||
1595 | if (p->access) { | |
1596 | snprintf(xname, 128, "cache_peer_access %s", p->name); | |
1597 | dump_acl_access(entry, xname, p->access); | |
1598 | } | |
1599 | ||
1600 | for (t = p->typelist; t; t = t->next) { | |
1601 | storeAppendPrintf(entry, "neighbor_type_domain %s %s %s\n", | |
1602 | p->host, | |
1603 | peer_type_str(t->type), | |
1604 | t->domain); | |
1605 | } | |
1606 | ||
1607 | p = p->next; | |
d41de3c1 | 1608 | } |
98ffb7e4 | 1609 | } |
1610 | ||
609fac72 | 1611 | /** |
1612 | \param proto 'tcp' or 'udp' for protocol | |
1613 | \returns Port the named service is supposed to be listening on. | |
1614 | */ | |
1615 | static u_short | |
1616 | GetService(const char *proto) | |
1617 | { | |
1618 | struct servent *port = NULL; | |
1619 | /** Parses a port number or service name from the squid.conf */ | |
1620 | char *token = strtok(NULL, w_space); | |
1621 | if (token == NULL) { | |
26ac0430 AJ |
1622 | self_destruct(); |
1623 | return 0; /* NEVER REACHED */ | |
609fac72 | 1624 | } |
1625 | /** Returns either the service port number from /etc/services */ | |
1626 | port = getservbyname(token, proto); | |
1627 | if (port != NULL) { | |
1628 | return ntohs((u_short)port->s_port); | |
1629 | } | |
1630 | /** Or a numeric translation of the config text. */ | |
1631 | return xatos(token); | |
1632 | } | |
1633 | ||
1634 | /** | |
1635 | \returns Port the named TCP service is supposed to be listening on. | |
1636 | \copydoc GetService(const char *proto) | |
1637 | */ | |
1638 | inline u_short | |
1639 | GetTcpService(void) | |
1640 | { | |
1641 | return GetService("tcp"); | |
1642 | } | |
1643 | ||
1644 | /** | |
1645 | \returns Port the named UDP service is supposed to be listening on. | |
1646 | \copydoc GetService(const char *proto) | |
1647 | */ | |
1648 | inline u_short | |
1649 | GetUdpService(void) | |
1650 | { | |
1651 | return GetService("udp"); | |
1652 | } | |
1653 | ||
8203a132 | 1654 | static void |
40a1495e | 1655 | parse_peer(peer ** head) |
7813c6d5 | 1656 | { |
270b86af | 1657 | char *token = NULL; |
40a1495e | 1658 | peer *p; |
f5691f9c | 1659 | CBDATA_INIT_TYPE_FREECB(peer, peerDestroy); |
72711e31 | 1660 | p = cbdataAlloc(peer); |
40a1495e | 1661 | p->http_port = CACHE_HTTP_PORT; |
399cabec | 1662 | p->icp.port = CACHE_ICP_PORT; |
40a1495e | 1663 | p->weight = 1; |
d1b63fc8 | 1664 | p->basetime = 0; |
dc835977 | 1665 | p->stats.logged_state = PEER_ALIVE; |
62e76326 | 1666 | |
e481c2dc | 1667 | if ((token = strtok(NULL, w_space)) == NULL) |
62e76326 | 1668 | self_destruct(); |
1669 | ||
40a1495e | 1670 | p->host = xstrdup(token); |
26ac0430 | 1671 | |
be753325 | 1672 | p->name = xstrdup(token); |
62e76326 | 1673 | |
e481c2dc | 1674 | if ((token = strtok(NULL, w_space)) == NULL) |
62e76326 | 1675 | self_destruct(); |
1676 | ||
40a1495e | 1677 | p->type = parseNeighborType(token); |
62e76326 | 1678 | |
0d5a2006 | 1679 | if (p->type == PEER_MULTICAST) { |
1680 | p->options.no_digest = 1; | |
1681 | p->options.no_netdb_exchange = 1; | |
1682 | } | |
1683 | ||
609fac72 | 1684 | p->http_port = GetTcpService(); |
62e76326 | 1685 | |
0e656b69 | 1686 | if (!p->http_port) |
1687 | self_destruct(); | |
62e76326 | 1688 | |
609fac72 | 1689 | p->icp.port = GetUdpService(); |
d67acb4e | 1690 | p->connection_auth = 2; /* auto */ |
62e76326 | 1691 | |
270b86af | 1692 | while ((token = strtok(NULL, w_space))) { |
62e76326 | 1693 | if (!strcasecmp(token, "proxy-only")) { |
1694 | p->options.proxy_only = 1; | |
1695 | } else if (!strcasecmp(token, "no-query")) { | |
1696 | p->options.no_query = 1; | |
1697 | } else if (!strcasecmp(token, "background-ping")) { | |
1698 | p->options.background_ping = 1; | |
1699 | } else if (!strcasecmp(token, "no-digest")) { | |
1700 | p->options.no_digest = 1; | |
1701 | } else if (!strcasecmp(token, "multicast-responder")) { | |
1702 | p->options.mcast_responder = 1; | |
1703 | } else if (!strncasecmp(token, "weight=", 7)) { | |
1704 | p->weight = xatoi(token + 7); | |
1705 | } else if (!strncasecmp(token, "basetime=", 9)) { | |
1706 | p->basetime = xatoi(token + 9); | |
1707 | } else if (!strcasecmp(token, "closest-only")) { | |
1708 | p->options.closest_only = 1; | |
1709 | } else if (!strncasecmp(token, "ttl=", 4)) { | |
1710 | p->mcast.ttl = xatoi(token + 4); | |
1711 | ||
1712 | if (p->mcast.ttl < 0) | |
1713 | p->mcast.ttl = 0; | |
1714 | ||
1715 | if (p->mcast.ttl > 128) | |
1716 | p->mcast.ttl = 128; | |
1717 | } else if (!strcasecmp(token, "default")) { | |
1718 | p->options.default_parent = 1; | |
1719 | } else if (!strcasecmp(token, "round-robin")) { | |
1720 | p->options.roundrobin = 1; | |
1721 | } else if (!strcasecmp(token, "weighted-round-robin")) { | |
1722 | p->options.weighted_roundrobin = 1; | |
dc9d133b | 1723 | #if USE_HTCP |
62e76326 | 1724 | |
1725 | } else if (!strcasecmp(token, "htcp")) { | |
1726 | p->options.htcp = 1; | |
527ee50d | 1727 | } else if (!strcasecmp(token, "htcp-oldsquid")) { |
1728 | p->options.htcp = 1; | |
1729 | p->options.htcp_oldsquid = 1; | |
4f4fa815 BR |
1730 | } else if (!strcasecmp(token, "htcp-no-clr")) { |
1731 | if (p->options.htcp_only_clr) | |
26ac0430 | 1732 | fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously"); |
4f4fa815 BR |
1733 | p->options.htcp = 1; |
1734 | p->options.htcp_no_clr = 1; | |
1735 | } else if (!strcasecmp(token, "htcp-no-purge-clr")) { | |
1736 | p->options.htcp = 1; | |
1737 | p->options.htcp_no_purge_clr = 1; | |
1738 | } else if (!strcasecmp(token, "htcp-only-clr")) { | |
1739 | if (p->options.htcp_no_clr) | |
26ac0430 | 1740 | fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously"); |
4f4fa815 BR |
1741 | p->options.htcp = 1; |
1742 | p->options.htcp_only_clr = 1; | |
1743 | } else if (!strcasecmp(token, "htcp-forward-clr")) { | |
1744 | p->options.htcp = 1; | |
1745 | p->options.htcp_forward_clr = 1; | |
dc9d133b | 1746 | #endif |
62e76326 | 1747 | |
1748 | } else if (!strcasecmp(token, "no-netdb-exchange")) { | |
1749 | p->options.no_netdb_exchange = 1; | |
62e76326 | 1750 | |
1751 | } else if (!strcasecmp(token, "carp")) { | |
1752 | if (p->type != PEER_PARENT) | |
1753 | fatalf("parse_peer: non-parent carp peer %s/%d\n", p->host, p->http_port); | |
1754 | ||
1755 | p->options.carp = 1; | |
1756 | ||
f7e1d9ce HN |
1757 | } else if (!strcasecmp(token, "userhash")) { |
1758 | if (p->type != PEER_PARENT) | |
1759 | fatalf("parse_peer: non-parent userhash peer %s/%d\n", p->host, p->http_port); | |
1760 | ||
1761 | p->options.userhash = 1; | |
1762 | ||
1763 | } else if (!strcasecmp(token, "sourcehash")) { | |
1764 | if (p->type != PEER_PARENT) | |
1765 | fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p->host, p->http_port); | |
1766 | ||
1767 | p->options.sourcehash = 1; | |
1768 | ||
95e36d02 | 1769 | #if DELAY_POOLS |
62e76326 | 1770 | |
1771 | } else if (!strcasecmp(token, "no-delay")) { | |
1772 | p->options.no_delay = 1; | |
afd88fbe | 1773 | #endif |
62e76326 | 1774 | |
1775 | } else if (!strncasecmp(token, "login=", 6)) { | |
1776 | p->login = xstrdup(token + 6); | |
1777 | rfc1738_unescape(p->login); | |
1778 | } else if (!strncasecmp(token, "connect-timeout=", 16)) { | |
1779 | p->connect_timeout = xatoi(token + 16); | |
7e3ce7b9 | 1780 | #if USE_CACHE_DIGESTS |
62e76326 | 1781 | |
1782 | } else if (!strncasecmp(token, "digest-url=", 11)) { | |
1783 | p->digest_url = xstrdup(token + 11); | |
7e3ce7b9 | 1784 | #endif |
62e76326 | 1785 | |
1786 | } else if (!strcasecmp(token, "allow-miss")) { | |
1787 | p->options.allow_miss = 1; | |
1788 | } else if (!strncasecmp(token, "max-conn=", 9)) { | |
1789 | p->max_conn = xatoi(token + 9); | |
1790 | } else if (!strcasecmp(token, "originserver")) { | |
1791 | p->options.originserver = 1; | |
1792 | } else if (!strncasecmp(token, "name=", 5)) { | |
1793 | safe_free(p->name); | |
1794 | ||
1795 | if (token[5]) | |
1796 | p->name = xstrdup(token + 5); | |
1797 | } else if (!strncasecmp(token, "forceddomain=", 13)) { | |
1798 | safe_free(p->domain); | |
1799 | ||
1800 | if (token[13]) | |
1801 | p->domain = xstrdup(token + 13); | |
1802 | ||
a7ad6e4e | 1803 | #if USE_SSL |
62e76326 | 1804 | |
1805 | } else if (strcmp(token, "ssl") == 0) { | |
1806 | p->use_ssl = 1; | |
1807 | } else if (strncmp(token, "sslcert=", 8) == 0) { | |
1808 | safe_free(p->sslcert); | |
1809 | p->sslcert = xstrdup(token + 8); | |
1810 | } else if (strncmp(token, "sslkey=", 7) == 0) { | |
1811 | safe_free(p->sslkey); | |
1812 | p->sslkey = xstrdup(token + 7); | |
1813 | } else if (strncmp(token, "sslversion=", 11) == 0) { | |
1814 | p->sslversion = atoi(token + 11); | |
1815 | } else if (strncmp(token, "ssloptions=", 11) == 0) { | |
1816 | safe_free(p->ssloptions); | |
1817 | p->ssloptions = xstrdup(token + 11); | |
1818 | } else if (strncmp(token, "sslcipher=", 10) == 0) { | |
1819 | safe_free(p->sslcipher); | |
1820 | p->sslcipher = xstrdup(token + 10); | |
1821 | } else if (strncmp(token, "sslcafile=", 10) == 0) { | |
1822 | safe_free(p->sslcafile); | |
a82a4fe4 | 1823 | p->sslcafile = xstrdup(token + 10); |
62e76326 | 1824 | } else if (strncmp(token, "sslcapath=", 10) == 0) { |
1825 | safe_free(p->sslcapath); | |
a82a4fe4 | 1826 | p->sslcapath = xstrdup(token + 10); |
1827 | } else if (strncmp(token, "sslcrlfile=", 11) == 0) { | |
1828 | safe_free(p->sslcrlfile); | |
1829 | p->sslcapath = xstrdup(token + 10); | |
62e76326 | 1830 | } else if (strncmp(token, "sslflags=", 9) == 0) { |
1831 | safe_free(p->sslflags); | |
1832 | p->sslflags = xstrdup(token + 9); | |
1833 | } else if (strncmp(token, "ssldomain=", 10) == 0) { | |
1834 | safe_free(p->ssldomain); | |
1835 | p->ssldomain = xstrdup(token + 10); | |
a7ad6e4e | 1836 | #endif |
62e76326 | 1837 | |
1838 | } else if (strcmp(token, "front-end-https") == 0) { | |
1839 | p->front_end_https = 1; | |
1840 | } else if (strcmp(token, "front-end-https=on") == 0) { | |
1841 | p->front_end_https = 1; | |
1842 | } else if (strcmp(token, "front-end-https=auto") == 0) { | |
1843 | p->front_end_https = 2; | |
26ac0430 | 1844 | } else if (strcmp(token, "connection-auth=off") == 0) { |
d67acb4e AJ |
1845 | p->connection_auth = 0; |
1846 | } else if (strcmp(token, "connection-auth") == 0) { | |
1847 | p->connection_auth = 1; | |
1848 | } else if (strcmp(token, "connection-auth=on") == 0) { | |
1849 | p->connection_auth = 1; | |
1850 | } else if (strcmp(token, "connection-auth=auto") == 0) { | |
1851 | p->connection_auth = 2; | |
62e76326 | 1852 | } else { |
bf8fe701 | 1853 | debugs(3, 0, "parse_peer: token='" << token << "'"); |
62e76326 | 1854 | self_destruct(); |
1855 | } | |
270b86af | 1856 | } |
62e76326 | 1857 | |
be753325 | 1858 | if (peerFindByName(p->name)) |
62e76326 | 1859 | fatalf("ERROR: cache_peer %s specified twice\n", p->name); |
1860 | ||
40a1495e | 1861 | if (p->weight < 1) |
62e76326 | 1862 | p->weight = 1; |
1863 | ||
399cabec | 1864 | p->icp.version = ICP_VERSION_CURRENT; |
62e76326 | 1865 | |
eb406bb7 | 1866 | p->test_fd = -1; |
62e76326 | 1867 | |
e13ee7ad | 1868 | #if USE_CACHE_DIGESTS |
62e76326 | 1869 | |
e13ee7ad | 1870 | if (!p->options.no_digest) { |
62e76326 | 1871 | /* XXX This looks odd.. who has the original pointer |
1872 | * then? | |
1873 | */ | |
1874 | PeerDigest *pd = peerDigestCreate(p); | |
1875 | p->digest = cbdataReference(pd); | |
8a6218c6 | 1876 | } |
62e76326 | 1877 | |
e13ee7ad | 1878 | #endif |
cc192b50 | 1879 | |
1880 | p->index = ++Config.npeers; | |
1881 | ||
0153d498 | 1882 | while (*head != NULL) |
62e76326 | 1883 | head = &(*head)->next; |
1884 | ||
0153d498 | 1885 | *head = p; |
62e76326 | 1886 | |
32a47e3e | 1887 | peerClearRRStart(); |
0153d498 | 1888 | } |
1889 | ||
1890 | static void | |
40a1495e | 1891 | free_peer(peer ** P) |
0153d498 | 1892 | { |
40a1495e | 1893 | peer *p; |
62e76326 | 1894 | |
79d39a72 | 1895 | while ((p = *P) != NULL) { |
62e76326 | 1896 | *P = p->next; |
3855c318 | 1897 | #if USE_CACHE_DIGESTS |
62e76326 | 1898 | |
1899 | cbdataReferenceDone(p->digest); | |
3855c318 | 1900 | #endif |
62e76326 | 1901 | |
1902 | cbdataFree(p); | |
a47b9029 | 1903 | } |
62e76326 | 1904 | |
987c67d1 | 1905 | Config.npeers = 0; |
270b86af | 1906 | } |
1907 | ||
1908 | static void | |
a7d59104 | 1909 | dump_cachemgrpasswd(StoreEntry * entry, const char *name, cachemgr_passwd * list) |
270b86af | 1910 | { |
d41de3c1 | 1911 | wordlist *w; |
62e76326 | 1912 | |
d41de3c1 | 1913 | while (list != NULL) { |
62e76326 | 1914 | if (strcmp(list->passwd, "none") && strcmp(list->passwd, "disable")) |
1915 | storeAppendPrintf(entry, "%s XXXXXXXXXX", name); | |
1916 | else | |
1917 | storeAppendPrintf(entry, "%s %s", name, list->passwd); | |
1918 | ||
1919 | for (w = list->actions; w != NULL; w = w->next) { | |
1920 | storeAppendPrintf(entry, " %s", w->key); | |
1921 | } | |
1922 | ||
1923 | storeAppendPrintf(entry, "\n"); | |
1924 | list = list->next; | |
d41de3c1 | 1925 | } |
270b86af | 1926 | } |
1927 | ||
1928 | static void | |
a47b9029 | 1929 | parse_cachemgrpasswd(cachemgr_passwd ** head) |
270b86af | 1930 | { |
1931 | char *passwd = NULL; | |
1932 | wordlist *actions = NULL; | |
22f3fd98 | 1933 | cachemgr_passwd *p; |
1934 | cachemgr_passwd **P; | |
270b86af | 1935 | parse_string(&passwd); |
1936 | parse_wordlist(&actions); | |
e6ccf245 | 1937 | p = static_cast<cachemgr_passwd *>(xcalloc(1, sizeof(cachemgr_passwd))); |
22f3fd98 | 1938 | p->passwd = passwd; |
1939 | p->actions = actions; | |
62e76326 | 1940 | |
26aa7e31 | 1941 | for (P = head; *P; P = &(*P)->next) { |
62e76326 | 1942 | /* |
1943 | * See if any of the actions from this line already have a | |
1944 | * password from previous lines. The password checking | |
1945 | * routines in cache_manager.c take the the password from | |
1946 | * the first cachemgr_passwd struct that contains the | |
1947 | * requested action. Thus, we should warn users who might | |
1948 | * think they can have two passwords for the same action. | |
1949 | */ | |
1950 | wordlist *w; | |
1951 | wordlist *u; | |
1952 | ||
1953 | for (w = (*P)->actions; w; w = w->next) { | |
1954 | for (u = actions; u; u = u->next) { | |
1955 | if (strcmp(w->key, u->key)) | |
1956 | continue; | |
1957 | ||
bf8fe701 | 1958 | debugs(0, 0, "WARNING: action '" << u->key << "' (line " << config_lineno << ") already has a password"); |
62e76326 | 1959 | } |
1960 | } | |
26aa7e31 | 1961 | } |
62e76326 | 1962 | |
22f3fd98 | 1963 | *P = p; |
270b86af | 1964 | } |
1965 | ||
1966 | static void | |
a47b9029 | 1967 | free_cachemgrpasswd(cachemgr_passwd ** head) |
270b86af | 1968 | { |
a47b9029 | 1969 | cachemgr_passwd *p; |
62e76326 | 1970 | |
79d39a72 | 1971 | while ((p = *head) != NULL) { |
62e76326 | 1972 | *head = p->next; |
1973 | xfree(p->passwd); | |
1974 | wordlistDestroy(&p->actions); | |
1975 | xfree(p); | |
a47b9029 | 1976 | } |
270b86af | 1977 | } |
1978 | ||
8203a132 | 1979 | static void |
16300b58 | 1980 | dump_denyinfo(StoreEntry * entry, const char *name, acl_deny_info_list * var) |
270b86af | 1981 | { |
d41de3c1 | 1982 | acl_name_list *a; |
62e76326 | 1983 | |
d41de3c1 | 1984 | while (var != NULL) { |
62e76326 | 1985 | storeAppendPrintf(entry, "%s %s", name, var->err_page_name); |
1986 | ||
1987 | for (a = var->acl_list; a != NULL; a = a->next) | |
1988 | storeAppendPrintf(entry, " %s", a->name); | |
1989 | ||
1990 | storeAppendPrintf(entry, "\n"); | |
1991 | ||
1992 | var = var->next; | |
d41de3c1 | 1993 | } |
270b86af | 1994 | } |
1995 | ||
1996 | static void | |
16300b58 | 1997 | parse_denyinfo(acl_deny_info_list ** var) |
6e40f263 | 1998 | { |
f1dc9b30 | 1999 | aclParseDenyInfoLine(var); |
6e40f263 | 2000 | } |
403279e0 | 2001 | |
1273d501 | 2002 | void |
a47b9029 | 2003 | free_denyinfo(acl_deny_info_list ** list) |
3c5557f9 | 2004 | { |
56b63fa1 | 2005 | acl_deny_info_list *a = NULL; |
2006 | acl_deny_info_list *a_next = NULL; | |
2007 | acl_name_list *l = NULL; | |
2008 | acl_name_list *l_next = NULL; | |
62e76326 | 2009 | |
1273d501 | 2010 | for (a = *list; a; a = a_next) { |
62e76326 | 2011 | for (l = a->acl_list; l; l = l_next) { |
2012 | l_next = l->next; | |
2013 | memFree(l, MEM_ACL_NAME_LIST); | |
2014 | l = NULL; | |
2015 | } | |
2016 | ||
2017 | a_next = a->next; | |
2018 | memFree(a, MEM_ACL_DENY_INFO_LIST); | |
2019 | a = NULL; | |
1273d501 | 2020 | } |
62e76326 | 2021 | |
1273d501 | 2022 | *list = NULL; |
270b86af | 2023 | } |
2024 | ||
2025 | static void | |
505e35db | 2026 | parse_peer_access(void) |
270b86af | 2027 | { |
2028 | char *host = NULL; | |
505e35db | 2029 | peer *p; |
62e76326 | 2030 | |
270b86af | 2031 | if (!(host = strtok(NULL, w_space))) |
62e76326 | 2032 | self_destruct(); |
2033 | ||
0cdcddb9 | 2034 | if ((p = peerFindByName(host)) == NULL) { |
bf8fe701 | 2035 | debugs(15, 0, "" << cfg_filename << ", line " << config_lineno << ": No cache_peer '" << host << "'"); |
62e76326 | 2036 | return; |
0cdcddb9 | 2037 | } |
62e76326 | 2038 | |
a9f20260 | 2039 | aclParseAccessLine(LegacyParser, &p->access); |
270b86af | 2040 | } |
2041 | ||
270b86af | 2042 | static void |
2043 | parse_hostdomain(void) | |
2044 | { | |
2045 | char *host = NULL; | |
2046 | char *domain = NULL; | |
62e76326 | 2047 | |
270b86af | 2048 | if (!(host = strtok(NULL, w_space))) |
62e76326 | 2049 | self_destruct(); |
2050 | ||
f1dc9b30 | 2051 | while ((domain = strtok(NULL, list_sep))) { |
62e76326 | 2052 | domain_ping *l = NULL; |
2053 | domain_ping **L = NULL; | |
2054 | peer *p; | |
2055 | ||
2056 | if ((p = peerFindByName(host)) == NULL) { | |
bf8fe701 | 2057 | debugs(15, 0, "" << cfg_filename << ", line " << config_lineno << ": No cache_peer '" << host << "'"); |
62e76326 | 2058 | continue; |
2059 | } | |
2060 | ||
2061 | l = static_cast<domain_ping *>(xcalloc(1, sizeof(domain_ping))); | |
2062 | l->do_ping = 1; | |
2063 | ||
2064 | if (*domain == '!') { /* check for !.edu */ | |
2065 | l->do_ping = 0; | |
2066 | domain++; | |
2067 | } | |
2068 | ||
2069 | l->domain = xstrdup(domain); | |
2070 | ||
3d0ac046 | 2071 | for (L = &(p->peer_domain); *L; L = &((*L)->next)); |
62e76326 | 2072 | *L = l; |
f1dc9b30 | 2073 | } |
270b86af | 2074 | } |
2075 | ||
2076 | static void | |
2077 | parse_hostdomaintype(void) | |
2078 | { | |
2079 | char *host = NULL; | |
2080 | char *type = NULL; | |
2081 | char *domain = NULL; | |
62e76326 | 2082 | |
270b86af | 2083 | if (!(host = strtok(NULL, w_space))) |
62e76326 | 2084 | self_destruct(); |
2085 | ||
270b86af | 2086 | if (!(type = strtok(NULL, w_space))) |
62e76326 | 2087 | self_destruct(); |
2088 | ||
f1dc9b30 | 2089 | while ((domain = strtok(NULL, list_sep))) { |
62e76326 | 2090 | domain_type *l = NULL; |
2091 | domain_type **L = NULL; | |
2092 | peer *p; | |
2093 | ||
2094 | if ((p = peerFindByName(host)) == NULL) { | |
bf8fe701 | 2095 | debugs(15, 0, "" << cfg_filename << ", line " << config_lineno << ": No cache_peer '" << host << "'"); |
62e76326 | 2096 | return; |
2097 | } | |
2098 | ||
2099 | l = static_cast<domain_type *>(xcalloc(1, sizeof(domain_type))); | |
2100 | l->type = parseNeighborType(type); | |
2101 | l->domain = xstrdup(domain); | |
2102 | ||
3d0ac046 | 2103 | for (L = &(p->typelist); *L; L = &((*L)->next)); |
62e76326 | 2104 | *L = l; |
f1dc9b30 | 2105 | } |
270b86af | 2106 | } |
2107 | ||
270b86af | 2108 | static void |
a7d59104 | 2109 | dump_int(StoreEntry * entry, const char *name, int var) |
270b86af | 2110 | { |
f53b06f9 | 2111 | storeAppendPrintf(entry, "%s %d\n", name, var); |
270b86af | 2112 | } |
c1c29eb6 | 2113 | |
94439e4e | 2114 | void |
270b86af | 2115 | parse_int(int *var) |
2116 | { | |
270b86af | 2117 | int i; |
0e4e0e7d | 2118 | i = GetInteger(); |
270b86af | 2119 | *var = i; |
2120 | } | |
090089c4 | 2121 | |
0153d498 | 2122 | static void |
2123 | free_int(int *var) | |
2124 | { | |
a47b9029 | 2125 | *var = 0; |
0153d498 | 2126 | } |
2127 | ||
270b86af | 2128 | static void |
a7d59104 | 2129 | dump_onoff(StoreEntry * entry, const char *name, int var) |
270b86af | 2130 | { |
f53b06f9 | 2131 | storeAppendPrintf(entry, "%s %s\n", name, var ? "on" : "off"); |
270b86af | 2132 | } |
090089c4 | 2133 | |
d205783b | 2134 | void |
270b86af | 2135 | parse_onoff(int *var) |
2136 | { | |
2137 | char *token = strtok(NULL, w_space); | |
090089c4 | 2138 | |
270b86af | 2139 | if (token == NULL) |
62e76326 | 2140 | self_destruct(); |
2141 | ||
270b86af | 2142 | if (!strcasecmp(token, "on") || !strcasecmp(token, "enable")) |
62e76326 | 2143 | *var = 1; |
270b86af | 2144 | else |
62e76326 | 2145 | *var = 0; |
270b86af | 2146 | } |
e90100aa | 2147 | |
0153d498 | 2148 | #define free_onoff free_int |
52d3f198 | 2149 | |
2150 | static void | |
2151 | dump_tristate(StoreEntry * entry, const char *name, int var) | |
2152 | { | |
2153 | const char *state; | |
2154 | ||
2155 | if (var > 0) | |
2156 | state = "on"; | |
2157 | else if (var < 0) | |
2158 | state = "warn"; | |
2159 | else | |
2160 | state = "off"; | |
2161 | ||
2162 | storeAppendPrintf(entry, "%s %s\n", name, state); | |
2163 | } | |
2164 | ||
2165 | static void | |
2166 | parse_tristate(int *var) | |
2167 | { | |
2168 | char *token = strtok(NULL, w_space); | |
2169 | ||
2170 | if (token == NULL) | |
2171 | self_destruct(); | |
2172 | ||
2173 | if (!strcasecmp(token, "on") || !strcasecmp(token, "enable")) | |
2174 | *var = 1; | |
2175 | else if (!strcasecmp(token, "warn")) | |
2176 | *var = -1; | |
2177 | else | |
2178 | *var = 0; | |
2179 | } | |
2180 | ||
2181 | #define free_tristate free_int | |
30a4f2a8 | 2182 | |
270b86af | 2183 | static void |
a7d59104 | 2184 | dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) |
270b86af | 2185 | { |
d41de3c1 | 2186 | while (head != NULL) { |
62e76326 | 2187 | storeAppendPrintf(entry, "%s%s %s %d %d%% %d\n", |
2188 | name, | |
2189 | head->flags.icase ? " -i" : null_string, | |
2190 | head->pattern, | |
2191 | (int) head->min / 60, | |
2192 | (int) (100.0 * head->pct + 0.5), | |
2193 | (int) head->max / 60); | |
4c3ef9b2 | 2194 | |
2195 | if (head->flags.refresh_ims) | |
2196 | storeAppendPrintf(entry, " refresh-ims"); | |
2197 | ||
9f60cfdf | 2198 | #if HTTP_VIOLATIONS |
62e76326 | 2199 | |
2200 | if (head->flags.override_expire) | |
2201 | storeAppendPrintf(entry, " override-expire"); | |
2202 | ||
2203 | if (head->flags.override_lastmod) | |
2204 | storeAppendPrintf(entry, " override-lastmod"); | |
2205 | ||
2206 | if (head->flags.reload_into_ims) | |
2207 | storeAppendPrintf(entry, " reload-into-ims"); | |
2208 | ||
2209 | if (head->flags.ignore_reload) | |
2210 | storeAppendPrintf(entry, " ignore-reload"); | |
2211 | ||
38f9c547 | 2212 | if (head->flags.ignore_no_cache) |
2213 | storeAppendPrintf(entry, " ignore-no-cache"); | |
2214 | ||
2215 | if (head->flags.ignore_no_store) | |
2216 | storeAppendPrintf(entry, " ignore-no-store"); | |
2217 | ||
4ca08219 AJ |
2218 | if (head->flags.ignore_must_revalidate) |
2219 | storeAppendPrintf(entry, " ignore-must-revalidate"); | |
2220 | ||
38f9c547 | 2221 | if (head->flags.ignore_private) |
2222 | storeAppendPrintf(entry, " ignore-private"); | |
2223 | ||
2224 | if (head->flags.ignore_auth) | |
2225 | storeAppendPrintf(entry, " ignore-auth"); | |
2226 | ||
9f60cfdf | 2227 | #endif |
62e76326 | 2228 | |
2229 | storeAppendPrintf(entry, "\n"); | |
2230 | ||
2231 | head = head->next; | |
d41de3c1 | 2232 | } |
270b86af | 2233 | } |
090089c4 | 2234 | |
270b86af | 2235 | static void |
f1dc9b30 | 2236 | parse_refreshpattern(refresh_t ** head) |
270b86af | 2237 | { |
f1dc9b30 | 2238 | char *token; |
2239 | char *pattern; | |
2240 | time_t min = 0; | |
c3f6d204 | 2241 | double pct = 0.0; |
f1dc9b30 | 2242 | time_t max = 0; |
4c3ef9b2 | 2243 | int refresh_ims = 0; |
9f60cfdf | 2244 | #if HTTP_VIOLATIONS |
62e76326 | 2245 | |
1dfa1d81 | 2246 | int override_expire = 0; |
2247 | int override_lastmod = 0; | |
cbe3a719 | 2248 | int reload_into_ims = 0; |
2249 | int ignore_reload = 0; | |
38f9c547 | 2250 | int ignore_no_cache = 0; |
2251 | int ignore_no_store = 0; | |
4ca08219 | 2252 | int ignore_must_revalidate = 0; |
38f9c547 | 2253 | int ignore_private = 0; |
2254 | int ignore_auth = 0; | |
9f60cfdf | 2255 | #endif |
62e76326 | 2256 | |
f1dc9b30 | 2257 | int i; |
2258 | refresh_t *t; | |
2259 | regex_t comp; | |
2260 | int errcode; | |
2261 | int flags = REG_EXTENDED | REG_NOSUB; | |
62e76326 | 2262 | |
9eeb8e4b | 2263 | if ((token = strtok(NULL, w_space)) == NULL) { |
62e76326 | 2264 | self_destruct(); |
9eeb8e4b | 2265 | return; |
2266 | } | |
62e76326 | 2267 | |
f1dc9b30 | 2268 | if (strcmp(token, "-i") == 0) { |
62e76326 | 2269 | flags |= REG_ICASE; |
2270 | token = strtok(NULL, w_space); | |
f1dc9b30 | 2271 | } else if (strcmp(token, "+i") == 0) { |
62e76326 | 2272 | flags &= ~REG_ICASE; |
2273 | token = strtok(NULL, w_space); | |
f1dc9b30 | 2274 | } |
62e76326 | 2275 | |
9eeb8e4b | 2276 | if (token == NULL) { |
62e76326 | 2277 | self_destruct(); |
9eeb8e4b | 2278 | return; |
2279 | } | |
62e76326 | 2280 | |
f1dc9b30 | 2281 | pattern = xstrdup(token); |
62e76326 | 2282 | |
0e4e0e7d | 2283 | i = GetInteger(); /* token: min */ |
62e76326 | 2284 | |
f1dc9b30 | 2285 | min = (time_t) (i * 60); /* convert minutes to seconds */ |
62e76326 | 2286 | |
0e4e0e7d | 2287 | i = GetInteger(); /* token: pct */ |
62e76326 | 2288 | |
c3f6d204 | 2289 | pct = (double) i / 100.0; |
62e76326 | 2290 | |
0e4e0e7d | 2291 | i = GetInteger(); /* token: max */ |
62e76326 | 2292 | |
f1dc9b30 | 2293 | max = (time_t) (i * 60); /* convert minutes to seconds */ |
62e76326 | 2294 | |
1dfa1d81 | 2295 | /* Options */ |
2296 | while ((token = strtok(NULL, w_space)) != NULL) { | |
4c3ef9b2 | 2297 | if (!strcmp(token, "refresh-ims")) { |
2298 | refresh_ims = 1; | |
9f60cfdf | 2299 | #if HTTP_VIOLATIONS |
62e76326 | 2300 | |
4c3ef9b2 | 2301 | } else if (!strcmp(token, "override-expire")) |
62e76326 | 2302 | override_expire = 1; |
2303 | else if (!strcmp(token, "override-lastmod")) | |
2304 | override_lastmod = 1; | |
38f9c547 | 2305 | else if (!strcmp(token, "ignore-no-cache")) |
2306 | ignore_no_cache = 1; | |
2307 | else if (!strcmp(token, "ignore-no-store")) | |
2308 | ignore_no_store = 1; | |
4ca08219 AJ |
2309 | else if (!strcmp(token, "ignore-must-revalidate")) |
2310 | ignore_must_revalidate = 1; | |
38f9c547 | 2311 | else if (!strcmp(token, "ignore-private")) |
2312 | ignore_private = 1; | |
2313 | else if (!strcmp(token, "ignore-auth")) | |
2314 | ignore_auth = 1; | |
62e76326 | 2315 | else if (!strcmp(token, "reload-into-ims")) { |
2316 | reload_into_ims = 1; | |
2317 | refresh_nocache_hack = 1; | |
2318 | /* tell client_side.c that this is used */ | |
2319 | } else if (!strcmp(token, "ignore-reload")) { | |
2320 | ignore_reload = 1; | |
2321 | refresh_nocache_hack = 1; | |
2322 | /* tell client_side.c that this is used */ | |
9f60cfdf | 2323 | #endif |
62e76326 | 2324 | |
4c3ef9b2 | 2325 | } else |
26ac0430 | 2326 | debugs(22, 0, "redreshAddToList: Unknown option '" << pattern << "': " << token); |
1dfa1d81 | 2327 | } |
62e76326 | 2328 | |
f1dc9b30 | 2329 | if ((errcode = regcomp(&comp, pattern, flags)) != 0) { |
62e76326 | 2330 | char errbuf[256]; |
2331 | regerror(errcode, &comp, errbuf, sizeof errbuf); | |
bf8fe701 | 2332 | debugs(22, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); |
2333 | debugs(22, 0, "refreshAddToList: Invalid regular expression '" << pattern << "': " << errbuf); | |
62e76326 | 2334 | return; |
f1dc9b30 | 2335 | } |
62e76326 | 2336 | |
c3f6d204 | 2337 | pct = pct < 0.0 ? 0.0 : pct; |
f1dc9b30 | 2338 | max = max < 0 ? 0 : max; |
e6ccf245 | 2339 | t = static_cast<refresh_t *>(xcalloc(1, sizeof(refresh_t))); |
f1dc9b30 | 2340 | t->pattern = (char *) xstrdup(pattern); |
2341 | t->compiled_pattern = comp; | |
2342 | t->min = min; | |
c3f6d204 | 2343 | t->pct = pct; |
f1dc9b30 | 2344 | t->max = max; |
62e76326 | 2345 | |
c3f6d204 | 2346 | if (flags & REG_ICASE) |
62e76326 | 2347 | t->flags.icase = 1; |
2348 | ||
4c3ef9b2 | 2349 | if (refresh_ims) |
2350 | t->flags.refresh_ims = 1; | |
2351 | ||
9f60cfdf | 2352 | #if HTTP_VIOLATIONS |
62e76326 | 2353 | |
1dfa1d81 | 2354 | if (override_expire) |
62e76326 | 2355 | t->flags.override_expire = 1; |
2356 | ||
1dfa1d81 | 2357 | if (override_lastmod) |
62e76326 | 2358 | t->flags.override_lastmod = 1; |
2359 | ||
cbe3a719 | 2360 | if (reload_into_ims) |
62e76326 | 2361 | t->flags.reload_into_ims = 1; |
2362 | ||
cbe3a719 | 2363 | if (ignore_reload) |
62e76326 | 2364 | t->flags.ignore_reload = 1; |
2365 | ||
38f9c547 | 2366 | if (ignore_no_cache) |
2367 | t->flags.ignore_no_cache = 1; | |
2368 | ||
2369 | if (ignore_no_store) | |
2370 | t->flags.ignore_no_store = 1; | |
2371 | ||
4ca08219 AJ |
2372 | if (ignore_must_revalidate) |
2373 | t->flags.ignore_must_revalidate = 1; | |
2374 | ||
38f9c547 | 2375 | if (ignore_private) |
2376 | t->flags.ignore_private = 1; | |
2377 | ||
2378 | if (ignore_auth) | |
2379 | t->flags.ignore_auth = 1; | |
2380 | ||
9f60cfdf | 2381 | #endif |
62e76326 | 2382 | |
f1dc9b30 | 2383 | t->next = NULL; |
62e76326 | 2384 | |
f1dc9b30 | 2385 | while (*head) |
62e76326 | 2386 | head = &(*head)->next; |
2387 | ||
f1dc9b30 | 2388 | *head = t; |
62e76326 | 2389 | |
f1dc9b30 | 2390 | safe_free(pattern); |
270b86af | 2391 | } |
090089c4 | 2392 | |
270b86af | 2393 | static void |
a47b9029 | 2394 | free_refreshpattern(refresh_t ** head) |
270b86af | 2395 | { |
f1dc9b30 | 2396 | refresh_t *t; |
62e76326 | 2397 | |
79d39a72 | 2398 | while ((t = *head) != NULL) { |
62e76326 | 2399 | *head = t->next; |
2400 | safe_free(t->pattern); | |
2401 | regfree(&t->compiled_pattern); | |
2402 | safe_free(t); | |
f1dc9b30 | 2403 | } |
c2066637 | 2404 | |
8970d351 | 2405 | #if HTTP_VIOLATIONS |
c2066637 | 2406 | refresh_nocache_hack = 0; |
8970d351 | 2407 | |
2408 | #endif | |
270b86af | 2409 | } |
12b9e9b1 | 2410 | |
270b86af | 2411 | static void |
a7d59104 | 2412 | dump_string(StoreEntry * entry, const char *name, char *var) |
270b86af | 2413 | { |
f53b06f9 | 2414 | if (var != NULL) |
62e76326 | 2415 | storeAppendPrintf(entry, "%s %s\n", name, var); |
270b86af | 2416 | } |
98ffb7e4 | 2417 | |
270b86af | 2418 | static void |
0153d498 | 2419 | parse_string(char **var) |
270b86af | 2420 | { |
2421 | char *token = strtok(NULL, w_space); | |
270b86af | 2422 | safe_free(*var); |
62e76326 | 2423 | |
270b86af | 2424 | if (token == NULL) |
62e76326 | 2425 | self_destruct(); |
2426 | ||
270b86af | 2427 | *var = xstrdup(token); |
2428 | } | |
b15e6857 | 2429 | |
3a69ddf3 | 2430 | void |
2431 | ConfigParser::ParseString(char **var) | |
2432 | { | |
2433 | parse_string(var); | |
2434 | } | |
2435 | ||
2436 | void | |
30abd221 | 2437 | ConfigParser::ParseString(String *var) |
3a69ddf3 | 2438 | { |
2439 | char *token = strtok(NULL, w_space); | |
2440 | ||
2441 | if (token == NULL) | |
2442 | self_destruct(); | |
2443 | ||
30abd221 | 2444 | var->reset(token); |
3a69ddf3 | 2445 | } |
2446 | ||
0153d498 | 2447 | static void |
2448 | free_string(char **var) | |
2449 | { | |
027acbaf | 2450 | safe_free(*var); |
0153d498 | 2451 | } |
caebbe00 | 2452 | |
94439e4e | 2453 | void |
f1dc9b30 | 2454 | parse_eol(char *volatile *var) |
270b86af | 2455 | { |
852751f7 | 2456 | unsigned char *token = (unsigned char *) strtok(NULL, null_string); |
270b86af | 2457 | safe_free(*var); |
62e76326 | 2458 | |
9eeb8e4b | 2459 | if (!token) { |
62e76326 | 2460 | self_destruct(); |
9eeb8e4b | 2461 | return; |
2462 | } | |
62e76326 | 2463 | |
e4755e29 | 2464 | while (*token && xisspace(*token)) |
62e76326 | 2465 | token++; |
2466 | ||
9eeb8e4b | 2467 | if (!*token) { |
62e76326 | 2468 | self_destruct(); |
9eeb8e4b | 2469 | return; |
2470 | } | |
62e76326 | 2471 | |
852751f7 | 2472 | *var = xstrdup((char *) token); |
270b86af | 2473 | } |
090089c4 | 2474 | |
52d3f198 | 2475 | #define dump_eol dump_string |
2476 | #define free_eol free_string | |
2477 | ||
270b86af | 2478 | static void |
a7d59104 | 2479 | dump_time_t(StoreEntry * entry, const char *name, time_t var) |
090089c4 | 2480 | { |
f53b06f9 | 2481 | storeAppendPrintf(entry, "%s %d seconds\n", name, (int) var); |
090089c4 | 2482 | } |
2483 | ||
94439e4e | 2484 | void |
a47b9029 | 2485 | parse_time_t(time_t * var) |
0ffd22bc | 2486 | { |
f1dc9b30 | 2487 | parseTimeLine(var, T_SECOND_STR); |
0ffd22bc | 2488 | } |
2489 | ||
270b86af | 2490 | static void |
a47b9029 | 2491 | free_time_t(time_t * var) |
270b86af | 2492 | { |
a47b9029 | 2493 | *var = 0; |
270b86af | 2494 | } |
9906e724 | 2495 | |
2496 | static void | |
a7d59104 | 2497 | dump_size_t(StoreEntry * entry, const char *name, size_t var) |
1b635117 | 2498 | { |
f53b06f9 | 2499 | storeAppendPrintf(entry, "%s %d\n", name, (int) var); |
1b635117 | 2500 | } |
2501 | ||
2502 | static void | |
a7d59104 | 2503 | dump_b_size_t(StoreEntry * entry, const char *name, size_t var) |
9906e724 | 2504 | { |
f53b06f9 | 2505 | storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_BYTES_STR); |
9906e724 | 2506 | } |
2507 | ||
3e62bd58 | 2508 | #if UNUSED_CODE |
9906e724 | 2509 | static void |
a7d59104 | 2510 | dump_kb_size_t(StoreEntry * entry, const char *name, size_t var) |
9906e724 | 2511 | { |
f53b06f9 | 2512 | storeAppendPrintf(entry, "%s %d %s\n", name, (int) var, B_KBYTES_STR); |
9906e724 | 2513 | } |
3e62bd58 | 2514 | #endif |
9906e724 | 2515 | |
47f6e231 | 2516 | static void |
2517 | dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var) | |
2518 | { | |
2519 | storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_BYTES_STR); | |
2520 | } | |
2521 | ||
2522 | static void | |
2523 | dump_kb_int64_t(StoreEntry * entry, const char *name, int64_t var) | |
2524 | { | |
2525 | storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_KBYTES_STR); | |
2526 | } | |
2527 | ||
9906e724 | 2528 | static void |
a47b9029 | 2529 | parse_size_t(size_t * var) |
1b635117 | 2530 | { |
1b635117 | 2531 | int i; |
0e4e0e7d | 2532 | i = GetInteger(); |
1b635117 | 2533 | *var = (size_t) i; |
2534 | } | |
2535 | ||
2536 | static void | |
2537 | parse_b_size_t(size_t * var) | |
9906e724 | 2538 | { |
2539 | parseBytesLine(var, B_BYTES_STR); | |
2540 | } | |
2541 | ||
3e62bd58 | 2542 | #if UNUSED_CODE |
9906e724 | 2543 | static void |
a47b9029 | 2544 | parse_kb_size_t(size_t * var) |
9906e724 | 2545 | { |
2546 | parseBytesLine(var, B_KBYTES_STR); | |
2547 | } | |
3e62bd58 | 2548 | #endif |
9906e724 | 2549 | |
47f6e231 | 2550 | static void |
2551 | parse_b_int64_t(int64_t * var) | |
2552 | { | |
2553 | parseBytesLine64(var, B_BYTES_STR); | |
2554 | } | |
2555 | ||
2556 | static void | |
2557 | parse_kb_int64_t(int64_t * var) | |
2558 | { | |
2559 | parseBytesLine64(var, B_KBYTES_STR); | |
2560 | } | |
2561 | ||
9906e724 | 2562 | static void |
a47b9029 | 2563 | free_size_t(size_t * var) |
9906e724 | 2564 | { |
a47b9029 | 2565 | *var = 0; |
9906e724 | 2566 | } |
2567 | ||
47f6e231 | 2568 | static void |
2569 | free_b_int64_t(int64_t * var) | |
2570 | { | |
2571 | *var = 0; | |
2572 | } | |
2573 | ||
1b635117 | 2574 | #define free_b_size_t free_size_t |
9906e724 | 2575 | #define free_kb_size_t free_size_t |
2576 | #define free_mb_size_t free_size_t | |
2577 | #define free_gb_size_t free_size_t | |
47f6e231 | 2578 | #define free_kb_int64_t free_b_int64_t |
090089c4 | 2579 | |
8203a132 | 2580 | static void |
a7d59104 | 2581 | dump_ushort(StoreEntry * entry, const char *name, u_short var) |
090089c4 | 2582 | { |
f53b06f9 | 2583 | storeAppendPrintf(entry, "%s %d\n", name, var); |
270b86af | 2584 | } |
090089c4 | 2585 | |
0153d498 | 2586 | static void |
a47b9029 | 2587 | free_ushort(u_short * u) |
0153d498 | 2588 | { |
2589 | *u = 0; | |
2590 | } | |
2591 | ||
270b86af | 2592 | static void |
2593 | parse_ushort(u_short * var) | |
b67e2c8c | 2594 | { |
2595 | ConfigParser::ParseUShort(var); | |
2596 | } | |
2597 | ||
2598 | void | |
2599 | ConfigParser::ParseUShort(u_short *var) | |
270b86af | 2600 | { |
0e656b69 | 2601 | *var = GetShort(); |
090089c4 | 2602 | } |
2603 | ||
3a69ddf3 | 2604 | void |
2605 | ConfigParser::ParseBool(bool *var) | |
2606 | { | |
2607 | int i = GetInteger(); | |
2608 | ||
2609 | if (0 == i) | |
2610 | *var = false; | |
2611 | else if (1 == i) | |
2612 | *var = true; | |
2613 | else | |
2614 | self_destruct(); | |
2615 | } | |
2616 | ||
270b86af | 2617 | static void |
a7d59104 | 2618 | dump_wordlist(StoreEntry * entry, const char *name, wordlist * list) |
270b86af | 2619 | { |
270b86af | 2620 | while (list != NULL) { |
62e76326 | 2621 | storeAppendPrintf(entry, "%s %s\n", name, list->key); |
2622 | list = list->next; | |
429fdbec | 2623 | } |
429fdbec | 2624 | } |
2625 | ||
3a69ddf3 | 2626 | void |
2627 | ConfigParser::ParseWordList(wordlist ** list) | |
2628 | { | |
2629 | parse_wordlist(list); | |
2630 | } | |
2631 | ||
94439e4e | 2632 | void |
270b86af | 2633 | parse_wordlist(wordlist ** list) |
429fdbec | 2634 | { |
270b86af | 2635 | char *token; |
a3c6890f | 2636 | char *t = strtok(NULL, ""); |
62e76326 | 2637 | |
a3c6890f | 2638 | while ((token = strwordtok(NULL, &t))) |
62e76326 | 2639 | wordlistAdd(list, token); |
429fdbec | 2640 | } |
270b86af | 2641 | |
b3d8a9e8 | 2642 | #if 0 /* now unused */ |
f8d9f54a | 2643 | static int |
5da06f20 | 2644 | check_null_wordlist(wordlist * w) |
f8d9f54a | 2645 | { |
2646 | return w == NULL; | |
2647 | } | |
b3d8a9e8 | 2648 | #endif |
f8d9f54a | 2649 | |
63e9d884 | 2650 | static int |
c6d5b87b | 2651 | check_null_acl_access(acl_access * a) |
63e9d884 | 2652 | { |
2653 | return a == NULL; | |
2654 | } | |
2655 | ||
0153d498 | 2656 | #define free_wordlist wordlistDestroy |
270b86af | 2657 | |
d548ee64 | 2658 | #define free_uri_whitespace free_int |
2659 | ||
2660 | static void | |
2661 | parse_uri_whitespace(int *var) | |
2662 | { | |
2663 | char *token = strtok(NULL, w_space); | |
62e76326 | 2664 | |
d548ee64 | 2665 | if (token == NULL) |
62e76326 | 2666 | self_destruct(); |
2667 | ||
7e3ce7b9 | 2668 | if (!strcasecmp(token, "strip")) |
62e76326 | 2669 | *var = URI_WHITESPACE_STRIP; |
7e3ce7b9 | 2670 | else if (!strcasecmp(token, "deny")) |
62e76326 | 2671 | *var = URI_WHITESPACE_DENY; |
d548ee64 | 2672 | else if (!strcasecmp(token, "allow")) |
62e76326 | 2673 | *var = URI_WHITESPACE_ALLOW; |
d548ee64 | 2674 | else if (!strcasecmp(token, "encode")) |
62e76326 | 2675 | *var = URI_WHITESPACE_ENCODE; |
d548ee64 | 2676 | else if (!strcasecmp(token, "chop")) |
62e76326 | 2677 | *var = URI_WHITESPACE_CHOP; |
d548ee64 | 2678 | else |
62e76326 | 2679 | self_destruct(); |
d548ee64 | 2680 | } |
2681 | ||
d548ee64 | 2682 | static void |
2683 | dump_uri_whitespace(StoreEntry * entry, const char *name, int var) | |
2684 | { | |
c193c972 | 2685 | const char *s; |
62e76326 | 2686 | |
d548ee64 | 2687 | if (var == URI_WHITESPACE_ALLOW) |
62e76326 | 2688 | s = "allow"; |
d548ee64 | 2689 | else if (var == URI_WHITESPACE_ENCODE) |
62e76326 | 2690 | s = "encode"; |
d548ee64 | 2691 | else if (var == URI_WHITESPACE_CHOP) |
62e76326 | 2692 | s = "chop"; |
7e3ce7b9 | 2693 | else if (var == URI_WHITESPACE_DENY) |
62e76326 | 2694 | s = "deny"; |
7e3ce7b9 | 2695 | else |
62e76326 | 2696 | s = "strip"; |
2697 | ||
d548ee64 | 2698 | storeAppendPrintf(entry, "%s %s\n", name, s); |
2699 | } | |
2700 | ||
6a566b9c | 2701 | static void |
c1dd71ae | 2702 | free_removalpolicy(RemovalPolicySettings ** settings) |
6a566b9c | 2703 | { |
2704 | if (!*settings) | |
62e76326 | 2705 | return; |
2706 | ||
6a566b9c | 2707 | free_string(&(*settings)->type); |
62e76326 | 2708 | |
6a566b9c | 2709 | free_wordlist(&(*settings)->args); |
62e76326 | 2710 | |
c8f4eac4 | 2711 | delete *settings; |
62e76326 | 2712 | |
6a566b9c | 2713 | *settings = NULL; |
2714 | } | |
2715 | ||
2716 | static void | |
c1dd71ae | 2717 | parse_removalpolicy(RemovalPolicySettings ** settings) |
6a566b9c | 2718 | { |
2719 | if (*settings) | |
62e76326 | 2720 | free_removalpolicy(settings); |
2721 | ||
c8f4eac4 | 2722 | *settings = new RemovalPolicySettings; |
62e76326 | 2723 | |
6a566b9c | 2724 | parse_string(&(*settings)->type); |
62e76326 | 2725 | |
6a566b9c | 2726 | parse_wordlist(&(*settings)->args); |
2727 | } | |
2728 | ||
2729 | static void | |
c1dd71ae | 2730 | dump_removalpolicy(StoreEntry * entry, const char *name, RemovalPolicySettings * settings) |
6a566b9c | 2731 | { |
2732 | wordlist *args; | |
2733 | storeAppendPrintf(entry, "%s %s", name, settings->type); | |
2734 | args = settings->args; | |
62e76326 | 2735 | |
6a566b9c | 2736 | while (args) { |
62e76326 | 2737 | storeAppendPrintf(entry, " %s", args->key); |
2738 | args = args->next; | |
6a566b9c | 2739 | } |
62e76326 | 2740 | |
be58afb5 | 2741 | storeAppendPrintf(entry, "\n"); |
6a566b9c | 2742 | } |
c1dd71ae | 2743 | |
1ee67578 | 2744 | #include "cf_parser.h" |
f1dc9b30 | 2745 | |
2746 | peer_t | |
2747 | parseNeighborType(const char *s) | |
2748 | { | |
2749 | if (!strcasecmp(s, "parent")) | |
62e76326 | 2750 | return PEER_PARENT; |
2751 | ||
f1dc9b30 | 2752 | if (!strcasecmp(s, "neighbor")) |
62e76326 | 2753 | return PEER_SIBLING; |
2754 | ||
f1dc9b30 | 2755 | if (!strcasecmp(s, "neighbour")) |
62e76326 | 2756 | return PEER_SIBLING; |
2757 | ||
f1dc9b30 | 2758 | if (!strcasecmp(s, "sibling")) |
62e76326 | 2759 | return PEER_SIBLING; |
2760 | ||
f1dc9b30 | 2761 | if (!strcasecmp(s, "multicast")) |
62e76326 | 2762 | return PEER_MULTICAST; |
2763 | ||
bf8fe701 | 2764 | debugs(15, 0, "WARNING: Unknown neighbor type: " << s); |
62e76326 | 2765 | |
f1dc9b30 | 2766 | return PEER_SIBLING; |
2767 | } | |
f150dd4b | 2768 | |
0b0cfcf2 | 2769 | #if USE_WCCPv2 |
52f772de | 2770 | void |
23f6a720 | 2771 | parse_IpAddress_list_token(IpAddress_list ** head, char *token) |
7e3ce7b9 | 2772 | { |
7e3ce7b9 | 2773 | char *t; |
efd900cb | 2774 | char *host; |
7d569f1b | 2775 | char *tmp; |
62e76326 | 2776 | |
ad61a2b4 | 2777 | IpAddress ipa; |
efd900cb | 2778 | unsigned short port; |
ad61a2b4 | 2779 | IpAddress_list *s; |
52f772de | 2780 | |
2781 | host = NULL; | |
2782 | port = 0; | |
62e76326 | 2783 | |
cc192b50 | 2784 | #if USE_IPV6 |
2785 | if (*token == '[') { | |
2786 | /* [host]:port */ | |
26ac0430 AJ |
2787 | host = token + 1; |
2788 | t = strchr(host, ']'); | |
2789 | if (!t) | |
2790 | self_destruct(); | |
2791 | *t++ = '\0'; | |
2792 | if (*t != ':') | |
2793 | self_destruct(); | |
2794 | port = xatos(t + 1); | |
cc192b50 | 2795 | } else |
2796 | #endif | |
26ac0430 AJ |
2797 | if ((t = strchr(token, ':'))) { |
2798 | /* host:port */ | |
2799 | host = token; | |
2800 | *t = '\0'; | |
2801 | port = xatos(t + 1); | |
2802 | ||
2803 | if (0 == port) | |
2804 | self_destruct(); | |
2805 | } else if ((port = strtol(token, &tmp, 10)), !*tmp) { | |
2806 | /* port */ | |
2807 | } else { | |
2808 | host = token; | |
2809 | port = 0; | |
2810 | } | |
62e76326 | 2811 | |
52f772de | 2812 | if (NULL == host) |
cc192b50 | 2813 | ipa.SetAnyAddr(); |
2814 | else if ( ipa.GetHostByName(host) ) /* dont use ipcache. Accept either FQDN or IPA. */ | |
62e76326 | 2815 | (void) 0; |
52f772de | 2816 | else |
62e76326 | 2817 | self_destruct(); |
2818 | ||
cc192b50 | 2819 | /* port MUST be set after the IPA lookup/conversion is perofrmed. */ |
2820 | ipa.SetPort(port); | |
2821 | ||
52f772de | 2822 | while (*head) |
62e76326 | 2823 | head = &(*head)->next; |
2824 | ||
ad61a2b4 | 2825 | s = static_cast<IpAddress_list *>(xcalloc(1, sizeof(*s))); |
cc192b50 | 2826 | s->s = ipa; |
2827 | ||
52f772de | 2828 | *head = s; |
2829 | } | |
2830 | ||
2831 | static void | |
23f6a720 | 2832 | parse_IpAddress_list(IpAddress_list ** head) |
52f772de | 2833 | { |
2834 | char *token; | |
62e76326 | 2835 | |
52f772de | 2836 | while ((token = strtok(NULL, w_space))) { |
ad61a2b4 | 2837 | parse_IpAddress_list_token(head, token); |
7e3ce7b9 | 2838 | } |
2839 | } | |
2840 | ||
2841 | static void | |
23f6a720 | 2842 | dump_IpAddress_list(StoreEntry * e, const char *n, const IpAddress_list * s) |
7e3ce7b9 | 2843 | { |
cc192b50 | 2844 | char ntoabuf[MAX_IPSTRLEN]; |
2845 | ||
7e3ce7b9 | 2846 | while (s) { |
cc192b50 | 2847 | storeAppendPrintf(e, "%s %s\n", |
62e76326 | 2848 | n, |
cc192b50 | 2849 | s->s.NtoA(ntoabuf,MAX_IPSTRLEN)); |
62e76326 | 2850 | s = s->next; |
7e3ce7b9 | 2851 | } |
2852 | } | |
2853 | ||
2854 | static void | |
23f6a720 | 2855 | free_IpAddress_list(IpAddress_list ** head) |
7e3ce7b9 | 2856 | { |
26ac0430 AJ |
2857 | if (*head) delete *head; |
2858 | *head = NULL; | |
7e3ce7b9 | 2859 | } |
2860 | ||
0b0cfcf2 | 2861 | #if CURRENTLY_UNUSED |
2862 | /* This code was previously used by http_port. Left as it really should | |
2863 | * be used by icp_port and htcp_port | |
2864 | */ | |
7e3ce7b9 | 2865 | static int |
ca2a792f | 2866 | check_null_IpAddress_list(const IpAddress_list * s) |
7e3ce7b9 | 2867 | { |
2868 | return NULL == s; | |
2869 | } | |
62e76326 | 2870 | |
3f38a55e | 2871 | #endif /* CURRENTLY_UNUSED */ |
0b0cfcf2 | 2872 | #endif /* USE_WCCPv2 */ |
7e3ce7b9 | 2873 | |
154dc884 | 2874 | CBDATA_CLASS_INIT(http_port_list); |
2875 | ||
d193a436 | 2876 | static void |
3f38a55e | 2877 | parse_http_port_specification(http_port_list * s, char *token) |
d193a436 | 2878 | { |
3f38a55e | 2879 | char *host = NULL; |
3f38a55e | 2880 | unsigned short port = 0; |
cc192b50 | 2881 | char *t = NULL; |
2882 | char *junk = NULL; | |
62e76326 | 2883 | |
5529ca8a | 2884 | s->disable_pmtu_discovery = DISABLE_PMTU_OFF; |
13adaf1f | 2885 | s->name = xstrdup(token); |
d67acb4e | 2886 | s->connection_auth_disabled = false; |
5529ca8a | 2887 | |
cc192b50 | 2888 | #if USE_IPV6 |
2889 | if (*token == '[') { | |
2890 | /* [ipv6]:port */ | |
26ac0430 AJ |
2891 | host = token + 1; |
2892 | t = strchr(host, ']'); | |
2893 | if (!t) { | |
cc192b50 | 2894 | debugs(3, 0, "http(s)_port: missing ']' on IPv6 address: " << token); |
26ac0430 | 2895 | self_destruct(); |
cc192b50 | 2896 | } |
26ac0430 AJ |
2897 | *t++ = '\0'; |
2898 | if (*t != ':') { | |
cc192b50 | 2899 | debugs(3, 0, "http(s)_port: missing Port in: " << token); |
26ac0430 | 2900 | self_destruct(); |
cc192b50 | 2901 | } |
26ac0430 | 2902 | port = xatos(t + 1); |
cc192b50 | 2903 | } else |
2904 | #endif | |
26ac0430 AJ |
2905 | if ((t = strchr(token, ':'))) { |
2906 | /* host:port */ | |
2907 | /* ipv4:port */ | |
2908 | host = token; | |
2909 | *t = '\0'; | |
2910 | port = xatos(t + 1); | |
2911 | ||
2912 | } else if ((port = strtol(token, &junk, 10)), !*junk) { | |
2913 | /* port */ | |
2914 | debugs(3, 3, "http(s)_port: found Listen on Port: " << port); | |
2915 | } else { | |
2916 | debugs(3, 0, "http(s)_port: missing Port: " << token); | |
2917 | self_destruct(); | |
2918 | } | |
62e76326 | 2919 | |
cc192b50 | 2920 | if (port == 0) { |
2921 | debugs(3, 0, "http(s)_port: Port cannot be 0: " << token); | |
0e656b69 | 2922 | self_destruct(); |
cc192b50 | 2923 | } |
0e656b69 | 2924 | |
cc192b50 | 2925 | if (NULL == host) { |
2926 | s->s.SetAnyAddr(); | |
2927 | s->s.SetPort(port); | |
2928 | debugs(3, 3, "http(s)_port: found Listen on wildcard address: " << s->s); | |
26ac0430 | 2929 | } else if ( s->s = host ) { /* check/parse numeric IPA */ |
cc192b50 | 2930 | s->s.SetPort(port); |
2931 | debugs(3, 3, "http(s)_port: Listen on Host/IP: " << host << " --> " << s->s); | |
26ac0430 | 2932 | } else if ( s->s.GetHostByName(host) ) { /* check/parse for FQDN */ |
62e76326 | 2933 | /* dont use ipcache */ |
62e76326 | 2934 | s->defaultsite = xstrdup(host); |
cc192b50 | 2935 | s->s.SetPort(port); |
2936 | debugs(3, 3, "http(s)_port: found Listen as Host " << s->defaultsite << " on IP: " << s->s); | |
26ac0430 | 2937 | } else { |
cc192b50 | 2938 | debugs(3, 0, "http(s)_port: failed to resolve Host/IP: " << host); |
62e76326 | 2939 | self_destruct(); |
cc192b50 | 2940 | } |
3f38a55e | 2941 | } |
2942 | ||
2943 | static void | |
2944 | parse_http_port_option(http_port_list * s, char *token) | |
2945 | { | |
2946 | if (strncmp(token, "defaultsite=", 12) == 0) { | |
62e76326 | 2947 | safe_free(s->defaultsite); |
2948 | s->defaultsite = xstrdup(token + 12); | |
2949 | s->accel = 1; | |
3f38a55e | 2950 | } else if (strncmp(token, "name=", 5) == 0) { |
62e76326 | 2951 | safe_free(s->name); |
2952 | s->name = xstrdup(token + 5); | |
3f38a55e | 2953 | } else if (strcmp(token, "vhost") == 0) { |
62e76326 | 2954 | s->vhost = 1; |
2955 | s->accel = 1; | |
3f38a55e | 2956 | } else if (strcmp(token, "vport") == 0) { |
62e76326 | 2957 | s->vport = -1; |
2958 | s->accel = 1; | |
3f38a55e | 2959 | } else if (strncmp(token, "vport=", 6) == 0) { |
0e656b69 | 2960 | s->vport = xatos(token + 6); |
62e76326 | 2961 | s->accel = 1; |
3f38a55e | 2962 | } else if (strncmp(token, "protocol=", 9) == 0) { |
62e76326 | 2963 | s->protocol = xstrdup(token + 9); |
2964 | s->accel = 1; | |
3f38a55e | 2965 | } else if (strcmp(token, "accel") == 0) { |
62e76326 | 2966 | s->accel = 1; |
d67acb4e AJ |
2967 | } else if (strcmp(token, "no-connection-auth") == 0) { |
2968 | s->connection_auth_disabled = true; | |
2969 | } else if (strcmp(token, "connection-auth=off") == 0) { | |
26ac0430 | 2970 | s->connection_auth_disabled = true; |
d67acb4e | 2971 | } else if (strcmp(token, "connection-auth") == 0) { |
26ac0430 | 2972 | s->connection_auth_disabled = false; |
d67acb4e | 2973 | } else if (strcmp(token, "connection-auth=on") == 0) { |
26ac0430 | 2974 | s->connection_auth_disabled = false; |
5529ca8a | 2975 | } else if (strncmp(token, "disable-pmtu-discovery=", 23) == 0) { |
2976 | if (!strcasecmp(token + 23, "off")) | |
2977 | s->disable_pmtu_discovery = DISABLE_PMTU_OFF; | |
2978 | else if (!strcasecmp(token + 23, "transparent")) | |
2979 | s->disable_pmtu_discovery = DISABLE_PMTU_TRANSPARENT; | |
2980 | else if (!strcasecmp(token + 23, "always")) | |
2981 | s->disable_pmtu_discovery = DISABLE_PMTU_ALWAYS; | |
2982 | else | |
2983 | self_destruct(); | |
fc68f6b1 | 2984 | |
2ad20b4f AJ |
2985 | } else if (strcmp(token, "transparent") == 0 || strcmp(token, "intercept") == 0) { |
2986 | s->intercepted = 1; | |
85944c1c | 2987 | IpInterceptor.StartInterception(); |
13b5cd0c AJ |
2988 | /* Log information regarding the port modes under interception. */ |
2989 | debugs(3, DBG_IMPORTANT, "Starting Authentication on port " << s->s); | |
2990 | debugs(3, DBG_IMPORTANT, "Disabling Authentication on port " << s->s << " (interception enabled)"); | |
2991 | ||
04f87469 AJ |
2992 | #if USE_IPV6 |
2993 | /* INET6: until transparent REDIRECT works on IPv6 SOCKET, force wildcard to IPv4 */ | |
13b5cd0c | 2994 | debugs(3, DBG_IMPORTANT, "Disabling IPv6 on port " << s->s << " (interception enabled)"); |
26ac0430 | 2995 | if ( !s->s.SetIPv4() ) { |
13b5cd0c | 2996 | debugs(3, DBG_CRITICAL, "http(s)_port: IPv6 addresses cannot be transparent (protocol does not provide NAT)" << s->s ); |
04f87469 AJ |
2997 | self_destruct(); |
2998 | } | |
2999 | #endif | |
fc68f6b1 | 3000 | } else if (strcmp(token, "tproxy") == 0) { |
26ac0430 | 3001 | if (s->intercepted || s->accel) { |
acaa7194 AJ |
3002 | debugs(3,DBG_CRITICAL, "http(s)_port: TPROXY option requires its own interception port. It cannot be shared."); |
3003 | self_destruct(); | |
3004 | } | |
f165d2fb | 3005 | s->spoof_client_ip = 1; |
85944c1c | 3006 | IpInterceptor.StartTransparency(); |
13b5cd0c AJ |
3007 | /* Log information regarding the port modes under transparency. */ |
3008 | debugs(3, DBG_IMPORTANT, "Starting IP Spoofing on port " << s->s); | |
3009 | debugs(3, DBG_IMPORTANT, "Disabling Authentication on port " << s->s << " (Ip spoofing enabled)"); | |
3010 | ||
cc192b50 | 3011 | #if USE_IPV6 |
04f87469 | 3012 | /* INET6: until target TPROXY is known to work on IPv6 SOCKET, force wildcard to IPv4 */ |
13b5cd0c | 3013 | debugs(3, DBG_IMPORTANT, "Disabling IPv6 on port " << s->s << " (interception enabled)"); |
26ac0430 | 3014 | if ( s->s.IsIPv6() && !s->s.SetIPv4() ) { |
13b5cd0c | 3015 | debugs(3, DBG_CRITICAL, "http(s)_port: IPv6 addresses cannot be transparent (protocol does not provide NAT)" << s->s ); |
cc192b50 | 3016 | self_destruct(); |
3017 | } | |
cc192b50 | 3018 | #endif |
f1e0717c | 3019 | |
cc192b50 | 3020 | } else if (strcmp(token, "ipv4") == 0) { |
3021 | #if USE_IPV6 | |
26ac0430 | 3022 | if ( !s->s.SetIPv4() ) { |
cc192b50 | 3023 | debugs(3, 0, "http(s)_port: IPv6 addresses cannot be used a IPv4-Only." << s->s ); |
3024 | self_destruct(); | |
3025 | } | |
fc68f6b1 | 3026 | #endif |
26ac0430 AJ |
3027 | } else if (strcmp(token, "tcpkeepalive") == 0) { |
3028 | s->tcp_keepalive.enabled = 1; | |
b2130d58 | 3029 | } else if (strncmp(token, "tcpkeepalive=", 13) == 0) { |
26ac0430 AJ |
3030 | char *t = token + 13; |
3031 | s->tcp_keepalive.enabled = 1; | |
3032 | s->tcp_keepalive.idle = atoi(t); | |
3033 | t = strchr(t, ','); | |
3034 | if (t) { | |
3035 | t++; | |
3036 | s->tcp_keepalive.interval = atoi(t); | |
3037 | t = strchr(t, ','); | |
3038 | } | |
3039 | if (t) { | |
3040 | t++; | |
3041 | s->tcp_keepalive.timeout = atoi(t); | |
3042 | t = strchr(t, ','); | |
3043 | } | |
154dc884 | 3044 | #if USE_SSL |
3045 | } else if (strncmp(token, "cert=", 5) == 0) { | |
3046 | safe_free(s->cert); | |
3047 | s->cert = xstrdup(token + 5); | |
3048 | } else if (strncmp(token, "key=", 4) == 0) { | |
3049 | safe_free(s->key); | |
3050 | s->key = xstrdup(token + 4); | |
3051 | } else if (strncmp(token, "version=", 8) == 0) { | |
3052 | s->version = xatoi(token + 8); | |
3053 | ||
3054 | if (s->version < 1 || s->version > 4) | |
3055 | self_destruct(); | |
3056 | } else if (strncmp(token, "options=", 8) == 0) { | |
3057 | safe_free(s->options); | |
3058 | s->options = xstrdup(token + 8); | |
3059 | } else if (strncmp(token, "cipher=", 7) == 0) { | |
3060 | safe_free(s->cipher); | |
3061 | s->cipher = xstrdup(token + 7); | |
3062 | } else if (strncmp(token, "clientca=", 9) == 0) { | |
3063 | safe_free(s->clientca); | |
3064 | s->clientca = xstrdup(token + 9); | |
3065 | } else if (strncmp(token, "cafile=", 7) == 0) { | |
3066 | safe_free(s->cafile); | |
3067 | s->cafile = xstrdup(token + 7); | |
3068 | } else if (strncmp(token, "capath=", 7) == 0) { | |
3069 | safe_free(s->capath); | |
3070 | s->capath = xstrdup(token + 7); | |
3071 | } else if (strncmp(token, "crlfile=", 8) == 0) { | |
3072 | safe_free(s->crlfile); | |
3073 | s->crlfile = xstrdup(token + 8); | |
3074 | } else if (strncmp(token, "dhparams=", 9) == 0) { | |
3075 | safe_free(s->dhfile); | |
3076 | s->dhfile = xstrdup(token + 9); | |
3077 | } else if (strncmp(token, "sslflags=", 9) == 0) { | |
3078 | safe_free(s->sslflags); | |
3079 | s->sslflags = xstrdup(token + 9); | |
3080 | } else if (strncmp(token, "sslcontext=", 11) == 0) { | |
3081 | safe_free(s->sslcontext); | |
3082 | s->sslcontext = xstrdup(token + 11); | |
3083 | } else if (strcmp(token, "sslBump") == 0) { | |
3084 | s->sslBump = 1; // accelerated when bumped, otherwise not | |
3085 | #endif | |
3f38a55e | 3086 | } else { |
62e76326 | 3087 | self_destruct(); |
3f38a55e | 3088 | } |
acaa7194 | 3089 | |
26ac0430 | 3090 | if ( s->spoof_client_ip && (s->intercepted || s->accel) ) { |
acaa7194 AJ |
3091 | debugs(3,DBG_CRITICAL, "http(s)_port: TPROXY option requires its own interception port. It cannot be shared."); |
3092 | self_destruct(); | |
3093 | } | |
3f38a55e | 3094 | } |
3095 | ||
3f38a55e | 3096 | static http_port_list * |
3097 | create_http_port(char *portspec) | |
3098 | { | |
154dc884 | 3099 | http_port_list *s = new http_port_list("http"); |
3f38a55e | 3100 | parse_http_port_specification(s, portspec); |
3101 | return s; | |
3102 | } | |
3103 | ||
3104 | void | |
3105 | add_http_port(char *portspec) | |
3106 | { | |
3107 | http_port_list *s = create_http_port(portspec); | |
3108 | s->next = Config.Sockaddr.http; | |
3109 | Config.Sockaddr.http = s; | |
3110 | } | |
3111 | ||
3112 | static void | |
3113 | parse_http_port_list(http_port_list ** head) | |
3114 | { | |
3115 | char *token = strtok(NULL, w_space); | |
62e76326 | 3116 | |
9eeb8e4b | 3117 | if (!token) { |
62e76326 | 3118 | self_destruct(); |
9eeb8e4b | 3119 | return; |
3120 | } | |
62e76326 | 3121 | |
3f38a55e | 3122 | http_port_list *s = create_http_port(token); |
62e76326 | 3123 | |
3f38a55e | 3124 | /* parse options ... */ |
3125 | while ((token = strtok(NULL, w_space))) { | |
62e76326 | 3126 | parse_http_port_option(s, token); |
3f38a55e | 3127 | } |
62e76326 | 3128 | |
3f38a55e | 3129 | while (*head) |
62e76326 | 3130 | head = &(*head)->next; |
3131 | ||
3f38a55e | 3132 | *head = s; |
3133 | } | |
3134 | ||
3135 | static void | |
3136 | dump_generic_http_port(StoreEntry * e, const char *n, const http_port_list * s) | |
3137 | { | |
cc192b50 | 3138 | char buf[MAX_IPSTRLEN]; |
3139 | ||
3140 | storeAppendPrintf(e, "%s %s", | |
62e76326 | 3141 | n, |
cc192b50 | 3142 | s->s.ToURL(buf,MAX_IPSTRLEN)); |
62e76326 | 3143 | |
3f38a55e | 3144 | if (s->defaultsite) |
62e76326 | 3145 | storeAppendPrintf(e, " defaultsite=%s", s->defaultsite); |
3146 | ||
2ad20b4f AJ |
3147 | if (s->intercepted) |
3148 | storeAppendPrintf(e, " intercept"); | |
62e76326 | 3149 | |
3f38a55e | 3150 | if (s->vhost) |
62e76326 | 3151 | storeAppendPrintf(e, " vhost"); |
3152 | ||
3f38a55e | 3153 | if (s->vport) |
62e76326 | 3154 | storeAppendPrintf(e, " vport"); |
5529ca8a | 3155 | |
d67acb4e AJ |
3156 | if (s->connection_auth_disabled) |
3157 | storeAppendPrintf(e, " connection-auth=off"); | |
3158 | else | |
3159 | storeAppendPrintf(e, " connection-auth=on"); | |
3160 | ||
5529ca8a | 3161 | if (s->disable_pmtu_discovery != DISABLE_PMTU_OFF) { |
3162 | const char *pmtu; | |
3163 | ||
3164 | if (s->disable_pmtu_discovery == DISABLE_PMTU_ALWAYS) | |
3165 | pmtu = "always"; | |
3166 | else | |
3167 | pmtu = "transparent"; | |
3168 | ||
3169 | storeAppendPrintf(e, " disable-pmtu-discovery=%s", pmtu); | |
3170 | } | |
b2130d58 | 3171 | |
3172 | if (s->tcp_keepalive.enabled) { | |
26ac0430 AJ |
3173 | if (s->tcp_keepalive.idle || s->tcp_keepalive.interval || s->tcp_keepalive.timeout) { |
3174 | storeAppendPrintf(e, " tcp_keepalive=%d,%d,%d", s->tcp_keepalive.idle, s->tcp_keepalive.interval, s->tcp_keepalive.timeout); | |
3175 | } else { | |
3176 | storeAppendPrintf(e, " tcp_keepalive"); | |
3177 | } | |
b2130d58 | 3178 | } |
154dc884 | 3179 | |
3180 | #if USE_SSL | |
26ac0430 AJ |
3181 | if (s->cert) |
3182 | storeAppendPrintf(e, " cert=%s", s->cert); | |
154dc884 | 3183 | |
26ac0430 AJ |
3184 | if (s->key) |
3185 | storeAppendPrintf(e, " key=%s", s->key); | |
154dc884 | 3186 | |
26ac0430 AJ |
3187 | if (s->version) |
3188 | storeAppendPrintf(e, " version=%d", s->version); | |
154dc884 | 3189 | |
26ac0430 AJ |
3190 | if (s->options) |
3191 | storeAppendPrintf(e, " options=%s", s->options); | |
154dc884 | 3192 | |
26ac0430 AJ |
3193 | if (s->cipher) |
3194 | storeAppendPrintf(e, " cipher=%s", s->cipher); | |
154dc884 | 3195 | |
26ac0430 AJ |
3196 | if (s->cafile) |
3197 | storeAppendPrintf(e, " cafile=%s", s->cafile); | |
154dc884 | 3198 | |
26ac0430 AJ |
3199 | if (s->capath) |
3200 | storeAppendPrintf(e, " capath=%s", s->capath); | |
154dc884 | 3201 | |
26ac0430 AJ |
3202 | if (s->crlfile) |
3203 | storeAppendPrintf(e, " crlfile=%s", s->crlfile); | |
154dc884 | 3204 | |
26ac0430 AJ |
3205 | if (s->dhfile) |
3206 | storeAppendPrintf(e, " dhparams=%s", s->dhfile); | |
154dc884 | 3207 | |
26ac0430 AJ |
3208 | if (s->sslflags) |
3209 | storeAppendPrintf(e, " sslflags=%s", s->sslflags); | |
154dc884 | 3210 | |
26ac0430 AJ |
3211 | if (s->sslcontext) |
3212 | storeAppendPrintf(e, " sslcontext=%s", s->sslcontext); | |
154dc884 | 3213 | |
26ac0430 AJ |
3214 | if (s->sslBump) |
3215 | storeAppendPrintf(e, " sslBump"); | |
154dc884 | 3216 | #endif |
3f38a55e | 3217 | } |
62e76326 | 3218 | |
3f38a55e | 3219 | static void |
3220 | dump_http_port_list(StoreEntry * e, const char *n, const http_port_list * s) | |
3221 | { | |
3222 | while (s) { | |
62e76326 | 3223 | dump_generic_http_port(e, n, s); |
3224 | storeAppendPrintf(e, "\n"); | |
3225 | s = s->next; | |
3f38a55e | 3226 | } |
3227 | } | |
3228 | ||
3229 | static void | |
3230 | free_http_port_list(http_port_list ** head) | |
3231 | { | |
3232 | http_port_list *s; | |
62e76326 | 3233 | |
3f38a55e | 3234 | while ((s = *head) != NULL) { |
62e76326 | 3235 | *head = s->next; |
154dc884 | 3236 | delete s; |
3f38a55e | 3237 | } |
3238 | } | |
3239 | ||
3f38a55e | 3240 | #if USE_SSL |
3f38a55e | 3241 | |
154dc884 | 3242 | // TODO: merge better with parse_http_port_list |
3f38a55e | 3243 | static void |
3244 | parse_https_port_list(https_port_list ** head) | |
3245 | { | |
3f38a55e | 3246 | char *token; |
3247 | https_port_list *s; | |
154dc884 | 3248 | |
3f38a55e | 3249 | token = strtok(NULL, w_space); |
62e76326 | 3250 | |
3f38a55e | 3251 | if (!token) |
62e76326 | 3252 | self_destruct(); |
3253 | ||
154dc884 | 3254 | s = new https_port_list; |
3f38a55e | 3255 | parse_http_port_specification(&s->http, token); |
62e76326 | 3256 | |
d193a436 | 3257 | /* parse options ... */ |
3258 | while ((token = strtok(NULL, w_space))) { | |
154dc884 | 3259 | parse_http_port_option(s, token); |
d193a436 | 3260 | } |
62e76326 | 3261 | |
8abf232c | 3262 | while (*head) { |
3263 | http_port_list ** headTmp = &(*head)->http.next; | |
3264 | head = (https_port_list **)headTmp; | |
3265 | } | |
62e76326 | 3266 | |
d193a436 | 3267 | *head = s; |
3268 | } | |
3269 | ||
3270 | static void | |
3271 | dump_https_port_list(StoreEntry * e, const char *n, const https_port_list * s) | |
3272 | { | |
154dc884 | 3273 | dump_http_port_list(e, n, s); |
d193a436 | 3274 | } |
3275 | ||
3276 | static void | |
3277 | free_https_port_list(https_port_list ** head) | |
3278 | { | |
154dc884 | 3279 | free_http_port_list((http_port_list**)head); |
d193a436 | 3280 | } |
3281 | ||
3282 | #if 0 | |
3283 | static int | |
3284 | check_null_https_port_list(const https_port_list * s) | |
3285 | { | |
3286 | return NULL == s; | |
3287 | } | |
62e76326 | 3288 | |
d193a436 | 3289 | #endif |
3290 | ||
3291 | #endif /* USE_SSL */ | |
3292 | ||
f150dd4b | 3293 | void |
3294 | configFreeMemory(void) | |
3295 | { | |
23ff6968 | 3296 | free_all(); |
f150dd4b | 3297 | } |
f0b19334 | 3298 | |
94439e4e | 3299 | void |
f0b19334 | 3300 | requirePathnameExists(const char *name, const char *path) |
3301 | { | |
62e76326 | 3302 | |
f0b19334 | 3303 | struct stat sb; |
08577e16 | 3304 | char pathbuf[BUFSIZ]; |
f0b19334 | 3305 | assert(path != NULL); |
62e76326 | 3306 | |
0b796acd | 3307 | if (Config.chroot_dir && (geteuid() == 0)) { |
62e76326 | 3308 | snprintf(pathbuf, BUFSIZ, "%s/%s", Config.chroot_dir, path); |
3309 | path = pathbuf; | |
08577e16 | 3310 | } |
62e76326 | 3311 | |
a572d8be | 3312 | if (stat(path, &sb) < 0) { |
3313 | if (opt_send_signal == -1 || opt_send_signal == SIGHUP) | |
3314 | fatalf("%s %s: %s", name, path, xstrerror()); | |
3315 | else | |
3316 | fprintf(stderr, "WARNING: %s %s: %s\n", name, path, xstrerror()); | |
3317 | } | |
f0b19334 | 3318 | } |
d860a1aa | 3319 | |
3320 | char * | |
3321 | strtokFile(void) | |
3322 | { | |
d295d770 | 3323 | return ConfigParser::strtokFile(); |
d860a1aa | 3324 | } |
7684c4b1 | 3325 | |
450e0c10 | 3326 | #include "AccessLogEntry.h" |
3327 | /* TODO: split out parsing somehow ...*/ | |
7684c4b1 | 3328 | static void |
3329 | parse_logformat(logformat ** logformat_definitions) | |
3330 | { | |
3331 | logformat *nlf; | |
3332 | char *name, *def; | |
3333 | ||
3334 | if ((name = strtok(NULL, w_space)) == NULL) | |
3335 | self_destruct(); | |
3336 | ||
9eeb8e4b | 3337 | if ((def = strtok(NULL, "\r\n")) == NULL) { |
7684c4b1 | 3338 | self_destruct(); |
9eeb8e4b | 3339 | return; |
3340 | } | |
7684c4b1 | 3341 | |
bf8fe701 | 3342 | debugs(3, 2, "Logformat for '" << name << "' is '" << def << "'"); |
7684c4b1 | 3343 | |
3344 | nlf = (logformat *)xcalloc(1, sizeof(logformat)); | |
3345 | ||
3346 | nlf->name = xstrdup(name); | |
3347 | ||
9eeb8e4b | 3348 | if (!accessLogParseLogFormat(&nlf->format, def)) { |
7684c4b1 | 3349 | self_destruct(); |
9eeb8e4b | 3350 | return; |
3351 | } | |
7684c4b1 | 3352 | |
3353 | nlf->next = *logformat_definitions; | |
3354 | ||
3355 | *logformat_definitions = nlf; | |
3356 | } | |
3357 | ||
3358 | static void | |
3359 | parse_access_log(customlog ** logs) | |
3360 | { | |
3361 | const char *filename, *logdef_name; | |
3362 | customlog *cl; | |
3363 | logformat *lf; | |
3364 | ||
3365 | cl = (customlog *)xcalloc(1, sizeof(*cl)); | |
3366 | ||
9eeb8e4b | 3367 | if ((filename = strtok(NULL, w_space)) == NULL) { |
7684c4b1 | 3368 | self_destruct(); |
9eeb8e4b | 3369 | return; |
3370 | } | |
7684c4b1 | 3371 | |
3372 | if (strcmp(filename, "none") == 0) { | |
3373 | cl->type = CLF_NONE; | |
3374 | goto done; | |
3375 | } | |
3376 | ||
3377 | if ((logdef_name = strtok(NULL, w_space)) == NULL) | |
3378 | logdef_name = "auto"; | |
3379 | ||
bf8fe701 | 3380 | debugs(3, 9, "Log definition name '" << logdef_name << "' file '" << filename << "'"); |
7684c4b1 | 3381 | |
3382 | cl->filename = xstrdup(filename); | |
3383 | ||
3384 | /* look for the definition pointer corresponding to this name */ | |
3385 | lf = Config.Log.logformats; | |
3386 | ||
3387 | while (lf != NULL) { | |
bf8fe701 | 3388 | debugs(3, 9, "Comparing against '" << lf->name << "'"); |
7684c4b1 | 3389 | |
3390 | if (strcmp(lf->name, logdef_name) == 0) | |
3391 | break; | |
3392 | ||
3393 | lf = lf->next; | |
3394 | } | |
3395 | ||
3396 | if (lf != NULL) { | |
3397 | cl->type = CLF_CUSTOM; | |
3398 | cl->logFormat = lf; | |
3399 | } else if (strcmp(logdef_name, "auto") == 0) { | |
3400 | cl->type = CLF_AUTO; | |
3401 | } else if (strcmp(logdef_name, "squid") == 0) { | |
3402 | cl->type = CLF_SQUID; | |
3403 | } else if (strcmp(logdef_name, "common") == 0) { | |
3404 | cl->type = CLF_COMMON; | |
3405 | } else { | |
bf8fe701 | 3406 | debugs(3, 0, "Log format '" << logdef_name << "' is not defined"); |
7684c4b1 | 3407 | self_destruct(); |
9eeb8e4b | 3408 | return; |
7684c4b1 | 3409 | } |
3410 | ||
3411 | done: | |
a9f20260 | 3412 | aclParseAclList(LegacyParser, &cl->aclList); |
7684c4b1 | 3413 | |
3414 | while (*logs) | |
3415 | logs = &(*logs)->next; | |
3416 | ||
3417 | *logs = cl; | |
3418 | } | |
3419 | ||
d64bef4c | 3420 | static int |
3421 | check_null_access_log(customlog *customlog_definitions) | |
3422 | { | |
3423 | return customlog_definitions == NULL; | |
3424 | } | |
3425 | ||
7684c4b1 | 3426 | static void |
3427 | dump_logformat(StoreEntry * entry, const char *name, logformat * definitions) | |
3428 | { | |
3429 | accessLogDumpLogFormat(entry, name, definitions); | |
3430 | } | |
3431 | ||
3432 | static void | |
3433 | dump_access_log(StoreEntry * entry, const char *name, customlog * logs) | |
3434 | { | |
3435 | customlog *log; | |
3436 | ||
3437 | for (log = logs; log; log = log->next) { | |
3438 | storeAppendPrintf(entry, "%s ", name); | |
3439 | ||
3440 | switch (log->type) { | |
3441 | ||
3442 | case CLF_CUSTOM: | |
3443 | storeAppendPrintf(entry, "%s %s", log->filename, log->logFormat->name); | |
3444 | break; | |
3445 | ||
3446 | case CLF_NONE: | |
3447 | storeAppendPrintf(entry, "none"); | |
3448 | break; | |
3449 | ||
3450 | case CLF_SQUID: | |
3451 | storeAppendPrintf(entry, "%s squid", log->filename); | |
3452 | break; | |
3453 | ||
3454 | case CLF_COMMON: | |
3455 | storeAppendPrintf(entry, "%s squid", log->filename); | |
3456 | break; | |
3457 | ||
3458 | case CLF_AUTO: | |
3459 | ||
3460 | if (log->aclList) | |
3461 | storeAppendPrintf(entry, "%s auto", log->filename); | |
3462 | else | |
3463 | storeAppendPrintf(entry, "%s", log->filename); | |
3464 | ||
3465 | break; | |
3466 | ||
3467 | case CLF_UNKNOWN: | |
3468 | break; | |
3469 | } | |
3470 | ||
3471 | if (log->aclList) | |
3472 | dump_acl_list(entry, log->aclList); | |
3473 | ||
3474 | storeAppendPrintf(entry, "\n"); | |
3475 | } | |
3476 | } | |
3477 | ||
3478 | static void | |
3479 | free_logformat(logformat ** definitions) | |
3480 | { | |
3481 | while (*definitions) { | |
3482 | logformat *format = *definitions; | |
3483 | *definitions = format->next; | |
61831b4a | 3484 | safe_free(format->name); |
7684c4b1 | 3485 | accessLogFreeLogFormat(&format->format); |
3486 | xfree(format); | |
3487 | } | |
3488 | } | |
3489 | ||
3490 | static void | |
3491 | free_access_log(customlog ** definitions) | |
3492 | { | |
3493 | while (*definitions) { | |
3494 | customlog *log = *definitions; | |
3495 | *definitions = log->next; | |
3496 | ||
3497 | log->logFormat = NULL; | |
3498 | log->type = CLF_UNKNOWN; | |
3499 | ||
3500 | if (log->aclList) | |
3501 | aclDestroyAclList(&log->aclList); | |
3502 | ||
3503 | safe_free(log->filename); | |
3504 | ||
3505 | xfree(log); | |
3506 | } | |
3507 | } | |
3a69ddf3 | 3508 | |
62c7f90e AR |
3509 | #if USE_ADAPTATION |
3510 | ||
3511 | static void | |
3512 | parse_adaptation_service_set_type() | |
3513 | { | |
3514 | Adaptation::Config::ParseServiceSet(); | |
3515 | } | |
3516 | ||
3517 | static void | |
3518 | parse_adaptation_access_type() | |
3519 | { | |
3520 | Adaptation::Config::ParseAccess(LegacyParser); | |
3521 | } | |
3522 | ||
62c7f90e AR |
3523 | #endif /* USE_ADAPTATION */ |
3524 | ||
3525 | ||
3a69ddf3 | 3526 | #if ICAP_CLIENT |
3527 | ||
3528 | static void | |
26cc52cb | 3529 | parse_icap_service_type(Adaptation::Icap::Config * cfg) |
3a69ddf3 | 3530 | { |
462e63d3 | 3531 | cfg->parseService(); |
3a69ddf3 | 3532 | } |
3533 | ||
3534 | static void | |
26cc52cb | 3535 | free_icap_service_type(Adaptation::Icap::Config * cfg) |
3a69ddf3 | 3536 | { |
462e63d3 | 3537 | cfg->freeService(); |
3a69ddf3 | 3538 | } |
3539 | ||
3540 | static void | |
26cc52cb | 3541 | dump_icap_service_type(StoreEntry * entry, const char *name, const Adaptation::Icap::Config &cfg) |
3a69ddf3 | 3542 | { |
462e63d3 | 3543 | cfg.dumpService(entry, name); |
3a69ddf3 | 3544 | } |
3545 | ||
3546 | static void | |
c939dc70 | 3547 | parse_icap_class_type() |
3a69ddf3 | 3548 | { |
62c7f90e | 3549 | debugs(93, 0, "WARNING: 'icap_class' is depricated. " << |
26ac0430 | 3550 | "Use 'adaptation_service_set' instead"); |
62c7f90e | 3551 | Adaptation::Config::ParseServiceSet(); |
3a69ddf3 | 3552 | } |
3553 | ||
3a69ddf3 | 3554 | static void |
c939dc70 | 3555 | parse_icap_access_type() |
3a69ddf3 | 3556 | { |
62c7f90e | 3557 | debugs(93, 0, "WARNING: 'icap_access' is depricated. " << |
26ac0430 | 3558 | "Use 'adaptation_access' instead"); |
21a26d31 | 3559 | Adaptation::Config::ParseAccess(LegacyParser); |
3a69ddf3 | 3560 | } |
3561 | ||
3a69ddf3 | 3562 | #endif |
21a26d31 AR |
3563 | |
3564 | ||
3565 | #if USE_ECAP | |
3566 | ||
3567 | static void | |
574b508c | 3568 | parse_ecap_service_type(Adaptation::Ecap::Config * cfg) |
21a26d31 AR |
3569 | { |
3570 | cfg->parseService(); | |
3571 | } | |
3572 | ||
3573 | static void | |
574b508c | 3574 | free_ecap_service_type(Adaptation::Ecap::Config * cfg) |
21a26d31 AR |
3575 | { |
3576 | cfg->freeService(); | |
3577 | } | |
3578 | ||
3579 | static void | |
574b508c | 3580 | dump_ecap_service_type(StoreEntry * entry, const char *name, const Adaptation::Ecap::Config &cfg) |
21a26d31 AR |
3581 | { |
3582 | cfg.dumpService(entry, name); | |
3583 | } | |
3584 | ||
3585 | #endif /* USE_ECAP */ |