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