2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 03 Configuration File Parsing */
13 #include "acl/AclDenyInfoList.h"
14 #include "acl/AclNameList.h"
15 #include "acl/AclSizeLimit.h"
16 #include "acl/Address.h"
17 #include "acl/Gadgets.h"
18 #include "acl/MethodData.h"
20 #include "anyp/PortCfg.h"
21 #include "anyp/UriScheme.h"
23 #include "base/RunnersRegistry.h"
25 #include "CachePeer.h"
26 #include "ConfigParser.h"
27 #include "CpuAffinityMap.h"
28 #include "DiskIO/DiskIOModule.h"
29 #include "eui/Config.h"
30 #include "ExternalACL.h"
31 #include "format/Format.h"
32 #include "ftp/Elements.h"
34 #include "HttpHeaderTools.h"
35 #include "icmp/IcmpConfig.h"
36 #include "ident/Config.h"
37 #include "ip/Intercept.h"
38 #include "ip/QosConfig.h"
41 #include "log/Config.h"
42 #include "log/CustomLog.h"
44 #include "mgr/ActionPasswordList.h"
45 #include "mgr/Registration.h"
46 #include "neighbors.h"
47 #include "NeighborTypeDomainList.h"
50 #include "PeerDigest.h"
51 #include "PeerPoolMgr.h"
53 #include "RefreshPattern.h"
56 #include "SquidConfig.h"
57 #include "SquidString.h"
58 #include "ssl/ProxyCerts.h"
60 #include "StoreFileSystem.h"
65 /* wccp2 has its own conditional definitions */
68 #include "adaptation/Config.h"
71 #include "adaptation/icap/Config.h"
74 #include "adaptation/ecap/Config.h"
77 #include "ssl/Config.h"
78 #include "ssl/support.h"
81 #include "auth/Config.h"
82 #include "auth/Scheme.h"
85 #include "esi/Parser.h"
103 #include <sys/stat.h>
107 #include "ssl/gadgets.h"
111 static void parse_adaptation_service_set_type();
112 static void parse_adaptation_service_chain_type();
113 static void parse_adaptation_access_type();
117 static void parse_icap_service_type(Adaptation::Icap::Config
*);
118 static void dump_icap_service_type(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
119 static void free_icap_service_type(Adaptation::Icap::Config
*);
120 static void parse_icap_class_type();
121 static void parse_icap_access_type();
123 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*);
124 static void dump_icap_service_failure_limit(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
125 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*);
129 static void parse_ecap_service_type(Adaptation::Ecap::Config
*);
130 static void dump_ecap_service_type(StoreEntry
*, const char *, const Adaptation::Ecap::Config
&);
131 static void free_ecap_service_type(Adaptation::Ecap::Config
*);
134 static peer_t
parseNeighborType(const char *s
);
136 static const char *const T_MILLISECOND_STR
= "millisecond";
137 static const char *const T_SECOND_STR
= "second";
138 static const char *const T_MINUTE_STR
= "minute";
139 static const char *const T_HOUR_STR
= "hour";
140 static const char *const T_DAY_STR
= "day";
141 static const char *const T_WEEK_STR
= "week";
142 static const char *const T_FORTNIGHT_STR
= "fortnight";
143 static const char *const T_MONTH_STR
= "month";
144 static const char *const T_YEAR_STR
= "year";
145 static const char *const T_DECADE_STR
= "decade";
147 static const char *const B_BYTES_STR
= "bytes";
148 static const char *const B_KBYTES_STR
= "KB";
149 static const char *const B_MBYTES_STR
= "MB";
150 static const char *const B_GBYTES_STR
= "GB";
152 static const char *const list_sep
= ", \t\n\r";
154 static void parse_access_log(CustomLog
** customlog_definitions
);
155 static int check_null_access_log(CustomLog
*customlog_definitions
);
156 static void dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* definitions
);
157 static void free_access_log(CustomLog
** definitions
);
158 static bool setLogformat(CustomLog
*cl
, const char *name
, const bool dieWhenMissing
);
160 static void configDoConfigure(void);
161 static void parse_refreshpattern(RefreshPattern
**);
162 static uint64_t parseTimeUnits(const char *unit
, bool allowMsec
);
163 static void parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
);
164 static void parse_u_short(unsigned short * var
);
165 static void parse_string(char **);
166 static void default_all(void);
167 static void defaults_if_none(void);
168 static void defaults_postscriptum(void);
169 static int parse_line(char *);
170 static void parse_obsolete(const char *);
171 static void parseBytesLine(size_t * bptr
, const char *units
);
173 static void parseBytesOptionValue(size_t * bptr
, const char *units
, char const * value
);
175 static void parseBytesLineSigned(ssize_t
* bptr
, const char *units
);
176 static size_t parseBytesUnits(const char *unit
);
177 static void free_all(void);
178 void requirePathnameExists(const char *name
, const char *path
);
179 static OBJH dump_config
;
180 #if USE_HTTP_VIOLATIONS
181 static void free_HeaderManglers(HeaderManglers
**pm
);
182 static void dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
183 static void parse_http_header_access(HeaderManglers
**manglers
);
184 #define free_http_header_access free_HeaderManglers
185 static void dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
186 static void parse_http_header_replace(HeaderManglers
**manglers
);
187 #define free_http_header_replace free_HeaderManglers
189 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
);
190 static void parse_HeaderWithAclList(HeaderWithAclList
**header
);
191 static void free_HeaderWithAclList(HeaderWithAclList
**header
);
192 static void parse_note(Notes
*);
193 static void dump_note(StoreEntry
*, const char *, Notes
&);
194 static void free_note(Notes
*);
195 static void parse_denyinfo(AclDenyInfoList
** var
);
196 static void dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
);
197 static void free_denyinfo(AclDenyInfoList
** var
);
200 static void parse_IpAddress_list(Ip::Address_list
**);
201 static void dump_IpAddress_list(StoreEntry
*, const char *, const Ip::Address_list
*);
202 static void free_IpAddress_list(Ip::Address_list
**);
204 static int check_null_IpAddress_list(const Ip::Address_list
*);
205 #endif /* CURRENTLY_UNUSED */
206 #endif /* USE_WCCPv2 */
208 static void parsePortCfg(AnyP::PortCfgPointer
*, const char *protocol
);
209 #define parse_PortCfg(l) parsePortCfg((l), token)
210 static void dump_PortCfg(StoreEntry
*, const char *, const AnyP::PortCfgPointer
&);
211 #define free_PortCfg(h) *(h)=NULL
214 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
215 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
);
216 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
217 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
218 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
);
219 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
220 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
);
221 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
);
222 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
);
223 #endif /* USE_OPENSSL */
225 static void parse_ftp_epsv(acl_access
**ftp_epsv
);
226 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
);
227 static void free_ftp_epsv(acl_access
**ftp_epsv
);
229 static void parse_b_size_t(size_t * var
);
230 static void parse_b_int64_t(int64_t * var
);
232 static bool parseNamedIntList(const char *data
, const String
&name
, std::vector
<int> &list
);
234 static void parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
235 static void dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
);
236 static void free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
238 static void parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
239 static void dump_UrlHelperTimeout(StoreEntry
*, const char *, SquidConfig::UrlHelperTimeout
&);
240 static void free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
242 static int parseOneConfigFile(const char *file_name
, unsigned int depth
);
244 static void parse_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
245 static void dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool recognizeQuotedValues
);
246 static void free_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
247 static void parse_on_unsupported_protocol(acl_access
**access
);
248 static void dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
);
249 static void free_on_unsupported_protocol(acl_access
**access
);
252 * LegacyParser is a parser for legacy code that uses the global
253 * approach. This is static so that it is only exposed to cache_cf.
254 * Other modules needing access to a ConfigParser should have it
255 * provided to them in their parserFOO methods.
257 static ConfigParser LegacyParser
= ConfigParser();
262 LegacyParser
.destruct();
266 SetConfigFilename(char const *file_name
, bool is_pipe
)
269 cfg_filename
= file_name
+ 1;
271 cfg_filename
= file_name
;
275 skip_ws(const char* s
)
284 parseManyConfigFiles(char* files
, int depth
)
287 char* saveptr
= NULL
;
292 memset(&globbuf
, 0, sizeof(globbuf
));
293 for (path
= strwordtok(files
, &saveptr
); path
; path
= strwordtok(NULL
, &saveptr
)) {
294 if (glob(path
, globbuf
.gl_pathc
? GLOB_APPEND
: 0, NULL
, &globbuf
) != 0) {
295 fatalf("Unable to find configuration file: %s: %s",
299 for (i
= 0; i
< (int)globbuf
.gl_pathc
; ++i
) {
300 error_count
+= parseOneConfigFile(globbuf
.gl_pathv
[i
], depth
);
304 char* file
= strwordtok(files
, &saveptr
);
305 while (file
!= NULL
) {
306 error_count
+= parseOneConfigFile(file
, depth
);
307 file
= strwordtok(NULL
, &saveptr
);
309 #endif /* HAVE_GLOB */
314 ReplaceSubstr(char*& str
, int& len
, unsigned substrIdx
, unsigned substrLen
, const char* newSubstr
)
317 assert(newSubstr
!= NULL
);
319 unsigned newSubstrLen
= strlen(newSubstr
);
320 if (newSubstrLen
> substrLen
)
321 str
= (char*)realloc(str
, len
- substrLen
+ newSubstrLen
+ 1);
323 // move tail part including zero
324 memmove(str
+ substrIdx
+ newSubstrLen
, str
+ substrIdx
+ substrLen
, len
- substrIdx
- substrLen
+ 1);
325 // copy new substring in place
326 memcpy(str
+ substrIdx
, newSubstr
, newSubstrLen
);
332 SubstituteMacro(char*& line
, int& len
, const char* macroName
, const char* substStr
)
334 assert(line
!= NULL
);
335 assert(macroName
!= NULL
);
336 assert(substStr
!= NULL
);
337 unsigned macroNameLen
= strlen(macroName
);
338 while (const char* macroPos
= strstr(line
, macroName
)) // we would replace all occurrences
339 ReplaceSubstr(line
, len
, macroPos
- line
, macroNameLen
, substStr
);
343 ProcessMacros(char*& line
, int& len
)
345 SubstituteMacro(line
, len
, "${service_name}", service_name
.c_str());
346 SubstituteMacro(line
, len
, "${process_name}", TheKidName
);
347 SubstituteMacro(line
, len
, "${process_number}", xitoa(KidIdentifier
));
351 trim_trailing_ws(char* str
)
354 unsigned i
= strlen(str
);
355 while ((i
> 0) && xisspace(str
[i
- 1]))
361 FindStatement(const char* line
, const char* statement
)
363 assert(line
!= NULL
);
364 assert(statement
!= NULL
);
366 const char* str
= skip_ws(line
);
367 unsigned len
= strlen(statement
);
368 if (strncmp(str
, statement
, len
) == 0) {
372 else if (xisspace(*str
))
380 StrToInt(const char* str
, long& number
)
385 number
= strtol(str
, &end
, 0);
387 return (end
!= str
) && (*end
== '\0'); // returns true if string contains nothing except number
391 EvalBoolExpr(const char* expr
)
393 assert(expr
!= NULL
);
394 if (strcmp(expr
, "true") == 0) {
396 } else if (strcmp(expr
, "false") == 0) {
398 } else if (const char* equation
= strchr(expr
, '=')) {
399 const char* rvalue
= skip_ws(equation
+ 1);
400 char* lvalue
= (char*)xmalloc(equation
- expr
+ 1);
401 xstrncpy(lvalue
, expr
, equation
- expr
+ 1);
402 trim_trailing_ws(lvalue
);
405 if (!StrToInt(lvalue
, number1
))
406 fatalf("String is not a integer number: '%s'\n", lvalue
);
408 if (!StrToInt(rvalue
, number2
))
409 fatalf("String is not a integer number: '%s'\n", rvalue
);
412 return number1
== number2
;
414 fatalf("Unable to evaluate expression '%s'\n", expr
);
415 return false; // this place cannot be reached
419 parseOneConfigFile(const char *file_name
, unsigned int depth
)
422 const char *orig_cfg_filename
= cfg_filename
;
423 const int orig_config_lineno
= config_lineno
;
425 char *tmp_line
= NULL
;
426 int tmp_line_len
= 0;
430 debugs(3, DBG_IMPORTANT
, "Processing Configuration File: " << file_name
<< " (depth " << depth
<< ")");
432 fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name
);
436 if (file_name
[0] == '!' || file_name
[0] == '|') {
437 fp
= popen(file_name
+ 1, "r");
440 fp
= fopen(file_name
, "r");
444 fatalf("Unable to open configuration file: %s: %s", file_name
, xstrerror());
447 setmode(fileno(fp
), O_TEXT
);
450 SetConfigFilename(file_name
, bool(is_pipe
));
452 memset(config_input_line
, '\0', BUFSIZ
);
456 std::vector
<bool> if_states
;
457 while (fgets(config_input_line
, BUFSIZ
, fp
)) {
460 if ((token
= strchr(config_input_line
, '\n')))
463 if ((token
= strchr(config_input_line
, '\r')))
466 // strip any prefix whitespace off the line.
467 const char *p
= skip_ws(config_input_line
);
468 if (config_input_line
!= p
)
469 memmove(config_input_line
, p
, strlen(p
)+1);
471 if (strncmp(config_input_line
, "#line ", 6) == 0) {
472 static char new_file_name
[1024];
474 static char new_lineno
;
475 token
= config_input_line
+ 6;
476 new_lineno
= strtol(token
, &file
, 0) - 1;
479 continue; /* Not a valid #line directive, may be a comment */
481 while (*file
&& xisspace((unsigned char) *file
))
486 continue; /* Not a valid #line directive, may be a comment */
488 xstrncpy(new_file_name
, file
+ 1, sizeof(new_file_name
));
490 if ((token
= strchr(new_file_name
, '"')))
493 SetConfigFilename(new_file_name
, false);
496 config_lineno
= new_lineno
;
499 if (config_input_line
[0] == '#')
502 if (config_input_line
[0] == '\0')
505 const char* append
= tmp_line_len
? skip_ws(config_input_line
) : config_input_line
;
507 size_t append_len
= strlen(append
);
509 tmp_line
= (char*)xrealloc(tmp_line
, tmp_line_len
+ append_len
+ 1);
511 strcpy(tmp_line
+ tmp_line_len
, append
);
513 tmp_line_len
+= append_len
;
515 if (tmp_line
[tmp_line_len
-1] == '\\') {
516 debugs(3, 5, "parseConfigFile: tmp_line='" << tmp_line
<< "'");
517 tmp_line
[--tmp_line_len
] = '\0';
521 trim_trailing_ws(tmp_line
);
522 ProcessMacros(tmp_line
, tmp_line_len
);
523 debugs(3, (opt_parse_cfg_only
?1:5), "Processing: " << tmp_line
);
525 if (const char* expr
= FindStatement(tmp_line
, "if")) {
526 if_states
.push_back(EvalBoolExpr(expr
)); // store last if-statement meaning
527 } else if (FindStatement(tmp_line
, "endif")) {
528 if (!if_states
.empty())
529 if_states
.pop_back(); // remove last if-statement meaning
531 fatalf("'endif' without 'if'\n");
532 } else if (FindStatement(tmp_line
, "else")) {
533 if (!if_states
.empty())
534 if_states
.back() = !if_states
.back();
536 fatalf("'else' without 'if'\n");
537 } else if (if_states
.empty() || if_states
.back()) { // test last if-statement meaning if present
538 /* Handle includes here */
539 if (tmp_line_len
>= 9 && strncmp(tmp_line
, "include", 7) == 0 && xisspace(tmp_line
[7])) {
540 err_count
+= parseManyConfigFiles(tmp_line
+ 8, depth
+ 1);
541 } else if (!parse_line(tmp_line
)) {
542 debugs(3, DBG_CRITICAL
, HERE
<< cfg_filename
<< ":" << config_lineno
<< " unrecognized: '" << tmp_line
<< "'");
551 if (!if_states
.empty())
552 fatalf("if-statement without 'endif'\n");
555 int ret
= pclose(fp
);
558 fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name
, ret
);
563 SetConfigFilename(orig_cfg_filename
, false);
564 config_lineno
= orig_config_lineno
;
571 parseConfigFile(const char *file_name
)
579 ACLMethodData::ThePurgeCount
= 0;
582 err_count
= parseOneConfigFile(file_name
, 0);
586 defaults_postscriptum();
589 * We must call configDoConfigure() before leave_suid() because
590 * configDoConfigure() is where we turn username strings into
595 if (!Config
.chroot_dir
) {
597 setUmask(Config
.umask
);
598 _db_init(Debug::cache_log
, Debug::debugOptions
);
602 if (opt_send_signal
== -1) {
603 Mgr::RegisterAction("config",
604 "Current Squid Configuration",
613 configDoConfigure(void)
615 memset(&Config2
, '\0', sizeof(SquidConfig2
));
616 /* init memory as early as possible */
620 Config
.cacheSwap
.n_strands
= 0; // no diskers by default
621 if (Config
.cacheSwap
.swapDirs
== NULL
) {
622 /* Memory-only cache probably in effect. */
623 /* turn off the cache rebuild delays... */
624 StoreController::store_dirs_rebuilding
= 0;
625 } else if (InDaemonMode()) { // no diskers in non-daemon mode
626 for (int i
= 0; i
< Config
.cacheSwap
.n_configured
; ++i
) {
627 const RefCount
<SwapDir
> sd
= Config
.cacheSwap
.swapDirs
[i
];
628 if (sd
->needsDiskStrand())
629 sd
->disker
= Config
.workers
+ (++Config
.cacheSwap
.n_strands
);
633 if (Debug::rotateNumber
< 0) {
634 Debug::rotateNumber
= Config
.Log
.rotateNumber
;
637 #if SIZEOF_OFF_T <= 4
638 if (Config
.Store
.maxObjectSize
> 0x7FFF0000) {
639 debugs(3, DBG_CRITICAL
, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
640 Config
.Store
.maxObjectSize
= 0x7FFF0000;
644 if (Config
.Announce
.period
> 0) {
645 Config
.onoff
.announce
= 1;
647 Config
.Announce
.period
= 86400 * 365; /* one year */
648 Config
.onoff
.announce
= 0;
651 if (Config
.onoff
.httpd_suppress_version_string
)
652 visible_appname_string
= (char *)appname_string
;
654 visible_appname_string
= (char const *)APP_FULLNAME
;
656 if (Config
.Program
.redirect
) {
657 if (Config
.redirectChildren
.n_max
< 1) {
658 Config
.redirectChildren
.n_max
= 0;
659 wordlistDestroy(&Config
.Program
.redirect
);
663 if (Config
.Program
.store_id
) {
664 if (Config
.storeIdChildren
.n_max
< 1) {
665 Config
.storeIdChildren
.n_max
= 0;
666 wordlistDestroy(&Config
.Program
.store_id
);
670 if (Config
.appendDomain
)
671 if (*Config
.appendDomain
!= '.')
672 fatal("append_domain must begin with a '.'");
674 if (Config
.errHtmlText
== NULL
)
675 Config
.errHtmlText
= xstrdup(null_string
);
677 #if !HAVE_SETRLIMIT || !defined(RLIMIT_NOFILE)
678 if (Config
.max_filedescriptors
> 0) {
679 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors disabled. Operating System setrlimit(RLIMIT_NOFILE) is missing.");
681 #elif USE_SELECT || USE_SELECT_WIN32
682 if (Config
.max_filedescriptors
> FD_SETSIZE
) {
683 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors limited to " << FD_SETSIZE
<< " by select() algorithm.");
689 snprintf(ThisCache
, sizeof(ThisCache
), "%s (%s)",
691 visible_appname_string
);
694 * the extra space is for loop detection in client_side.c -- we search
695 * for substrings in the Via header.
697 snprintf(ThisCache2
, sizeof(ThisCache
), " %s (%s)",
699 visible_appname_string
);
701 /* Use visible_hostname as default surrogate_id */
702 if (!Config
.Accel
.surrogate_id
) {
703 const char *t
= getMyHostname();
704 Config
.Accel
.surrogate_id
= xstrdup( (t
?t
:"unset-id") );
707 if (!Config
.udpMaxHitObjsz
|| Config
.udpMaxHitObjsz
> SQUID_UDP_SO_SNDBUF
)
708 Config
.udpMaxHitObjsz
= SQUID_UDP_SO_SNDBUF
;
710 if (Config
.appendDomain
)
711 Config
.appendDomainLen
= strlen(Config
.appendDomain
);
713 Config
.appendDomainLen
= 0;
715 if (Config
.connect_retries
> 10) {
716 debugs(0,DBG_CRITICAL
, "WARNING: connect_retries cannot be larger than 10. Resetting to 10.");
717 Config
.connect_retries
= 10;
720 requirePathnameExists("MIME Config Table", Config
.mimeTablePathname
);
723 requirePathnameExists("unlinkd_program", Config
.Program
.unlinkd
);
725 requirePathnameExists("logfile_daemon", Log::TheConfig
.logfile_daemon
);
726 if (Config
.Program
.redirect
)
727 requirePathnameExists("redirect_program", Config
.Program
.redirect
->key
);
729 if (Config
.Program
.store_id
)
730 requirePathnameExists("store_id_program", Config
.Program
.store_id
->key
);
732 requirePathnameExists("Icon Directory", Config
.icons
.directory
);
734 if (Config
.errorDirectory
)
735 requirePathnameExists("Error Directory", Config
.errorDirectory
);
737 #if USE_HTTP_VIOLATIONS
740 const RefreshPattern
*R
;
742 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
743 if (!R
->flags
.override_expire
)
746 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP");
751 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
752 if (!R
->flags
.override_lastmod
)
755 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP");
760 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
761 if (!R
->flags
.reload_into_ims
)
764 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP");
769 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
770 if (!R
->flags
.ignore_reload
)
773 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP");
778 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
779 if (!R
->flags
.ignore_no_store
)
782 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP");
787 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
788 if (!R
->flags
.ignore_private
)
791 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP");
797 #if !USE_HTTP_VIOLATIONS
798 Config
.onoff
.via
= 1;
801 if (!Config
.onoff
.via
)
802 debugs(22, DBG_IMPORTANT
, "WARNING: HTTP requires the use of Via");
806 // we enable runtime PURGE checks if there is at least one PURGE method ACL
807 // TODO: replace with a dedicated "purge" ACL option?
808 Config2
.onoff
.enable_purge
= (ACLMethodData::ThePurgeCount
> 0);
810 Config2
.onoff
.mangle_request_headers
= (Config
.request_header_access
!= NULL
);
812 if (geteuid() == 0) {
813 if (NULL
!= Config
.effectiveUser
) {
815 struct passwd
*pwd
= getpwnam(Config
.effectiveUser
);
819 * Andres Kroonmaa <andre@online.ee>:
820 * Some getpwnam() implementations (Solaris?) require
821 * an available FD < 256 for opening a FILE* to the
824 * This should be safe at startup, but might still fail
825 * during reconfigure.
827 fatalf("getpwnam failed to find userid for effective user '%s'",
828 Config
.effectiveUser
);
832 Config2
.effectiveUserID
= pwd
->pw_uid
;
834 Config2
.effectiveGroupID
= pwd
->pw_gid
;
837 if (pwd
->pw_dir
&& *pwd
->pw_dir
) {
838 // putenv() leaks by design; avoid leaks when nothing changes
840 if (lastDir
.isEmpty() || !lastDir
.cmp(pwd
->pw_dir
)) {
841 lastDir
= pwd
->pw_dir
;
842 int len
= strlen(pwd
->pw_dir
) + 6;
843 char *env_str
= (char *)xcalloc(len
, 1);
844 snprintf(env_str
, len
, "HOME=%s", pwd
->pw_dir
);
851 Config2
.effectiveUserID
= geteuid();
852 Config2
.effectiveGroupID
= getegid();
855 if (NULL
!= Config
.effectiveGroup
) {
857 struct group
*grp
= getgrnam(Config
.effectiveGroup
);
860 fatalf("getgrnam failed to find groupid for effective group '%s'",
861 Config
.effectiveGroup
);
865 Config2
.effectiveGroupID
= grp
->gr_gid
;
868 if (Security::ProxyOutgoingConfig
.encryptTransport
) {
869 debugs(3, DBG_IMPORTANT
, "Initializing https:// proxy context");
870 Config
.ssl_client
.sslContext
= Security::ProxyOutgoingConfig
.createClientContext(false);
871 if (!Config
.ssl_client
.sslContext
) {
873 fatal("ERROR: Could not initialize https:// proxy context");
875 debugs(3, DBG_IMPORTANT
, "ERROR: proxying https:// currently still requires --with-openssl");
880 for (CachePeer
*p
= Config
.peers
; p
!= NULL
; p
= p
->next
) {
882 // default value for ssldomain= is the peer host/IP
883 if (p
->secure
.sslDomain
.isEmpty())
884 p
->secure
.sslDomain
= p
->host
;
886 if (p
->secure
.encryptTransport
) {
887 debugs(3, DBG_IMPORTANT
, "Initializing cache_peer " << p
->name
<< " TLS context");
888 p
->sslContext
= p
->secure
.createClientContext(true);
889 if (!p
->sslContext
) {
890 debugs(3, DBG_CRITICAL
, "ERROR: Could not initialize cache_peer " << p
->name
<< " TLS context");
897 for (AnyP::PortCfgPointer s
= HttpPortList
; s
!= NULL
; s
= s
->next
) {
898 if (!s
->secure
.encryptTransport
)
900 debugs(3, DBG_IMPORTANT
, "Initializing " << AnyP::UriScheme(s
->transport
.protocol
) << "_port " << s
->s
<< " TLS context");
901 s
->configureSslServerContext();
905 // prevent infinite fetch loops in the request parser
906 // due to buffer full but not enough data recived to finish parse
907 if (Config
.maxRequestBufferSize
<= Config
.maxRequestHeaderSize
) {
908 fatalf("Client request buffer of %u bytes cannot hold a request with %u bytes of headers." \
909 " Change client_request_buffer_max or request_header_max_size limits.",
910 (uint32_t)Config
.maxRequestBufferSize
, (uint32_t)Config
.maxRequestHeaderSize
);
914 * Disable client side request pipelining if client_persistent_connections OFF.
915 * Waste of resources queueing any pipelined requests when the first will close the connection.
917 if (Config
.pipeline_max_prefetch
> 0 && !Config
.onoff
.client_pconns
) {
918 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch " << Config
.pipeline_max_prefetch
<<
919 " requires client_persistent_connections ON. Forced pipeline_prefetch 0.");
920 Config
.pipeline_max_prefetch
= 0;
925 * disable client side request pipelining. There is a race with
926 * Negotiate and NTLM when the client sends a second request on an
927 * connection before the authenticate challenge is sent. With
928 * pipelining OFF, the client may fail to authenticate, but squid's
929 * state will be preserved.
931 if (Config
.pipeline_max_prefetch
> 0) {
932 Auth::Config
*nego
= Auth::Config::Find("Negotiate");
933 Auth::Config
*ntlm
= Auth::Config::Find("NTLM");
934 if ((nego
&& nego
->active()) || (ntlm
&& ntlm
->active())) {
935 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch breaks NTLM and Negotiate authentication. Forced pipeline_prefetch 0.");
936 Config
.pipeline_max_prefetch
= 0;
942 /** Parse a line containing an obsolete directive.
943 * To upgrade it where possible instead of just "Bungled config" for
944 * directives which cannot be marked as simply aliases of the some name.
945 * For example if the parameter order and content has changed.
946 * Or if the directive has been completely removed.
949 parse_obsolete(const char *name
)
951 // Directives which have been radically changed rather than removed
952 if (!strcmp(name
, "url_rewrite_concurrency")) {
955 debugs(3, DBG_CRITICAL
, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
956 Config
.redirectChildren
.concurrency
= cval
;
959 if (!strcmp(name
, "log_access"))
962 if (!strcmp(name
, "log_icap"))
965 if (!strcmp(name
, "ignore_ims_on_miss")) {
966 // the replacement directive cache_revalidate_on_miss has opposite meanings for ON/OFF value
967 // than the 2.7 directive. We need to parse and invert the configured value.
970 Config
.onoff
.cache_miss_revalidate
= !temp
;
973 if (!strncmp(name
, "sslproxy_", 9)) {
974 // the replacement directive tls_outgoing_options uses options instead of whole-line input
976 if (!strcmp(name
, "sslproxy_cafile"))
977 tmp
.append("cafile=");
978 else if (!strcmp(name
, "sslproxy_capath"))
979 tmp
.append("capath=");
980 else if (!strcmp(name
, "sslproxy_cipher"))
981 tmp
.append("cipher=");
982 else if (!strcmp(name
, "sslproxy_client_certificate"))
984 else if (!strcmp(name
, "sslproxy_client_key"))
986 else if (!strcmp(name
, "sslproxy_flags"))
987 tmp
.append("flags=");
988 else if (!strcmp(name
, "sslproxy_options"))
989 tmp
.append("options=");
990 else if (!strcmp(name
, "sslproxy_version"))
991 tmp
.append("version=");
993 debugs(3, DBG_CRITICAL
, "ERROR: unknown directive: " << name
);
997 // add the value as unquoted-string because the old values did not support whitespace
998 const char *token
= ConfigParser::NextQuotedOrToEol();
999 tmp
.append(token
, strlen(token
));
1000 Security::ProxyOutgoingConfig
.parse(tmp
.c_str());
1004 /* Parse a time specification from the config file. Store the
1005 * result in 'tptr', after converting it to 'units' */
1007 parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
= false)
1010 if ((u
= parseTimeUnits(units
, allowMsec
)) == 0)
1014 if ((token
= ConfigParser::NextToken()) == NULL
)
1017 double d
= xatof(token
);
1019 time_msec_t m
= u
; /* default to 'units' if none specified */
1022 if ((token
= ConfigParser::PeekAtToken()) && (m
= parseTimeUnits(token
, allowMsec
))) {
1023 (void)ConfigParser::NextToken();
1025 } else if (!expectMoreArguments
) {
1029 token
= NULL
; // show default units if dying below
1030 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" << config_input_line
<< "', assuming " << d
<< " " << units
);
1033 token
= NULL
; // show default units if dying below.
1035 *tptr
= static_cast<time_msec_t
>(m
* d
);
1037 if (static_cast<double>(*tptr
) * 2 != m
* d
* 2) {
1038 debugs(3, DBG_CRITICAL
, "FATAL: Invalid value '" <<
1039 d
<< " " << (token
? token
: units
) << ": integer overflow (time_msec_t).");
1045 parseTimeUnits(const char *unit
, bool allowMsec
)
1047 if (allowMsec
&& !strncasecmp(unit
, T_MILLISECOND_STR
, strlen(T_MILLISECOND_STR
)))
1050 if (!strncasecmp(unit
, T_SECOND_STR
, strlen(T_SECOND_STR
)))
1053 if (!strncasecmp(unit
, T_MINUTE_STR
, strlen(T_MINUTE_STR
)))
1056 if (!strncasecmp(unit
, T_HOUR_STR
, strlen(T_HOUR_STR
)))
1059 if (!strncasecmp(unit
, T_DAY_STR
, strlen(T_DAY_STR
)))
1060 return 86400 * 1000;
1062 if (!strncasecmp(unit
, T_WEEK_STR
, strlen(T_WEEK_STR
)))
1063 return 86400 * 7 * 1000;
1065 if (!strncasecmp(unit
, T_FORTNIGHT_STR
, strlen(T_FORTNIGHT_STR
)))
1066 return 86400 * 14 * 1000;
1068 if (!strncasecmp(unit
, T_MONTH_STR
, strlen(T_MONTH_STR
)))
1069 return static_cast<uint64_t>(86400) * 30 * 1000;
1071 if (!strncasecmp(unit
, T_YEAR_STR
, strlen(T_YEAR_STR
)))
1072 return static_cast<uint64_t>(86400 * 1000 * 365.2522);
1074 if (!strncasecmp(unit
, T_DECADE_STR
, strlen(T_DECADE_STR
)))
1075 return static_cast<uint64_t>(86400 * 1000 * 365.2522 * 10);
1077 debugs(3, DBG_IMPORTANT
, "parseTimeUnits: unknown time unit '" << unit
<< "'");
1083 parseBytesLine64(int64_t * bptr
, const char *units
)
1090 if ((u
= parseBytesUnits(units
)) == 0) {
1095 if ((token
= ConfigParser::NextToken()) == NULL
) {
1100 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1107 m
= u
; /* default to 'units' if none specified */
1111 else if ((token
= ConfigParser::NextToken()) == NULL
)
1112 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1113 config_input_line
<< "', assuming " <<
1114 d
<< " " << units
);
1115 else if ((m
= parseBytesUnits(token
)) == 0) {
1120 *bptr
= static_cast<int64_t>(m
* d
/ u
);
1122 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1123 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1124 d
<< " " << token
<< ": integer overflow (int64_t).");
1130 parseBytesLine(size_t * bptr
, const char *units
)
1137 if ((u
= parseBytesUnits(units
)) == 0) {
1142 if ((token
= ConfigParser::NextToken()) == NULL
) {
1147 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1148 *bptr
= static_cast<size_t>(-1);
1154 m
= u
; /* default to 'units' if none specified */
1158 else if ((token
= ConfigParser::NextToken()) == NULL
)
1159 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1160 config_input_line
<< "', assuming " <<
1161 d
<< " " << units
);
1162 else if ((m
= parseBytesUnits(token
)) == 0) {
1167 *bptr
= static_cast<size_t>(m
* d
/ u
);
1169 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1170 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1171 d
<< " " << token
<< ": integer overflow (size_t).");
1177 parseBytesLineSigned(ssize_t
* bptr
, const char *units
)
1184 if ((u
= parseBytesUnits(units
)) == 0) {
1189 if ((token
= ConfigParser::NextToken()) == NULL
) {
1194 if (strcmp(token
, "none") == 0 || token
[0] == '-' /* -N */) {
1201 m
= u
; /* default to 'units' if none specified */
1205 else if ((token
= ConfigParser::NextToken()) == NULL
)
1206 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1207 config_input_line
<< "', assuming " <<
1208 d
<< " " << units
);
1209 else if ((m
= parseBytesUnits(token
)) == 0) {
1214 *bptr
= static_cast<ssize_t
>(m
* d
/ u
);
1216 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1217 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1218 d
<< " " << token
<< ": integer overflow (ssize_t).");
1224 * Parse bytes from a string.
1225 * Similar to the parseBytesLine function but parses the string value instead of
1226 * the current token value.
1228 static void parseBytesOptionValue(size_t * bptr
, const char *units
, char const * value
)
1231 if ((u
= parseBytesUnits(units
)) == 0) {
1236 // Find number from string beginning.
1237 char const * number_begin
= value
;
1238 char const * number_end
= value
;
1240 while ((*number_end
>= '0' && *number_end
<= '9')) {
1245 number
.limitInit(number_begin
, number_end
- number_begin
);
1247 int d
= xatoi(number
.termedBuf());
1249 if ((m
= parseBytesUnits(number_end
)) == 0) {
1254 *bptr
= static_cast<size_t>(m
* d
/ u
);
1255 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2)
1260 parseBytesUnits(const char *unit
)
1262 if (!strncasecmp(unit
, B_BYTES_STR
, strlen(B_BYTES_STR
)))
1265 if (!strncasecmp(unit
, B_KBYTES_STR
, strlen(B_KBYTES_STR
)))
1268 if (!strncasecmp(unit
, B_MBYTES_STR
, strlen(B_MBYTES_STR
)))
1271 if (!strncasecmp(unit
, B_GBYTES_STR
, strlen(B_GBYTES_STR
)))
1274 debugs(3, DBG_CRITICAL
, "WARNING: Unknown bytes unit '" << unit
<< "'");
1280 dump_SBufList(StoreEntry
* entry
, const SBufList
&words
)
1282 for (SBufList::const_iterator i
= words
.begin(); i
!= words
.end(); ++i
) {
1283 entry
->append(i
->rawContent(), i
->length());
1284 entry
->append(" ",1);
1286 entry
->append("\n",1);
1290 dump_acl(StoreEntry
* entry
, const char *name
, ACL
* ae
)
1292 while (ae
!= NULL
) {
1293 debugs(3, 3, "dump_acl: " << name
<< " " << ae
->name
);
1294 storeAppendPrintf(entry
, "%s %s %s %s ",
1298 ae
->flags
.flagsStr());
1299 dump_SBufList(entry
, ae
->dump());
1305 parse_acl(ACL
** ae
)
1307 ACL::ParseAclLine(LegacyParser
, ae
);
1317 dump_acl_list(StoreEntry
* entry
, ACLList
* head
)
1319 dump_SBufList(entry
, head
->dump());
1323 dump_acl_access(StoreEntry
* entry
, const char *name
, acl_access
* head
)
1326 dump_SBufList(entry
, head
->treeDump(name
,NULL
));
1330 parse_acl_access(acl_access
** head
)
1332 aclParseAccessLine(cfg_directive
, LegacyParser
, head
);
1336 free_acl_access(acl_access
** head
)
1338 aclDestroyAccessList(head
);
1342 dump_address(StoreEntry
* entry
, const char *name
, Ip::Address
&addr
)
1344 char buf
[MAX_IPSTRLEN
];
1345 storeAppendPrintf(entry
, "%s %s\n", name
, addr
.toStr(buf
,MAX_IPSTRLEN
) );
1349 parse_address(Ip::Address
*addr
)
1351 char *token
= ConfigParser::NextToken();
1358 if (!strcmp(token
,"any_addr"))
1360 else if ( (!strcmp(token
,"no_addr")) || (!strcmp(token
,"full_mask")) )
1362 else if ( (*addr
= token
) ) // try parse numeric/IPA
1364 else if (addr
->GetHostByName(token
)) // dont use ipcache
1366 else { // not an IP and not a hostname
1367 debugs(3, DBG_CRITICAL
, "FATAL: invalid IP address or domain name '" << token
<< "'");
1373 free_address(Ip::Address
*addr
)
1379 dump_acl_address(StoreEntry
* entry
, const char *name
, Acl::Address
* head
)
1381 char buf
[MAX_IPSTRLEN
];
1383 for (Acl::Address
*l
= head
; l
; l
= l
->next
) {
1384 if (!l
->addr
.isAnyAddr())
1385 storeAppendPrintf(entry
, "%s %s", name
, l
->addr
.toStr(buf
,MAX_IPSTRLEN
));
1387 storeAppendPrintf(entry
, "%s autoselect", name
);
1389 dump_acl_list(entry
, l
->aclList
);
1391 storeAppendPrintf(entry
, "\n");
1396 parse_acl_address(Acl::Address
** head
)
1398 Acl::Address
*l
= new Acl::Address
;
1399 parse_address(&l
->addr
);
1400 aclParseAclList(LegacyParser
, &l
->aclList
, l
->addr
);
1402 Acl::Address
**tail
= head
;
1404 tail
= &(*tail
)->next
;
1410 free_acl_address(Acl::Address
** head
)
1417 dump_acl_tos(StoreEntry
* entry
, const char *name
, acl_tos
* head
)
1421 for (l
= head
; l
; l
= l
->next
) {
1423 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->tos
);
1425 storeAppendPrintf(entry
, "%s none", name
);
1427 dump_acl_list(entry
, l
->aclList
);
1429 storeAppendPrintf(entry
, "\n");
1434 parse_acl_tos(acl_tos
** head
)
1436 unsigned int tos
; /* Initially uint for strtoui. Casted to tos_t before return */
1437 char *token
= ConfigParser::NextToken();
1444 if (!xstrtoui(token
, NULL
, &tos
, 0, std::numeric_limits
<tos_t
>::max())) {
1449 const unsigned int chTos
= tos
& 0xFC;
1451 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: Tos value '" << tos
<< "' adjusted to '" << chTos
<< "'");
1455 acl_tos
*l
= new acl_tos
;
1457 l
->tos
= (tos_t
)tos
;
1459 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1461 acl_tos
**tail
= head
; /* sane name below */
1463 tail
= &(*tail
)->next
;
1469 free_acl_tos(acl_tos
** head
)
1475 #if SO_MARK && USE_LIBCAP
1478 dump_acl_nfmark(StoreEntry
* entry
, const char *name
, acl_nfmark
* head
)
1480 for (acl_nfmark
*l
= head
; l
; l
= l
->next
) {
1482 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->nfmark
);
1484 storeAppendPrintf(entry
, "%s none", name
);
1486 dump_acl_list(entry
, l
->aclList
);
1488 storeAppendPrintf(entry
, "\n");
1493 parse_acl_nfmark(acl_nfmark
** head
)
1496 char *token
= ConfigParser::NextToken();
1503 if (!xstrtoui(token
, NULL
, &mark
, 0, std::numeric_limits
<nfmark_t
>::max())) {
1508 acl_nfmark
*l
= new acl_nfmark
;
1512 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1514 acl_nfmark
**tail
= head
; /* sane name below */
1516 tail
= &(*tail
)->next
;
1522 free_acl_nfmark(acl_nfmark
** head
)
1527 #endif /* SO_MARK */
1530 dump_acl_b_size_t(StoreEntry
* entry
, const char *name
, AclSizeLimit
* head
)
1532 for (AclSizeLimit
*l
= head
; l
; l
= l
->next
) {
1534 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) l
->size
, B_BYTES_STR
);
1536 storeAppendPrintf(entry
, "%s none", name
);
1538 dump_acl_list(entry
, l
->aclList
);
1540 storeAppendPrintf(entry
, "\n");
1545 parse_acl_b_size_t(AclSizeLimit
** head
)
1547 AclSizeLimit
*l
= new AclSizeLimit
;
1549 parse_b_int64_t(&l
->size
);
1551 aclParseAclList(LegacyParser
, &l
->aclList
, l
->size
);
1553 AclSizeLimit
**tail
= head
; /* sane name below */
1555 tail
= &(*tail
)->next
;
1561 free_acl_b_size_t(AclSizeLimit
** head
)
1569 #include "DelayConfig.h"
1570 #include "DelayPools.h"
1571 /* do nothing - free_delay_pool_count is the magic free function.
1572 * this is why delay_pool_count isn't just marked TYPE: u_short
1574 #define free_delay_pool_class(X)
1575 #define free_delay_pool_access(X)
1576 #define free_delay_pool_rates(X)
1577 #define dump_delay_pool_class(X, Y, Z)
1578 #define dump_delay_pool_access(X, Y, Z)
1579 #define dump_delay_pool_rates(X, Y, Z)
1582 free_delay_pool_count(DelayConfig
* cfg
)
1584 cfg
->freePoolCount();
1588 dump_delay_pool_count(StoreEntry
* entry
, const char *name
, DelayConfig
&cfg
)
1590 cfg
.dumpPoolCount (entry
, name
);
1594 parse_delay_pool_count(DelayConfig
* cfg
)
1596 cfg
->parsePoolCount();
1600 parse_delay_pool_class(DelayConfig
* cfg
)
1602 cfg
->parsePoolClass();
1606 parse_delay_pool_rates(DelayConfig
* cfg
)
1608 cfg
->parsePoolRates();
1612 parse_delay_pool_access(DelayConfig
* cfg
)
1614 cfg
->parsePoolAccess(LegacyParser
);
1620 #include "ClientDelayConfig.h"
1621 /* do nothing - free_client_delay_pool_count is the magic free function.
1622 * this is why client_delay_pool_count isn't just marked TYPE: u_short
1625 #define free_client_delay_pool_access(X)
1626 #define free_client_delay_pool_rates(X)
1627 #define dump_client_delay_pool_access(X, Y, Z)
1628 #define dump_client_delay_pool_rates(X, Y, Z)
1631 free_client_delay_pool_count(ClientDelayConfig
* cfg
)
1633 cfg
->freePoolCount();
1637 dump_client_delay_pool_count(StoreEntry
* entry
, const char *name
, ClientDelayConfig
&cfg
)
1639 cfg
.dumpPoolCount (entry
, name
);
1643 parse_client_delay_pool_count(ClientDelayConfig
* cfg
)
1645 cfg
->parsePoolCount();
1649 parse_client_delay_pool_rates(ClientDelayConfig
* cfg
)
1651 cfg
->parsePoolRates();
1655 parse_client_delay_pool_access(ClientDelayConfig
* cfg
)
1657 cfg
->parsePoolAccess(LegacyParser
);
1661 #if USE_HTTP_VIOLATIONS
1663 dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1666 manglers
->dumpAccess(entry
, name
);
1670 parse_http_header_access(HeaderManglers
**pm
)
1674 if ((t
= ConfigParser::NextToken()) == NULL
) {
1675 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1676 debugs(3, DBG_CRITICAL
, "parse_http_header_access: missing header name.");
1681 *pm
= new HeaderManglers
;
1682 HeaderManglers
*manglers
= *pm
;
1683 headerMangler
*mangler
= manglers
->track(t
);
1686 std::string directive
= "http_header_access ";
1688 aclParseAccessLine(directive
.c_str(), LegacyParser
, &mangler
->access_list
);
1692 free_HeaderManglers(HeaderManglers
**pm
)
1694 // we delete the entire http_header_* mangler configuration at once
1695 if (const HeaderManglers
*manglers
= *pm
) {
1702 dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1705 manglers
->dumpReplacement(entry
, name
);
1709 parse_http_header_replace(HeaderManglers
**pm
)
1713 if ((t
= ConfigParser::NextToken()) == NULL
) {
1714 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1715 debugs(3, DBG_CRITICAL
, "parse_http_header_replace: missing header name.");
1719 const char *value
= ConfigParser::NextQuotedOrToEol();
1722 *pm
= new HeaderManglers
;
1723 HeaderManglers
*manglers
= *pm
;
1724 manglers
->setReplacement(t
, value
);
1730 dump_cachedir(StoreEntry
* entry
, const char *name
, SquidConfig::_cacheSwap swap
)
1736 for (i
= 0; i
< swap
.n_configured
; ++i
) {
1737 s
= dynamic_cast<SwapDir
*>(swap
.swapDirs
[i
].getRaw());
1739 storeAppendPrintf(entry
, "%s %s %s", name
, s
->type(), s
->path
);
1741 storeAppendPrintf(entry
, "\n");
1746 check_null_string(char *s
)
1753 parse_authparam(Auth::ConfigVector
* config
)
1758 if ((type_str
= ConfigParser::NextToken()) == NULL
)
1761 if ((param_str
= ConfigParser::NextToken()) == NULL
)
1764 /* find a configuration for the scheme in the currently parsed configs... */
1765 Auth::Config
*schemeCfg
= Auth::Config::Find(type_str
);
1767 if (schemeCfg
== NULL
) {
1768 /* Create a configuration based on the scheme info */
1769 Auth::Scheme::Pointer theScheme
= Auth::Scheme::Find(type_str
);
1771 if (theScheme
== NULL
) {
1772 debugs(3, DBG_CRITICAL
, "Parsing Config File: Unknown authentication scheme '" << type_str
<< "'.");
1776 config
->push_back(theScheme
->createConfig());
1777 schemeCfg
= Auth::Config::Find(type_str
);
1778 if (schemeCfg
== NULL
) {
1779 debugs(3, DBG_CRITICAL
, "Parsing Config File: Corruption configuring authentication scheme '" << type_str
<< "'.");
1784 schemeCfg
->parse(schemeCfg
, config
->size(), param_str
);
1788 free_authparam(Auth::ConfigVector
* cfg
)
1790 /* Wipe the Auth globals and Detach/Destruct component config + state. */
1793 /* on reconfigure initialize new auth schemes for the new config. */
1794 if (reconfiguring
) {
1800 dump_authparam(StoreEntry
* entry
, const char *name
, Auth::ConfigVector cfg
)
1802 for (Auth::ConfigVector::iterator i
= cfg
.begin(); i
!= cfg
.end(); ++i
)
1803 (*i
)->dump(entry
, name
, (*i
));
1805 #endif /* USE_AUTH */
1807 /* TODO: just return the object, the # is irrelevant */
1809 find_fstype(char *type
)
1811 for (size_t i
= 0; i
< StoreFileSystem::FileSystems().size(); ++i
)
1812 if (strcasecmp(type
, StoreFileSystem::FileSystems().at(i
)->type()) == 0)
1819 parse_cachedir(SquidConfig::_cacheSwap
* swap
)
1823 RefCount
<SwapDir
> sd
;
1827 if ((type_str
= ConfigParser::NextToken()) == NULL
)
1830 if ((path_str
= ConfigParser::NextToken()) == NULL
)
1833 fs
= find_fstype(type_str
);
1836 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: This proxy does not support the '" << type_str
<< "' cache type. Ignoring.");
1840 /* reconfigure existing dir */
1842 for (i
= 0; i
< swap
->n_configured
; ++i
) {
1843 assert (swap
->swapDirs
[i
].getRaw());
1845 if ((strcasecmp(path_str
, dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw())->path
)) == 0) {
1846 /* this is specific to on-fs Stores. The right
1847 * way to handle this is probably to have a mapping
1848 * from paths to stores, and have on-fs stores
1849 * register with that, and lookip in that in their
1850 * own setup logic. RBC 20041225. TODO.
1853 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw());
1855 if (strcmp(sd
->type(), StoreFileSystem::FileSystems().at(fs
)->type()) != 0) {
1856 debugs(3, DBG_CRITICAL
, "ERROR: Can't change type of existing cache_dir " <<
1857 sd
->type() << " " << sd
->path
<< " to " << type_str
<< ". Restart required");
1867 if (swap
->n_configured
> 63) {
1868 /* 7 bits, signed */
1869 debugs(3, DBG_CRITICAL
, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle.");
1870 debugs(3, DBG_CRITICAL
, "WARNING: '" << path_str
<< "' is one to many.");
1875 allocate_new_swapdir(swap
);
1877 swap
->swapDirs
[swap
->n_configured
] = StoreFileSystem::FileSystems().at(fs
)->createSwapDir();
1879 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[swap
->n_configured
].getRaw());
1881 /* parse the FS parameters and options */
1882 sd
->parse(swap
->n_configured
, path_str
);
1884 ++swap
->n_configured
;
1888 peer_type_str(const peer_t type
)
1890 const char * result
;
1902 case PEER_MULTICAST
:
1903 result
= "multicast";
1915 dump_peer(StoreEntry
* entry
, const char *name
, CachePeer
* p
)
1917 NeighborTypeDomainList
*t
;
1918 LOCAL_ARRAY(char, xname
, 128);
1921 storeAppendPrintf(entry
, "%s %s %s %d %d name=%s",
1928 dump_peer_options(entry
, p
);
1931 snprintf(xname
, 128, "cache_peer_access %s", p
->name
);
1932 dump_acl_access(entry
, xname
, p
->access
);
1935 for (t
= p
->typelist
; t
; t
= t
->next
) {
1936 storeAppendPrintf(entry
, "neighbor_type_domain %s %s %s\n",
1938 peer_type_str(t
->type
),
1947 * utility function to prevent getservbyname() being called with a numeric value
1948 * on Windows at least it returns garage results.
1951 isUnsignedNumeric(const char *str
, size_t len
)
1953 if (len
< 1) return false;
1955 for (; len
>0 && *str
; ++str
, --len
) {
1956 if (! isdigit(*str
))
1963 \param proto 'tcp' or 'udp' for protocol
1964 \returns Port the named service is supposed to be listening on.
1966 static unsigned short
1967 GetService(const char *proto
)
1969 struct servent
*port
= NULL
;
1970 /** Parses a port number or service name from the squid.conf */
1971 char *token
= ConfigParser::NextToken();
1972 if (token
== NULL
) {
1974 return 0; /* NEVER REACHED */
1976 /** Returns either the service port number from /etc/services */
1977 if ( !isUnsignedNumeric(token
, strlen(token
)) )
1978 port
= getservbyname(token
, proto
);
1980 return ntohs((unsigned short)port
->s_port
);
1982 /** Or a numeric translation of the config text. */
1983 return xatos(token
);
1987 \returns Port the named TCP service is supposed to be listening on.
1988 \copydoc GetService(const char *proto)
1990 inline unsigned short
1993 return GetService("tcp");
1997 \returns Port the named UDP service is supposed to be listening on.
1998 \copydoc GetService(const char *proto)
2000 inline unsigned short
2003 return GetService("udp");
2007 parse_peer(CachePeer
** head
)
2010 CachePeer
*p
= new CachePeer
;
2012 if ((token
= ConfigParser::NextToken()) == NULL
)
2015 p
->host
= xstrdup(token
);
2017 p
->name
= xstrdup(token
);
2019 if ((token
= ConfigParser::NextToken()) == NULL
)
2022 p
->type
= parseNeighborType(token
);
2024 if (p
->type
== PEER_MULTICAST
) {
2025 p
->options
.no_digest
= true;
2026 p
->options
.no_netdb_exchange
= true;
2029 p
->http_port
= GetTcpService();
2034 p
->icp
.port
= GetUdpService();
2036 while ((token
= ConfigParser::NextToken())) {
2037 if (!strcmp(token
, "proxy-only")) {
2038 p
->options
.proxy_only
= true;
2039 } else if (!strcmp(token
, "no-query")) {
2040 p
->options
.no_query
= true;
2041 } else if (!strcmp(token
, "background-ping")) {
2042 p
->options
.background_ping
= true;
2043 } else if (!strcmp(token
, "no-digest")) {
2044 p
->options
.no_digest
= true;
2045 } else if (!strcmp(token
, "no-tproxy")) {
2046 p
->options
.no_tproxy
= true;
2047 } else if (!strcmp(token
, "multicast-responder")) {
2048 p
->options
.mcast_responder
= true;
2049 #if PEER_MULTICAST_SIBLINGS
2050 } else if (!strcmp(token
, "multicast-siblings")) {
2051 p
->options
.mcast_siblings
= true;
2053 } else if (!strncmp(token
, "weight=", 7)) {
2054 p
->weight
= xatoi(token
+ 7);
2055 } else if (!strncmp(token
, "basetime=", 9)) {
2056 p
->basetime
= xatoi(token
+ 9);
2057 } else if (!strcmp(token
, "closest-only")) {
2058 p
->options
.closest_only
= true;
2059 } else if (!strncmp(token
, "ttl=", 4)) {
2060 p
->mcast
.ttl
= xatoi(token
+ 4);
2062 if (p
->mcast
.ttl
< 0)
2065 if (p
->mcast
.ttl
> 128)
2067 } else if (!strcmp(token
, "default")) {
2068 p
->options
.default_parent
= true;
2069 } else if (!strcmp(token
, "round-robin")) {
2070 p
->options
.roundrobin
= true;
2071 } else if (!strcmp(token
, "weighted-round-robin")) {
2072 p
->options
.weighted_roundrobin
= true;
2074 } else if (!strcmp(token
, "htcp")) {
2075 p
->options
.htcp
= true;
2076 } else if (!strncmp(token
, "htcp=", 5) || !strncmp(token
, "htcp-", 5)) {
2077 /* Note: The htcp- form is deprecated, replaced by htcp= */
2078 p
->options
.htcp
= true;
2079 char *tmp
= xstrdup(token
+5);
2080 char *mode
, *nextmode
;
2081 for (mode
= nextmode
= tmp
; mode
; mode
= nextmode
) {
2082 nextmode
= strchr(mode
, ',');
2087 if (!strcmp(mode
, "no-clr")) {
2088 if (p
->options
.htcp_only_clr
)
2089 fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
2090 p
->options
.htcp_no_clr
= true;
2091 } else if (!strcmp(mode
, "no-purge-clr")) {
2092 p
->options
.htcp_no_purge_clr
= true;
2093 } else if (!strcmp(mode
, "only-clr")) {
2094 if (p
->options
.htcp_no_clr
)
2095 fatalf("parse_peer: can't set htcp no-clr and only-clr simultaneously");
2096 p
->options
.htcp_only_clr
= true;
2097 } else if (!strcmp(mode
, "forward-clr")) {
2098 p
->options
.htcp_forward_clr
= true;
2099 } else if (!strcmp(mode
, "oldsquid")) {
2100 p
->options
.htcp_oldsquid
= true;
2102 fatalf("invalid HTCP mode '%s'", mode
);
2107 } else if (!strcmp(token
, "no-netdb-exchange")) {
2108 p
->options
.no_netdb_exchange
= true;
2110 } else if (!strcmp(token
, "carp")) {
2111 if (p
->type
!= PEER_PARENT
)
2112 fatalf("parse_peer: non-parent carp peer %s/%d\n", p
->host
, p
->http_port
);
2114 p
->options
.carp
= true;
2115 } else if (!strncmp(token
, "carp-key=", 9)) {
2116 if (p
->options
.carp
!= true)
2117 fatalf("parse_peer: carp-key specified on non-carp peer %s/%d\n", p
->host
, p
->http_port
);
2118 p
->options
.carp_key
.set
= true;
2119 char *nextkey
=token
+strlen("carp-key="), *key
=nextkey
;
2120 for (; key
; key
= nextkey
) {
2121 nextkey
=strchr(key
,',');
2122 if (nextkey
) ++nextkey
; // skip the comma, any
2123 if (0==strncmp(key
,"scheme",6)) {
2124 p
->options
.carp_key
.scheme
= true;
2125 } else if (0==strncmp(key
,"host",4)) {
2126 p
->options
.carp_key
.host
= true;
2127 } else if (0==strncmp(key
,"port",4)) {
2128 p
->options
.carp_key
.port
= true;
2129 } else if (0==strncmp(key
,"path",4)) {
2130 p
->options
.carp_key
.path
= true;
2131 } else if (0==strncmp(key
,"params",6)) {
2132 p
->options
.carp_key
.params
= true;
2134 fatalf("invalid carp-key '%s'",key
);
2137 } else if (!strcmp(token
, "userhash")) {
2139 if (p
->type
!= PEER_PARENT
)
2140 fatalf("parse_peer: non-parent userhash peer %s/%d\n", p
->host
, p
->http_port
);
2142 p
->options
.userhash
= true;
2144 fatalf("parse_peer: userhash requires authentication. peer %s/%d\n", p
->host
, p
->http_port
);
2146 } else if (!strcmp(token
, "sourcehash")) {
2147 if (p
->type
!= PEER_PARENT
)
2148 fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p
->host
, p
->http_port
);
2150 p
->options
.sourcehash
= true;
2152 } else if (!strcmp(token
, "no-delay")) {
2154 p
->options
.no_delay
= true;
2156 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option 'no-delay' requires --enable-delay-pools");
2158 } else if (!strncmp(token
, "login=", 6)) {
2159 p
->login
= xstrdup(token
+ 6);
2160 rfc1738_unescape(p
->login
);
2161 } else if (!strncmp(token
, "connect-timeout=", 16)) {
2162 p
->connect_timeout
= xatoi(token
+ 16);
2163 } else if (!strncmp(token
, "connect-fail-limit=", 19)) {
2164 p
->connect_fail_limit
= xatoi(token
+ 19);
2165 #if USE_CACHE_DIGESTS
2166 } else if (!strncmp(token
, "digest-url=", 11)) {
2167 p
->digest_url
= xstrdup(token
+ 11);
2170 } else if (!strcmp(token
, "allow-miss")) {
2171 p
->options
.allow_miss
= true;
2172 } else if (!strncmp(token
, "max-conn=", 9)) {
2173 p
->max_conn
= xatoi(token
+ 9);
2174 } else if (!strncmp(token
, "standby=", 8)) {
2175 p
->standby
.limit
= xatoi(token
+ 8);
2176 } else if (!strcmp(token
, "originserver")) {
2177 p
->options
.originserver
= true;
2178 } else if (!strncmp(token
, "name=", 5)) {
2182 p
->name
= xstrdup(token
+ 5);
2183 } else if (!strncmp(token
, "forceddomain=", 13)) {
2184 safe_free(p
->domain
);
2186 p
->domain
= xstrdup(token
+ 13);
2188 } else if (strncmp(token
, "ssl", 3) == 0) {
2190 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option '" << token
<< "' requires --with-openssl");
2192 p
->secure
.parse(token
+3);
2194 } else if (strncmp(token
, "tls-", 4) == 0) {
2195 p
->secure
.parse(token
+4);
2196 } else if (strcmp(token
, "front-end-https") == 0) {
2197 p
->front_end_https
= 1;
2198 } else if (strcmp(token
, "front-end-https=on") == 0) {
2199 p
->front_end_https
= 1;
2200 } else if (strcmp(token
, "front-end-https=auto") == 0) {
2201 p
->front_end_https
= 2;
2202 } else if (strcmp(token
, "connection-auth=off") == 0) {
2203 p
->connection_auth
= 0;
2204 } else if (strcmp(token
, "connection-auth") == 0) {
2205 p
->connection_auth
= 1;
2206 } else if (strcmp(token
, "connection-auth=on") == 0) {
2207 p
->connection_auth
= 1;
2208 } else if (strcmp(token
, "connection-auth=auto") == 0) {
2209 p
->connection_auth
= 2;
2210 } else if (token
[0] == '#') {
2211 // start of a text comment. stop reading this line.
2214 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Ignoring unknown cache_peer option '" << token
<< "'");
2218 if (peerFindByName(p
->name
))
2219 fatalf("ERROR: cache_peer %s specified twice\n", p
->name
);
2221 if (p
->max_conn
> 0 && p
->max_conn
< p
->standby
.limit
)
2222 fatalf("ERROR: cache_peer %s max-conn=%d is lower than its standby=%d\n", p
->host
, p
->max_conn
, p
->standby
.limit
);
2227 if (p
->connect_fail_limit
< 1)
2228 p
->connect_fail_limit
= 10;
2230 #if USE_CACHE_DIGESTS
2232 if (!p
->options
.no_digest
) {
2233 /* XXX This looks odd.. who has the original pointer
2236 PeerDigest
*pd
= peerDigestCreate(p
);
2237 p
->digest
= cbdataReference(pd
);
2242 p
->index
= ++Config
.npeers
;
2244 while (*head
!= NULL
)
2245 head
= &(*head
)->next
;
2253 free_peer(CachePeer
** P
)
2261 dump_cachemgrpasswd(StoreEntry
* entry
, const char *name
, Mgr::ActionPasswordList
* list
)
2265 while (list
!= NULL
) {
2266 if (strcmp(list
->passwd
, "none") && strcmp(list
->passwd
, "disable"))
2267 storeAppendPrintf(entry
, "%s XXXXXXXXXX", name
);
2269 storeAppendPrintf(entry
, "%s %s", name
, list
->passwd
);
2271 for (w
= list
->actions
; w
!= NULL
; w
= w
->next
) {
2272 storeAppendPrintf(entry
, " %s", w
->key
);
2275 storeAppendPrintf(entry
, "\n");
2281 parse_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2283 char *passwd
= NULL
;
2284 wordlist
*actions
= NULL
;
2285 Mgr::ActionPasswordList
*p
;
2286 Mgr::ActionPasswordList
**P
;
2287 parse_string(&passwd
);
2288 parse_wordlist(&actions
);
2289 p
= new Mgr::ActionPasswordList
;
2291 p
->actions
= actions
;
2293 for (P
= head
; *P
; P
= &(*P
)->next
) {
2295 * See if any of the actions from this line already have a
2296 * password from previous lines. The password checking
2297 * routines in cache_manager.c take the the password from
2298 * the first Mgr::ActionPasswordList that contains the
2299 * requested action. Thus, we should warn users who might
2300 * think they can have two passwords for the same action.
2305 for (w
= (*P
)->actions
; w
; w
= w
->next
) {
2306 for (u
= actions
; u
; u
= u
->next
) {
2307 if (strcmp(w
->key
, u
->key
))
2310 debugs(0, DBG_CRITICAL
, "WARNING: action '" << u
->key
<< "' (line " << config_lineno
<< ") already has a password");
2319 free_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2321 Mgr::ActionPasswordList
*p
;
2323 while ((p
= *head
) != NULL
) {
2326 wordlistDestroy(&p
->actions
);
2332 dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
)
2336 while (var
!= NULL
) {
2337 storeAppendPrintf(entry
, "%s %s", name
, var
->err_page_name
);
2339 for (a
= var
->acl_list
; a
!= NULL
; a
= a
->next
)
2340 storeAppendPrintf(entry
, " %s", a
->name
);
2342 storeAppendPrintf(entry
, "\n");
2349 parse_denyinfo(AclDenyInfoList
** var
)
2351 aclParseDenyInfoLine(var
);
2355 free_denyinfo(AclDenyInfoList
** list
)
2357 AclDenyInfoList
*a
= NULL
;
2358 AclDenyInfoList
*a_next
= NULL
;
2359 AclNameList
*l
= NULL
;
2360 AclNameList
*l_next
= NULL
;
2362 for (a
= *list
; a
; a
= a_next
) {
2363 for (l
= a
->acl_list
; l
; l
= l_next
) {
2365 memFree(l
, MEM_ACL_NAME_LIST
);
2370 memFree(a
, MEM_ACL_DENY_INFO_LIST
);
2378 parse_peer_access(void)
2383 if (!(host
= ConfigParser::NextToken()))
2386 if ((p
= peerFindByName(host
)) == NULL
) {
2387 debugs(15, DBG_CRITICAL
, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2391 std::string directive
= "peer_access ";
2393 aclParseAccessLine(directive
.c_str(), LegacyParser
, &p
->access
);
2397 parse_hostdomaintype(void)
2401 char *domain
= NULL
;
2403 if (!(host
= ConfigParser::NextToken()))
2406 if (!(type
= ConfigParser::NextToken()))
2409 while ((domain
= ConfigParser::NextToken())) {
2410 NeighborTypeDomainList
*l
= NULL
;
2411 NeighborTypeDomainList
**L
= NULL
;
2414 if ((p
= peerFindByName(host
)) == NULL
) {
2415 debugs(15, DBG_CRITICAL
, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2419 l
= static_cast<NeighborTypeDomainList
*>(xcalloc(1, sizeof(NeighborTypeDomainList
)));
2420 l
->type
= parseNeighborType(type
);
2421 l
->domain
= xstrdup(domain
);
2423 for (L
= &(p
->typelist
); *L
; L
= &((*L
)->next
));
2429 dump_int(StoreEntry
* entry
, const char *name
, int var
)
2431 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2449 dump_onoff(StoreEntry
* entry
, const char *name
, int var
)
2451 storeAppendPrintf(entry
, "%s %s\n", name
, var
? "on" : "off");
2455 parse_onoff(int *var
)
2457 char *token
= ConfigParser::NextToken();
2462 if (!strcmp(token
, "on")) {
2464 } else if (!strcmp(token
, "enable")) {
2465 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use 'on'.");
2467 } else if (!strcmp(token
, "off")) {
2469 } else if (!strcmp(token
, "disable")) {
2470 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use 'off'.");
2473 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Boolean options can only be 'on' or 'off'.");
2478 #define free_onoff free_int
2481 dump_tristate(StoreEntry
* entry
, const char *name
, int var
)
2492 storeAppendPrintf(entry
, "%s %s\n", name
, state
);
2496 parse_tristate(int *var
)
2498 char *token
= ConfigParser::NextToken();
2503 if (!strcmp(token
, "on")) {
2505 } else if (!strcmp(token
, "enable")) {
2506 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use value 'on'.");
2508 } else if (!strcmp(token
, "warn")) {
2510 } else if (!strcmp(token
, "off")) {
2512 } else if (!strcmp(token
, "disable")) {
2513 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use value 'off'.");
2516 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Tristate options can only be 'on', 'off', or 'warn'.");
2521 #define free_tristate free_int
2524 parse_pipelinePrefetch(int *var
)
2526 char *token
= ConfigParser::PeekAtToken();
2531 if (!strcmp(token
, "on")) {
2532 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'pipeline_prefetch on' is deprecated. Please update to use 1 (or a higher number).");
2535 (void)ConfigParser::NextToken();
2536 } else if (!strcmp(token
, "off")) {
2537 debugs(0, DBG_PARSE_NOTE(2), "WARNING: 'pipeline_prefetch off' is deprecated. Please update to use '0'.");
2540 (void)ConfigParser::NextToken();
2545 #define free_pipelinePrefetch free_int
2546 #define dump_pipelinePrefetch dump_int
2549 dump_refreshpattern(StoreEntry
* entry
, const char *name
, RefreshPattern
* head
)
2551 while (head
!= NULL
) {
2552 storeAppendPrintf(entry
, "%s%s %s %d %d%% %d",
2554 head
->pattern
.flags
®_ICASE
? " -i" : null_string
,
2555 head
->pattern
.c_str(),
2556 (int) head
->min
/ 60,
2557 (int) (100.0 * head
->pct
+ 0.5),
2558 (int) head
->max
/ 60);
2560 if (head
->max_stale
>= 0)
2561 storeAppendPrintf(entry
, " max-stale=%d", head
->max_stale
);
2563 if (head
->flags
.refresh_ims
)
2564 storeAppendPrintf(entry
, " refresh-ims");
2566 if (head
->flags
.store_stale
)
2567 storeAppendPrintf(entry
, " store-stale");
2569 #if USE_HTTP_VIOLATIONS
2571 if (head
->flags
.override_expire
)
2572 storeAppendPrintf(entry
, " override-expire");
2574 if (head
->flags
.override_lastmod
)
2575 storeAppendPrintf(entry
, " override-lastmod");
2577 if (head
->flags
.reload_into_ims
)
2578 storeAppendPrintf(entry
, " reload-into-ims");
2580 if (head
->flags
.ignore_reload
)
2581 storeAppendPrintf(entry
, " ignore-reload");
2583 if (head
->flags
.ignore_no_store
)
2584 storeAppendPrintf(entry
, " ignore-no-store");
2586 if (head
->flags
.ignore_private
)
2587 storeAppendPrintf(entry
, " ignore-private");
2590 storeAppendPrintf(entry
, "\n");
2597 parse_refreshpattern(RefreshPattern
** head
)
2604 int refresh_ims
= 0;
2605 int store_stale
= 0;
2608 #if USE_HTTP_VIOLATIONS
2610 int override_expire
= 0;
2611 int override_lastmod
= 0;
2612 int reload_into_ims
= 0;
2613 int ignore_reload
= 0;
2614 int ignore_no_store
= 0;
2615 int ignore_private
= 0;
2622 int flags
= REG_EXTENDED
| REG_NOSUB
;
2624 if ((token
= ConfigParser::RegexPattern()) != NULL
) {
2626 if (strcmp(token
, "-i") == 0) {
2628 token
= ConfigParser::RegexPattern();
2629 } else if (strcmp(token
, "+i") == 0) {
2630 flags
&= ~REG_ICASE
;
2631 token
= ConfigParser::RegexPattern();
2636 if (token
== NULL
) {
2637 debugs(3, DBG_CRITICAL
, "FATAL: refresh_pattern missing the regex pattern parameter");
2642 pattern
= xstrdup(token
);
2644 i
= GetInteger(); /* token: min */
2646 /* catch negative and insanely huge values close to 32-bit wrap */
2648 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age negative. Cropped back to zero.");
2651 if (i
> 60*24*365) {
2652 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age too high. Cropped back to 1 year.");
2656 min
= (time_t) (i
* 60); /* convert minutes to seconds */
2658 pct
= GetPercentage(false); /* token: pct . with no limit on size */
2660 i
= GetInteger(); /* token: max */
2662 /* catch negative and insanely huge values close to 32-bit wrap */
2664 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age negative. Cropped back to zero.");
2667 if (i
> 60*24*365) {
2668 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age too high. Cropped back to 1 year.");
2672 max
= (time_t) (i
* 60); /* convert minutes to seconds */
2675 while ((token
= ConfigParser::NextToken()) != NULL
) {
2676 if (!strcmp(token
, "refresh-ims")) {
2678 } else if (!strcmp(token
, "store-stale")) {
2680 } else if (!strncmp(token
, "max-stale=", 10)) {
2681 max_stale
= xatoi(token
+ 10);
2683 #if USE_HTTP_VIOLATIONS
2685 } else if (!strcmp(token
, "override-expire"))
2686 override_expire
= 1;
2687 else if (!strcmp(token
, "override-lastmod"))
2688 override_lastmod
= 1;
2689 else if (!strcmp(token
, "ignore-no-store"))
2690 ignore_no_store
= 1;
2691 else if (!strcmp(token
, "ignore-private"))
2693 else if (!strcmp(token
, "reload-into-ims")) {
2694 reload_into_ims
= 1;
2695 refresh_nocache_hack
= 1;
2696 /* tell client_side.c that this is used */
2697 } else if (!strcmp(token
, "ignore-reload")) {
2699 refresh_nocache_hack
= 1;
2700 /* tell client_side.c that this is used */
2703 } else if (!strcmp(token
, "ignore-no-cache") ||
2704 !strcmp(token
, "ignore-must-revalidate") ||
2705 !strcmp(token
, "ignore-auth")
2707 debugs(22, DBG_PARSE_NOTE(2), "UPGRADE: refresh_pattern option '" << token
<< "' is obsolete. Remove it.");
2709 debugs(22, DBG_CRITICAL
, "refreshAddToList: Unknown option '" << pattern
<< "': " << token
);
2712 if ((errcode
= regcomp(&comp
, pattern
, flags
)) != 0) {
2714 regerror(errcode
, &comp
, errbuf
, sizeof errbuf
);
2715 debugs(22, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
2716 debugs(22, DBG_CRITICAL
, "refreshAddToList: Invalid regular expression '" << pattern
<< "': " << errbuf
);
2721 pct
= pct
< 0.0 ? 0.0 : pct
;
2722 max
= max
< 0 ? 0 : max
;
2723 t
= new RefreshPattern(pattern
, flags
);
2724 t
->pattern
.regex
= comp
;
2730 t
->flags
.refresh_ims
= true;
2733 t
->flags
.store_stale
= true;
2735 t
->max_stale
= max_stale
;
2737 #if USE_HTTP_VIOLATIONS
2739 if (override_expire
)
2740 t
->flags
.override_expire
= true;
2742 if (override_lastmod
)
2743 t
->flags
.override_lastmod
= true;
2745 if (reload_into_ims
)
2746 t
->flags
.reload_into_ims
= true;
2749 t
->flags
.ignore_reload
= true;
2751 if (ignore_no_store
)
2752 t
->flags
.ignore_no_store
= true;
2755 t
->flags
.ignore_private
= true;
2761 head
= &(*head
)->next
;
2769 free_refreshpattern(RefreshPattern
** head
)
2774 #if USE_HTTP_VIOLATIONS
2775 refresh_nocache_hack
= 0;
2781 dump_string(StoreEntry
* entry
, const char *name
, char *var
)
2784 storeAppendPrintf(entry
, "%s %s\n", name
, var
);
2788 parse_string(char **var
)
2790 char *token
= ConfigParser::NextToken();
2796 *var
= xstrdup(token
);
2800 free_string(char **var
)
2806 parse_eol(char *volatile *var
)
2813 unsigned char *token
= (unsigned char *) ConfigParser::NextQuotedOrToEol();
2821 while (*token
&& xisspace(*token
))
2829 *var
= xstrdup((char *) token
);
2832 #define dump_eol dump_string
2833 #define free_eol free_string
2836 parse_TokenOrQuotedString(char **var
)
2838 char *token
= ConfigParser::NextQuotedToken();
2844 *var
= xstrdup(token
);
2847 #define dump_TokenOrQuotedString dump_string
2848 #define free_TokenOrQuotedString free_string
2851 dump_time_t(StoreEntry
* entry
, const char *name
, time_t var
)
2853 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int) var
);
2857 parse_time_t(time_t * var
)
2860 parseTimeLine(&tval
, T_SECOND_STR
, false);
2861 *var
= static_cast<time_t>(tval
/1000);
2865 free_time_t(time_t * var
)
2871 dump_time_msec(StoreEntry
* entry
, const char *name
, time_msec_t var
)
2874 storeAppendPrintf(entry
, "%s %" PRId64
" milliseconds\n", name
, var
);
2876 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int)(var
/1000) );
2880 parse_time_msec(time_msec_t
* var
)
2882 parseTimeLine(var
, T_SECOND_STR
, true);
2886 free_time_msec(time_msec_t
* var
)
2893 dump_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2895 storeAppendPrintf(entry
, "%s %d\n", name
, (int) var
);
2900 dump_b_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2902 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2906 dump_b_ssize_t(StoreEntry
* entry
, const char *name
, ssize_t var
)
2908 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2913 dump_kb_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2915 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_KBYTES_STR
);
2920 dump_b_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2922 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_BYTES_STR
);
2926 dump_kb_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2928 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_KBYTES_STR
);
2933 parse_size_t(size_t * var
)
2942 parse_b_size_t(size_t * var
)
2944 parseBytesLine(var
, B_BYTES_STR
);
2948 parse_b_ssize_t(ssize_t
* var
)
2950 parseBytesLineSigned(var
, B_BYTES_STR
);
2955 parse_kb_size_t(size_t * var
)
2957 parseBytesLine(var
, B_KBYTES_STR
);
2962 parse_b_int64_t(int64_t * var
)
2964 parseBytesLine64(var
, B_BYTES_STR
);
2968 parse_kb_int64_t(int64_t * var
)
2970 parseBytesLine64(var
, B_KBYTES_STR
);
2974 free_size_t(size_t * var
)
2980 free_ssize_t(ssize_t
* var
)
2986 free_b_int64_t(int64_t * var
)
2991 #define free_b_size_t free_size_t
2992 #define free_b_ssize_t free_ssize_t
2993 #define free_kb_size_t free_size_t
2994 #define free_mb_size_t free_size_t
2995 #define free_gb_size_t free_size_t
2996 #define free_kb_int64_t free_b_int64_t
2999 dump_u_short(StoreEntry
* entry
, const char *name
, unsigned short var
)
3001 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
3005 free_u_short(unsigned short * u
)
3011 parse_u_short(unsigned short * var
)
3013 ConfigParser::ParseUShort(var
);
3017 ConfigParser::ParseUShort(unsigned short *var
)
3023 ConfigParser::ParseBool(bool *var
)
3025 int i
= GetInteger();
3036 dump_wordlist(StoreEntry
* entry
, const char *name
, wordlist
* list
)
3038 while (list
!= NULL
) {
3039 storeAppendPrintf(entry
, "%s %s\n", name
, list
->key
);
3045 ConfigParser::ParseWordList(wordlist
** list
)
3047 parse_wordlist(list
);
3051 parse_wordlist(wordlist
** list
)
3054 while ((token
= ConfigParser::NextQuotedToken()))
3055 wordlistAdd(list
, token
);
3058 #if 0 /* now unused */
3060 check_null_wordlist(wordlist
* w
)
3067 check_null_acl_access(acl_access
* a
)
3072 #define free_wordlist wordlistDestroy
3074 #define free_uri_whitespace free_int
3077 parse_uri_whitespace(int *var
)
3079 char *token
= ConfigParser::NextToken();
3084 if (!strcmp(token
, "strip"))
3085 *var
= URI_WHITESPACE_STRIP
;
3086 else if (!strcmp(token
, "deny"))
3087 *var
= URI_WHITESPACE_DENY
;
3088 else if (!strcmp(token
, "allow"))
3089 *var
= URI_WHITESPACE_ALLOW
;
3090 else if (!strcmp(token
, "encode"))
3091 *var
= URI_WHITESPACE_ENCODE
;
3092 else if (!strcmp(token
, "chop"))
3093 *var
= URI_WHITESPACE_CHOP
;
3095 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'uri_whitespace' accepts 'strip', 'deny', 'allow', 'encode', and 'chop'.");
3101 dump_uri_whitespace(StoreEntry
* entry
, const char *name
, int var
)
3105 if (var
== URI_WHITESPACE_ALLOW
)
3107 else if (var
== URI_WHITESPACE_ENCODE
)
3109 else if (var
== URI_WHITESPACE_CHOP
)
3111 else if (var
== URI_WHITESPACE_DENY
)
3116 storeAppendPrintf(entry
, "%s %s\n", name
, s
);
3120 free_removalpolicy(RemovalPolicySettings
** settings
)
3125 free_string(&(*settings
)->type
);
3127 free_wordlist(&(*settings
)->args
);
3135 parse_removalpolicy(RemovalPolicySettings
** settings
)
3138 free_removalpolicy(settings
);
3140 *settings
= new RemovalPolicySettings
;
3142 parse_string(&(*settings
)->type
);
3144 parse_wordlist(&(*settings
)->args
);
3148 dump_removalpolicy(StoreEntry
* entry
, const char *name
, RemovalPolicySettings
* settings
)
3151 storeAppendPrintf(entry
, "%s %s", name
, settings
->type
);
3152 args
= settings
->args
;
3155 storeAppendPrintf(entry
, " %s", args
->key
);
3159 storeAppendPrintf(entry
, "\n");
3163 free_YesNoNone(YesNoNone
*)
3167 parse_YesNoNone(YesNoNone
*option
)
3170 parse_onoff(&value
);
3171 option
->configure(value
> 0);
3175 dump_YesNoNone(StoreEntry
* entry
, const char *name
, YesNoNone
&option
)
3177 if (option
.configured())
3178 dump_onoff(entry
, name
, option
? 1 : 0);
3182 free_memcachemode(SquidConfig
*)
3186 parse_memcachemode(SquidConfig
*)
3188 char *token
= ConfigParser::NextToken();
3192 if (strcmp(token
, "always") == 0) {
3193 Config
.onoff
.memory_cache_first
= 1;
3194 Config
.onoff
.memory_cache_disk
= 1;
3195 } else if (strcmp(token
, "disk") == 0) {
3196 Config
.onoff
.memory_cache_first
= 0;
3197 Config
.onoff
.memory_cache_disk
= 1;
3198 } else if (strncmp(token
, "net", 3) == 0) {
3199 Config
.onoff
.memory_cache_first
= 1;
3200 Config
.onoff
.memory_cache_disk
= 0;
3201 } else if (strcmp(token
, "never") == 0) {
3202 Config
.onoff
.memory_cache_first
= 0;
3203 Config
.onoff
.memory_cache_disk
= 0;
3205 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'memory_cache_mode' accepts 'always', 'disk', 'network', and 'never'.");
3211 dump_memcachemode(StoreEntry
* entry
, const char *name
, SquidConfig
&)
3213 storeAppendPrintf(entry
, "%s ", name
);
3214 if (Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3215 storeAppendPrintf(entry
, "always");
3216 else if (!Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3217 storeAppendPrintf(entry
, "disk");
3218 else if (Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3219 storeAppendPrintf(entry
, "network");
3220 else if (!Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3221 storeAppendPrintf(entry
, "none");
3222 storeAppendPrintf(entry
, "\n");
3225 #include "cf_parser.cci"
3228 parseNeighborType(const char *s
)
3230 if (!strcmp(s
, "parent"))
3233 if (!strcmp(s
, "neighbor"))
3234 return PEER_SIBLING
;
3236 if (!strcmp(s
, "neighbour"))
3237 return PEER_SIBLING
;
3239 if (!strcmp(s
, "sibling"))
3240 return PEER_SIBLING
;
3242 if (!strcmp(s
, "multicast"))
3243 return PEER_MULTICAST
;
3245 debugs(15, DBG_CRITICAL
, "WARNING: Unknown neighbor type: " << s
);
3247 return PEER_SIBLING
;
3252 parse_IpAddress_list(Ip::Address_list
** head
)
3255 Ip::Address_list
*s
;
3258 while ((token
= ConfigParser::NextToken())) {
3259 if (GetHostWithPort(token
, &ipa
)) {
3262 head
= &(*head
)->next
;
3264 s
= static_cast<Ip::Address_list
*>(xcalloc(1, sizeof(*s
)));
3274 dump_IpAddress_list(StoreEntry
* e
, const char *n
, const Ip::Address_list
* s
)
3276 char ntoabuf
[MAX_IPSTRLEN
];
3279 storeAppendPrintf(e
, "%s %s\n",
3281 s
->s
.toStr(ntoabuf
,MAX_IPSTRLEN
));
3287 free_IpAddress_list(Ip::Address_list
** head
)
3289 if (*head
) delete *head
;
3293 #if CURRENTLY_UNUSED
3294 /* This code was previously used by http_port. Left as it really should
3295 * be used by icp_port and htcp_port
3298 check_null_IpAddress_list(const Ip::Address_list
* s
)
3303 #endif /* CURRENTLY_UNUSED */
3304 #endif /* USE_WCCPv2 */
3307 parsePortSpecification(const AnyP::PortCfgPointer
&s
, char *token
)
3310 unsigned short port
= 0;
3314 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3315 s
->name
= xstrdup(token
);
3316 s
->connection_auth_disabled
= false;
3318 const char *portType
= AnyP::UriScheme(s
->transport
.protocol
).c_str();
3320 if (*token
== '[') {
3323 t
= strchr(host
, ']');
3325 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing ']' on IPv6 address: " << token
);
3331 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port in: " << token
);
3334 if (!Ip::EnableIpv6
) {
3335 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: IPv6 is not available.");
3338 port
= xatos(t
+ 1);
3339 } else if ((t
= strchr(token
, ':'))) {
3344 port
= xatos(t
+ 1);
3346 } else if (strtol(token
, &junk
, 10) && !*junk
) {
3347 port
= xatos(token
);
3348 debugs(3, 3, portType
<< "_port: found Listen on Port: " << port
);
3350 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port: " << token
);
3354 if (port
== 0 && host
!= NULL
) {
3355 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: Port cannot be 0: " << token
);
3362 if (!Ip::EnableIpv6
)
3364 debugs(3, 3, portType
<< "_port: found Listen on wildcard address: *:" << s
->s
.port());
3365 } else if ( (s
->s
= host
) ) { /* check/parse numeric IPA */
3367 if (!Ip::EnableIpv6
)
3369 debugs(3, 3, portType
<< "_port: Listen on Host/IP: " << host
<< " --> " << s
->s
);
3370 } else if ( s
->s
.GetHostByName(host
) ) { /* check/parse for FQDN */
3371 /* dont use ipcache */
3372 s
->defaultsite
= xstrdup(host
);
3374 if (!Ip::EnableIpv6
)
3376 debugs(3, 3, portType
<< "_port: found Listen as Host " << s
->defaultsite
<< " on IP: " << s
->s
);
3378 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: failed to resolve Host/IP: " << host
);
3383 /// parses the protocol= option of the *_port directive, returning parsed value
3384 /// unsupported option values result in a fatal error message
3385 /// upper case values required; caller may convert for backward compatibility
3386 static AnyP::ProtocolVersion
3387 parsePortProtocol(const SBuf
&value
)
3389 // HTTP/1.0 not supported because we are version 1.1 which contains a superset of 1.0
3390 // and RFC 2616 requires us to upgrade 1.0 to 1.1
3391 if (value
.cmp("HTTP") == 0 || value
.cmp("HTTP/1.1") == 0)
3392 return AnyP::ProtocolVersion(AnyP::PROTO_HTTP
, 1,1);
3394 if (value
.cmp("HTTPS") == 0 || value
.cmp("HTTPS/1.1") == 0)
3395 return AnyP::ProtocolVersion(AnyP::PROTO_HTTPS
, 1,1);
3397 if (value
.cmp("FTP") == 0)
3398 return Ftp::ProtocolVersion();
3400 fatalf("%s directive does not support protocol=" SQUIDSBUFPH
"\n", cfg_directive
, SQUIDSBUFPRINT(value
));
3401 return AnyP::ProtocolVersion(); // not reached
3405 parse_port_option(AnyP::PortCfgPointer
&s
, char *token
)
3409 if (strcmp(token
, "accel") == 0) {
3410 if (s
->flags
.isIntercepted()) {
3411 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Accelerator mode requires its own port. It cannot be shared with other modes.");
3414 s
->flags
.accelSurrogate
= true;
3416 } else if (strcmp(token
, "transparent") == 0 || strcmp(token
, "intercept") == 0) {
3417 if (s
->flags
.accelSurrogate
|| s
->flags
.tproxyIntercept
) {
3418 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Intercept mode requires its own interception port. It cannot be shared with other modes.");
3421 s
->flags
.natIntercept
= true;
3422 Ip::Interceptor
.StartInterception();
3423 /* Log information regarding the port modes under interception. */
3424 debugs(3, DBG_IMPORTANT
, "Starting Authentication on port " << s
->s
);
3425 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (interception enabled)");
3426 } else if (strcmp(token
, "tproxy") == 0) {
3427 if (s
->flags
.natIntercept
|| s
->flags
.accelSurrogate
) {
3428 debugs(3,DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY option requires its own interception port. It cannot be shared with other modes.");
3431 s
->flags
.tproxyIntercept
= true;
3432 Ip::Interceptor
.StartTransparency();
3433 /* Log information regarding the port modes under transparency. */
3434 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (TPROXY enabled)");
3436 if (s
->flags
.proxySurrogate
) {
3437 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3440 if (!Ip::Interceptor
.ProbeForTproxy(s
->s
)) {
3441 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY support in the system does not work.");
3445 } else if (strcmp(token
, "require-proxy-header") == 0) {
3446 s
->flags
.proxySurrogate
= true;
3447 if (s
->flags
.tproxyIntercept
) {
3448 // receiving is still permitted, so we do not unset the TPROXY flag
3449 // spoofing access control override takes care of the spoof disable later
3450 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3453 } else if (strncmp(token
, "defaultsite=", 12) == 0) {
3454 if (!s
->flags
.accelSurrogate
) {
3455 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": defaultsite option requires Acceleration mode flag.");
3458 safe_free(s
->defaultsite
);
3459 s
->defaultsite
= xstrdup(token
+ 12);
3460 } else if (strcmp(token
, "vhost") == 0) {
3461 if (!s
->flags
.accelSurrogate
) {
3462 debugs(3, DBG_CRITICAL
, "WARNING: " << cfg_directive
<< ": vhost option is deprecated. Use 'accel' mode flag instead.");
3464 s
->flags
.accelSurrogate
= true;
3466 } else if (strcmp(token
, "no-vhost") == 0) {
3467 if (!s
->flags
.accelSurrogate
) {
3468 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": no-vhost option requires Acceleration mode flag.");
3471 } else if (strcmp(token
, "vport") == 0) {
3472 if (!s
->flags
.accelSurrogate
) {
3473 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3477 } else if (strncmp(token
, "vport=", 6) == 0) {
3478 if (!s
->flags
.accelSurrogate
) {
3479 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3482 s
->vport
= xatos(token
+ 6);
3483 } else if (strncmp(token
, "protocol=", 9) == 0) {
3484 if (!s
->flags
.accelSurrogate
) {
3485 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": protocol option requires Acceleration mode flag.");
3488 s
->transport
= parsePortProtocol(ToUpper(SBuf(token
+ 9)));
3489 } else if (strcmp(token
, "allow-direct") == 0) {
3490 if (!s
->flags
.accelSurrogate
) {
3491 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": allow-direct option requires Acceleration mode flag.");
3494 s
->allow_direct
= true;
3495 } else if (strcmp(token
, "act-as-origin") == 0) {
3496 if (!s
->flags
.accelSurrogate
) {
3497 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": act-as-origin option requires Acceleration mode flag.");
3499 s
->actAsOrigin
= true;
3500 } else if (strcmp(token
, "ignore-cc") == 0) {
3501 #if !USE_HTTP_VIOLATIONS
3502 if (!s
->flags
.accelSurrogate
) {
3503 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": ignore-cc option requires Acceleration mode flag.");
3507 s
->ignore_cc
= true;
3508 } else if (strncmp(token
, "name=", 5) == 0) {
3510 s
->name
= xstrdup(token
+ 5);
3511 } else if (strcmp(token
, "no-connection-auth") == 0) {
3512 s
->connection_auth_disabled
= true;
3513 } else if (strcmp(token
, "connection-auth=off") == 0) {
3514 s
->connection_auth_disabled
= true;
3515 } else if (strcmp(token
, "connection-auth") == 0) {
3516 s
->connection_auth_disabled
= false;
3517 } else if (strcmp(token
, "connection-auth=on") == 0) {
3518 s
->connection_auth_disabled
= false;
3519 } else if (strncmp(token
, "disable-pmtu-discovery=", 23) == 0) {
3520 if (!strcmp(token
+ 23, "off"))
3521 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3522 else if (!strcmp(token
+ 23, "transparent"))
3523 s
->disable_pmtu_discovery
= DISABLE_PMTU_TRANSPARENT
;
3524 else if (!strcmp(token
+ 23, "always"))
3525 s
->disable_pmtu_discovery
= DISABLE_PMTU_ALWAYS
;
3528 } else if (strcmp(token
, "ipv4") == 0) {
3529 if ( !s
->s
.setIPv4() ) {
3530 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": IPv6 addresses cannot be used as IPv4-Only. " << s
->s
);
3533 } else if (strcmp(token
, "tcpkeepalive") == 0) {
3534 s
->tcp_keepalive
.enabled
= true;
3535 } else if (strncmp(token
, "tcpkeepalive=", 13) == 0) {
3536 char *t
= token
+ 13;
3537 s
->tcp_keepalive
.enabled
= true;
3538 s
->tcp_keepalive
.idle
= xatoui(t
,',');
3542 s
->tcp_keepalive
.interval
= xatoui(t
,',');
3547 s
->tcp_keepalive
.timeout
= xatoui(t
);
3550 } else if (strcmp(token
, "sslBump") == 0) {
3551 debugs(3, DBG_PARSE_NOTE(1), "WARNING: '" << token
<< "' is deprecated " <<
3552 "in " << cfg_directive
<< ". Use 'ssl-bump' instead.");
3553 s
->flags
.tunnelSslBumping
= true;
3554 } else if (strcmp(token
, "ssl-bump") == 0) {
3555 s
->flags
.tunnelSslBumping
= true;
3556 } else if (strncmp(token
, "cert=", 5) == 0) {
3557 s
->secure
.parse(token
);
3558 } else if (strncmp(token
, "key=", 4) == 0) {
3559 s
->secure
.parse(token
);
3560 } else if (strncmp(token
, "version=", 8) == 0) {
3561 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3562 "in " << cfg_directive
<< ". Use 'options=' instead.");
3563 s
->secure
.parse(token
);
3564 } else if (strncmp(token
, "options=", 8) == 0) {
3565 s
->secure
.parse(token
);
3566 } else if (strncmp(token
, "cipher=", 7) == 0) {
3567 s
->secure
.parse(token
);
3568 } else if (strncmp(token
, "clientca=", 9) == 0) {
3569 safe_free(s
->clientca
);
3570 s
->clientca
= xstrdup(token
+ 9);
3571 } else if (strncmp(token
, "cafile=", 7) == 0) {
3572 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3573 "in " << cfg_directive
<< ". Use 'tls-cafile=' instead.");
3574 s
->secure
.parse(token
);
3575 } else if (strncmp(token
, "capath=", 7) == 0) {
3576 s
->secure
.parse(token
);
3577 } else if (strncmp(token
, "crlfile=", 8) == 0) {
3578 s
->secure
.parse(token
);
3579 } else if (strncmp(token
, "dhparams=", 9) == 0) {
3580 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: '" << token
<< "' is deprecated " <<
3581 "in " << cfg_directive
<< ". Use 'tls-dh=' instead.");
3582 s
->secure
.parse(token
);
3583 } else if (strncmp(token
, "sslflags=", 9) == 0) {
3584 // NP: deprecation warnings output by secure.parse() when relevant
3585 s
->secure
.parse(token
+3);
3586 } else if (strncmp(token
, "sslcontext=", 11) == 0) {
3587 safe_free(s
->sslContextSessionId
);
3588 s
->sslContextSessionId
= xstrdup(token
+ 11);
3589 } else if (strcmp(token
, "generate-host-certificates") == 0) {
3590 s
->generateHostCertificates
= true;
3591 } else if (strcmp(token
, "generate-host-certificates=on") == 0) {
3592 s
->generateHostCertificates
= true;
3593 } else if (strcmp(token
, "generate-host-certificates=off") == 0) {
3594 s
->generateHostCertificates
= false;
3595 } else if (strncmp(token
, "dynamic_cert_mem_cache_size=", 28) == 0) {
3596 parseBytesOptionValue(&s
->dynamicCertMemCacheSize
, B_BYTES_STR
, token
+ 28);
3598 } else if (strncmp(token
, "tls-", 4) == 0) {
3599 s
->secure
.parse(token
+4);
3600 } else if (strcmp(token
, "ftp-track-dirs") == 0) {
3601 s
->ftp_track_dirs
= true;
3603 debugs(3, DBG_CRITICAL
, "FATAL: Unknown " << cfg_directive
<< " option '" << token
<< "'.");
3609 add_http_port(char *portspec
)
3611 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3612 s
->transport
= parsePortProtocol(SBuf("HTTP"));
3613 parsePortSpecification(s
, portspec
);
3614 // we may need to merge better if the above returns a list with clones
3615 assert(s
->next
== NULL
);
3616 s
->next
= HttpPortList
;
3621 parsePortCfg(AnyP::PortCfgPointer
*head
, const char *optionName
)
3624 if (strcmp(optionName
, "http_port") == 0 ||
3625 strcmp(optionName
, "ascii_port") == 0)
3627 else if (strcmp(optionName
, "https_port") == 0)
3628 protoName
= "HTTPS";
3629 else if (strcmp(optionName
, "ftp_port") == 0)
3631 if (protoName
.isEmpty()) {
3636 char *token
= ConfigParser::NextToken();
3643 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3644 s
->transport
= parsePortProtocol(protoName
); // default; protocol=... overwrites
3645 parsePortSpecification(s
, token
);
3647 /* parse options ... */
3648 while ((token
= ConfigParser::NextToken())) {
3649 parse_port_option(s
, token
);
3653 // if clientca has been defined but not cafile, then use it to verify
3654 // but if cafile has been defined, only use that to verify
3655 if (s
->clientca
&& !s
->secure
.caFiles
.size())
3656 s
->secure
.caFiles
.emplace_back(SBuf(s
->clientca
));
3659 if (s
->transport
.protocol
== AnyP::PROTO_HTTPS
) {
3660 s
->secure
.encryptTransport
= true;
3662 /* ssl-bump on https_port configuration requires either tproxy or intercept, and vice versa */
3663 const bool hijacked
= s
->flags
.isIntercepted();
3664 if (s
->flags
.tunnelSslBumping
&& !hijacked
) {
3665 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump on https_port requires tproxy/intercept which is missing.");
3668 if (hijacked
&& !s
->flags
.tunnelSslBumping
) {
3669 debugs(3, DBG_CRITICAL
, "FATAL: tproxy/intercept on https_port requires ssl-bump which is missing.");
3673 if (s
->flags
.proxySurrogate
) {
3674 debugs(3,DBG_CRITICAL
, "FATAL: https_port: require-proxy-header option is not supported on HTTPS ports.");
3677 } else if (protoName
.cmp("FTP") == 0) {
3678 /* ftp_port does not support ssl-bump */
3679 if (s
->flags
.tunnelSslBumping
) {
3680 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump is not supported for ftp_port.");
3683 if (s
->flags
.proxySurrogate
) {
3684 // Passive FTP data channel does not work without deep protocol inspection in the frontend.
3685 debugs(3,DBG_CRITICAL
, "FATAL: require-proxy-header option is not supported on ftp_port.");
3690 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& s
->s
.isAnyAddr()) {
3691 // clone the port options from *s to *(s->next)
3692 s
->next
= s
->clone();
3693 s
->next
->s
.setIPv4();
3694 debugs(3, 3, AnyP::UriScheme(s
->transport
.protocol
).c_str() << "_port: clone wildcard address for split-stack: " << s
->s
<< " and " << s
->next
->s
);
3697 while (*head
!= NULL
)
3698 head
= &((*head
)->next
);
3704 dump_generic_port(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3706 char buf
[MAX_IPSTRLEN
];
3708 storeAppendPrintf(e
, "%s %s",
3710 s
->s
.toUrl(buf
,MAX_IPSTRLEN
));
3712 // MODES and specific sub-options.
3713 if (s
->flags
.natIntercept
)
3714 storeAppendPrintf(e
, " intercept");
3716 else if (s
->flags
.tproxyIntercept
)
3717 storeAppendPrintf(e
, " tproxy");
3719 else if (s
->flags
.proxySurrogate
)
3720 storeAppendPrintf(e
, " require-proxy-header");
3722 else if (s
->flags
.accelSurrogate
) {
3723 storeAppendPrintf(e
, " accel");
3726 storeAppendPrintf(e
, " vhost");
3729 storeAppendPrintf(e
, " vport");
3730 else if (s
->vport
> 0)
3731 storeAppendPrintf(e
, " vport=%d", s
->vport
);
3734 storeAppendPrintf(e
, " defaultsite=%s", s
->defaultsite
);
3736 // TODO: compare against prefix of 'n' instead of assuming http_port
3737 if (s
->transport
.protocol
!= AnyP::PROTO_HTTP
)
3738 storeAppendPrintf(e
, " protocol=%s", AnyP::UriScheme(s
->transport
.protocol
).c_str());
3740 if (s
->allow_direct
)
3741 storeAppendPrintf(e
, " allow-direct");
3744 storeAppendPrintf(e
, " ignore-cc");
3748 // Generic independent options
3751 storeAppendPrintf(e
, " name=%s", s
->name
);
3753 #if USE_HTTP_VIOLATIONS
3754 if (!s
->flags
.accelSurrogate
&& s
->ignore_cc
)
3755 storeAppendPrintf(e
, " ignore-cc");
3758 if (s
->connection_auth_disabled
)
3759 storeAppendPrintf(e
, " connection-auth=off");
3761 storeAppendPrintf(e
, " connection-auth=on");
3763 if (s
->disable_pmtu_discovery
!= DISABLE_PMTU_OFF
) {
3766 if (s
->disable_pmtu_discovery
== DISABLE_PMTU_ALWAYS
)
3769 pmtu
= "transparent";
3771 storeAppendPrintf(e
, " disable-pmtu-discovery=%s", pmtu
);
3774 if (s
->s
.isAnyAddr() && !s
->s
.isIPv6())
3775 storeAppendPrintf(e
, " ipv4");
3777 if (s
->tcp_keepalive
.enabled
) {
3778 if (s
->tcp_keepalive
.idle
|| s
->tcp_keepalive
.interval
|| s
->tcp_keepalive
.timeout
) {
3779 storeAppendPrintf(e
, " tcpkeepalive=%d,%d,%d", s
->tcp_keepalive
.idle
, s
->tcp_keepalive
.interval
, s
->tcp_keepalive
.timeout
);
3781 storeAppendPrintf(e
, " tcpkeepalive");
3786 if (s
->flags
.tunnelSslBumping
)
3787 storeAppendPrintf(e
, " ssl-bump");
3790 s
->secure
.dumpCfg(e
, "tls-");
3793 if (s
->sslContextSessionId
)
3794 storeAppendPrintf(e
, " sslcontext=%s", s
->sslContextSessionId
);
3796 if (s
->generateHostCertificates
)
3797 storeAppendPrintf(e
, " generate-host-certificates");
3799 if (s
->dynamicCertMemCacheSize
!= std::numeric_limits
<size_t>::max())
3800 storeAppendPrintf(e
, "dynamic_cert_mem_cache_size=%lu%s\n", (unsigned long)s
->dynamicCertMemCacheSize
, B_BYTES_STR
);
3805 dump_PortCfg(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3807 for (AnyP::PortCfgPointer p
= s
; p
!= NULL
; p
= p
->next
) {
3808 dump_generic_port(e
, n
, p
);
3809 storeAppendPrintf(e
, "\n");
3814 configFreeMemory(void)
3818 SSL_CTX_free(Config
.ssl_client
.sslContext
);
3823 requirePathnameExists(const char *name
, const char *path
)
3827 char pathbuf
[BUFSIZ
];
3828 assert(path
!= NULL
);
3830 if (Config
.chroot_dir
&& (geteuid() == 0)) {
3831 snprintf(pathbuf
, BUFSIZ
, "%s/%s", Config
.chroot_dir
, path
);
3835 if (stat(path
, &sb
) < 0) {
3836 debugs(0, DBG_CRITICAL
, (opt_parse_cfg_only
?"FATAL: ":"ERROR: ") << name
<< " " << path
<< ": " << xstrerror());
3837 // keep going to find more issues if we are only checking the config file with "-k parse"
3838 if (opt_parse_cfg_only
)
3840 // this is fatal if it is found during startup or reconfigure
3841 if (opt_send_signal
== -1 || opt_send_signal
== SIGHUP
)
3842 fatalf("%s %s: %s", name
, path
, xstrerror());
3846 #include "AccessLogEntry.h"
3849 * We support several access_log configuration styles:
3851 * #1: Deprecated ancient style without an explicit logging module:
3852 * access_log /var/log/access.log
3854 * #2: The "none" logging module (i.e., no logging [of matching transactions]):
3855 * access_log none [acl ...]
3857 * #3: Configurable logging module without named options:
3858 * Logformat or the first ACL name, whichever comes first, may not contain '='.
3859 * If no explicit logformat name is given, the first ACL name, if any,
3860 * should not be an existing logformat name or it will be treated as such.
3861 * access_log module:place [logformat_name] [acl ...]
3863 * #4: Configurable logging module with name=value options such as logformat=x:
3864 * The first ACL name may not contain '='.
3865 * access_log module:place [option ...] [acl ...]
3869 parse_access_log(CustomLog
** logs
)
3871 CustomLog
*cl
= (CustomLog
*)xcalloc(1, sizeof(*cl
));
3873 // default buffer size and fatal settings
3874 cl
->bufferSize
= 8*MAX_URL
;
3877 /* determine configuration style */
3879 const char *filename
= ConfigParser::NextToken();
3885 if (strcmp(filename
, "none") == 0) {
3886 cl
->type
= Log::Format::CLF_NONE
;
3887 aclParseAclList(LegacyParser
, &cl
->aclList
, filename
);
3889 logs
= &(*logs
)->next
;
3894 cl
->filename
= xstrdup(filename
);
3895 cl
->type
= Log::Format::CLF_UNKNOWN
;
3896 cl
->rotateCount
= -1; // default: use global logfile_rotate setting.
3898 const char *token
= ConfigParser::PeekAtToken();
3899 if (!token
) { // style #1
3900 // no options to deal with
3901 } else if (!strchr(token
, '=')) { // style #3
3902 // if logformat name is recognized,
3903 // pop the previewed token; Else it must be an ACL name
3904 if (setLogformat(cl
, token
, false))
3905 (void)ConfigParser::NextToken();
3906 } else { // style #4
3908 if (strncasecmp(token
, "on-error=", 9) == 0) {
3909 if (strncasecmp(token
+9, "die", 3) == 0) {
3911 } else if (strncasecmp(token
+9, "drop", 4) == 0) {
3914 debugs(3, DBG_CRITICAL
, "Unknown value for on-error '" <<
3915 token
<< "' expected 'drop' or 'die'");
3918 } else if (strncasecmp(token
, "buffer-size=", 12) == 0) {
3919 parseBytesOptionValue(&cl
->bufferSize
, B_BYTES_STR
, token
+12);
3920 } else if (strncasecmp(token
, "rotate=", 7) == 0) {
3921 cl
->rotateCount
= xatoi(token
+ 7);
3922 } else if (strncasecmp(token
, "logformat=", 10) == 0) {
3923 setLogformat(cl
, token
+10, true);
3924 } else if (!strchr(token
, '=')) {
3925 // Do not pop the token; it must be an ACL name
3926 break; // done with name=value options, now to ACLs
3928 debugs(3, DBG_CRITICAL
, "Unknown access_log option " << token
);
3931 // Pop the token, it was a valid "name=value" option
3932 (void)ConfigParser::NextToken();
3933 // Get next with preview ConfigParser::NextToken call.
3934 } while ((token
= ConfigParser::PeekAtToken()) != NULL
);
3937 // set format if it has not been specified explicitly
3938 if (cl
->type
== Log::Format::CLF_UNKNOWN
)
3939 setLogformat(cl
, "squid", true);
3941 aclParseAclList(LegacyParser
, &cl
->aclList
, cl
->filename
);
3944 logs
= &(*logs
)->next
;
3949 /// sets CustomLog::type and, if needed, CustomLog::lf
3950 /// returns false iff there is no named log format
3952 setLogformat(CustomLog
*cl
, const char *logdef_name
, const bool dieWhenMissing
)
3955 assert(logdef_name
);
3957 debugs(3, 9, "possible " << cl
->filename
<< " logformat: " << logdef_name
);
3959 if (cl
->type
!= Log::Format::CLF_UNKNOWN
) {
3960 debugs(3, DBG_CRITICAL
, "Second logformat name in one access_log: " <<
3961 logdef_name
<< " " << cl
->type
<< " ? " << Log::Format::CLF_NONE
);
3966 /* look for the definition pointer corresponding to this name */
3967 Format::Format
*lf
= Log::TheConfig
.logformats
;
3969 while (lf
!= NULL
) {
3970 debugs(3, 9, "Comparing against '" << lf
->name
<< "'");
3972 if (strcmp(lf
->name
, logdef_name
) == 0)
3979 cl
->type
= Log::Format::CLF_CUSTOM
;
3981 } else if (strcmp(logdef_name
, "auto") == 0) {
3982 debugs(0, DBG_CRITICAL
, "WARNING: Log format 'auto' no longer exists. Using 'squid' instead.");
3983 cl
->type
= Log::Format::CLF_SQUID
;
3984 } else if (strcmp(logdef_name
, "squid") == 0) {
3985 cl
->type
= Log::Format::CLF_SQUID
;
3986 } else if (strcmp(logdef_name
, "common") == 0) {
3987 cl
->type
= Log::Format::CLF_COMMON
;
3988 } else if (strcmp(logdef_name
, "combined") == 0) {
3989 cl
->type
= Log::Format::CLF_COMBINED
;
3991 } else if (strcmp(logdef_name
, "icap_squid") == 0) {
3992 cl
->type
= Log::Format::CLF_ICAP_SQUID
;
3994 } else if (strcmp(logdef_name
, "useragent") == 0) {
3995 cl
->type
= Log::Format::CLF_USERAGENT
;
3996 } else if (strcmp(logdef_name
, "referrer") == 0) {
3997 cl
->type
= Log::Format::CLF_REFERER
;
3998 } else if (dieWhenMissing
) {
3999 debugs(3, DBG_CRITICAL
, "Log format '" << logdef_name
<< "' is not defined");
4010 check_null_access_log(CustomLog
*customlog_definitions
)
4012 return customlog_definitions
== NULL
;
4016 dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* logs
)
4020 for (log
= logs
; log
; log
= log
->next
) {
4021 storeAppendPrintf(entry
, "%s ", name
);
4023 switch (log
->type
) {
4025 case Log::Format::CLF_CUSTOM
:
4026 storeAppendPrintf(entry
, "%s logformat=%s", log
->filename
, log
->logFormat
->name
);
4029 case Log::Format::CLF_NONE
:
4030 storeAppendPrintf(entry
, "logformat=none");
4033 case Log::Format::CLF_SQUID
:
4034 storeAppendPrintf(entry
, "%s logformat=squid", log
->filename
);
4037 case Log::Format::CLF_COMBINED
:
4038 storeAppendPrintf(entry
, "%s logformat=combined", log
->filename
);
4041 case Log::Format::CLF_COMMON
:
4042 storeAppendPrintf(entry
, "%s logformat=common", log
->filename
);
4046 case Log::Format::CLF_ICAP_SQUID
:
4047 storeAppendPrintf(entry
, "%s logformat=icap_squid", log
->filename
);
4050 case Log::Format::CLF_USERAGENT
:
4051 storeAppendPrintf(entry
, "%s logformat=useragent", log
->filename
);
4054 case Log::Format::CLF_REFERER
:
4055 storeAppendPrintf(entry
, "%s logformat=referrer", log
->filename
);
4058 case Log::Format::CLF_UNKNOWN
:
4062 // default is on-error=die
4064 storeAppendPrintf(entry
, " on-error=drop");
4067 if (log
->bufferSize
!= 64*1024)
4068 storeAppendPrintf(entry
, " buffer-size=%" PRIuSIZE
, log
->bufferSize
);
4070 if (log
->rotateCount
>= 0)
4071 storeAppendPrintf(entry
, " rotate=%d", log
->rotateCount
);
4074 dump_acl_list(entry
, log
->aclList
);
4076 storeAppendPrintf(entry
, "\n");
4081 free_access_log(CustomLog
** definitions
)
4083 while (*definitions
) {
4084 CustomLog
*log
= *definitions
;
4085 *definitions
= log
->next
;
4087 log
->logFormat
= NULL
;
4088 log
->type
= Log::Format::CLF_UNKNOWN
;
4091 aclDestroyAclList(&log
->aclList
);
4093 safe_free(log
->filename
);
4099 /// parses list of integers form name=N1,N2,N3,...
4101 parseNamedIntList(const char *data
, const String
&name
, std::vector
<int> &list
)
4103 if (data
&& (strncmp(data
, name
.rawBuf(), name
.size()) == 0)) {
4104 data
+= name
.size();
4109 if (!StringToInt(data
, value
, &data
, 10))
4111 list
.push_back(value
);
4112 if (*data
== '\0' || *data
!= ',')
4117 return data
&& *data
== '\0';
4121 parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4123 #if !HAVE_CPU_AFFINITY
4124 debugs(3, DBG_CRITICAL
, "FATAL: Squid built with no CPU affinity " <<
4125 "support, do not set 'cpu_affinity_map'");
4127 #endif /* HAVE_CPU_AFFINITY */
4129 if (!*cpuAffinityMap
)
4130 *cpuAffinityMap
= new CpuAffinityMap
;
4132 const char *const pToken
= ConfigParser::NextToken();
4133 const char *const cToken
= ConfigParser::NextToken();
4134 std::vector
<int> processes
, cores
;
4135 if (!parseNamedIntList(pToken
, "process_numbers", processes
)) {
4136 debugs(3, DBG_CRITICAL
, "FATAL: bad 'process_numbers' parameter " <<
4137 "in 'cpu_affinity_map'");
4139 } else if (!parseNamedIntList(cToken
, "cores", cores
)) {
4140 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cores' parameter in " <<
4141 "'cpu_affinity_map'");
4143 } else if (!(*cpuAffinityMap
)->add(processes
, cores
)) {
4144 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cpu_affinity_map'; " <<
4145 "process_numbers and cores lists differ in length or " <<
4146 "contain numbers <= 0");
4152 dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
)
4154 if (cpuAffinityMap
) {
4155 storeAppendPrintf(entry
, "%s process_numbers=", name
);
4156 for (size_t i
= 0; i
< cpuAffinityMap
->processes().size(); ++i
) {
4157 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4158 cpuAffinityMap
->processes()[i
]);
4160 storeAppendPrintf(entry
, " cores=");
4161 for (size_t i
= 0; i
< cpuAffinityMap
->cores().size(); ++i
) {
4162 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4163 cpuAffinityMap
->cores()[i
]);
4165 storeAppendPrintf(entry
, "\n");
4170 free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4172 delete *cpuAffinityMap
;
4173 *cpuAffinityMap
= NULL
;
4179 parse_adaptation_service_set_type()
4181 Adaptation::Config::ParseServiceSet();
4185 parse_adaptation_service_chain_type()
4187 Adaptation::Config::ParseServiceChain();
4191 parse_adaptation_access_type()
4193 Adaptation::Config::ParseAccess(LegacyParser
);
4195 #endif /* USE_ADAPTATION */
4200 parse_icap_service_type(Adaptation::Icap::Config
* cfg
)
4202 cfg
->parseService();
4206 free_icap_service_type(Adaptation::Icap::Config
* cfg
)
4212 dump_icap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4214 cfg
.dumpService(entry
, name
);
4218 parse_icap_class_type()
4220 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_class' is depricated. " <<
4221 "Use 'adaptation_service_set' instead");
4222 Adaptation::Config::ParseServiceSet();
4226 parse_icap_access_type()
4228 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_access' is depricated. " <<
4229 "Use 'adaptation_access' instead");
4230 Adaptation::Config::ParseAccess(LegacyParser
);
4238 parse_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4240 cfg
->parseService();
4244 free_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4250 dump_ecap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Ecap::Config
&cfg
)
4252 cfg
.dumpService(entry
, name
);
4255 #endif /* USE_ECAP */
4258 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4263 cfg
->service_failure_limit
= GetInteger();
4265 if ((token
= ConfigParser::NextToken()) == NULL
)
4268 if (strcmp(token
,"in") != 0) {
4269 debugs(3, DBG_CRITICAL
, "expecting 'in' on'" << config_input_line
<< "'");
4273 if ((token
= ConfigParser::NextToken()) == NULL
) {
4277 d
= static_cast<time_t> (xatoi(token
));
4279 m
= static_cast<time_t> (1);
4283 else if ((token
= ConfigParser::NextToken()) == NULL
) {
4284 debugs(3, DBG_CRITICAL
, "No time-units on '" << config_input_line
<< "'");
4286 } else if ((m
= parseTimeUnits(token
, false)) == 0)
4289 cfg
->oldest_service_failure
= (m
* d
);
4292 static void dump_icap_service_failure_limit(StoreEntry
*entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4294 storeAppendPrintf(entry
, "%s %d", name
, cfg
.service_failure_limit
);
4295 if (cfg
.oldest_service_failure
> 0) {
4296 storeAppendPrintf(entry
, " in %d seconds", (int)cfg
.oldest_service_failure
);
4298 storeAppendPrintf(entry
, "\n");
4301 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4303 cfg
->oldest_service_failure
= 0;
4304 cfg
->service_failure_limit
= 0;
4309 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4312 sslproxy_cert_adapt
*ca
= (sslproxy_cert_adapt
*) xcalloc(1, sizeof(sslproxy_cert_adapt
));
4313 if ((al
= ConfigParser::NextToken()) == NULL
) {
4319 if ( char *s
= strchr(al
, '{')) {
4320 *s
= '\0'; // terminate the al string
4332 if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidAfter
]) == 0) {
4333 ca
->alg
= Ssl::algSetValidAfter
;
4334 ca
->param
= xstrdup("on");
4335 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidBefore
]) == 0) {
4336 ca
->alg
= Ssl::algSetValidBefore
;
4337 ca
->param
= xstrdup("on");
4338 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetCommonName
]) == 0) {
4339 ca
->alg
= Ssl::algSetCommonName
;
4341 if (strlen(param
) > 64) {
4342 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: setCommonName{" <<param
<< "} : using common name longer than 64 bytes is not supported");
4346 ca
->param
= xstrdup(param
);
4349 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: unknown cert adaptation algorithm: " << al
);
4354 aclParseAclList(LegacyParser
, &ca
->aclList
, al
);
4357 cert_adapt
= &(*cert_adapt
)->next
;
4362 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
)
4364 for (sslproxy_cert_adapt
*ca
= cert_adapt
; ca
!= NULL
; ca
= ca
->next
) {
4365 storeAppendPrintf(entry
, "%s ", name
);
4366 storeAppendPrintf(entry
, "%s{%s} ", Ssl::sslCertAdaptAlgoritm(ca
->alg
), ca
->param
);
4368 dump_acl_list(entry
, ca
->aclList
);
4369 storeAppendPrintf(entry
, "\n");
4373 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4375 while (*cert_adapt
) {
4376 sslproxy_cert_adapt
*ca
= *cert_adapt
;
4377 *cert_adapt
= ca
->next
;
4378 safe_free(ca
->param
);
4381 aclDestroyAclList(&ca
->aclList
);
4387 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4390 sslproxy_cert_sign
*cs
= (sslproxy_cert_sign
*) xcalloc(1, sizeof(sslproxy_cert_sign
));
4391 if ((al
= ConfigParser::NextToken()) == NULL
) {
4396 if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignTrusted
]) == 0)
4397 cs
->alg
= Ssl::algSignTrusted
;
4398 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignUntrusted
]) == 0)
4399 cs
->alg
= Ssl::algSignUntrusted
;
4400 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignSelf
]) == 0)
4401 cs
->alg
= Ssl::algSignSelf
;
4403 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_sign: unknown cert signing algorithm: " << al
);
4408 aclParseAclList(LegacyParser
, &cs
->aclList
, al
);
4411 cert_sign
= &(*cert_sign
)->next
;
4416 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
)
4418 sslproxy_cert_sign
*cs
;
4419 for (cs
= cert_sign
; cs
!= NULL
; cs
= cs
->next
) {
4420 storeAppendPrintf(entry
, "%s ", name
);
4421 storeAppendPrintf(entry
, "%s ", Ssl::certSignAlgorithm(cs
->alg
));
4423 dump_acl_list(entry
, cs
->aclList
);
4424 storeAppendPrintf(entry
, "\n");
4428 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4430 while (*cert_sign
) {
4431 sslproxy_cert_sign
*cs
= *cert_sign
;
4432 *cert_sign
= cs
->next
;
4435 aclDestroyAclList(&cs
->aclList
);
4441 class sslBumpCfgRr
: public ::RegisteredRunner
4444 static Ssl::BumpMode lastDeprecatedRule
;
4445 /* RegisteredRunner API */
4446 virtual void finalizeConfig();
4449 Ssl::BumpMode
sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4451 RunnerRegistrationEntry(sslBumpCfgRr
);
4454 sslBumpCfgRr::finalizeConfig()
4456 if (lastDeprecatedRule
!= Ssl::bumpEnd
) {
4457 assert( lastDeprecatedRule
== Ssl::bumpClientFirst
|| lastDeprecatedRule
== Ssl::bumpNone
);
4458 static char buf
[1024];
4459 if (lastDeprecatedRule
== Ssl::bumpClientFirst
) {
4460 strcpy(buf
, "ssl_bump deny all");
4461 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated implicit "
4462 "\"ssl_bump deny all\" to \"ssl_bump none all\". New ssl_bump configurations "
4463 "must not use implicit rules. Update your ssl_bump rules.");
4465 strcpy(buf
, "ssl_bump allow all");
4466 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated implicit "
4467 "\"ssl_bump allow all\" to \"ssl_bump client-first all\" which is usually "
4468 "inferior to the newer server-first bumping mode. New ssl_bump"
4469 " configurations must not use implicit rules. Update your ssl_bump rules.");
4475 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4477 typedef const char *BumpCfgStyle
;
4478 BumpCfgStyle bcsNone
= NULL
;
4479 BumpCfgStyle bcsNew
= "new client/server-first/none";
4480 BumpCfgStyle bcsOld
= "deprecated allow/deny";
4481 static BumpCfgStyle bumpCfgStyleLast
= bcsNone
;
4482 BumpCfgStyle bumpCfgStyleNow
= bcsNone
;
4484 if ((bm
= ConfigParser::NextToken()) == NULL
) {
4489 // if this is the first rule proccessed
4490 if (*ssl_bump
== NULL
) {
4491 bumpCfgStyleLast
= bcsNone
;
4492 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4495 allow_t action
= allow_t(ACCESS_ALLOWED
);
4497 if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpClientFirst
]) == 0) {
4498 action
.kind
= Ssl::bumpClientFirst
;
4499 bumpCfgStyleNow
= bcsNew
;
4500 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpServerFirst
]) == 0) {
4501 action
.kind
= Ssl::bumpServerFirst
;
4502 bumpCfgStyleNow
= bcsNew
;
4503 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpPeek
]) == 0) {
4504 action
.kind
= Ssl::bumpPeek
;
4505 bumpCfgStyleNow
= bcsNew
;
4506 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpStare
]) == 0) {
4507 action
.kind
= Ssl::bumpStare
;
4508 bumpCfgStyleNow
= bcsNew
;
4509 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpSplice
]) == 0) {
4510 action
.kind
= Ssl::bumpSplice
;
4511 bumpCfgStyleNow
= bcsNew
;
4512 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpBump
]) == 0) {
4513 action
.kind
= Ssl::bumpBump
;
4514 bumpCfgStyleNow
= bcsNew
;
4515 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpTerminate
]) == 0) {
4516 action
.kind
= Ssl::bumpTerminate
;
4517 bumpCfgStyleNow
= bcsNew
;
4518 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpNone
]) == 0) {
4519 action
.kind
= Ssl::bumpNone
;
4520 bumpCfgStyleNow
= bcsNew
;
4521 } else if (strcmp(bm
, "allow") == 0) {
4522 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated "
4523 "\"ssl_bump allow <acl>\" to \"ssl_bump client-first <acl>\" which "
4524 "is usually inferior to the newer server-first "
4525 "bumping mode. Update your ssl_bump rules.");
4526 action
.kind
= Ssl::bumpClientFirst
;
4527 bumpCfgStyleNow
= bcsOld
;
4528 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpClientFirst
;
4529 } else if (strcmp(bm
, "deny") == 0) {
4530 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated "
4531 "\"ssl_bump deny <acl>\" to \"ssl_bump none <acl>\". Update "
4532 "your ssl_bump rules.");
4533 action
.kind
= Ssl::bumpNone
;
4534 bumpCfgStyleNow
= bcsOld
;
4535 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpNone
;
4537 debugs(3, DBG_CRITICAL
, "FATAL: unknown ssl_bump mode: " << bm
);
4542 if (bumpCfgStyleLast
!= bcsNone
&& bumpCfgStyleNow
!= bumpCfgStyleLast
) {
4543 debugs(3, DBG_CRITICAL
, "FATAL: do not mix " << bumpCfgStyleNow
<< " actions with " <<
4544 bumpCfgStyleLast
<< " actions. Update your ssl_bump rules.");
4549 bumpCfgStyleLast
= bumpCfgStyleNow
;
4551 Acl::AndNode
*rule
= new Acl::AndNode
;
4552 rule
->context("(ssl_bump rule)", config_input_line
);
4558 *ssl_bump
= new Acl::Tree
;
4559 (*ssl_bump
)->context("(ssl_bump rules)", config_input_line
);
4562 (*ssl_bump
)->add(rule
, action
);
4565 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
)
4568 dump_SBufList(entry
, ssl_bump
->treeDump(name
, Ssl::BumpModeStr
));
4571 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4573 free_acl_access(ssl_bump
);
4578 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
)
4583 for (HeaderWithAclList::iterator hwa
= headers
->begin(); hwa
!= headers
->end(); ++hwa
) {
4584 storeAppendPrintf(entry
, "%s %s %s", name
, hwa
->fieldName
.c_str(), hwa
->fieldValue
.c_str());
4586 dump_acl_list(entry
, hwa
->aclList
);
4587 storeAppendPrintf(entry
, "\n");
4591 static void parse_HeaderWithAclList(HeaderWithAclList
**headers
)
4595 *headers
= new HeaderWithAclList
;
4597 if ((fn
= ConfigParser::NextToken()) == NULL
) {
4603 hwa
.fieldId
= Http::HeaderLookupTable
.lookup(hwa
.fieldName
).id
;
4604 if (hwa
.fieldId
== Http::HdrType::BAD_HDR
)
4605 hwa
.fieldId
= Http::HdrType::OTHER
;
4607 Format::Format
*nlf
= new ::Format::Format("hdrWithAcl");
4608 ConfigParser::EnableMacros();
4609 String buf
= ConfigParser::NextQuotedToken();
4610 ConfigParser::DisableMacros();
4611 hwa
.fieldValue
= buf
.termedBuf();
4612 hwa
.quoted
= ConfigParser::LastTokenWasQuoted();
4614 if (!nlf
->parse(hwa
.fieldValue
.c_str())) {
4618 hwa
.valueFormat
= nlf
;
4621 aclParseAclList(LegacyParser
, &hwa
.aclList
, (hwa
.fieldName
+ ':' + hwa
.fieldValue
).c_str());
4622 (*headers
)->push_back(hwa
);
4625 static void free_HeaderWithAclList(HeaderWithAclList
**header
)
4630 for (HeaderWithAclList::iterator hwa
= (*header
)->begin(); hwa
!= (*header
)->end(); ++hwa
) {
4632 aclDestroyAclList(&hwa
->aclList
);
4634 if (hwa
->valueFormat
) {
4635 delete hwa
->valueFormat
;
4636 hwa
->valueFormat
= NULL
;
4643 static void parse_note(Notes
*notes
)
4646 notes
->parse(LegacyParser
);
4649 static void dump_note(StoreEntry
*entry
, const char *name
, Notes
¬es
)
4651 notes
.dump(entry
, name
);
4654 static void free_note(Notes
*notes
)
4659 static bool FtpEspvDeprecated
= false;
4660 static void parse_ftp_epsv(acl_access
**ftp_epsv
)
4662 allow_t ftpEpsvDeprecatedAction
;
4663 bool ftpEpsvIsDeprecatedRule
= false;
4665 char *t
= ConfigParser::PeekAtToken();
4671 if (!strcmp(t
, "off")) {
4672 (void)ConfigParser::NextToken();
4673 ftpEpsvIsDeprecatedRule
= true;
4674 ftpEpsvDeprecatedAction
= allow_t(ACCESS_DENIED
);
4675 } else if (!strcmp(t
, "on")) {
4676 (void)ConfigParser::NextToken();
4677 ftpEpsvIsDeprecatedRule
= true;
4678 ftpEpsvDeprecatedAction
= allow_t(ACCESS_ALLOWED
);
4681 // Check for mixing "ftp_epsv on|off" and "ftp_epsv allow|deny .." rules:
4682 // 1) if this line is "ftp_epsv allow|deny ..." and already exist rules of "ftp_epsv on|off"
4683 // 2) if this line is "ftp_epsv on|off" and already exist rules of "ftp_epsv allow|deny ..."
4685 if ((!ftpEpsvIsDeprecatedRule
&& FtpEspvDeprecated
) ||
4686 (ftpEpsvIsDeprecatedRule
&& !FtpEspvDeprecated
&& *ftp_epsv
!= NULL
)) {
4687 debugs(3, DBG_CRITICAL
, "FATAL: do not mix \"ftp_epsv on|off\" cfg lines with \"ftp_epsv allow|deny ...\" cfg lines. Update your ftp_epsv rules.");
4691 if (ftpEpsvIsDeprecatedRule
) {
4692 // overwrite previous ftp_epsv lines
4694 if (ftpEpsvDeprecatedAction
== allow_t(ACCESS_DENIED
)) {
4695 Acl::AndNode
*ftpEpsvRule
= new Acl::AndNode
;
4696 ftpEpsvRule
->context("(ftp_epsv rule)", config_input_line
);
4697 ACL
*a
= ACL::FindByName("all");
4702 ftpEpsvRule
->add(a
);
4703 *ftp_epsv
= new Acl::Tree
;
4704 (*ftp_epsv
)->context("(ftp_epsv rules)", config_input_line
);
4705 (*ftp_epsv
)->add(ftpEpsvRule
, ftpEpsvDeprecatedAction
);
4708 FtpEspvDeprecated
= true;
4710 aclParseAccessLine(cfg_directive
, LegacyParser
, ftp_epsv
);
4714 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
)
4717 dump_SBufList(entry
, ftp_epsv
->treeDump(name
, NULL
));
4720 static void free_ftp_epsv(acl_access
**ftp_epsv
)
4722 free_acl_access(ftp_epsv
);
4723 FtpEspvDeprecated
= false;
4727 parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4730 parseTimeLine(&tval
, T_SECOND_STR
, false, true);
4731 Config
.Timeout
.urlRewrite
= static_cast<time_t>(tval
/1000);
4734 while(ConfigParser::NextKvPair(key
, value
)) {
4735 if (strcasecmp(key
, "on_timeout") == 0) {
4736 if (strcasecmp(value
, "bypass") == 0)
4737 config
->action
= toutActBypass
;
4738 else if (strcasecmp(value
, "fail") == 0)
4739 config
->action
= toutActFail
;
4740 else if (strcasecmp(value
, "retry") == 0)
4741 config
->action
= toutActRetry
;
4742 else if (strcasecmp(value
, "use_configured_response") == 0) {
4743 config
->action
= toutActUseConfiguredResponse
;
4745 debugs(3, DBG_CRITICAL
, "FATAL: unsuported \"on_timeout\" action:" << value
);
4748 } else if (strcasecmp(key
, "response") == 0) {
4749 config
->response
= xstrdup(value
);
4751 debugs(3, DBG_CRITICAL
, "FATAL: unsuported option " << key
);
4756 if (config
->action
== toutActUseConfiguredResponse
&& !config
->response
) {
4757 debugs(3, DBG_CRITICAL
, "FATAL: Expected 'response=' option after 'on_timeout=use_configured_response' option");
4761 if (config
->action
!= toutActUseConfiguredResponse
&& config
->response
) {
4762 debugs(3, DBG_CRITICAL
, "FATAL: 'response=' option is valid only when used with the 'on_timeout=use_configured_response' option");
4768 dump_UrlHelperTimeout(StoreEntry
*entry
, const char *name
, SquidConfig::UrlHelperTimeout
&config
)
4770 const char *onTimedOutActions
[] = {"bypass", "fail", "retry", "use_configured_response"};
4771 assert(config
.action
>= 0 && config
.action
<= toutActUseConfiguredResponse
);
4773 dump_time_t(entry
, name
, Config
.Timeout
.urlRewrite
);
4774 storeAppendPrintf(entry
, " on_timeout=%s", onTimedOutActions
[config
.action
]);
4776 if (config
.response
)
4777 storeAppendPrintf(entry
, " response=\"%s\"", config
.response
);
4779 storeAppendPrintf(entry
, "\n");
4783 free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4785 Config
.Timeout
.urlRewrite
= 0;
4787 safe_free(config
->response
);
4791 parse_configuration_includes_quoted_values(bool *)
4796 // If quoted values is set to on then enable new strict mode parsing
4798 ConfigParser::RecognizeQuotedValues
= true;
4799 ConfigParser::StrictMode
= true;
4801 ConfigParser::RecognizeQuotedValues
= false;
4802 ConfigParser::StrictMode
= false;
4807 dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool)
4809 int val
= ConfigParser::RecognizeQuotedValues
? 1 : 0;
4810 dump_onoff(entry
, name
, val
);
4814 free_configuration_includes_quoted_values(bool *)
4816 ConfigParser::RecognizeQuotedValues
= false;
4817 ConfigParser::StrictMode
= false;
4821 parse_on_unsupported_protocol(acl_access
**access
)
4824 if ((tm
= ConfigParser::NextToken()) == NULL
) {
4829 allow_t action
= allow_t(ACCESS_ALLOWED
);
4830 if (strcmp(tm
, "tunnel") == 0)
4832 else if (strcmp(tm
, "respond") == 0)
4835 debugs(3, DBG_CRITICAL
, "FATAL: unknown on_unsupported_protocol mode: " << tm
);
4840 Acl::AndNode
*rule
= new Acl::AndNode
;
4841 rule
->context("(on_unsupported_protocol rule)", config_input_line
);
4847 *access
= new Acl::Tree
;
4848 (*access
)->context("(on_unsupported_protocol rules)", config_input_line
);
4851 (*access
)->add(rule
, action
);
4855 dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
)
4857 const char *on_error_tunnel_mode_str
[] = {
4864 SBufList lines
= access
->treeDump(name
, on_error_tunnel_mode_str
);
4865 dump_SBufList(entry
, lines
);
4870 free_on_unsupported_protocol(acl_access
**access
)
4872 free_acl_access(access
);