2 * Copyright (C) 1996-2016 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"
55 #include "sbuf/List.h"
56 #include "SquidConfig.h"
57 #include "SquidString.h"
58 #include "ssl/ProxyCerts.h"
60 #include "store/Disk.h"
61 #include "store/Disks.h"
62 #include "StoreFileSystem.h"
66 /* wccp2 has its own conditional definitions */
69 #include "adaptation/Config.h"
72 #include "adaptation/icap/Config.h"
75 #include "adaptation/ecap/Config.h"
78 #include "ssl/Config.h"
79 #include "ssl/support.h"
82 #include "auth/Config.h"
83 #include "auth/Scheme.h"
86 #include "esi/Parser.h"
104 #include <sys/stat.h>
108 #include "ssl/gadgets.h"
112 static void parse_adaptation_service_set_type();
113 static void parse_adaptation_service_chain_type();
114 static void parse_adaptation_access_type();
118 static void parse_icap_service_type(Adaptation::Icap::Config
*);
119 static void dump_icap_service_type(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
120 static void free_icap_service_type(Adaptation::Icap::Config
*);
121 static void parse_icap_class_type();
122 static void parse_icap_access_type();
124 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*);
125 static void dump_icap_service_failure_limit(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
126 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*);
130 static void parse_ecap_service_type(Adaptation::Ecap::Config
*);
131 static void dump_ecap_service_type(StoreEntry
*, const char *, const Adaptation::Ecap::Config
&);
132 static void free_ecap_service_type(Adaptation::Ecap::Config
*);
135 static peer_t
parseNeighborType(const char *s
);
137 static const char *const T_MILLISECOND_STR
= "millisecond";
138 static const char *const T_SECOND_STR
= "second";
139 static const char *const T_MINUTE_STR
= "minute";
140 static const char *const T_HOUR_STR
= "hour";
141 static const char *const T_DAY_STR
= "day";
142 static const char *const T_WEEK_STR
= "week";
143 static const char *const T_FORTNIGHT_STR
= "fortnight";
144 static const char *const T_MONTH_STR
= "month";
145 static const char *const T_YEAR_STR
= "year";
146 static const char *const T_DECADE_STR
= "decade";
148 static const char *const B_BYTES_STR
= "bytes";
149 static const char *const B_KBYTES_STR
= "KB";
150 static const char *const B_MBYTES_STR
= "MB";
151 static const char *const B_GBYTES_STR
= "GB";
153 static const char *const list_sep
= ", \t\n\r";
155 static void parse_access_log(CustomLog
** customlog_definitions
);
156 static int check_null_access_log(CustomLog
*customlog_definitions
);
157 static void dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* definitions
);
158 static void free_access_log(CustomLog
** definitions
);
159 static bool setLogformat(CustomLog
*cl
, const char *name
, const bool dieWhenMissing
);
161 static void configDoConfigure(void);
162 static void parse_refreshpattern(RefreshPattern
**);
163 static uint64_t parseTimeUnits(const char *unit
, bool allowMsec
);
164 static void parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
);
165 static void parse_u_short(unsigned short * var
);
166 static void parse_string(char **);
167 static void default_all(void);
168 static void defaults_if_none(void);
169 static void defaults_postscriptum(void);
170 static int parse_line(char *);
171 static void parse_obsolete(const char *);
172 static void parseBytesLine(size_t * bptr
, const char *units
);
174 static void parseBytesOptionValue(size_t * bptr
, const char *units
, char const * value
);
176 static void parseBytesLineSigned(ssize_t
* bptr
, const char *units
);
177 static size_t parseBytesUnits(const char *unit
);
178 static void free_all(void);
179 void requirePathnameExists(const char *name
, const char *path
);
180 static OBJH dump_config
;
181 #if USE_HTTP_VIOLATIONS
182 static void free_HeaderManglers(HeaderManglers
**pm
);
183 static void dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
184 static void parse_http_header_access(HeaderManglers
**manglers
);
185 #define free_http_header_access free_HeaderManglers
186 static void dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
187 static void parse_http_header_replace(HeaderManglers
**manglers
);
188 #define free_http_header_replace free_HeaderManglers
190 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
);
191 static void parse_HeaderWithAclList(HeaderWithAclList
**header
);
192 static void free_HeaderWithAclList(HeaderWithAclList
**header
);
193 static void parse_note(Notes
*);
194 static void dump_note(StoreEntry
*, const char *, Notes
&);
195 static void free_note(Notes
*);
196 static void parse_denyinfo(AclDenyInfoList
** var
);
197 static void dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
);
198 static void free_denyinfo(AclDenyInfoList
** var
);
201 static void parse_IpAddress_list(Ip::Address_list
**);
202 static void dump_IpAddress_list(StoreEntry
*, const char *, const Ip::Address_list
*);
203 static void free_IpAddress_list(Ip::Address_list
**);
205 static int check_null_IpAddress_list(const Ip::Address_list
*);
206 #endif /* CURRENTLY_UNUSED */
207 #endif /* USE_WCCPv2 */
209 static void parsePortCfg(AnyP::PortCfgPointer
*, const char *protocol
);
210 #define parse_PortCfg(l) parsePortCfg((l), token)
211 static void dump_PortCfg(StoreEntry
*, const char *, const AnyP::PortCfgPointer
&);
212 #define free_PortCfg(h) *(h)=NULL
215 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
216 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
);
217 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
218 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
219 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
);
220 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
221 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
);
222 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
);
223 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
);
224 #endif /* USE_OPENSSL */
226 static void parse_ftp_epsv(acl_access
**ftp_epsv
);
227 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
);
228 static void free_ftp_epsv(acl_access
**ftp_epsv
);
230 static void parse_b_size_t(size_t * var
);
231 static void parse_b_int64_t(int64_t * var
);
233 static bool parseNamedIntList(const char *data
, const String
&name
, std::vector
<int> &list
);
235 static void parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
236 static void dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
);
237 static void free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
239 static void parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
240 static void dump_UrlHelperTimeout(StoreEntry
*, const char *, SquidConfig::UrlHelperTimeout
&);
241 static void free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
243 static int parseOneConfigFile(const char *file_name
, unsigned int depth
);
245 static void parse_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
246 static void dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool recognizeQuotedValues
);
247 static void free_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
248 static void parse_on_unsupported_protocol(acl_access
**access
);
249 static void dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
);
250 static void free_on_unsupported_protocol(acl_access
**access
);
253 * LegacyParser is a parser for legacy code that uses the global
254 * approach. This is static so that it is only exposed to cache_cf.
255 * Other modules needing access to a ConfigParser should have it
256 * provided to them in their parserFOO methods.
258 static ConfigParser LegacyParser
= ConfigParser();
263 LegacyParser
.destruct();
267 SetConfigFilename(char const *file_name
, bool is_pipe
)
270 cfg_filename
= file_name
+ 1;
272 cfg_filename
= file_name
;
276 skip_ws(const char* s
)
285 parseManyConfigFiles(char* files
, int depth
)
288 char* saveptr
= NULL
;
293 memset(&globbuf
, 0, sizeof(globbuf
));
294 for (path
= strwordtok(files
, &saveptr
); path
; path
= strwordtok(NULL
, &saveptr
)) {
295 if (glob(path
, globbuf
.gl_pathc
? GLOB_APPEND
: 0, NULL
, &globbuf
) != 0) {
297 fatalf("Unable to find configuration file: %s: %s", path
, xstrerr(xerrno
));
300 for (i
= 0; i
< (int)globbuf
.gl_pathc
; ++i
) {
301 error_count
+= parseOneConfigFile(globbuf
.gl_pathv
[i
], depth
);
305 char* file
= strwordtok(files
, &saveptr
);
306 while (file
!= NULL
) {
307 error_count
+= parseOneConfigFile(file
, depth
);
308 file
= strwordtok(NULL
, &saveptr
);
310 #endif /* HAVE_GLOB */
315 ReplaceSubstr(char*& str
, int& len
, unsigned substrIdx
, unsigned substrLen
, const char* newSubstr
)
318 assert(newSubstr
!= NULL
);
320 unsigned newSubstrLen
= strlen(newSubstr
);
321 if (newSubstrLen
> substrLen
)
322 str
= (char*)realloc(str
, len
- substrLen
+ newSubstrLen
+ 1);
324 // move tail part including zero
325 memmove(str
+ substrIdx
+ newSubstrLen
, str
+ substrIdx
+ substrLen
, len
- substrIdx
- substrLen
+ 1);
326 // copy new substring in place
327 memcpy(str
+ substrIdx
, newSubstr
, newSubstrLen
);
333 SubstituteMacro(char*& line
, int& len
, const char* macroName
, const char* substStr
)
335 assert(line
!= NULL
);
336 assert(macroName
!= NULL
);
337 assert(substStr
!= NULL
);
338 unsigned macroNameLen
= strlen(macroName
);
339 while (const char* macroPos
= strstr(line
, macroName
)) // we would replace all occurrences
340 ReplaceSubstr(line
, len
, macroPos
- line
, macroNameLen
, substStr
);
344 ProcessMacros(char*& line
, int& len
)
346 SubstituteMacro(line
, len
, "${service_name}", service_name
.c_str());
347 SubstituteMacro(line
, len
, "${process_name}", TheKidName
);
348 SubstituteMacro(line
, len
, "${process_number}", xitoa(KidIdentifier
));
352 trim_trailing_ws(char* str
)
355 unsigned i
= strlen(str
);
356 while ((i
> 0) && xisspace(str
[i
- 1]))
362 FindStatement(const char* line
, const char* statement
)
364 assert(line
!= NULL
);
365 assert(statement
!= NULL
);
367 const char* str
= skip_ws(line
);
368 unsigned len
= strlen(statement
);
369 if (strncmp(str
, statement
, len
) == 0) {
373 else if (xisspace(*str
))
381 StrToInt(const char* str
, long& number
)
386 number
= strtol(str
, &end
, 0);
388 return (end
!= str
) && (*end
== '\0'); // returns true if string contains nothing except number
392 EvalBoolExpr(const char* expr
)
394 assert(expr
!= NULL
);
395 if (strcmp(expr
, "true") == 0) {
397 } else if (strcmp(expr
, "false") == 0) {
399 } else if (const char* equation
= strchr(expr
, '=')) {
400 const char* rvalue
= skip_ws(equation
+ 1);
401 char* lvalue
= (char*)xmalloc(equation
- expr
+ 1);
402 xstrncpy(lvalue
, expr
, equation
- expr
+ 1);
403 trim_trailing_ws(lvalue
);
406 if (!StrToInt(lvalue
, number1
))
407 fatalf("String is not a integer number: '%s'\n", lvalue
);
409 if (!StrToInt(rvalue
, number2
))
410 fatalf("String is not a integer number: '%s'\n", rvalue
);
413 return number1
== number2
;
415 fatalf("Unable to evaluate expression '%s'\n", expr
);
416 return false; // this place cannot be reached
420 parseOneConfigFile(const char *file_name
, unsigned int depth
)
423 const char *orig_cfg_filename
= cfg_filename
;
424 const int orig_config_lineno
= config_lineno
;
426 char *tmp_line
= NULL
;
427 int tmp_line_len
= 0;
431 debugs(3, DBG_IMPORTANT
, "Processing Configuration File: " << file_name
<< " (depth " << depth
<< ")");
433 fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name
);
437 if (file_name
[0] == '!' || file_name
[0] == '|') {
438 fp
= popen(file_name
+ 1, "r");
441 fp
= fopen(file_name
, "r");
446 fatalf("Unable to open configuration file: %s: %s", file_name
, xstrerr(xerrno
));
450 setmode(fileno(fp
), O_TEXT
);
453 SetConfigFilename(file_name
, bool(is_pipe
));
455 memset(config_input_line
, '\0', BUFSIZ
);
459 std::vector
<bool> if_states
;
460 while (fgets(config_input_line
, BUFSIZ
, fp
)) {
463 if ((token
= strchr(config_input_line
, '\n')))
466 if ((token
= strchr(config_input_line
, '\r')))
469 // strip any prefix whitespace off the line.
470 const char *p
= skip_ws(config_input_line
);
471 if (config_input_line
!= p
)
472 memmove(config_input_line
, p
, strlen(p
)+1);
474 if (strncmp(config_input_line
, "#line ", 6) == 0) {
475 static char new_file_name
[1024];
477 static char new_lineno
;
478 token
= config_input_line
+ 6;
479 new_lineno
= strtol(token
, &file
, 0) - 1;
482 continue; /* Not a valid #line directive, may be a comment */
484 while (*file
&& xisspace((unsigned char) *file
))
489 continue; /* Not a valid #line directive, may be a comment */
491 xstrncpy(new_file_name
, file
+ 1, sizeof(new_file_name
));
493 if ((token
= strchr(new_file_name
, '"')))
496 SetConfigFilename(new_file_name
, false);
499 config_lineno
= new_lineno
;
502 if (config_input_line
[0] == '#')
505 if (config_input_line
[0] == '\0')
508 const char* append
= tmp_line_len
? skip_ws(config_input_line
) : config_input_line
;
510 size_t append_len
= strlen(append
);
512 tmp_line
= (char*)xrealloc(tmp_line
, tmp_line_len
+ append_len
+ 1);
514 strcpy(tmp_line
+ tmp_line_len
, append
);
516 tmp_line_len
+= append_len
;
518 if (tmp_line
[tmp_line_len
-1] == '\\') {
519 debugs(3, 5, "parseConfigFile: tmp_line='" << tmp_line
<< "'");
520 tmp_line
[--tmp_line_len
] = '\0';
524 trim_trailing_ws(tmp_line
);
525 ProcessMacros(tmp_line
, tmp_line_len
);
526 debugs(3, (opt_parse_cfg_only
?1:5), "Processing: " << tmp_line
);
528 if (const char* expr
= FindStatement(tmp_line
, "if")) {
529 if_states
.push_back(EvalBoolExpr(expr
)); // store last if-statement meaning
530 } else if (FindStatement(tmp_line
, "endif")) {
531 if (!if_states
.empty())
532 if_states
.pop_back(); // remove last if-statement meaning
534 fatalf("'endif' without 'if'\n");
535 } else if (FindStatement(tmp_line
, "else")) {
536 if (!if_states
.empty())
537 if_states
.back() = !if_states
.back();
539 fatalf("'else' without 'if'\n");
540 } else if (if_states
.empty() || if_states
.back()) { // test last if-statement meaning if present
541 /* Handle includes here */
542 if (tmp_line_len
>= 9 && strncmp(tmp_line
, "include", 7) == 0 && xisspace(tmp_line
[7])) {
543 err_count
+= parseManyConfigFiles(tmp_line
+ 8, depth
+ 1);
544 } else if (!parse_line(tmp_line
)) {
545 debugs(3, DBG_CRITICAL
, HERE
<< cfg_filename
<< ":" << config_lineno
<< " unrecognized: '" << tmp_line
<< "'");
554 if (!if_states
.empty())
555 fatalf("if-statement without 'endif'\n");
558 int ret
= pclose(fp
);
561 fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name
, ret
);
566 SetConfigFilename(orig_cfg_filename
, false);
567 config_lineno
= orig_config_lineno
;
574 parseConfigFile(const char *file_name
)
582 ACLMethodData::ThePurgeCount
= 0;
585 err_count
= parseOneConfigFile(file_name
, 0);
589 defaults_postscriptum();
592 * We must call configDoConfigure() before leave_suid() because
593 * configDoConfigure() is where we turn username strings into
598 if (!Config
.chroot_dir
) {
600 setUmask(Config
.umask
);
601 _db_init(Debug::cache_log
, Debug::debugOptions
);
605 if (opt_send_signal
== -1) {
606 Mgr::RegisterAction("config",
607 "Current Squid Configuration",
616 configDoConfigure(void)
618 memset(&Config2
, '\0', sizeof(SquidConfig2
));
619 /* init memory as early as possible */
623 Config
.cacheSwap
.n_strands
= 0; // no diskers by default
624 if (Config
.cacheSwap
.swapDirs
== NULL
) {
625 /* Memory-only cache probably in effect. */
626 /* turn off the cache rebuild delays... */
627 StoreController::store_dirs_rebuilding
= 0;
628 } else if (InDaemonMode()) { // no diskers in non-daemon mode
629 for (int i
= 0; i
< Config
.cacheSwap
.n_configured
; ++i
) {
630 const RefCount
<SwapDir
> sd
= Config
.cacheSwap
.swapDirs
[i
];
631 if (sd
->needsDiskStrand())
632 sd
->disker
= Config
.workers
+ (++Config
.cacheSwap
.n_strands
);
636 if (Debug::rotateNumber
< 0) {
637 Debug::rotateNumber
= Config
.Log
.rotateNumber
;
640 #if SIZEOF_OFF_T <= 4
641 if (Config
.Store
.maxObjectSize
> 0x7FFF0000) {
642 debugs(3, DBG_CRITICAL
, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
643 Config
.Store
.maxObjectSize
= 0x7FFF0000;
647 if (Config
.Announce
.period
> 0) {
648 Config
.onoff
.announce
= 1;
650 Config
.Announce
.period
= 86400 * 365; /* one year */
651 Config
.onoff
.announce
= 0;
654 if (Config
.onoff
.httpd_suppress_version_string
)
655 visible_appname_string
= (char *)appname_string
;
657 visible_appname_string
= (char const *)APP_FULLNAME
;
659 if (Config
.Program
.redirect
) {
660 if (Config
.redirectChildren
.n_max
< 1) {
661 Config
.redirectChildren
.n_max
= 0;
662 wordlistDestroy(&Config
.Program
.redirect
);
666 if (Config
.Program
.store_id
) {
667 if (Config
.storeIdChildren
.n_max
< 1) {
668 Config
.storeIdChildren
.n_max
= 0;
669 wordlistDestroy(&Config
.Program
.store_id
);
673 if (Config
.appendDomain
)
674 if (*Config
.appendDomain
!= '.')
675 fatal("append_domain must begin with a '.'");
677 if (Config
.errHtmlText
== NULL
)
678 Config
.errHtmlText
= xstrdup(null_string
);
680 #if !HAVE_SETRLIMIT || !defined(RLIMIT_NOFILE)
681 if (Config
.max_filedescriptors
> 0) {
682 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors disabled. Operating System setrlimit(RLIMIT_NOFILE) is missing.");
684 #elif USE_SELECT || USE_SELECT_WIN32
685 if (Config
.max_filedescriptors
> FD_SETSIZE
) {
686 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors limited to " << FD_SETSIZE
<< " by select() algorithm.");
692 snprintf(ThisCache
, sizeof(ThisCache
), "%s (%s)",
694 visible_appname_string
);
697 * the extra space is for loop detection in client_side.c -- we search
698 * for substrings in the Via header.
700 snprintf(ThisCache2
, sizeof(ThisCache
), " %s (%s)",
702 visible_appname_string
);
704 /* Use visible_hostname as default surrogate_id */
705 if (!Config
.Accel
.surrogate_id
) {
706 const char *t
= getMyHostname();
707 Config
.Accel
.surrogate_id
= xstrdup( (t
?t
:"unset-id") );
710 if (!Config
.udpMaxHitObjsz
|| Config
.udpMaxHitObjsz
> SQUID_UDP_SO_SNDBUF
)
711 Config
.udpMaxHitObjsz
= SQUID_UDP_SO_SNDBUF
;
713 if (Config
.appendDomain
)
714 Config
.appendDomainLen
= strlen(Config
.appendDomain
);
716 Config
.appendDomainLen
= 0;
718 if (Config
.connect_retries
> 10) {
719 debugs(0,DBG_CRITICAL
, "WARNING: connect_retries cannot be larger than 10. Resetting to 10.");
720 Config
.connect_retries
= 10;
723 requirePathnameExists("MIME Config Table", Config
.mimeTablePathname
);
726 requirePathnameExists("unlinkd_program", Config
.Program
.unlinkd
);
728 requirePathnameExists("logfile_daemon", Log::TheConfig
.logfile_daemon
);
729 if (Config
.Program
.redirect
)
730 requirePathnameExists("redirect_program", Config
.Program
.redirect
->key
);
732 if (Config
.Program
.store_id
)
733 requirePathnameExists("store_id_program", Config
.Program
.store_id
->key
);
735 requirePathnameExists("Icon Directory", Config
.icons
.directory
);
737 if (Config
.errorDirectory
)
738 requirePathnameExists("Error Directory", Config
.errorDirectory
);
740 #if USE_HTTP_VIOLATIONS
743 const RefreshPattern
*R
;
745 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
746 if (!R
->flags
.override_expire
)
749 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP");
754 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
755 if (!R
->flags
.override_lastmod
)
758 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP");
763 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
764 if (!R
->flags
.reload_into_ims
)
767 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP");
772 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
773 if (!R
->flags
.ignore_reload
)
776 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP");
781 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
782 if (!R
->flags
.ignore_no_store
)
785 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP");
790 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
791 if (!R
->flags
.ignore_private
)
794 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP");
800 #if !USE_HTTP_VIOLATIONS
801 Config
.onoff
.via
= 1;
804 if (!Config
.onoff
.via
)
805 debugs(22, DBG_IMPORTANT
, "WARNING: HTTP requires the use of Via");
809 // we enable runtime PURGE checks if there is at least one PURGE method ACL
810 // TODO: replace with a dedicated "purge" ACL option?
811 Config2
.onoff
.enable_purge
= (ACLMethodData::ThePurgeCount
> 0);
813 if (geteuid() == 0) {
814 if (NULL
!= Config
.effectiveUser
) {
816 struct passwd
*pwd
= getpwnam(Config
.effectiveUser
);
820 * Andres Kroonmaa <andre@online.ee>:
821 * Some getpwnam() implementations (Solaris?) require
822 * an available FD < 256 for opening a FILE* to the
825 * This should be safe at startup, but might still fail
826 * during reconfigure.
828 fatalf("getpwnam failed to find userid for effective user '%s'",
829 Config
.effectiveUser
);
833 Config2
.effectiveUserID
= pwd
->pw_uid
;
835 Config2
.effectiveGroupID
= pwd
->pw_gid
;
838 if (pwd
->pw_dir
&& *pwd
->pw_dir
) {
839 // putenv() leaks by design; avoid leaks when nothing changes
841 if (lastDir
.isEmpty() || !lastDir
.cmp(pwd
->pw_dir
)) {
842 lastDir
= pwd
->pw_dir
;
843 int len
= strlen(pwd
->pw_dir
) + 6;
844 char *env_str
= (char *)xcalloc(len
, 1);
845 snprintf(env_str
, len
, "HOME=%s", pwd
->pw_dir
);
852 Config2
.effectiveUserID
= geteuid();
853 Config2
.effectiveGroupID
= getegid();
856 if (NULL
!= Config
.effectiveGroup
) {
858 struct group
*grp
= getgrnam(Config
.effectiveGroup
);
861 fatalf("getgrnam failed to find groupid for effective group '%s'",
862 Config
.effectiveGroup
);
866 Config2
.effectiveGroupID
= grp
->gr_gid
;
870 if (Config
.ssl_client
.foreignIntermediateCertsPath
)
871 Ssl::loadSquidUntrusted(Config
.ssl_client
.foreignIntermediateCertsPath
);
874 if (Security::ProxyOutgoingConfig
.encryptTransport
) {
875 debugs(3, DBG_IMPORTANT
, "Initializing https:// proxy context");
876 Config
.ssl_client
.sslContext
= Security::ProxyOutgoingConfig
.createClientContext(false);
877 if (!Config
.ssl_client
.sslContext
) {
879 fatal("ERROR: Could not initialize https:// proxy context");
881 debugs(3, DBG_IMPORTANT
, "ERROR: proxying https:// currently still requires --with-openssl");
885 Ssl::useSquidUntrusted(Config
.ssl_client
.sslContext
);
889 for (CachePeer
*p
= Config
.peers
; p
!= NULL
; p
= p
->next
) {
891 // default value for ssldomain= is the peer host/IP
892 if (p
->secure
.sslDomain
.isEmpty())
893 p
->secure
.sslDomain
= p
->host
;
895 if (p
->secure
.encryptTransport
) {
896 debugs(3, DBG_IMPORTANT
, "Initializing cache_peer " << p
->name
<< " TLS context");
897 p
->sslContext
= p
->secure
.createClientContext(true);
898 if (!p
->sslContext
) {
899 debugs(3, DBG_CRITICAL
, "ERROR: Could not initialize cache_peer " << p
->name
<< " TLS context");
906 for (AnyP::PortCfgPointer s
= HttpPortList
; s
!= NULL
; s
= s
->next
) {
907 if (!s
->secure
.encryptTransport
)
909 debugs(3, DBG_IMPORTANT
, "Initializing " << AnyP::UriScheme(s
->transport
.protocol
) << "_port " << s
->s
<< " TLS context");
910 s
->configureSslServerContext();
914 // prevent infinite fetch loops in the request parser
915 // due to buffer full but not enough data recived to finish parse
916 if (Config
.maxRequestBufferSize
<= Config
.maxRequestHeaderSize
) {
917 fatalf("Client request buffer of %u bytes cannot hold a request with %u bytes of headers." \
918 " Change client_request_buffer_max or request_header_max_size limits.",
919 (uint32_t)Config
.maxRequestBufferSize
, (uint32_t)Config
.maxRequestHeaderSize
);
923 * Disable client side request pipelining if client_persistent_connections OFF.
924 * Waste of resources queueing any pipelined requests when the first will close the connection.
926 if (Config
.pipeline_max_prefetch
> 0 && !Config
.onoff
.client_pconns
) {
927 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch " << Config
.pipeline_max_prefetch
<<
928 " requires client_persistent_connections ON. Forced pipeline_prefetch 0.");
929 Config
.pipeline_max_prefetch
= 0;
934 * disable client side request pipelining. There is a race with
935 * Negotiate and NTLM when the client sends a second request on an
936 * connection before the authenticate challenge is sent. With
937 * pipelining OFF, the client may fail to authenticate, but squid's
938 * state will be preserved.
940 if (Config
.pipeline_max_prefetch
> 0) {
941 Auth::Config
*nego
= Auth::Config::Find("Negotiate");
942 Auth::Config
*ntlm
= Auth::Config::Find("NTLM");
943 if ((nego
&& nego
->active()) || (ntlm
&& ntlm
->active())) {
944 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch breaks NTLM and Negotiate authentication. Forced pipeline_prefetch 0.");
945 Config
.pipeline_max_prefetch
= 0;
951 /** Parse a line containing an obsolete directive.
952 * To upgrade it where possible instead of just "Bungled config" for
953 * directives which cannot be marked as simply aliases of the some name.
954 * For example if the parameter order and content has changed.
955 * Or if the directive has been completely removed.
958 parse_obsolete(const char *name
)
960 // Directives which have been radically changed rather than removed
961 if (!strcmp(name
, "url_rewrite_concurrency")) {
964 debugs(3, DBG_CRITICAL
, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
965 Config
.redirectChildren
.concurrency
= cval
;
968 if (!strcmp(name
, "log_access"))
971 if (!strcmp(name
, "log_icap"))
974 if (!strcmp(name
, "ignore_ims_on_miss")) {
975 // the replacement directive cache_revalidate_on_miss has opposite meanings for ON/OFF value
976 // than the 2.7 directive. We need to parse and invert the configured value.
979 Config
.onoff
.cache_miss_revalidate
= !temp
;
982 if (!strncmp(name
, "sslproxy_", 9)) {
983 // the replacement directive tls_outgoing_options uses options instead of whole-line input
985 if (!strcmp(name
, "sslproxy_cafile"))
986 tmp
.append("cafile=");
987 else if (!strcmp(name
, "sslproxy_capath"))
988 tmp
.append("capath=");
989 else if (!strcmp(name
, "sslproxy_cipher"))
990 tmp
.append("cipher=");
991 else if (!strcmp(name
, "sslproxy_client_certificate"))
993 else if (!strcmp(name
, "sslproxy_client_key"))
995 else if (!strcmp(name
, "sslproxy_flags"))
996 tmp
.append("flags=");
997 else if (!strcmp(name
, "sslproxy_options"))
998 tmp
.append("options=");
999 else if (!strcmp(name
, "sslproxy_version"))
1000 tmp
.append("version=");
1002 debugs(3, DBG_CRITICAL
, "ERROR: unknown directive: " << name
);
1006 // add the value as unquoted-string because the old values did not support whitespace
1007 const char *token
= ConfigParser::NextQuotedOrToEol();
1008 tmp
.append(token
, strlen(token
));
1009 Security::ProxyOutgoingConfig
.parse(tmp
.c_str());
1013 /* Parse a time specification from the config file. Store the
1014 * result in 'tptr', after converting it to 'units' */
1016 parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
= false)
1019 if ((u
= parseTimeUnits(units
, allowMsec
)) == 0)
1023 if ((token
= ConfigParser::NextToken()) == NULL
)
1026 double d
= xatof(token
);
1028 time_msec_t m
= u
; /* default to 'units' if none specified */
1031 if ((token
= ConfigParser::PeekAtToken()) && (m
= parseTimeUnits(token
, allowMsec
))) {
1032 (void)ConfigParser::NextToken();
1034 } else if (!expectMoreArguments
) {
1038 token
= NULL
; // show default units if dying below
1039 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" << config_input_line
<< "', assuming " << d
<< " " << units
);
1042 token
= NULL
; // show default units if dying below.
1044 *tptr
= static_cast<time_msec_t
>(m
* d
);
1046 if (static_cast<double>(*tptr
) * 2 != m
* d
* 2) {
1047 debugs(3, DBG_CRITICAL
, "FATAL: Invalid value '" <<
1048 d
<< " " << (token
? token
: units
) << ": integer overflow (time_msec_t).");
1054 parseTimeUnits(const char *unit
, bool allowMsec
)
1056 if (allowMsec
&& !strncasecmp(unit
, T_MILLISECOND_STR
, strlen(T_MILLISECOND_STR
)))
1059 if (!strncasecmp(unit
, T_SECOND_STR
, strlen(T_SECOND_STR
)))
1062 if (!strncasecmp(unit
, T_MINUTE_STR
, strlen(T_MINUTE_STR
)))
1065 if (!strncasecmp(unit
, T_HOUR_STR
, strlen(T_HOUR_STR
)))
1068 if (!strncasecmp(unit
, T_DAY_STR
, strlen(T_DAY_STR
)))
1069 return 86400 * 1000;
1071 if (!strncasecmp(unit
, T_WEEK_STR
, strlen(T_WEEK_STR
)))
1072 return 86400 * 7 * 1000;
1074 if (!strncasecmp(unit
, T_FORTNIGHT_STR
, strlen(T_FORTNIGHT_STR
)))
1075 return 86400 * 14 * 1000;
1077 if (!strncasecmp(unit
, T_MONTH_STR
, strlen(T_MONTH_STR
)))
1078 return static_cast<uint64_t>(86400) * 30 * 1000;
1080 if (!strncasecmp(unit
, T_YEAR_STR
, strlen(T_YEAR_STR
)))
1081 return static_cast<uint64_t>(86400 * 1000 * 365.2522);
1083 if (!strncasecmp(unit
, T_DECADE_STR
, strlen(T_DECADE_STR
)))
1084 return static_cast<uint64_t>(86400 * 1000 * 365.2522 * 10);
1086 debugs(3, DBG_IMPORTANT
, "parseTimeUnits: unknown time unit '" << unit
<< "'");
1092 parseBytesLine64(int64_t * bptr
, const char *units
)
1099 if ((u
= parseBytesUnits(units
)) == 0) {
1104 if ((token
= ConfigParser::NextToken()) == NULL
) {
1109 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1116 m
= u
; /* default to 'units' if none specified */
1120 else if ((token
= ConfigParser::NextToken()) == NULL
)
1121 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1122 config_input_line
<< "', assuming " <<
1123 d
<< " " << units
);
1124 else if ((m
= parseBytesUnits(token
)) == 0) {
1129 *bptr
= static_cast<int64_t>(m
* d
/ u
);
1131 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1132 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1133 d
<< " " << token
<< ": integer overflow (int64_t).");
1139 parseBytesLine(size_t * bptr
, const char *units
)
1146 if ((u
= parseBytesUnits(units
)) == 0) {
1151 if ((token
= ConfigParser::NextToken()) == NULL
) {
1156 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1157 *bptr
= static_cast<size_t>(-1);
1163 m
= u
; /* default to 'units' if none specified */
1167 else if ((token
= ConfigParser::NextToken()) == NULL
)
1168 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1169 config_input_line
<< "', assuming " <<
1170 d
<< " " << units
);
1171 else if ((m
= parseBytesUnits(token
)) == 0) {
1176 *bptr
= static_cast<size_t>(m
* d
/ u
);
1178 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1179 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1180 d
<< " " << token
<< ": integer overflow (size_t).");
1186 parseBytesLineSigned(ssize_t
* bptr
, const char *units
)
1193 if ((u
= parseBytesUnits(units
)) == 0) {
1198 if ((token
= ConfigParser::NextToken()) == NULL
) {
1203 if (strcmp(token
, "none") == 0 || token
[0] == '-' /* -N */) {
1210 m
= u
; /* default to 'units' if none specified */
1214 else if ((token
= ConfigParser::NextToken()) == NULL
)
1215 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1216 config_input_line
<< "', assuming " <<
1217 d
<< " " << units
);
1218 else if ((m
= parseBytesUnits(token
)) == 0) {
1223 *bptr
= static_cast<ssize_t
>(m
* d
/ u
);
1225 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1226 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1227 d
<< " " << token
<< ": integer overflow (ssize_t).");
1233 * Parse bytes from a string.
1234 * Similar to the parseBytesLine function but parses the string value instead of
1235 * the current token value.
1237 static void parseBytesOptionValue(size_t * bptr
, const char *units
, char const * value
)
1240 if ((u
= parseBytesUnits(units
)) == 0) {
1245 // Find number from string beginning.
1246 char const * number_begin
= value
;
1247 char const * number_end
= value
;
1249 while ((*number_end
>= '0' && *number_end
<= '9')) {
1254 number
.limitInit(number_begin
, number_end
- number_begin
);
1256 int d
= xatoi(number
.termedBuf());
1258 if ((m
= parseBytesUnits(number_end
)) == 0) {
1263 *bptr
= static_cast<size_t>(m
* d
/ u
);
1264 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2)
1269 parseBytesUnits(const char *unit
)
1271 if (!strncasecmp(unit
, B_BYTES_STR
, strlen(B_BYTES_STR
)))
1274 if (!strncasecmp(unit
, B_KBYTES_STR
, strlen(B_KBYTES_STR
)))
1277 if (!strncasecmp(unit
, B_MBYTES_STR
, strlen(B_MBYTES_STR
)))
1280 if (!strncasecmp(unit
, B_GBYTES_STR
, strlen(B_GBYTES_STR
)))
1283 debugs(3, DBG_CRITICAL
, "WARNING: Unknown bytes unit '" << unit
<< "'");
1289 dump_SBufList(StoreEntry
* entry
, const SBufList
&words
)
1291 for (SBufList::const_iterator i
= words
.begin(); i
!= words
.end(); ++i
) {
1292 entry
->append(i
->rawContent(), i
->length());
1293 entry
->append(" ",1);
1295 entry
->append("\n",1);
1299 dump_acl(StoreEntry
* entry
, const char *name
, ACL
* ae
)
1301 while (ae
!= NULL
) {
1302 debugs(3, 3, "dump_acl: " << name
<< " " << ae
->name
);
1303 storeAppendPrintf(entry
, "%s %s %s %s ",
1307 ae
->flags
.flagsStr());
1308 dump_SBufList(entry
, ae
->dump());
1314 parse_acl(ACL
** ae
)
1316 ACL::ParseAclLine(LegacyParser
, ae
);
1326 dump_acl_list(StoreEntry
* entry
, ACLList
* head
)
1328 dump_SBufList(entry
, head
->dump());
1332 dump_acl_access(StoreEntry
* entry
, const char *name
, acl_access
* head
)
1335 dump_SBufList(entry
, head
->treeDump(name
,NULL
));
1339 parse_acl_access(acl_access
** head
)
1341 aclParseAccessLine(cfg_directive
, LegacyParser
, head
);
1345 free_acl_access(acl_access
** head
)
1347 aclDestroyAccessList(head
);
1351 dump_address(StoreEntry
* entry
, const char *name
, Ip::Address
&addr
)
1353 char buf
[MAX_IPSTRLEN
];
1354 storeAppendPrintf(entry
, "%s %s\n", name
, addr
.toStr(buf
,MAX_IPSTRLEN
) );
1358 parse_address(Ip::Address
*addr
)
1360 char *token
= ConfigParser::NextToken();
1367 if (!strcmp(token
,"any_addr"))
1369 else if ( (!strcmp(token
,"no_addr")) || (!strcmp(token
,"full_mask")) )
1371 else if ( (*addr
= token
) ) // try parse numeric/IPA
1373 else if (addr
->GetHostByName(token
)) // dont use ipcache
1375 else { // not an IP and not a hostname
1376 debugs(3, DBG_CRITICAL
, "FATAL: invalid IP address or domain name '" << token
<< "'");
1382 free_address(Ip::Address
*addr
)
1388 dump_acl_address(StoreEntry
* entry
, const char *name
, Acl::Address
* head
)
1390 char buf
[MAX_IPSTRLEN
];
1392 for (Acl::Address
*l
= head
; l
; l
= l
->next
) {
1393 if (!l
->addr
.isAnyAddr())
1394 storeAppendPrintf(entry
, "%s %s", name
, l
->addr
.toStr(buf
,MAX_IPSTRLEN
));
1396 storeAppendPrintf(entry
, "%s autoselect", name
);
1398 dump_acl_list(entry
, l
->aclList
);
1400 storeAppendPrintf(entry
, "\n");
1405 parse_acl_address(Acl::Address
** head
)
1407 Acl::Address
*l
= new Acl::Address
;
1408 parse_address(&l
->addr
);
1409 aclParseAclList(LegacyParser
, &l
->aclList
, l
->addr
);
1411 Acl::Address
**tail
= head
;
1413 tail
= &(*tail
)->next
;
1419 free_acl_address(Acl::Address
** head
)
1426 dump_acl_tos(StoreEntry
* entry
, const char *name
, acl_tos
* head
)
1430 for (l
= head
; l
; l
= l
->next
) {
1432 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->tos
);
1434 storeAppendPrintf(entry
, "%s none", name
);
1436 dump_acl_list(entry
, l
->aclList
);
1438 storeAppendPrintf(entry
, "\n");
1443 parse_acl_tos(acl_tos
** head
)
1445 unsigned int tos
; /* Initially uint for strtoui. Casted to tos_t before return */
1446 char *token
= ConfigParser::NextToken();
1453 if (!xstrtoui(token
, NULL
, &tos
, 0, std::numeric_limits
<tos_t
>::max())) {
1458 const unsigned int chTos
= tos
& 0xFC;
1460 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: Tos value '" << tos
<< "' adjusted to '" << chTos
<< "'");
1464 acl_tos
*l
= new acl_tos
;
1466 l
->tos
= (tos_t
)tos
;
1468 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1470 acl_tos
**tail
= head
; /* sane name below */
1472 tail
= &(*tail
)->next
;
1478 free_acl_tos(acl_tos
** head
)
1484 #if SO_MARK && USE_LIBCAP
1487 dump_acl_nfmark(StoreEntry
* entry
, const char *name
, acl_nfmark
* head
)
1489 for (acl_nfmark
*l
= head
; l
; l
= l
->next
) {
1491 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->nfmark
);
1493 storeAppendPrintf(entry
, "%s none", name
);
1495 dump_acl_list(entry
, l
->aclList
);
1497 storeAppendPrintf(entry
, "\n");
1502 parse_acl_nfmark(acl_nfmark
** head
)
1505 char *token
= ConfigParser::NextToken();
1512 if (!xstrtoui(token
, NULL
, &mark
, 0, std::numeric_limits
<nfmark_t
>::max())) {
1517 acl_nfmark
*l
= new acl_nfmark
;
1521 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1523 acl_nfmark
**tail
= head
; /* sane name below */
1525 tail
= &(*tail
)->next
;
1531 free_acl_nfmark(acl_nfmark
** head
)
1536 #endif /* SO_MARK */
1539 dump_acl_b_size_t(StoreEntry
* entry
, const char *name
, AclSizeLimit
* head
)
1541 for (AclSizeLimit
*l
= head
; l
; l
= l
->next
) {
1543 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) l
->size
, B_BYTES_STR
);
1545 storeAppendPrintf(entry
, "%s none", name
);
1547 dump_acl_list(entry
, l
->aclList
);
1549 storeAppendPrintf(entry
, "\n");
1554 parse_acl_b_size_t(AclSizeLimit
** head
)
1556 AclSizeLimit
*l
= new AclSizeLimit
;
1558 parse_b_int64_t(&l
->size
);
1560 aclParseAclList(LegacyParser
, &l
->aclList
, l
->size
);
1562 AclSizeLimit
**tail
= head
; /* sane name below */
1564 tail
= &(*tail
)->next
;
1570 free_acl_b_size_t(AclSizeLimit
** head
)
1578 #include "DelayConfig.h"
1579 #include "DelayPools.h"
1580 /* do nothing - free_delay_pool_count is the magic free function.
1581 * this is why delay_pool_count isn't just marked TYPE: u_short
1583 #define free_delay_pool_class(X)
1584 #define free_delay_pool_access(X)
1585 #define free_delay_pool_rates(X)
1586 #define dump_delay_pool_class(X, Y, Z)
1587 #define dump_delay_pool_access(X, Y, Z)
1588 #define dump_delay_pool_rates(X, Y, Z)
1591 free_delay_pool_count(DelayConfig
* cfg
)
1593 cfg
->freePoolCount();
1597 dump_delay_pool_count(StoreEntry
* entry
, const char *name
, DelayConfig
&cfg
)
1599 cfg
.dumpPoolCount (entry
, name
);
1603 parse_delay_pool_count(DelayConfig
* cfg
)
1605 cfg
->parsePoolCount();
1609 parse_delay_pool_class(DelayConfig
* cfg
)
1611 cfg
->parsePoolClass();
1615 parse_delay_pool_rates(DelayConfig
* cfg
)
1617 cfg
->parsePoolRates();
1621 parse_delay_pool_access(DelayConfig
* cfg
)
1623 cfg
->parsePoolAccess(LegacyParser
);
1629 #include "ClientDelayConfig.h"
1630 /* do nothing - free_client_delay_pool_count is the magic free function.
1631 * this is why client_delay_pool_count isn't just marked TYPE: u_short
1634 #define free_client_delay_pool_access(X)
1635 #define free_client_delay_pool_rates(X)
1636 #define dump_client_delay_pool_access(X, Y, Z)
1637 #define dump_client_delay_pool_rates(X, Y, Z)
1640 free_client_delay_pool_count(ClientDelayConfig
* cfg
)
1642 cfg
->freePoolCount();
1646 dump_client_delay_pool_count(StoreEntry
* entry
, const char *name
, ClientDelayConfig
&cfg
)
1648 cfg
.dumpPoolCount (entry
, name
);
1652 parse_client_delay_pool_count(ClientDelayConfig
* cfg
)
1654 cfg
->parsePoolCount();
1658 parse_client_delay_pool_rates(ClientDelayConfig
* cfg
)
1660 cfg
->parsePoolRates();
1664 parse_client_delay_pool_access(ClientDelayConfig
* cfg
)
1666 cfg
->parsePoolAccess(LegacyParser
);
1670 #if USE_HTTP_VIOLATIONS
1672 dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1675 manglers
->dumpAccess(entry
, name
);
1679 parse_http_header_access(HeaderManglers
**pm
)
1683 if ((t
= ConfigParser::NextToken()) == NULL
) {
1684 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1685 debugs(3, DBG_CRITICAL
, "parse_http_header_access: missing header name.");
1690 *pm
= new HeaderManglers
;
1691 HeaderManglers
*manglers
= *pm
;
1692 headerMangler
*mangler
= manglers
->track(t
);
1695 std::string directive
= "http_header_access ";
1697 aclParseAccessLine(directive
.c_str(), LegacyParser
, &mangler
->access_list
);
1701 free_HeaderManglers(HeaderManglers
**pm
)
1703 // we delete the entire http_header_* mangler configuration at once
1704 if (const HeaderManglers
*manglers
= *pm
) {
1711 dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1714 manglers
->dumpReplacement(entry
, name
);
1718 parse_http_header_replace(HeaderManglers
**pm
)
1722 if ((t
= ConfigParser::NextToken()) == NULL
) {
1723 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1724 debugs(3, DBG_CRITICAL
, "parse_http_header_replace: missing header name.");
1728 const char *value
= ConfigParser::NextQuotedOrToEol();
1731 *pm
= new HeaderManglers
;
1732 HeaderManglers
*manglers
= *pm
;
1733 manglers
->setReplacement(t
, value
);
1739 dump_cachedir(StoreEntry
* entry
, const char *name
, const Store::DiskConfig
&swap
)
1745 for (i
= 0; i
< swap
.n_configured
; ++i
) {
1746 s
= dynamic_cast<SwapDir
*>(swap
.swapDirs
[i
].getRaw());
1748 storeAppendPrintf(entry
, "%s %s %s", name
, s
->type(), s
->path
);
1750 storeAppendPrintf(entry
, "\n");
1755 check_null_string(char *s
)
1762 parse_authparam(Auth::ConfigVector
* config
)
1767 if ((type_str
= ConfigParser::NextToken()) == NULL
)
1770 if ((param_str
= ConfigParser::NextToken()) == NULL
)
1773 /* find a configuration for the scheme in the currently parsed configs... */
1774 Auth::Config
*schemeCfg
= Auth::Config::Find(type_str
);
1776 if (schemeCfg
== NULL
) {
1777 /* Create a configuration based on the scheme info */
1778 Auth::Scheme::Pointer theScheme
= Auth::Scheme::Find(type_str
);
1780 if (theScheme
== NULL
) {
1781 debugs(3, DBG_CRITICAL
, "Parsing Config File: Unknown authentication scheme '" << type_str
<< "'.");
1785 config
->push_back(theScheme
->createConfig());
1786 schemeCfg
= Auth::Config::Find(type_str
);
1787 if (schemeCfg
== NULL
) {
1788 debugs(3, DBG_CRITICAL
, "Parsing Config File: Corruption configuring authentication scheme '" << type_str
<< "'.");
1793 schemeCfg
->parse(schemeCfg
, config
->size(), param_str
);
1797 free_authparam(Auth::ConfigVector
* cfg
)
1799 /* Wipe the Auth globals and Detach/Destruct component config + state. */
1802 /* on reconfigure initialize new auth schemes for the new config. */
1803 if (reconfiguring
) {
1809 dump_authparam(StoreEntry
* entry
, const char *name
, Auth::ConfigVector cfg
)
1811 for (Auth::ConfigVector::iterator i
= cfg
.begin(); i
!= cfg
.end(); ++i
)
1812 (*i
)->dump(entry
, name
, (*i
));
1814 #endif /* USE_AUTH */
1816 /* TODO: just return the object, the # is irrelevant */
1818 find_fstype(char *type
)
1820 for (size_t i
= 0; i
< StoreFileSystem::FileSystems().size(); ++i
)
1821 if (strcasecmp(type
, StoreFileSystem::FileSystems().at(i
)->type()) == 0)
1828 parse_cachedir(Store::DiskConfig
*swap
)
1832 RefCount
<SwapDir
> sd
;
1836 if ((type_str
= ConfigParser::NextToken()) == NULL
)
1839 if ((path_str
= ConfigParser::NextToken()) == NULL
)
1842 fs
= find_fstype(type_str
);
1845 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: This proxy does not support the '" << type_str
<< "' cache type. Ignoring.");
1849 /* reconfigure existing dir */
1851 for (i
= 0; i
< swap
->n_configured
; ++i
) {
1852 assert (swap
->swapDirs
[i
].getRaw());
1854 if ((strcasecmp(path_str
, dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw())->path
)) == 0) {
1855 /* this is specific to on-fs Stores. The right
1856 * way to handle this is probably to have a mapping
1857 * from paths to stores, and have on-fs stores
1858 * register with that, and lookip in that in their
1859 * own setup logic. RBC 20041225. TODO.
1862 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw());
1864 if (strcmp(sd
->type(), StoreFileSystem::FileSystems().at(fs
)->type()) != 0) {
1865 debugs(3, DBG_CRITICAL
, "ERROR: Can't change type of existing cache_dir " <<
1866 sd
->type() << " " << sd
->path
<< " to " << type_str
<< ". Restart required");
1876 if (swap
->n_configured
> 63) {
1877 /* 7 bits, signed */
1878 debugs(3, DBG_CRITICAL
, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle.");
1879 debugs(3, DBG_CRITICAL
, "WARNING: '" << path_str
<< "' is one to many.");
1884 allocate_new_swapdir(swap
);
1886 swap
->swapDirs
[swap
->n_configured
] = StoreFileSystem::FileSystems().at(fs
)->createSwapDir();
1888 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[swap
->n_configured
].getRaw());
1890 /* parse the FS parameters and options */
1891 sd
->parse(swap
->n_configured
, path_str
);
1893 ++swap
->n_configured
;
1897 peer_type_str(const peer_t type
)
1899 const char * result
;
1911 case PEER_MULTICAST
:
1912 result
= "multicast";
1924 dump_peer(StoreEntry
* entry
, const char *name
, CachePeer
* p
)
1926 NeighborTypeDomainList
*t
;
1927 LOCAL_ARRAY(char, xname
, 128);
1930 storeAppendPrintf(entry
, "%s %s %s %d %d name=%s",
1937 dump_peer_options(entry
, p
);
1940 snprintf(xname
, 128, "cache_peer_access %s", p
->name
);
1941 dump_acl_access(entry
, xname
, p
->access
);
1944 for (t
= p
->typelist
; t
; t
= t
->next
) {
1945 storeAppendPrintf(entry
, "neighbor_type_domain %s %s %s\n",
1947 peer_type_str(t
->type
),
1956 * utility function to prevent getservbyname() being called with a numeric value
1957 * on Windows at least it returns garage results.
1960 isUnsignedNumeric(const char *str
, size_t len
)
1962 if (len
< 1) return false;
1964 for (; len
>0 && *str
; ++str
, --len
) {
1965 if (! isdigit(*str
))
1972 \param proto 'tcp' or 'udp' for protocol
1973 \returns Port the named service is supposed to be listening on.
1975 static unsigned short
1976 GetService(const char *proto
)
1978 struct servent
*port
= NULL
;
1979 /** Parses a port number or service name from the squid.conf */
1980 char *token
= ConfigParser::NextToken();
1981 if (token
== NULL
) {
1983 return 0; /* NEVER REACHED */
1985 /** Returns either the service port number from /etc/services */
1986 if ( !isUnsignedNumeric(token
, strlen(token
)) )
1987 port
= getservbyname(token
, proto
);
1989 return ntohs((unsigned short)port
->s_port
);
1991 /** Or a numeric translation of the config text. */
1992 return xatos(token
);
1996 \returns Port the named TCP service is supposed to be listening on.
1997 \copydoc GetService(const char *proto)
1999 inline unsigned short
2002 return GetService("tcp");
2006 \returns Port the named UDP service is supposed to be listening on.
2007 \copydoc GetService(const char *proto)
2009 inline unsigned short
2012 return GetService("udp");
2016 parse_peer(CachePeer
** head
)
2019 CachePeer
*p
= new CachePeer
;
2021 if ((token
= ConfigParser::NextToken()) == NULL
)
2024 p
->host
= xstrdup(token
);
2026 p
->name
= xstrdup(token
);
2028 if ((token
= ConfigParser::NextToken()) == NULL
)
2031 p
->type
= parseNeighborType(token
);
2033 if (p
->type
== PEER_MULTICAST
) {
2034 p
->options
.no_digest
= true;
2035 p
->options
.no_netdb_exchange
= true;
2038 p
->http_port
= GetTcpService();
2043 p
->icp
.port
= GetUdpService();
2045 while ((token
= ConfigParser::NextToken())) {
2046 if (!strcmp(token
, "proxy-only")) {
2047 p
->options
.proxy_only
= true;
2048 } else if (!strcmp(token
, "no-query")) {
2049 p
->options
.no_query
= true;
2050 } else if (!strcmp(token
, "background-ping")) {
2051 p
->options
.background_ping
= true;
2052 } else if (!strcmp(token
, "no-digest")) {
2053 p
->options
.no_digest
= true;
2054 } else if (!strcmp(token
, "no-tproxy")) {
2055 p
->options
.no_tproxy
= true;
2056 } else if (!strcmp(token
, "multicast-responder")) {
2057 p
->options
.mcast_responder
= true;
2058 #if PEER_MULTICAST_SIBLINGS
2059 } else if (!strcmp(token
, "multicast-siblings")) {
2060 p
->options
.mcast_siblings
= true;
2062 } else if (!strncmp(token
, "weight=", 7)) {
2063 p
->weight
= xatoi(token
+ 7);
2064 } else if (!strncmp(token
, "basetime=", 9)) {
2065 p
->basetime
= xatoi(token
+ 9);
2066 } else if (!strcmp(token
, "closest-only")) {
2067 p
->options
.closest_only
= true;
2068 } else if (!strncmp(token
, "ttl=", 4)) {
2069 p
->mcast
.ttl
= xatoi(token
+ 4);
2071 if (p
->mcast
.ttl
< 0)
2074 if (p
->mcast
.ttl
> 128)
2076 } else if (!strcmp(token
, "default")) {
2077 p
->options
.default_parent
= true;
2078 } else if (!strcmp(token
, "round-robin")) {
2079 p
->options
.roundrobin
= true;
2080 } else if (!strcmp(token
, "weighted-round-robin")) {
2081 p
->options
.weighted_roundrobin
= true;
2083 } else if (!strcmp(token
, "htcp")) {
2084 p
->options
.htcp
= true;
2085 } else if (!strncmp(token
, "htcp=", 5) || !strncmp(token
, "htcp-", 5)) {
2086 /* Note: The htcp- form is deprecated, replaced by htcp= */
2087 p
->options
.htcp
= true;
2088 char *tmp
= xstrdup(token
+5);
2089 char *mode
, *nextmode
;
2090 for (mode
= nextmode
= tmp
; mode
; mode
= nextmode
) {
2091 nextmode
= strchr(mode
, ',');
2096 if (!strcmp(mode
, "no-clr")) {
2097 if (p
->options
.htcp_only_clr
)
2098 fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
2099 p
->options
.htcp_no_clr
= true;
2100 } else if (!strcmp(mode
, "no-purge-clr")) {
2101 p
->options
.htcp_no_purge_clr
= true;
2102 } else if (!strcmp(mode
, "only-clr")) {
2103 if (p
->options
.htcp_no_clr
)
2104 fatalf("parse_peer: can't set htcp no-clr and only-clr simultaneously");
2105 p
->options
.htcp_only_clr
= true;
2106 } else if (!strcmp(mode
, "forward-clr")) {
2107 p
->options
.htcp_forward_clr
= true;
2108 } else if (!strcmp(mode
, "oldsquid")) {
2109 p
->options
.htcp_oldsquid
= true;
2111 fatalf("invalid HTCP mode '%s'", mode
);
2116 } else if (!strcmp(token
, "no-netdb-exchange")) {
2117 p
->options
.no_netdb_exchange
= true;
2119 } else if (!strcmp(token
, "carp")) {
2120 if (p
->type
!= PEER_PARENT
)
2121 fatalf("parse_peer: non-parent carp peer %s/%d\n", p
->host
, p
->http_port
);
2123 p
->options
.carp
= true;
2124 } else if (!strncmp(token
, "carp-key=", 9)) {
2125 if (p
->options
.carp
!= true)
2126 fatalf("parse_peer: carp-key specified on non-carp peer %s/%d\n", p
->host
, p
->http_port
);
2127 p
->options
.carp_key
.set
= true;
2128 char *nextkey
=token
+strlen("carp-key="), *key
=nextkey
;
2129 for (; key
; key
= nextkey
) {
2130 nextkey
=strchr(key
,',');
2131 if (nextkey
) ++nextkey
; // skip the comma, any
2132 if (0==strncmp(key
,"scheme",6)) {
2133 p
->options
.carp_key
.scheme
= true;
2134 } else if (0==strncmp(key
,"host",4)) {
2135 p
->options
.carp_key
.host
= true;
2136 } else if (0==strncmp(key
,"port",4)) {
2137 p
->options
.carp_key
.port
= true;
2138 } else if (0==strncmp(key
,"path",4)) {
2139 p
->options
.carp_key
.path
= true;
2140 } else if (0==strncmp(key
,"params",6)) {
2141 p
->options
.carp_key
.params
= true;
2143 fatalf("invalid carp-key '%s'",key
);
2146 } else if (!strcmp(token
, "userhash")) {
2148 if (p
->type
!= PEER_PARENT
)
2149 fatalf("parse_peer: non-parent userhash peer %s/%d\n", p
->host
, p
->http_port
);
2151 p
->options
.userhash
= true;
2153 fatalf("parse_peer: userhash requires authentication. peer %s/%d\n", p
->host
, p
->http_port
);
2155 } else if (!strcmp(token
, "sourcehash")) {
2156 if (p
->type
!= PEER_PARENT
)
2157 fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p
->host
, p
->http_port
);
2159 p
->options
.sourcehash
= true;
2161 } else if (!strcmp(token
, "no-delay")) {
2163 p
->options
.no_delay
= true;
2165 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option 'no-delay' requires --enable-delay-pools");
2167 } else if (!strncmp(token
, "login=", 6)) {
2168 p
->login
= xstrdup(token
+ 6);
2169 rfc1738_unescape(p
->login
);
2170 } else if (!strcmp(token
, "auth-no-keytab")) {
2171 p
->options
.auth_no_keytab
= 1;
2172 } else if (!strncmp(token
, "connect-timeout=", 16)) {
2173 p
->connect_timeout
= xatoi(token
+ 16);
2174 } else if (!strncmp(token
, "connect-fail-limit=", 19)) {
2175 p
->connect_fail_limit
= xatoi(token
+ 19);
2176 #if USE_CACHE_DIGESTS
2177 } else if (!strncmp(token
, "digest-url=", 11)) {
2178 p
->digest_url
= xstrdup(token
+ 11);
2181 } else if (!strcmp(token
, "allow-miss")) {
2182 p
->options
.allow_miss
= true;
2183 } else if (!strncmp(token
, "max-conn=", 9)) {
2184 p
->max_conn
= xatoi(token
+ 9);
2185 } else if (!strncmp(token
, "standby=", 8)) {
2186 p
->standby
.limit
= xatoi(token
+ 8);
2187 } else if (!strcmp(token
, "originserver")) {
2188 p
->options
.originserver
= true;
2189 } else if (!strncmp(token
, "name=", 5)) {
2193 p
->name
= xstrdup(token
+ 5);
2194 } else if (!strncmp(token
, "forceddomain=", 13)) {
2195 safe_free(p
->domain
);
2197 p
->domain
= xstrdup(token
+ 13);
2199 } else if (strncmp(token
, "ssl", 3) == 0) {
2201 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option '" << token
<< "' requires --with-openssl");
2203 p
->secure
.parse(token
+3);
2205 } else if (strncmp(token
, "tls-", 4) == 0) {
2206 p
->secure
.parse(token
+4);
2207 } else if (strncmp(token
, "tls", 3) == 0) {
2208 p
->secure
.parse(token
+3);
2209 } else if (strcmp(token
, "front-end-https") == 0) {
2210 p
->front_end_https
= 1;
2211 } else if (strcmp(token
, "front-end-https=on") == 0) {
2212 p
->front_end_https
= 1;
2213 } else if (strcmp(token
, "front-end-https=auto") == 0) {
2214 p
->front_end_https
= 2;
2215 } else if (strcmp(token
, "connection-auth=off") == 0) {
2216 p
->connection_auth
= 0;
2217 } else if (strcmp(token
, "connection-auth") == 0) {
2218 p
->connection_auth
= 1;
2219 } else if (strcmp(token
, "connection-auth=on") == 0) {
2220 p
->connection_auth
= 1;
2221 } else if (strcmp(token
, "connection-auth=auto") == 0) {
2222 p
->connection_auth
= 2;
2223 } else if (token
[0] == '#') {
2224 // start of a text comment. stop reading this line.
2227 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Ignoring unknown cache_peer option '" << token
<< "'");
2231 if (peerFindByName(p
->name
))
2232 fatalf("ERROR: cache_peer %s specified twice\n", p
->name
);
2234 if (p
->max_conn
> 0 && p
->max_conn
< p
->standby
.limit
)
2235 fatalf("ERROR: cache_peer %s max-conn=%d is lower than its standby=%d\n", p
->host
, p
->max_conn
, p
->standby
.limit
);
2240 if (p
->connect_fail_limit
< 1)
2241 p
->connect_fail_limit
= 10;
2243 #if USE_CACHE_DIGESTS
2245 if (!p
->options
.no_digest
) {
2246 /* XXX This looks odd.. who has the original pointer
2249 PeerDigest
*pd
= peerDigestCreate(p
);
2250 p
->digest
= cbdataReference(pd
);
2255 p
->index
= ++Config
.npeers
;
2257 while (*head
!= NULL
)
2258 head
= &(*head
)->next
;
2266 free_peer(CachePeer
** P
)
2274 dump_cachemgrpasswd(StoreEntry
* entry
, const char *name
, Mgr::ActionPasswordList
* list
)
2278 while (list
!= NULL
) {
2279 if (strcmp(list
->passwd
, "none") && strcmp(list
->passwd
, "disable"))
2280 storeAppendPrintf(entry
, "%s XXXXXXXXXX", name
);
2282 storeAppendPrintf(entry
, "%s %s", name
, list
->passwd
);
2284 for (w
= list
->actions
; w
!= NULL
; w
= w
->next
) {
2285 storeAppendPrintf(entry
, " %s", w
->key
);
2288 storeAppendPrintf(entry
, "\n");
2294 parse_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2296 char *passwd
= NULL
;
2297 wordlist
*actions
= NULL
;
2298 Mgr::ActionPasswordList
*p
;
2299 Mgr::ActionPasswordList
**P
;
2300 parse_string(&passwd
);
2301 parse_wordlist(&actions
);
2302 p
= new Mgr::ActionPasswordList
;
2304 p
->actions
= actions
;
2306 for (P
= head
; *P
; P
= &(*P
)->next
) {
2308 * See if any of the actions from this line already have a
2309 * password from previous lines. The password checking
2310 * routines in cache_manager.c take the the password from
2311 * the first Mgr::ActionPasswordList that contains the
2312 * requested action. Thus, we should warn users who might
2313 * think they can have two passwords for the same action.
2318 for (w
= (*P
)->actions
; w
; w
= w
->next
) {
2319 for (u
= actions
; u
; u
= u
->next
) {
2320 if (strcmp(w
->key
, u
->key
))
2323 debugs(0, DBG_CRITICAL
, "WARNING: action '" << u
->key
<< "' (line " << config_lineno
<< ") already has a password");
2332 free_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2334 Mgr::ActionPasswordList
*p
;
2336 while ((p
= *head
) != NULL
) {
2339 wordlistDestroy(&p
->actions
);
2345 dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
)
2349 while (var
!= NULL
) {
2350 storeAppendPrintf(entry
, "%s %s", name
, var
->err_page_name
);
2352 for (a
= var
->acl_list
; a
!= NULL
; a
= a
->next
)
2353 storeAppendPrintf(entry
, " %s", a
->name
);
2355 storeAppendPrintf(entry
, "\n");
2362 parse_denyinfo(AclDenyInfoList
** var
)
2364 aclParseDenyInfoLine(var
);
2368 free_denyinfo(AclDenyInfoList
** list
)
2370 AclDenyInfoList
*a
= NULL
;
2371 AclDenyInfoList
*a_next
= NULL
;
2372 AclNameList
*l
= NULL
;
2373 AclNameList
*l_next
= NULL
;
2375 for (a
= *list
; a
; a
= a_next
) {
2376 for (l
= a
->acl_list
; l
; l
= l_next
) {
2378 memFree(l
, MEM_ACL_NAME_LIST
);
2383 memFree(a
, MEM_ACL_DENY_INFO_LIST
);
2391 parse_peer_access(void)
2396 if (!(host
= ConfigParser::NextToken()))
2399 if ((p
= peerFindByName(host
)) == NULL
) {
2400 debugs(15, DBG_CRITICAL
, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2404 std::string directive
= "peer_access ";
2406 aclParseAccessLine(directive
.c_str(), LegacyParser
, &p
->access
);
2410 parse_hostdomaintype(void)
2414 char *domain
= NULL
;
2416 if (!(host
= ConfigParser::NextToken()))
2419 if (!(type
= ConfigParser::NextToken()))
2422 while ((domain
= ConfigParser::NextToken())) {
2423 NeighborTypeDomainList
*l
= NULL
;
2424 NeighborTypeDomainList
**L
= NULL
;
2427 if ((p
= peerFindByName(host
)) == NULL
) {
2428 debugs(15, DBG_CRITICAL
, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2432 l
= static_cast<NeighborTypeDomainList
*>(xcalloc(1, sizeof(NeighborTypeDomainList
)));
2433 l
->type
= parseNeighborType(type
);
2434 l
->domain
= xstrdup(domain
);
2436 for (L
= &(p
->typelist
); *L
; L
= &((*L
)->next
));
2442 dump_int(StoreEntry
* entry
, const char *name
, int var
)
2444 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2462 dump_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2464 storeAppendPrintf(entry
, "%s %" PRId64
"\n", name
, var
);
2468 parse_int64_t(int64_t *var
)
2476 free_int64_t(int64_t *var
)
2482 dump_onoff(StoreEntry
* entry
, const char *name
, int var
)
2484 storeAppendPrintf(entry
, "%s %s\n", name
, var
? "on" : "off");
2488 parse_onoff(int *var
)
2490 char *token
= ConfigParser::NextToken();
2495 if (!strcmp(token
, "on")) {
2497 } else if (!strcmp(token
, "enable")) {
2498 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use 'on'.");
2500 } else if (!strcmp(token
, "off")) {
2502 } else if (!strcmp(token
, "disable")) {
2503 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use 'off'.");
2506 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Boolean options can only be 'on' or 'off'.");
2511 #define free_onoff free_int
2514 dump_tristate(StoreEntry
* entry
, const char *name
, int var
)
2525 storeAppendPrintf(entry
, "%s %s\n", name
, state
);
2529 parse_tristate(int *var
)
2531 char *token
= ConfigParser::NextToken();
2536 if (!strcmp(token
, "on")) {
2538 } else if (!strcmp(token
, "enable")) {
2539 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use value 'on'.");
2541 } else if (!strcmp(token
, "warn")) {
2543 } else if (!strcmp(token
, "off")) {
2545 } else if (!strcmp(token
, "disable")) {
2546 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use value 'off'.");
2549 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Tristate options can only be 'on', 'off', or 'warn'.");
2554 #define free_tristate free_int
2557 parse_pipelinePrefetch(int *var
)
2559 char *token
= ConfigParser::PeekAtToken();
2564 if (!strcmp(token
, "on")) {
2565 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'pipeline_prefetch on' is deprecated. Please update to use 1 (or a higher number).");
2568 (void)ConfigParser::NextToken();
2569 } else if (!strcmp(token
, "off")) {
2570 debugs(0, DBG_PARSE_NOTE(2), "WARNING: 'pipeline_prefetch off' is deprecated. Please update to use '0'.");
2573 (void)ConfigParser::NextToken();
2578 #define free_pipelinePrefetch free_int
2579 #define dump_pipelinePrefetch dump_int
2582 dump_refreshpattern(StoreEntry
* entry
, const char *name
, RefreshPattern
* head
)
2584 while (head
!= NULL
) {
2585 storeAppendPrintf(entry
, "%s%s %s %d %d%% %d",
2587 head
->pattern
.flags
®_ICASE
? " -i" : null_string
,
2588 head
->pattern
.c_str(),
2589 (int) head
->min
/ 60,
2590 (int) (100.0 * head
->pct
+ 0.5),
2591 (int) head
->max
/ 60);
2593 if (head
->max_stale
>= 0)
2594 storeAppendPrintf(entry
, " max-stale=%d", head
->max_stale
);
2596 if (head
->flags
.refresh_ims
)
2597 storeAppendPrintf(entry
, " refresh-ims");
2599 if (head
->flags
.store_stale
)
2600 storeAppendPrintf(entry
, " store-stale");
2602 #if USE_HTTP_VIOLATIONS
2604 if (head
->flags
.override_expire
)
2605 storeAppendPrintf(entry
, " override-expire");
2607 if (head
->flags
.override_lastmod
)
2608 storeAppendPrintf(entry
, " override-lastmod");
2610 if (head
->flags
.reload_into_ims
)
2611 storeAppendPrintf(entry
, " reload-into-ims");
2613 if (head
->flags
.ignore_reload
)
2614 storeAppendPrintf(entry
, " ignore-reload");
2616 if (head
->flags
.ignore_no_store
)
2617 storeAppendPrintf(entry
, " ignore-no-store");
2619 if (head
->flags
.ignore_private
)
2620 storeAppendPrintf(entry
, " ignore-private");
2623 storeAppendPrintf(entry
, "\n");
2630 parse_refreshpattern(RefreshPattern
** head
)
2637 int refresh_ims
= 0;
2638 int store_stale
= 0;
2641 #if USE_HTTP_VIOLATIONS
2643 int override_expire
= 0;
2644 int override_lastmod
= 0;
2645 int reload_into_ims
= 0;
2646 int ignore_reload
= 0;
2647 int ignore_no_store
= 0;
2648 int ignore_private
= 0;
2655 int flags
= REG_EXTENDED
| REG_NOSUB
;
2657 if ((token
= ConfigParser::RegexPattern()) != NULL
) {
2659 if (strcmp(token
, "-i") == 0) {
2661 token
= ConfigParser::RegexPattern();
2662 } else if (strcmp(token
, "+i") == 0) {
2663 flags
&= ~REG_ICASE
;
2664 token
= ConfigParser::RegexPattern();
2669 if (token
== NULL
) {
2670 debugs(3, DBG_CRITICAL
, "FATAL: refresh_pattern missing the regex pattern parameter");
2675 pattern
= xstrdup(token
);
2677 i
= GetInteger(); /* token: min */
2679 /* catch negative and insanely huge values close to 32-bit wrap */
2681 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age negative. Cropped back to zero.");
2684 if (i
> 60*24*365) {
2685 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age too high. Cropped back to 1 year.");
2689 min
= (time_t) (i
* 60); /* convert minutes to seconds */
2691 pct
= GetPercentage(false); /* token: pct . with no limit on size */
2693 i
= GetInteger(); /* token: max */
2695 /* catch negative and insanely huge values close to 32-bit wrap */
2697 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age negative. Cropped back to zero.");
2700 if (i
> 60*24*365) {
2701 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age too high. Cropped back to 1 year.");
2705 max
= (time_t) (i
* 60); /* convert minutes to seconds */
2708 while ((token
= ConfigParser::NextToken()) != NULL
) {
2709 if (!strcmp(token
, "refresh-ims")) {
2711 } else if (!strcmp(token
, "store-stale")) {
2713 } else if (!strncmp(token
, "max-stale=", 10)) {
2714 max_stale
= xatoi(token
+ 10);
2716 #if USE_HTTP_VIOLATIONS
2718 } else if (!strcmp(token
, "override-expire"))
2719 override_expire
= 1;
2720 else if (!strcmp(token
, "override-lastmod"))
2721 override_lastmod
= 1;
2722 else if (!strcmp(token
, "ignore-no-store"))
2723 ignore_no_store
= 1;
2724 else if (!strcmp(token
, "ignore-private"))
2726 else if (!strcmp(token
, "reload-into-ims")) {
2727 reload_into_ims
= 1;
2728 refresh_nocache_hack
= 1;
2729 /* tell client_side.c that this is used */
2730 } else if (!strcmp(token
, "ignore-reload")) {
2732 refresh_nocache_hack
= 1;
2733 /* tell client_side.c that this is used */
2736 } else if (!strcmp(token
, "ignore-no-cache") ||
2737 !strcmp(token
, "ignore-must-revalidate") ||
2738 !strcmp(token
, "ignore-auth")
2740 debugs(22, DBG_PARSE_NOTE(2), "UPGRADE: refresh_pattern option '" << token
<< "' is obsolete. Remove it.");
2742 debugs(22, DBG_CRITICAL
, "refreshAddToList: Unknown option '" << pattern
<< "': " << token
);
2745 if ((errcode
= regcomp(&comp
, pattern
, flags
)) != 0) {
2747 regerror(errcode
, &comp
, errbuf
, sizeof errbuf
);
2748 debugs(22, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
2749 debugs(22, DBG_CRITICAL
, "refreshAddToList: Invalid regular expression '" << pattern
<< "': " << errbuf
);
2754 pct
= pct
< 0.0 ? 0.0 : pct
;
2755 max
= max
< 0 ? 0 : max
;
2756 t
= new RefreshPattern(pattern
, flags
);
2757 t
->pattern
.regex
= comp
;
2763 t
->flags
.refresh_ims
= true;
2766 t
->flags
.store_stale
= true;
2768 t
->max_stale
= max_stale
;
2770 #if USE_HTTP_VIOLATIONS
2772 if (override_expire
)
2773 t
->flags
.override_expire
= true;
2775 if (override_lastmod
)
2776 t
->flags
.override_lastmod
= true;
2778 if (reload_into_ims
)
2779 t
->flags
.reload_into_ims
= true;
2782 t
->flags
.ignore_reload
= true;
2784 if (ignore_no_store
)
2785 t
->flags
.ignore_no_store
= true;
2788 t
->flags
.ignore_private
= true;
2794 head
= &(*head
)->next
;
2802 free_refreshpattern(RefreshPattern
** head
)
2807 #if USE_HTTP_VIOLATIONS
2808 refresh_nocache_hack
= 0;
2814 dump_string(StoreEntry
* entry
, const char *name
, char *var
)
2817 storeAppendPrintf(entry
, "%s %s\n", name
, var
);
2821 parse_string(char **var
)
2823 char *token
= ConfigParser::NextToken();
2829 *var
= xstrdup(token
);
2833 free_string(char **var
)
2839 parse_eol(char *volatile *var
)
2846 unsigned char *token
= (unsigned char *) ConfigParser::NextQuotedOrToEol();
2854 while (*token
&& xisspace(*token
))
2862 *var
= xstrdup((char *) token
);
2865 #define dump_eol dump_string
2866 #define free_eol free_string
2869 parse_TokenOrQuotedString(char **var
)
2871 char *token
= ConfigParser::NextQuotedToken();
2877 *var
= xstrdup(token
);
2880 #define dump_TokenOrQuotedString dump_string
2881 #define free_TokenOrQuotedString free_string
2884 dump_time_t(StoreEntry
* entry
, const char *name
, time_t var
)
2886 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int) var
);
2890 parse_time_t(time_t * var
)
2893 parseTimeLine(&tval
, T_SECOND_STR
, false);
2894 *var
= static_cast<time_t>(tval
/1000);
2898 free_time_t(time_t * var
)
2904 dump_time_msec(StoreEntry
* entry
, const char *name
, time_msec_t var
)
2907 storeAppendPrintf(entry
, "%s %" PRId64
" milliseconds\n", name
, var
);
2909 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int)(var
/1000) );
2913 parse_time_msec(time_msec_t
* var
)
2915 parseTimeLine(var
, T_SECOND_STR
, true);
2919 free_time_msec(time_msec_t
* var
)
2926 dump_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2928 storeAppendPrintf(entry
, "%s %d\n", name
, (int) var
);
2933 dump_b_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2935 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2939 dump_b_ssize_t(StoreEntry
* entry
, const char *name
, ssize_t var
)
2941 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
2946 dump_kb_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
2948 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_KBYTES_STR
);
2953 dump_b_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2955 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_BYTES_STR
);
2959 dump_kb_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2961 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_KBYTES_STR
);
2966 parse_size_t(size_t * var
)
2975 parse_b_size_t(size_t * var
)
2977 parseBytesLine(var
, B_BYTES_STR
);
2981 parse_b_ssize_t(ssize_t
* var
)
2983 parseBytesLineSigned(var
, B_BYTES_STR
);
2988 parse_kb_size_t(size_t * var
)
2990 parseBytesLine(var
, B_KBYTES_STR
);
2995 parse_b_int64_t(int64_t * var
)
2997 parseBytesLine64(var
, B_BYTES_STR
);
3001 parse_kb_int64_t(int64_t * var
)
3003 parseBytesLine64(var
, B_KBYTES_STR
);
3007 free_size_t(size_t * var
)
3013 free_ssize_t(ssize_t
* var
)
3019 free_b_int64_t(int64_t * var
)
3024 #define free_b_size_t free_size_t
3025 #define free_b_ssize_t free_ssize_t
3026 #define free_kb_size_t free_size_t
3027 #define free_mb_size_t free_size_t
3028 #define free_gb_size_t free_size_t
3029 #define free_kb_int64_t free_b_int64_t
3032 dump_u_short(StoreEntry
* entry
, const char *name
, unsigned short var
)
3034 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
3038 free_u_short(unsigned short * u
)
3044 parse_u_short(unsigned short * var
)
3046 ConfigParser::ParseUShort(var
);
3050 ConfigParser::ParseUShort(unsigned short *var
)
3056 ConfigParser::ParseBool(bool *var
)
3058 int i
= GetInteger();
3069 dump_wordlist(StoreEntry
* entry
, const char *name
, wordlist
* list
)
3071 while (list
!= NULL
) {
3072 storeAppendPrintf(entry
, "%s %s\n", name
, list
->key
);
3078 ConfigParser::ParseWordList(wordlist
** list
)
3080 parse_wordlist(list
);
3084 parse_wordlist(wordlist
** list
)
3087 while ((token
= ConfigParser::NextQuotedToken()))
3088 wordlistAdd(list
, token
);
3091 #if 0 /* now unused */
3093 check_null_wordlist(wordlist
* w
)
3100 check_null_acl_access(acl_access
* a
)
3105 #define free_wordlist wordlistDestroy
3107 #define free_uri_whitespace free_int
3110 parse_uri_whitespace(int *var
)
3112 char *token
= ConfigParser::NextToken();
3117 if (!strcmp(token
, "strip"))
3118 *var
= URI_WHITESPACE_STRIP
;
3119 else if (!strcmp(token
, "deny"))
3120 *var
= URI_WHITESPACE_DENY
;
3121 else if (!strcmp(token
, "allow"))
3122 *var
= URI_WHITESPACE_ALLOW
;
3123 else if (!strcmp(token
, "encode"))
3124 *var
= URI_WHITESPACE_ENCODE
;
3125 else if (!strcmp(token
, "chop"))
3126 *var
= URI_WHITESPACE_CHOP
;
3128 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'uri_whitespace' accepts 'strip', 'deny', 'allow', 'encode', and 'chop'.");
3134 dump_uri_whitespace(StoreEntry
* entry
, const char *name
, int var
)
3138 if (var
== URI_WHITESPACE_ALLOW
)
3140 else if (var
== URI_WHITESPACE_ENCODE
)
3142 else if (var
== URI_WHITESPACE_CHOP
)
3144 else if (var
== URI_WHITESPACE_DENY
)
3149 storeAppendPrintf(entry
, "%s %s\n", name
, s
);
3153 free_removalpolicy(RemovalPolicySettings
** settings
)
3158 free_string(&(*settings
)->type
);
3160 free_wordlist(&(*settings
)->args
);
3168 parse_removalpolicy(RemovalPolicySettings
** settings
)
3171 free_removalpolicy(settings
);
3173 *settings
= new RemovalPolicySettings
;
3175 parse_string(&(*settings
)->type
);
3177 parse_wordlist(&(*settings
)->args
);
3181 dump_removalpolicy(StoreEntry
* entry
, const char *name
, RemovalPolicySettings
* settings
)
3184 storeAppendPrintf(entry
, "%s %s", name
, settings
->type
);
3185 args
= settings
->args
;
3188 storeAppendPrintf(entry
, " %s", args
->key
);
3192 storeAppendPrintf(entry
, "\n");
3196 free_YesNoNone(YesNoNone
*)
3200 parse_YesNoNone(YesNoNone
*option
)
3203 parse_onoff(&value
);
3204 option
->configure(value
> 0);
3208 dump_YesNoNone(StoreEntry
* entry
, const char *name
, YesNoNone
&option
)
3210 if (option
.configured())
3211 dump_onoff(entry
, name
, option
? 1 : 0);
3215 free_memcachemode(SquidConfig
*)
3219 parse_memcachemode(SquidConfig
*)
3221 char *token
= ConfigParser::NextToken();
3225 if (strcmp(token
, "always") == 0) {
3226 Config
.onoff
.memory_cache_first
= 1;
3227 Config
.onoff
.memory_cache_disk
= 1;
3228 } else if (strcmp(token
, "disk") == 0) {
3229 Config
.onoff
.memory_cache_first
= 0;
3230 Config
.onoff
.memory_cache_disk
= 1;
3231 } else if (strncmp(token
, "net", 3) == 0) {
3232 Config
.onoff
.memory_cache_first
= 1;
3233 Config
.onoff
.memory_cache_disk
= 0;
3234 } else if (strcmp(token
, "never") == 0) {
3235 Config
.onoff
.memory_cache_first
= 0;
3236 Config
.onoff
.memory_cache_disk
= 0;
3238 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'memory_cache_mode' accepts 'always', 'disk', 'network', and 'never'.");
3244 dump_memcachemode(StoreEntry
* entry
, const char *name
, SquidConfig
&)
3246 storeAppendPrintf(entry
, "%s ", name
);
3247 if (Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3248 storeAppendPrintf(entry
, "always");
3249 else if (!Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3250 storeAppendPrintf(entry
, "disk");
3251 else if (Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3252 storeAppendPrintf(entry
, "network");
3253 else if (!Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3254 storeAppendPrintf(entry
, "none");
3255 storeAppendPrintf(entry
, "\n");
3258 #include "cf_parser.cci"
3261 parseNeighborType(const char *s
)
3263 if (!strcmp(s
, "parent"))
3266 if (!strcmp(s
, "neighbor"))
3267 return PEER_SIBLING
;
3269 if (!strcmp(s
, "neighbour"))
3270 return PEER_SIBLING
;
3272 if (!strcmp(s
, "sibling"))
3273 return PEER_SIBLING
;
3275 if (!strcmp(s
, "multicast"))
3276 return PEER_MULTICAST
;
3278 debugs(15, DBG_CRITICAL
, "WARNING: Unknown neighbor type: " << s
);
3280 return PEER_SIBLING
;
3285 parse_IpAddress_list(Ip::Address_list
** head
)
3288 Ip::Address_list
*s
;
3291 while ((token
= ConfigParser::NextToken())) {
3292 if (GetHostWithPort(token
, &ipa
)) {
3295 head
= &(*head
)->next
;
3297 s
= static_cast<Ip::Address_list
*>(xcalloc(1, sizeof(*s
)));
3307 dump_IpAddress_list(StoreEntry
* e
, const char *n
, const Ip::Address_list
* s
)
3309 char ntoabuf
[MAX_IPSTRLEN
];
3312 storeAppendPrintf(e
, "%s %s\n",
3314 s
->s
.toStr(ntoabuf
,MAX_IPSTRLEN
));
3320 free_IpAddress_list(Ip::Address_list
** head
)
3322 if (*head
) delete *head
;
3326 #if CURRENTLY_UNUSED
3327 /* This code was previously used by http_port. Left as it really should
3328 * be used by icp_port and htcp_port
3331 check_null_IpAddress_list(const Ip::Address_list
* s
)
3336 #endif /* CURRENTLY_UNUSED */
3337 #endif /* USE_WCCPv2 */
3340 parsePortSpecification(const AnyP::PortCfgPointer
&s
, char *token
)
3343 unsigned short port
= 0;
3347 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3348 s
->name
= xstrdup(token
);
3349 s
->connection_auth_disabled
= false;
3351 const char *portType
= AnyP::UriScheme(s
->transport
.protocol
).c_str();
3353 if (*token
== '[') {
3356 t
= strchr(host
, ']');
3358 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing ']' on IPv6 address: " << token
);
3364 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port in: " << token
);
3367 if (!Ip::EnableIpv6
) {
3368 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: IPv6 is not available.");
3371 port
= xatos(t
+ 1);
3372 } else if ((t
= strchr(token
, ':'))) {
3377 port
= xatos(t
+ 1);
3379 } else if (strtol(token
, &junk
, 10) && !*junk
) {
3380 port
= xatos(token
);
3381 debugs(3, 3, portType
<< "_port: found Listen on Port: " << port
);
3383 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port: " << token
);
3387 if (port
== 0 && host
!= NULL
) {
3388 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: Port cannot be 0: " << token
);
3395 if (!Ip::EnableIpv6
)
3397 debugs(3, 3, portType
<< "_port: found Listen on wildcard address: *:" << s
->s
.port());
3398 } else if ( (s
->s
= host
) ) { /* check/parse numeric IPA */
3400 if (!Ip::EnableIpv6
)
3402 debugs(3, 3, portType
<< "_port: Listen on Host/IP: " << host
<< " --> " << s
->s
);
3403 } else if ( s
->s
.GetHostByName(host
) ) { /* check/parse for FQDN */
3404 /* dont use ipcache */
3405 s
->defaultsite
= xstrdup(host
);
3407 if (!Ip::EnableIpv6
)
3409 debugs(3, 3, portType
<< "_port: found Listen as Host " << s
->defaultsite
<< " on IP: " << s
->s
);
3411 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: failed to resolve Host/IP: " << host
);
3416 /// parses the protocol= option of the *_port directive, returning parsed value
3417 /// unsupported option values result in a fatal error message
3418 /// upper case values required; caller may convert for backward compatibility
3419 static AnyP::ProtocolVersion
3420 parsePortProtocol(const SBuf
&value
)
3422 // HTTP/1.0 not supported because we are version 1.1 which contains a superset of 1.0
3423 // and RFC 2616 requires us to upgrade 1.0 to 1.1
3424 if (value
.cmp("HTTP") == 0 || value
.cmp("HTTP/1.1") == 0)
3425 return AnyP::ProtocolVersion(AnyP::PROTO_HTTP
, 1,1);
3427 if (value
.cmp("HTTPS") == 0 || value
.cmp("HTTPS/1.1") == 0)
3428 return AnyP::ProtocolVersion(AnyP::PROTO_HTTPS
, 1,1);
3430 if (value
.cmp("FTP") == 0)
3431 return Ftp::ProtocolVersion();
3433 fatalf("%s directive does not support protocol=" SQUIDSBUFPH
"\n", cfg_directive
, SQUIDSBUFPRINT(value
));
3434 return AnyP::ProtocolVersion(); // not reached
3438 parse_port_option(AnyP::PortCfgPointer
&s
, char *token
)
3442 if (strcmp(token
, "accel") == 0) {
3443 if (s
->flags
.isIntercepted()) {
3444 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Accelerator mode requires its own port. It cannot be shared with other modes.");
3447 s
->flags
.accelSurrogate
= true;
3449 } else if (strcmp(token
, "transparent") == 0 || strcmp(token
, "intercept") == 0) {
3450 if (s
->flags
.accelSurrogate
|| s
->flags
.tproxyIntercept
) {
3451 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Intercept mode requires its own interception port. It cannot be shared with other modes.");
3454 s
->flags
.natIntercept
= true;
3455 Ip::Interceptor
.StartInterception();
3456 /* Log information regarding the port modes under interception. */
3457 debugs(3, DBG_IMPORTANT
, "Starting Authentication on port " << s
->s
);
3458 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (interception enabled)");
3459 } else if (strcmp(token
, "tproxy") == 0) {
3460 if (s
->flags
.natIntercept
|| s
->flags
.accelSurrogate
) {
3461 debugs(3,DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY option requires its own interception port. It cannot be shared with other modes.");
3464 s
->flags
.tproxyIntercept
= true;
3465 Ip::Interceptor
.StartTransparency();
3466 /* Log information regarding the port modes under transparency. */
3467 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (TPROXY enabled)");
3469 if (s
->flags
.proxySurrogate
) {
3470 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3473 if (!Ip::Interceptor
.ProbeForTproxy(s
->s
)) {
3474 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY support in the system does not work.");
3478 } else if (strcmp(token
, "require-proxy-header") == 0) {
3479 s
->flags
.proxySurrogate
= true;
3480 if (s
->flags
.tproxyIntercept
) {
3481 // receiving is still permitted, so we do not unset the TPROXY flag
3482 // spoofing access control override takes care of the spoof disable later
3483 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3486 } else if (strncmp(token
, "defaultsite=", 12) == 0) {
3487 if (!s
->flags
.accelSurrogate
) {
3488 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": defaultsite option requires Acceleration mode flag.");
3491 safe_free(s
->defaultsite
);
3492 s
->defaultsite
= xstrdup(token
+ 12);
3493 } else if (strcmp(token
, "vhost") == 0) {
3494 if (!s
->flags
.accelSurrogate
) {
3495 debugs(3, DBG_CRITICAL
, "WARNING: " << cfg_directive
<< ": vhost option is deprecated. Use 'accel' mode flag instead.");
3497 s
->flags
.accelSurrogate
= true;
3499 } else if (strcmp(token
, "no-vhost") == 0) {
3500 if (!s
->flags
.accelSurrogate
) {
3501 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": no-vhost option requires Acceleration mode flag.");
3504 } else if (strcmp(token
, "vport") == 0) {
3505 if (!s
->flags
.accelSurrogate
) {
3506 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3510 } else if (strncmp(token
, "vport=", 6) == 0) {
3511 if (!s
->flags
.accelSurrogate
) {
3512 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3515 s
->vport
= xatos(token
+ 6);
3516 } else if (strncmp(token
, "protocol=", 9) == 0) {
3517 if (!s
->flags
.accelSurrogate
) {
3518 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": protocol option requires Acceleration mode flag.");
3521 s
->transport
= parsePortProtocol(ToUpper(SBuf(token
+ 9)));
3522 } else if (strcmp(token
, "allow-direct") == 0) {
3523 if (!s
->flags
.accelSurrogate
) {
3524 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": allow-direct option requires Acceleration mode flag.");
3527 s
->allow_direct
= true;
3528 } else if (strcmp(token
, "act-as-origin") == 0) {
3529 if (!s
->flags
.accelSurrogate
) {
3530 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": act-as-origin option requires Acceleration mode flag.");
3532 s
->actAsOrigin
= true;
3533 } else if (strcmp(token
, "ignore-cc") == 0) {
3534 #if !USE_HTTP_VIOLATIONS
3535 if (!s
->flags
.accelSurrogate
) {
3536 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": ignore-cc option requires Acceleration mode flag.");
3540 s
->ignore_cc
= true;
3541 } else if (strncmp(token
, "name=", 5) == 0) {
3543 s
->name
= xstrdup(token
+ 5);
3544 } else if (strcmp(token
, "no-connection-auth") == 0) {
3545 s
->connection_auth_disabled
= true;
3546 } else if (strcmp(token
, "connection-auth=off") == 0) {
3547 s
->connection_auth_disabled
= true;
3548 } else if (strcmp(token
, "connection-auth") == 0) {
3549 s
->connection_auth_disabled
= false;
3550 } else if (strcmp(token
, "connection-auth=on") == 0) {
3551 s
->connection_auth_disabled
= false;
3552 } else if (strncmp(token
, "disable-pmtu-discovery=", 23) == 0) {
3553 if (!strcmp(token
+ 23, "off"))
3554 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3555 else if (!strcmp(token
+ 23, "transparent"))
3556 s
->disable_pmtu_discovery
= DISABLE_PMTU_TRANSPARENT
;
3557 else if (!strcmp(token
+ 23, "always"))
3558 s
->disable_pmtu_discovery
= DISABLE_PMTU_ALWAYS
;
3561 } else if (strcmp(token
, "ipv4") == 0) {
3562 if ( !s
->s
.setIPv4() ) {
3563 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": IPv6 addresses cannot be used as IPv4-Only. " << s
->s
);
3566 } else if (strcmp(token
, "tcpkeepalive") == 0) {
3567 s
->tcp_keepalive
.enabled
= true;
3568 } else if (strncmp(token
, "tcpkeepalive=", 13) == 0) {
3569 char *t
= token
+ 13;
3570 s
->tcp_keepalive
.enabled
= true;
3571 s
->tcp_keepalive
.idle
= xatoui(t
,',');
3575 s
->tcp_keepalive
.interval
= xatoui(t
,',');
3580 s
->tcp_keepalive
.timeout
= xatoui(t
);
3583 } else if (strcmp(token
, "sslBump") == 0) {
3584 debugs(3, DBG_PARSE_NOTE(1), "WARNING: '" << token
<< "' is deprecated " <<
3585 "in " << cfg_directive
<< ". Use 'ssl-bump' instead.");
3586 s
->flags
.tunnelSslBumping
= true;
3587 } else if (strcmp(token
, "ssl-bump") == 0) {
3588 s
->flags
.tunnelSslBumping
= true;
3589 } else if (strncmp(token
, "cert=", 5) == 0) {
3590 s
->secure
.parse(token
);
3591 } else if (strncmp(token
, "key=", 4) == 0) {
3592 s
->secure
.parse(token
);
3593 } else if (strncmp(token
, "version=", 8) == 0) {
3594 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3595 "in " << cfg_directive
<< ". Use 'options=' instead.");
3596 s
->secure
.parse(token
);
3597 } else if (strncmp(token
, "options=", 8) == 0) {
3598 s
->secure
.parse(token
);
3599 } else if (strncmp(token
, "cipher=", 7) == 0) {
3600 s
->secure
.parse(token
);
3601 } else if (strncmp(token
, "clientca=", 9) == 0) {
3602 safe_free(s
->clientca
);
3603 s
->clientca
= xstrdup(token
+ 9);
3604 } else if (strncmp(token
, "cafile=", 7) == 0) {
3605 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3606 "in " << cfg_directive
<< ". Use 'tls-cafile=' instead.");
3607 s
->secure
.parse(token
);
3608 } else if (strncmp(token
, "capath=", 7) == 0) {
3609 s
->secure
.parse(token
);
3610 } else if (strncmp(token
, "crlfile=", 8) == 0) {
3611 s
->secure
.parse(token
);
3612 } else if (strncmp(token
, "dhparams=", 9) == 0) {
3613 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: '" << token
<< "' is deprecated " <<
3614 "in " << cfg_directive
<< ". Use 'tls-dh=' instead.");
3615 s
->secure
.parse(token
);
3616 } else if (strncmp(token
, "sslflags=", 9) == 0) {
3617 // NP: deprecation warnings output by secure.parse() when relevant
3618 s
->secure
.parse(token
+3);
3619 } else if (strncmp(token
, "sslcontext=", 11) == 0) {
3620 safe_free(s
->sslContextSessionId
);
3621 s
->sslContextSessionId
= xstrdup(token
+ 11);
3622 } else if (strcmp(token
, "generate-host-certificates") == 0) {
3623 s
->generateHostCertificates
= true;
3624 } else if (strcmp(token
, "generate-host-certificates=on") == 0) {
3625 s
->generateHostCertificates
= true;
3626 } else if (strcmp(token
, "generate-host-certificates=off") == 0) {
3627 s
->generateHostCertificates
= false;
3628 } else if (strncmp(token
, "dynamic_cert_mem_cache_size=", 28) == 0) {
3629 parseBytesOptionValue(&s
->dynamicCertMemCacheSize
, B_BYTES_STR
, token
+ 28);
3631 } else if (strncmp(token
, "tls-", 4) == 0) {
3632 s
->secure
.parse(token
+4);
3633 } else if (strcmp(token
, "ftp-track-dirs") == 0) {
3634 s
->ftp_track_dirs
= true;
3636 debugs(3, DBG_CRITICAL
, "FATAL: Unknown " << cfg_directive
<< " option '" << token
<< "'.");
3642 add_http_port(char *portspec
)
3644 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3645 s
->transport
= parsePortProtocol(SBuf("HTTP"));
3646 parsePortSpecification(s
, portspec
);
3647 // we may need to merge better if the above returns a list with clones
3648 assert(s
->next
== NULL
);
3649 s
->next
= HttpPortList
;
3654 parsePortCfg(AnyP::PortCfgPointer
*head
, const char *optionName
)
3657 if (strcmp(optionName
, "http_port") == 0 ||
3658 strcmp(optionName
, "ascii_port") == 0)
3660 else if (strcmp(optionName
, "https_port") == 0)
3661 protoName
= "HTTPS";
3662 else if (strcmp(optionName
, "ftp_port") == 0)
3664 if (protoName
.isEmpty()) {
3669 char *token
= ConfigParser::NextToken();
3676 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3677 s
->transport
= parsePortProtocol(protoName
); // default; protocol=... overwrites
3678 parsePortSpecification(s
, token
);
3680 /* parse options ... */
3681 while ((token
= ConfigParser::NextToken())) {
3682 parse_port_option(s
, token
);
3686 // if clientca has been defined but not cafile, then use it to verify
3687 // but if cafile has been defined, only use that to verify
3688 if (s
->clientca
&& !s
->secure
.caFiles
.size())
3689 s
->secure
.caFiles
.emplace_back(SBuf(s
->clientca
));
3692 if (s
->transport
.protocol
== AnyP::PROTO_HTTPS
) {
3693 s
->secure
.encryptTransport
= true;
3695 /* ssl-bump on https_port configuration requires either tproxy or intercept, and vice versa */
3696 const bool hijacked
= s
->flags
.isIntercepted();
3697 if (s
->flags
.tunnelSslBumping
&& !hijacked
) {
3698 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump on https_port requires tproxy/intercept which is missing.");
3701 if (hijacked
&& !s
->flags
.tunnelSslBumping
) {
3702 debugs(3, DBG_CRITICAL
, "FATAL: tproxy/intercept on https_port requires ssl-bump which is missing.");
3706 if (s
->flags
.proxySurrogate
) {
3707 debugs(3,DBG_CRITICAL
, "FATAL: https_port: require-proxy-header option is not supported on HTTPS ports.");
3710 } else if (protoName
.cmp("FTP") == 0) {
3711 /* ftp_port does not support ssl-bump */
3712 if (s
->flags
.tunnelSslBumping
) {
3713 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump is not supported for ftp_port.");
3716 if (s
->flags
.proxySurrogate
) {
3717 // Passive FTP data channel does not work without deep protocol inspection in the frontend.
3718 debugs(3,DBG_CRITICAL
, "FATAL: require-proxy-header option is not supported on ftp_port.");
3723 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& s
->s
.isAnyAddr()) {
3724 // clone the port options from *s to *(s->next)
3725 s
->next
= s
->clone();
3726 s
->next
->s
.setIPv4();
3727 debugs(3, 3, AnyP::UriScheme(s
->transport
.protocol
).c_str() << "_port: clone wildcard address for split-stack: " << s
->s
<< " and " << s
->next
->s
);
3730 while (*head
!= NULL
)
3731 head
= &((*head
)->next
);
3737 dump_generic_port(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3739 char buf
[MAX_IPSTRLEN
];
3741 storeAppendPrintf(e
, "%s %s",
3743 s
->s
.toUrl(buf
,MAX_IPSTRLEN
));
3745 // MODES and specific sub-options.
3746 if (s
->flags
.natIntercept
)
3747 storeAppendPrintf(e
, " intercept");
3749 else if (s
->flags
.tproxyIntercept
)
3750 storeAppendPrintf(e
, " tproxy");
3752 else if (s
->flags
.proxySurrogate
)
3753 storeAppendPrintf(e
, " require-proxy-header");
3755 else if (s
->flags
.accelSurrogate
) {
3756 storeAppendPrintf(e
, " accel");
3759 storeAppendPrintf(e
, " vhost");
3762 storeAppendPrintf(e
, " vport");
3763 else if (s
->vport
> 0)
3764 storeAppendPrintf(e
, " vport=%d", s
->vport
);
3767 storeAppendPrintf(e
, " defaultsite=%s", s
->defaultsite
);
3769 // TODO: compare against prefix of 'n' instead of assuming http_port
3770 if (s
->transport
.protocol
!= AnyP::PROTO_HTTP
)
3771 storeAppendPrintf(e
, " protocol=%s", AnyP::UriScheme(s
->transport
.protocol
).c_str());
3773 if (s
->allow_direct
)
3774 storeAppendPrintf(e
, " allow-direct");
3777 storeAppendPrintf(e
, " ignore-cc");
3781 // Generic independent options
3784 storeAppendPrintf(e
, " name=%s", s
->name
);
3786 #if USE_HTTP_VIOLATIONS
3787 if (!s
->flags
.accelSurrogate
&& s
->ignore_cc
)
3788 storeAppendPrintf(e
, " ignore-cc");
3791 if (s
->connection_auth_disabled
)
3792 storeAppendPrintf(e
, " connection-auth=off");
3794 storeAppendPrintf(e
, " connection-auth=on");
3796 if (s
->disable_pmtu_discovery
!= DISABLE_PMTU_OFF
) {
3799 if (s
->disable_pmtu_discovery
== DISABLE_PMTU_ALWAYS
)
3802 pmtu
= "transparent";
3804 storeAppendPrintf(e
, " disable-pmtu-discovery=%s", pmtu
);
3807 if (s
->s
.isAnyAddr() && !s
->s
.isIPv6())
3808 storeAppendPrintf(e
, " ipv4");
3810 if (s
->tcp_keepalive
.enabled
) {
3811 if (s
->tcp_keepalive
.idle
|| s
->tcp_keepalive
.interval
|| s
->tcp_keepalive
.timeout
) {
3812 storeAppendPrintf(e
, " tcpkeepalive=%d,%d,%d", s
->tcp_keepalive
.idle
, s
->tcp_keepalive
.interval
, s
->tcp_keepalive
.timeout
);
3814 storeAppendPrintf(e
, " tcpkeepalive");
3819 if (s
->flags
.tunnelSslBumping
)
3820 storeAppendPrintf(e
, " ssl-bump");
3823 s
->secure
.dumpCfg(e
, "tls-");
3826 if (s
->sslContextSessionId
)
3827 storeAppendPrintf(e
, " sslcontext=%s", s
->sslContextSessionId
);
3829 if (s
->generateHostCertificates
)
3830 storeAppendPrintf(e
, " generate-host-certificates");
3832 if (s
->dynamicCertMemCacheSize
!= std::numeric_limits
<size_t>::max())
3833 storeAppendPrintf(e
, "dynamic_cert_mem_cache_size=%lu%s\n", (unsigned long)s
->dynamicCertMemCacheSize
, B_BYTES_STR
);
3838 dump_PortCfg(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3840 for (AnyP::PortCfgPointer p
= s
; p
!= NULL
; p
= p
->next
) {
3841 dump_generic_port(e
, n
, p
);
3842 storeAppendPrintf(e
, "\n");
3847 configFreeMemory(void)
3851 SSL_CTX_free(Config
.ssl_client
.sslContext
);
3852 Ssl::unloadSquidUntrusted();
3857 requirePathnameExists(const char *name
, const char *path
)
3861 char pathbuf
[BUFSIZ
];
3862 assert(path
!= NULL
);
3864 if (Config
.chroot_dir
&& (geteuid() == 0)) {
3865 snprintf(pathbuf
, BUFSIZ
, "%s/%s", Config
.chroot_dir
, path
);
3869 if (stat(path
, &sb
) < 0) {
3871 debugs(0, DBG_CRITICAL
, (opt_parse_cfg_only
?"FATAL: ":"ERROR: ") << name
<< " " << path
<< ": " << xstrerr(xerrno
));
3872 // keep going to find more issues if we are only checking the config file with "-k parse"
3873 if (opt_parse_cfg_only
)
3875 // this is fatal if it is found during startup or reconfigure
3876 if (opt_send_signal
== -1 || opt_send_signal
== SIGHUP
)
3877 fatalf("%s %s: %s", name
, path
, xstrerr(xerrno
));
3881 #include "AccessLogEntry.h"
3884 * We support several access_log configuration styles:
3886 * #1: Deprecated ancient style without an explicit logging module:
3887 * access_log /var/log/access.log
3889 * #2: The "none" logging module (i.e., no logging [of matching transactions]):
3890 * access_log none [acl ...]
3892 * #3: Configurable logging module without named options:
3893 * Logformat or the first ACL name, whichever comes first, may not contain '='.
3894 * If no explicit logformat name is given, the first ACL name, if any,
3895 * should not be an existing logformat name or it will be treated as such.
3896 * access_log module:place [logformat_name] [acl ...]
3898 * #4: Configurable logging module with name=value options such as logformat=x:
3899 * The first ACL name may not contain '='.
3900 * access_log module:place [option ...] [acl ...]
3904 parse_access_log(CustomLog
** logs
)
3906 const char *filename
= ConfigParser::NextToken();
3912 CustomLog
*cl
= (CustomLog
*)xcalloc(1, sizeof(*cl
));
3914 cl
->filename
= xstrdup(filename
);
3915 // default buffer size and fatal settings
3916 cl
->bufferSize
= 8*MAX_URL
;
3919 if (strcmp(filename
, "none") == 0) {
3920 cl
->type
= Log::Format::CLF_NONE
;
3921 aclParseAclList(LegacyParser
, &cl
->aclList
, filename
);
3923 logs
= &(*logs
)->next
;
3928 cl
->type
= Log::Format::CLF_UNKNOWN
;
3929 cl
->rotateCount
= -1; // default: use global logfile_rotate setting.
3931 const char *token
= ConfigParser::PeekAtToken();
3932 if (!token
) { // style #1
3933 // no options to deal with
3934 } else if (!strchr(token
, '=')) { // style #3
3935 // if logformat name is recognized,
3936 // pop the previewed token; Else it must be an ACL name
3937 if (setLogformat(cl
, token
, false))
3938 (void)ConfigParser::NextToken();
3939 } else { // style #4
3941 if (strncasecmp(token
, "on-error=", 9) == 0) {
3942 if (strncasecmp(token
+9, "die", 3) == 0) {
3944 } else if (strncasecmp(token
+9, "drop", 4) == 0) {
3947 debugs(3, DBG_CRITICAL
, "Unknown value for on-error '" <<
3948 token
<< "' expected 'drop' or 'die'");
3949 xfree(cl
->filename
);
3954 } else if (strncasecmp(token
, "buffer-size=", 12) == 0) {
3955 parseBytesOptionValue(&cl
->bufferSize
, B_BYTES_STR
, token
+12);
3956 } else if (strncasecmp(token
, "rotate=", 7) == 0) {
3957 cl
->rotateCount
= xatoi(token
+ 7);
3958 } else if (strncasecmp(token
, "logformat=", 10) == 0) {
3959 setLogformat(cl
, token
+10, true);
3960 } else if (!strchr(token
, '=')) {
3961 // Do not pop the token; it must be an ACL name
3962 break; // done with name=value options, now to ACLs
3964 debugs(3, DBG_CRITICAL
, "Unknown access_log option " << token
);
3965 xfree(cl
->filename
);
3970 // Pop the token, it was a valid "name=value" option
3971 (void)ConfigParser::NextToken();
3972 // Get next with preview ConfigParser::NextToken call.
3973 } while ((token
= ConfigParser::PeekAtToken()) != NULL
);
3976 // set format if it has not been specified explicitly
3977 if (cl
->type
== Log::Format::CLF_UNKNOWN
)
3978 setLogformat(cl
, "squid", true);
3980 aclParseAclList(LegacyParser
, &cl
->aclList
, cl
->filename
);
3983 logs
= &(*logs
)->next
;
3988 /// sets CustomLog::type and, if needed, CustomLog::lf
3989 /// returns false iff there is no named log format
3991 setLogformat(CustomLog
*cl
, const char *logdef_name
, const bool dieWhenMissing
)
3994 assert(logdef_name
);
3996 debugs(3, 9, "possible " << cl
->filename
<< " logformat: " << logdef_name
);
3998 if (cl
->type
!= Log::Format::CLF_UNKNOWN
) {
3999 debugs(3, DBG_CRITICAL
, "Second logformat name in one access_log: " <<
4000 logdef_name
<< " " << cl
->type
<< " ? " << Log::Format::CLF_NONE
);
4005 /* look for the definition pointer corresponding to this name */
4006 Format::Format
*lf
= Log::TheConfig
.logformats
;
4008 while (lf
!= NULL
) {
4009 debugs(3, 9, "Comparing against '" << lf
->name
<< "'");
4011 if (strcmp(lf
->name
, logdef_name
) == 0)
4018 cl
->type
= Log::Format::CLF_CUSTOM
;
4020 } else if (strcmp(logdef_name
, "auto") == 0) {
4021 debugs(0, DBG_CRITICAL
, "WARNING: Log format 'auto' no longer exists. Using 'squid' instead.");
4022 cl
->type
= Log::Format::CLF_SQUID
;
4023 } else if (strcmp(logdef_name
, "squid") == 0) {
4024 cl
->type
= Log::Format::CLF_SQUID
;
4025 } else if (strcmp(logdef_name
, "common") == 0) {
4026 cl
->type
= Log::Format::CLF_COMMON
;
4027 } else if (strcmp(logdef_name
, "combined") == 0) {
4028 cl
->type
= Log::Format::CLF_COMBINED
;
4030 } else if (strcmp(logdef_name
, "icap_squid") == 0) {
4031 cl
->type
= Log::Format::CLF_ICAP_SQUID
;
4033 } else if (strcmp(logdef_name
, "useragent") == 0) {
4034 cl
->type
= Log::Format::CLF_USERAGENT
;
4035 } else if (strcmp(logdef_name
, "referrer") == 0) {
4036 cl
->type
= Log::Format::CLF_REFERER
;
4037 } else if (dieWhenMissing
) {
4038 debugs(3, DBG_CRITICAL
, "Log format '" << logdef_name
<< "' is not defined");
4049 check_null_access_log(CustomLog
*customlog_definitions
)
4051 return customlog_definitions
== NULL
;
4055 dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* logs
)
4059 for (log
= logs
; log
; log
= log
->next
) {
4060 storeAppendPrintf(entry
, "%s ", name
);
4062 switch (log
->type
) {
4064 case Log::Format::CLF_CUSTOM
:
4065 storeAppendPrintf(entry
, "%s logformat=%s", log
->filename
, log
->logFormat
->name
);
4068 case Log::Format::CLF_NONE
:
4069 storeAppendPrintf(entry
, "logformat=none");
4072 case Log::Format::CLF_SQUID
:
4073 storeAppendPrintf(entry
, "%s logformat=squid", log
->filename
);
4076 case Log::Format::CLF_COMBINED
:
4077 storeAppendPrintf(entry
, "%s logformat=combined", log
->filename
);
4080 case Log::Format::CLF_COMMON
:
4081 storeAppendPrintf(entry
, "%s logformat=common", log
->filename
);
4085 case Log::Format::CLF_ICAP_SQUID
:
4086 storeAppendPrintf(entry
, "%s logformat=icap_squid", log
->filename
);
4089 case Log::Format::CLF_USERAGENT
:
4090 storeAppendPrintf(entry
, "%s logformat=useragent", log
->filename
);
4093 case Log::Format::CLF_REFERER
:
4094 storeAppendPrintf(entry
, "%s logformat=referrer", log
->filename
);
4097 case Log::Format::CLF_UNKNOWN
:
4101 // default is on-error=die
4103 storeAppendPrintf(entry
, " on-error=drop");
4106 if (log
->bufferSize
!= 64*1024)
4107 storeAppendPrintf(entry
, " buffer-size=%" PRIuSIZE
, log
->bufferSize
);
4109 if (log
->rotateCount
>= 0)
4110 storeAppendPrintf(entry
, " rotate=%d", log
->rotateCount
);
4113 dump_acl_list(entry
, log
->aclList
);
4115 storeAppendPrintf(entry
, "\n");
4120 free_access_log(CustomLog
** definitions
)
4122 while (*definitions
) {
4123 CustomLog
*log
= *definitions
;
4124 *definitions
= log
->next
;
4126 log
->logFormat
= NULL
;
4127 log
->type
= Log::Format::CLF_UNKNOWN
;
4130 aclDestroyAclList(&log
->aclList
);
4132 safe_free(log
->filename
);
4138 /// parses list of integers form name=N1,N2,N3,...
4140 parseNamedIntList(const char *data
, const String
&name
, std::vector
<int> &list
)
4142 if (data
&& (strncmp(data
, name
.rawBuf(), name
.size()) == 0)) {
4143 data
+= name
.size();
4148 if (!StringToInt(data
, value
, &data
, 10))
4150 list
.push_back(value
);
4151 if (*data
== '\0' || *data
!= ',')
4156 return data
&& *data
== '\0';
4160 parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4162 #if !HAVE_CPU_AFFINITY
4163 debugs(3, DBG_CRITICAL
, "FATAL: Squid built with no CPU affinity " <<
4164 "support, do not set 'cpu_affinity_map'");
4166 #endif /* HAVE_CPU_AFFINITY */
4168 if (!*cpuAffinityMap
)
4169 *cpuAffinityMap
= new CpuAffinityMap
;
4171 const char *const pToken
= ConfigParser::NextToken();
4172 const char *const cToken
= ConfigParser::NextToken();
4173 std::vector
<int> processes
, cores
;
4174 if (!parseNamedIntList(pToken
, "process_numbers", processes
)) {
4175 debugs(3, DBG_CRITICAL
, "FATAL: bad 'process_numbers' parameter " <<
4176 "in 'cpu_affinity_map'");
4178 } else if (!parseNamedIntList(cToken
, "cores", cores
)) {
4179 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cores' parameter in " <<
4180 "'cpu_affinity_map'");
4182 } else if (!(*cpuAffinityMap
)->add(processes
, cores
)) {
4183 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cpu_affinity_map'; " <<
4184 "process_numbers and cores lists differ in length or " <<
4185 "contain numbers <= 0");
4191 dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
)
4193 if (cpuAffinityMap
) {
4194 storeAppendPrintf(entry
, "%s process_numbers=", name
);
4195 for (size_t i
= 0; i
< cpuAffinityMap
->processes().size(); ++i
) {
4196 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4197 cpuAffinityMap
->processes()[i
]);
4199 storeAppendPrintf(entry
, " cores=");
4200 for (size_t i
= 0; i
< cpuAffinityMap
->cores().size(); ++i
) {
4201 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4202 cpuAffinityMap
->cores()[i
]);
4204 storeAppendPrintf(entry
, "\n");
4209 free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4211 delete *cpuAffinityMap
;
4212 *cpuAffinityMap
= NULL
;
4218 parse_adaptation_service_set_type()
4220 Adaptation::Config::ParseServiceSet();
4224 parse_adaptation_service_chain_type()
4226 Adaptation::Config::ParseServiceChain();
4230 parse_adaptation_access_type()
4232 Adaptation::Config::ParseAccess(LegacyParser
);
4234 #endif /* USE_ADAPTATION */
4239 parse_icap_service_type(Adaptation::Icap::Config
* cfg
)
4241 cfg
->parseService();
4245 free_icap_service_type(Adaptation::Icap::Config
* cfg
)
4251 dump_icap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4253 cfg
.dumpService(entry
, name
);
4257 parse_icap_class_type()
4259 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_class' is depricated. " <<
4260 "Use 'adaptation_service_set' instead");
4261 Adaptation::Config::ParseServiceSet();
4265 parse_icap_access_type()
4267 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_access' is depricated. " <<
4268 "Use 'adaptation_access' instead");
4269 Adaptation::Config::ParseAccess(LegacyParser
);
4277 parse_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4279 cfg
->parseService();
4283 free_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4289 dump_ecap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Ecap::Config
&cfg
)
4291 cfg
.dumpService(entry
, name
);
4294 #endif /* USE_ECAP */
4297 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4302 cfg
->service_failure_limit
= GetInteger();
4304 if ((token
= ConfigParser::NextToken()) == NULL
)
4307 if (strcmp(token
,"in") != 0) {
4308 debugs(3, DBG_CRITICAL
, "expecting 'in' on'" << config_input_line
<< "'");
4312 if ((token
= ConfigParser::NextToken()) == NULL
) {
4316 d
= static_cast<time_t> (xatoi(token
));
4318 m
= static_cast<time_t> (1);
4322 else if ((token
= ConfigParser::NextToken()) == NULL
) {
4323 debugs(3, DBG_CRITICAL
, "No time-units on '" << config_input_line
<< "'");
4325 } else if ((m
= parseTimeUnits(token
, false)) == 0)
4328 cfg
->oldest_service_failure
= (m
* d
);
4331 static void dump_icap_service_failure_limit(StoreEntry
*entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4333 storeAppendPrintf(entry
, "%s %d", name
, cfg
.service_failure_limit
);
4334 if (cfg
.oldest_service_failure
> 0) {
4335 storeAppendPrintf(entry
, " in %d seconds", (int)cfg
.oldest_service_failure
);
4337 storeAppendPrintf(entry
, "\n");
4340 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4342 cfg
->oldest_service_failure
= 0;
4343 cfg
->service_failure_limit
= 0;
4348 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4351 sslproxy_cert_adapt
*ca
= (sslproxy_cert_adapt
*) xcalloc(1, sizeof(sslproxy_cert_adapt
));
4352 if ((al
= ConfigParser::NextToken()) == NULL
) {
4359 if ( char *s
= strchr(al
, '{')) {
4360 *s
= '\0'; // terminate the al string
4373 if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidAfter
]) == 0) {
4374 ca
->alg
= Ssl::algSetValidAfter
;
4375 ca
->param
= xstrdup("on");
4376 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidBefore
]) == 0) {
4377 ca
->alg
= Ssl::algSetValidBefore
;
4378 ca
->param
= xstrdup("on");
4379 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetCommonName
]) == 0) {
4380 ca
->alg
= Ssl::algSetCommonName
;
4382 if (strlen(param
) > 64) {
4383 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: setCommonName{" <<param
<< "} : using common name longer than 64 bytes is not supported");
4388 ca
->param
= xstrdup(param
);
4391 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: unknown cert adaptation algorithm: " << al
);
4397 aclParseAclList(LegacyParser
, &ca
->aclList
, al
);
4400 cert_adapt
= &(*cert_adapt
)->next
;
4405 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
)
4407 for (sslproxy_cert_adapt
*ca
= cert_adapt
; ca
!= NULL
; ca
= ca
->next
) {
4408 storeAppendPrintf(entry
, "%s ", name
);
4409 storeAppendPrintf(entry
, "%s{%s} ", Ssl::sslCertAdaptAlgoritm(ca
->alg
), ca
->param
);
4411 dump_acl_list(entry
, ca
->aclList
);
4412 storeAppendPrintf(entry
, "\n");
4416 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4418 while (*cert_adapt
) {
4419 sslproxy_cert_adapt
*ca
= *cert_adapt
;
4420 *cert_adapt
= ca
->next
;
4421 safe_free(ca
->param
);
4424 aclDestroyAclList(&ca
->aclList
);
4430 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4433 sslproxy_cert_sign
*cs
= (sslproxy_cert_sign
*) xcalloc(1, sizeof(sslproxy_cert_sign
));
4434 if ((al
= ConfigParser::NextToken()) == NULL
) {
4440 if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignTrusted
]) == 0)
4441 cs
->alg
= Ssl::algSignTrusted
;
4442 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignUntrusted
]) == 0)
4443 cs
->alg
= Ssl::algSignUntrusted
;
4444 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignSelf
]) == 0)
4445 cs
->alg
= Ssl::algSignSelf
;
4447 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_sign: unknown cert signing algorithm: " << al
);
4453 aclParseAclList(LegacyParser
, &cs
->aclList
, al
);
4456 cert_sign
= &(*cert_sign
)->next
;
4461 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
)
4463 sslproxy_cert_sign
*cs
;
4464 for (cs
= cert_sign
; cs
!= NULL
; cs
= cs
->next
) {
4465 storeAppendPrintf(entry
, "%s ", name
);
4466 storeAppendPrintf(entry
, "%s ", Ssl::certSignAlgorithm(cs
->alg
));
4468 dump_acl_list(entry
, cs
->aclList
);
4469 storeAppendPrintf(entry
, "\n");
4473 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4475 while (*cert_sign
) {
4476 sslproxy_cert_sign
*cs
= *cert_sign
;
4477 *cert_sign
= cs
->next
;
4480 aclDestroyAclList(&cs
->aclList
);
4486 class sslBumpCfgRr
: public ::RegisteredRunner
4489 static Ssl::BumpMode lastDeprecatedRule
;
4490 /* RegisteredRunner API */
4491 virtual void finalizeConfig();
4494 Ssl::BumpMode
sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4496 RunnerRegistrationEntry(sslBumpCfgRr
);
4499 sslBumpCfgRr::finalizeConfig()
4501 if (lastDeprecatedRule
!= Ssl::bumpEnd
) {
4502 assert( lastDeprecatedRule
== Ssl::bumpClientFirst
|| lastDeprecatedRule
== Ssl::bumpNone
);
4503 static char buf
[1024];
4504 if (lastDeprecatedRule
== Ssl::bumpClientFirst
) {
4505 strcpy(buf
, "ssl_bump deny all");
4506 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated implicit "
4507 "\"ssl_bump deny all\" to \"ssl_bump none all\". New ssl_bump configurations "
4508 "must not use implicit rules. Update your ssl_bump rules.");
4510 strcpy(buf
, "ssl_bump allow all");
4511 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated implicit "
4512 "\"ssl_bump allow all\" to \"ssl_bump client-first all\" which is usually "
4513 "inferior to the newer server-first bumping mode. New ssl_bump"
4514 " configurations must not use implicit rules. Update your ssl_bump rules.");
4520 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4522 typedef const char *BumpCfgStyle
;
4523 BumpCfgStyle bcsNone
= NULL
;
4524 BumpCfgStyle bcsNew
= "new client/server-first/none";
4525 BumpCfgStyle bcsOld
= "deprecated allow/deny";
4526 static BumpCfgStyle bumpCfgStyleLast
= bcsNone
;
4527 BumpCfgStyle bumpCfgStyleNow
= bcsNone
;
4529 if ((bm
= ConfigParser::NextToken()) == NULL
) {
4534 // if this is the first rule proccessed
4535 if (*ssl_bump
== NULL
) {
4536 bumpCfgStyleLast
= bcsNone
;
4537 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4540 allow_t action
= allow_t(ACCESS_ALLOWED
);
4542 if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpClientFirst
]) == 0) {
4543 action
.kind
= Ssl::bumpClientFirst
;
4544 bumpCfgStyleNow
= bcsNew
;
4545 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpServerFirst
]) == 0) {
4546 action
.kind
= Ssl::bumpServerFirst
;
4547 bumpCfgStyleNow
= bcsNew
;
4548 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpPeek
]) == 0) {
4549 action
.kind
= Ssl::bumpPeek
;
4550 bumpCfgStyleNow
= bcsNew
;
4551 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpStare
]) == 0) {
4552 action
.kind
= Ssl::bumpStare
;
4553 bumpCfgStyleNow
= bcsNew
;
4554 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpSplice
]) == 0) {
4555 action
.kind
= Ssl::bumpSplice
;
4556 bumpCfgStyleNow
= bcsNew
;
4557 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpBump
]) == 0) {
4558 action
.kind
= Ssl::bumpBump
;
4559 bumpCfgStyleNow
= bcsNew
;
4560 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpTerminate
]) == 0) {
4561 action
.kind
= Ssl::bumpTerminate
;
4562 bumpCfgStyleNow
= bcsNew
;
4563 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpNone
]) == 0) {
4564 action
.kind
= Ssl::bumpNone
;
4565 bumpCfgStyleNow
= bcsNew
;
4566 } else if (strcmp(bm
, "allow") == 0) {
4567 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated "
4568 "\"ssl_bump allow <acl>\" to \"ssl_bump client-first <acl>\" which "
4569 "is usually inferior to the newer server-first "
4570 "bumping mode. Update your ssl_bump rules.");
4571 action
.kind
= Ssl::bumpClientFirst
;
4572 bumpCfgStyleNow
= bcsOld
;
4573 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpClientFirst
;
4574 } else if (strcmp(bm
, "deny") == 0) {
4575 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated "
4576 "\"ssl_bump deny <acl>\" to \"ssl_bump none <acl>\". Update "
4577 "your ssl_bump rules.");
4578 action
.kind
= Ssl::bumpNone
;
4579 bumpCfgStyleNow
= bcsOld
;
4580 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpNone
;
4582 debugs(3, DBG_CRITICAL
, "FATAL: unknown ssl_bump mode: " << bm
);
4587 if (bumpCfgStyleLast
!= bcsNone
&& bumpCfgStyleNow
!= bumpCfgStyleLast
) {
4588 debugs(3, DBG_CRITICAL
, "FATAL: do not mix " << bumpCfgStyleNow
<< " actions with " <<
4589 bumpCfgStyleLast
<< " actions. Update your ssl_bump rules.");
4594 bumpCfgStyleLast
= bumpCfgStyleNow
;
4596 Acl::AndNode
*rule
= new Acl::AndNode
;
4597 rule
->context("(ssl_bump rule)", config_input_line
);
4603 *ssl_bump
= new Acl::Tree
;
4604 (*ssl_bump
)->context("(ssl_bump rules)", config_input_line
);
4607 (*ssl_bump
)->add(rule
, action
);
4610 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
)
4613 dump_SBufList(entry
, ssl_bump
->treeDump(name
, Ssl::BumpModeStr
));
4616 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4618 free_acl_access(ssl_bump
);
4623 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
)
4628 for (HeaderWithAclList::iterator hwa
= headers
->begin(); hwa
!= headers
->end(); ++hwa
) {
4629 storeAppendPrintf(entry
, "%s %s %s", name
, hwa
->fieldName
.c_str(), hwa
->fieldValue
.c_str());
4631 dump_acl_list(entry
, hwa
->aclList
);
4632 storeAppendPrintf(entry
, "\n");
4636 static void parse_HeaderWithAclList(HeaderWithAclList
**headers
)
4640 *headers
= new HeaderWithAclList
;
4642 if ((fn
= ConfigParser::NextToken()) == NULL
) {
4648 hwa
.fieldId
= Http::HeaderLookupTable
.lookup(hwa
.fieldName
).id
;
4649 if (hwa
.fieldId
== Http::HdrType::BAD_HDR
)
4650 hwa
.fieldId
= Http::HdrType::OTHER
;
4652 Format::Format
*nlf
= new ::Format::Format("hdrWithAcl");
4653 ConfigParser::EnableMacros();
4654 String buf
= ConfigParser::NextQuotedToken();
4655 ConfigParser::DisableMacros();
4656 hwa
.fieldValue
= buf
.termedBuf();
4657 hwa
.quoted
= ConfigParser::LastTokenWasQuoted();
4659 if (!nlf
->parse(hwa
.fieldValue
.c_str())) {
4663 hwa
.valueFormat
= nlf
;
4666 aclParseAclList(LegacyParser
, &hwa
.aclList
, (hwa
.fieldName
+ ':' + hwa
.fieldValue
).c_str());
4667 (*headers
)->push_back(hwa
);
4670 static void free_HeaderWithAclList(HeaderWithAclList
**header
)
4675 for (HeaderWithAclList::iterator hwa
= (*header
)->begin(); hwa
!= (*header
)->end(); ++hwa
) {
4677 aclDestroyAclList(&hwa
->aclList
);
4679 if (hwa
->valueFormat
) {
4680 delete hwa
->valueFormat
;
4681 hwa
->valueFormat
= NULL
;
4688 static void parse_note(Notes
*notes
)
4691 notes
->parse(LegacyParser
);
4694 static void dump_note(StoreEntry
*entry
, const char *name
, Notes
¬es
)
4696 notes
.dump(entry
, name
);
4699 static void free_note(Notes
*notes
)
4704 static bool FtpEspvDeprecated
= false;
4705 static void parse_ftp_epsv(acl_access
**ftp_epsv
)
4707 allow_t ftpEpsvDeprecatedAction
;
4708 bool ftpEpsvIsDeprecatedRule
= false;
4710 char *t
= ConfigParser::PeekAtToken();
4716 if (!strcmp(t
, "off")) {
4717 (void)ConfigParser::NextToken();
4718 ftpEpsvIsDeprecatedRule
= true;
4719 ftpEpsvDeprecatedAction
= allow_t(ACCESS_DENIED
);
4720 } else if (!strcmp(t
, "on")) {
4721 (void)ConfigParser::NextToken();
4722 ftpEpsvIsDeprecatedRule
= true;
4723 ftpEpsvDeprecatedAction
= allow_t(ACCESS_ALLOWED
);
4726 // Check for mixing "ftp_epsv on|off" and "ftp_epsv allow|deny .." rules:
4727 // 1) if this line is "ftp_epsv allow|deny ..." and already exist rules of "ftp_epsv on|off"
4728 // 2) if this line is "ftp_epsv on|off" and already exist rules of "ftp_epsv allow|deny ..."
4730 if ((!ftpEpsvIsDeprecatedRule
&& FtpEspvDeprecated
) ||
4731 (ftpEpsvIsDeprecatedRule
&& !FtpEspvDeprecated
&& *ftp_epsv
!= NULL
)) {
4732 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.");
4737 if (ftpEpsvIsDeprecatedRule
) {
4738 // overwrite previous ftp_epsv lines
4740 if (ftpEpsvDeprecatedAction
== allow_t(ACCESS_DENIED
)) {
4741 Acl::AndNode
*ftpEpsvRule
= new Acl::AndNode
;
4742 ftpEpsvRule
->context("(ftp_epsv rule)", config_input_line
);
4743 ACL
*a
= ACL::FindByName("all");
4749 ftpEpsvRule
->add(a
);
4750 *ftp_epsv
= new Acl::Tree
;
4751 (*ftp_epsv
)->context("(ftp_epsv rules)", config_input_line
);
4752 (*ftp_epsv
)->add(ftpEpsvRule
, ftpEpsvDeprecatedAction
);
4755 FtpEspvDeprecated
= true;
4757 aclParseAccessLine(cfg_directive
, LegacyParser
, ftp_epsv
);
4761 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
)
4764 dump_SBufList(entry
, ftp_epsv
->treeDump(name
, NULL
));
4767 static void free_ftp_epsv(acl_access
**ftp_epsv
)
4769 free_acl_access(ftp_epsv
);
4770 FtpEspvDeprecated
= false;
4774 parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4777 parseTimeLine(&tval
, T_SECOND_STR
, false, true);
4778 Config
.Timeout
.urlRewrite
= static_cast<time_t>(tval
/1000);
4781 while(ConfigParser::NextKvPair(key
, value
)) {
4782 if (strcasecmp(key
, "on_timeout") == 0) {
4783 if (strcasecmp(value
, "bypass") == 0)
4784 config
->action
= toutActBypass
;
4785 else if (strcasecmp(value
, "fail") == 0)
4786 config
->action
= toutActFail
;
4787 else if (strcasecmp(value
, "retry") == 0)
4788 config
->action
= toutActRetry
;
4789 else if (strcasecmp(value
, "use_configured_response") == 0) {
4790 config
->action
= toutActUseConfiguredResponse
;
4792 debugs(3, DBG_CRITICAL
, "FATAL: unsuported \"on_timeout\" action:" << value
);
4795 } else if (strcasecmp(key
, "response") == 0) {
4796 config
->response
= xstrdup(value
);
4798 debugs(3, DBG_CRITICAL
, "FATAL: unsuported option " << key
);
4803 if (config
->action
== toutActUseConfiguredResponse
&& !config
->response
) {
4804 debugs(3, DBG_CRITICAL
, "FATAL: Expected 'response=' option after 'on_timeout=use_configured_response' option");
4808 if (config
->action
!= toutActUseConfiguredResponse
&& config
->response
) {
4809 debugs(3, DBG_CRITICAL
, "FATAL: 'response=' option is valid only when used with the 'on_timeout=use_configured_response' option");
4815 dump_UrlHelperTimeout(StoreEntry
*entry
, const char *name
, SquidConfig::UrlHelperTimeout
&config
)
4817 const char *onTimedOutActions
[] = {"bypass", "fail", "retry", "use_configured_response"};
4818 assert(config
.action
>= 0 && config
.action
<= toutActUseConfiguredResponse
);
4820 dump_time_t(entry
, name
, Config
.Timeout
.urlRewrite
);
4821 storeAppendPrintf(entry
, " on_timeout=%s", onTimedOutActions
[config
.action
]);
4823 if (config
.response
)
4824 storeAppendPrintf(entry
, " response=\"%s\"", config
.response
);
4826 storeAppendPrintf(entry
, "\n");
4830 free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4832 Config
.Timeout
.urlRewrite
= 0;
4834 safe_free(config
->response
);
4838 parse_configuration_includes_quoted_values(bool *)
4843 // If quoted values is set to on then enable new strict mode parsing
4845 ConfigParser::RecognizeQuotedValues
= true;
4846 ConfigParser::StrictMode
= true;
4848 ConfigParser::RecognizeQuotedValues
= false;
4849 ConfigParser::StrictMode
= false;
4854 dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool)
4856 int val
= ConfigParser::RecognizeQuotedValues
? 1 : 0;
4857 dump_onoff(entry
, name
, val
);
4861 free_configuration_includes_quoted_values(bool *)
4863 ConfigParser::RecognizeQuotedValues
= false;
4864 ConfigParser::StrictMode
= false;
4868 parse_on_unsupported_protocol(acl_access
**access
)
4871 if ((tm
= ConfigParser::NextToken()) == NULL
) {
4876 allow_t action
= allow_t(ACCESS_ALLOWED
);
4877 if (strcmp(tm
, "tunnel") == 0)
4879 else if (strcmp(tm
, "respond") == 0)
4882 debugs(3, DBG_CRITICAL
, "FATAL: unknown on_unsupported_protocol mode: " << tm
);
4887 Acl::AndNode
*rule
= new Acl::AndNode
;
4888 rule
->context("(on_unsupported_protocol rule)", config_input_line
);
4894 *access
= new Acl::Tree
;
4895 (*access
)->context("(on_unsupported_protocol rules)", config_input_line
);
4898 (*access
)->add(rule
, action
);
4902 dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
)
4904 const char *on_error_tunnel_mode_str
[] = {
4911 SBufList lines
= access
->treeDump(name
, on_error_tunnel_mode_str
);
4912 dump_SBufList(entry
, lines
);
4917 free_on_unsupported_protocol(acl_access
**access
)
4919 free_acl_access(access
);