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