2 * Copyright (C) 1996-2018 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/AclSizeLimit.h"
15 #include "acl/Address.h"
16 #include "acl/Gadgets.h"
17 #include "acl/MethodData.h"
19 #include "anyp/PortCfg.h"
20 #include "anyp/UriScheme.h"
21 #include "auth/Config.h"
22 #include "auth/Scheme.h"
24 #include "base/RunnersRegistry.h"
26 #include "CachePeer.h"
27 #include "ConfigParser.h"
28 #include "CpuAffinityMap.h"
29 #include "DiskIO/DiskIOModule.h"
30 #include "eui/Config.h"
31 #include "ExternalACL.h"
32 #include "format/Format.h"
33 #include "ftp/Elements.h"
35 #include "HttpHeaderTools.h"
36 #include "icmp/IcmpConfig.h"
37 #include "ident/Config.h"
38 #include "ip/Intercept.h"
39 #include "ip/QosConfig.h"
42 #include "log/Config.h"
43 #include "log/CustomLog.h"
45 #include "MessageDelayPools.h"
46 #include "mgr/ActionPasswordList.h"
47 #include "mgr/Registration.h"
48 #include "neighbors.h"
49 #include "NeighborTypeDomainList.h"
52 #include "PeerDigest.h"
53 #include "PeerPoolMgr.h"
55 #include "RefreshPattern.h"
57 #include "sbuf/List.h"
58 #include "SquidConfig.h"
59 #include "SquidString.h"
60 #include "ssl/ProxyCerts.h"
62 #include "store/Disk.h"
63 #include "store/Disks.h"
64 #include "StoreFileSystem.h"
68 /* wccp2 has its own conditional definitions */
71 #include "adaptation/Config.h"
74 #include "adaptation/icap/Config.h"
77 #include "adaptation/ecap/Config.h"
80 #include "ssl/Config.h"
81 #include "ssl/support.h"
84 #include "esi/Parser.h"
102 #include <sys/stat.h>
106 #include "ssl/gadgets.h"
110 static void parse_adaptation_service_set_type();
111 static void parse_adaptation_service_chain_type();
112 static void parse_adaptation_access_type();
116 static void parse_icap_service_type(Adaptation::Icap::Config
*);
117 static void dump_icap_service_type(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
118 static void free_icap_service_type(Adaptation::Icap::Config
*);
119 static void parse_icap_class_type();
120 static void parse_icap_access_type();
122 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*);
123 static void dump_icap_service_failure_limit(StoreEntry
*, const char *, const Adaptation::Icap::Config
&);
124 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*);
128 static void parse_ecap_service_type(Adaptation::Ecap::Config
*);
129 static void dump_ecap_service_type(StoreEntry
*, const char *, const Adaptation::Ecap::Config
&);
130 static void free_ecap_service_type(Adaptation::Ecap::Config
*);
133 static peer_t
parseNeighborType(const char *s
);
135 static const char *const T_MILLISECOND_STR
= "millisecond";
136 static const char *const T_SECOND_STR
= "second";
137 static const char *const T_MINUTE_STR
= "minute";
138 static const char *const T_HOUR_STR
= "hour";
139 static const char *const T_DAY_STR
= "day";
140 static const char *const T_WEEK_STR
= "week";
141 static const char *const T_FORTNIGHT_STR
= "fortnight";
142 static const char *const T_MONTH_STR
= "month";
143 static const char *const T_YEAR_STR
= "year";
144 static const char *const T_DECADE_STR
= "decade";
146 static const char *const B_BYTES_STR
= "bytes";
147 static const char *const B_KBYTES_STR
= "KB";
148 static const char *const B_MBYTES_STR
= "MB";
149 static const char *const B_GBYTES_STR
= "GB";
151 static const char *const list_sep
= ", \t\n\r";
153 static void parse_access_log(CustomLog
** customlog_definitions
);
154 static int check_null_access_log(CustomLog
*customlog_definitions
);
155 static void dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* definitions
);
156 static void free_access_log(CustomLog
** definitions
);
157 static bool setLogformat(CustomLog
*cl
, const char *name
, const bool dieWhenMissing
);
159 static void configDoConfigure(void);
160 static void parse_refreshpattern(RefreshPattern
**);
161 static uint64_t parseTimeUnits(const char *unit
, bool allowMsec
);
162 static void parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
);
163 static void parse_u_short(unsigned short * var
);
164 static void parse_string(char **);
165 static void default_all(void);
166 static void defaults_if_none(void);
167 static void defaults_postscriptum(void);
168 static int parse_line(char *);
169 static void parse_obsolete(const char *);
170 static void parseBytesLine(size_t * bptr
, const char *units
);
171 static void parseBytesLineSigned(ssize_t
* bptr
, const char *units
);
172 static size_t parseBytesUnits(const char *unit
);
173 static void free_all(void);
174 void requirePathnameExists(const char *name
, const char *path
);
175 static OBJH dump_config
;
176 #if USE_HTTP_VIOLATIONS
177 static void free_HeaderManglers(HeaderManglers
**pm
);
178 static void dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
179 static void parse_http_header_access(HeaderManglers
**manglers
);
180 #define free_http_header_access free_HeaderManglers
181 static void dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
);
182 static void parse_http_header_replace(HeaderManglers
**manglers
);
183 #define free_http_header_replace free_HeaderManglers
185 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
);
186 static void parse_HeaderWithAclList(HeaderWithAclList
**header
);
187 static void free_HeaderWithAclList(HeaderWithAclList
**header
);
188 static void parse_note(Notes
*);
189 static void dump_note(StoreEntry
*, const char *, Notes
&);
190 static void free_note(Notes
*);
191 static void parse_denyinfo(AclDenyInfoList
** var
);
192 static void dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
);
193 static void free_denyinfo(AclDenyInfoList
** var
);
196 static void parse_IpAddress_list(Ip::Address_list
**);
197 static void dump_IpAddress_list(StoreEntry
*, const char *, const Ip::Address_list
*);
198 static void free_IpAddress_list(Ip::Address_list
**);
200 static int check_null_IpAddress_list(const Ip::Address_list
*);
201 #endif /* CURRENTLY_UNUSED */
202 #endif /* USE_WCCPv2 */
204 static void parsePortCfg(AnyP::PortCfgPointer
*, const char *protocol
);
205 #define parse_PortCfg(l) parsePortCfg((l), token)
206 static void dump_PortCfg(StoreEntry
*, const char *, const AnyP::PortCfgPointer
&);
207 #define free_PortCfg(h) *(h)=NULL
210 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
211 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
);
212 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
);
213 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
214 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
);
215 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
);
216 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
);
217 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
);
218 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
);
219 #endif /* USE_OPENSSL */
221 static void parse_ftp_epsv(acl_access
**ftp_epsv
);
222 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
);
223 static void free_ftp_epsv(acl_access
**ftp_epsv
);
225 static void parse_b_size_t(size_t * var
);
226 static void parse_b_int64_t(int64_t * var
);
228 static void parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
229 static void dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
);
230 static void free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
);
232 static void parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
233 static void dump_UrlHelperTimeout(StoreEntry
*, const char *, SquidConfig::UrlHelperTimeout
&);
234 static void free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*);
236 static int parseOneConfigFile(const char *file_name
, unsigned int depth
);
238 static void parse_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
239 static void dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool recognizeQuotedValues
);
240 static void free_configuration_includes_quoted_values(bool *recognizeQuotedValues
);
241 static void parse_on_unsupported_protocol(acl_access
**access
);
242 static void dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
);
243 static void free_on_unsupported_protocol(acl_access
**access
);
244 static void ParseAclWithAction(acl_access
**access
, const allow_t
&action
, const char *desc
, ACL
*acl
= nullptr);
247 * LegacyParser is a parser for legacy code that uses the global
248 * approach. This is static so that it is only exposed to cache_cf.
249 * Other modules needing access to a ConfigParser should have it
250 * provided to them in their parserFOO methods.
252 static ConfigParser LegacyParser
= ConfigParser();
257 LegacyParser
.destruct();
261 SetConfigFilename(char const *file_name
, bool is_pipe
)
264 cfg_filename
= file_name
+ 1;
266 cfg_filename
= file_name
;
270 skip_ws(const char* s
)
279 parseManyConfigFiles(char* files
, int depth
)
282 char* saveptr
= NULL
;
287 memset(&globbuf
, 0, sizeof(globbuf
));
288 for (path
= strwordtok(files
, &saveptr
); path
; path
= strwordtok(NULL
, &saveptr
)) {
289 if (glob(path
, globbuf
.gl_pathc
? GLOB_APPEND
: 0, NULL
, &globbuf
) != 0) {
291 fatalf("Unable to find configuration file: %s: %s", path
, xstrerr(xerrno
));
294 for (i
= 0; i
< (int)globbuf
.gl_pathc
; ++i
) {
295 error_count
+= parseOneConfigFile(globbuf
.gl_pathv
[i
], depth
);
299 char* file
= strwordtok(files
, &saveptr
);
300 while (file
!= NULL
) {
301 error_count
+= parseOneConfigFile(file
, depth
);
302 file
= strwordtok(NULL
, &saveptr
);
304 #endif /* HAVE_GLOB */
309 ReplaceSubstr(char*& str
, int& len
, unsigned substrIdx
, unsigned substrLen
, const char* newSubstr
)
312 assert(newSubstr
!= NULL
);
314 unsigned newSubstrLen
= strlen(newSubstr
);
315 if (newSubstrLen
> substrLen
)
316 str
= (char*)realloc(str
, len
- substrLen
+ newSubstrLen
+ 1);
318 // move tail part including zero
319 memmove(str
+ substrIdx
+ newSubstrLen
, str
+ substrIdx
+ substrLen
, len
- substrIdx
- substrLen
+ 1);
320 // copy new substring in place
321 memcpy(str
+ substrIdx
, newSubstr
, newSubstrLen
);
327 SubstituteMacro(char*& line
, int& len
, const char* macroName
, const char* substStr
)
329 assert(line
!= NULL
);
330 assert(macroName
!= NULL
);
331 assert(substStr
!= NULL
);
332 unsigned macroNameLen
= strlen(macroName
);
333 while (const char* macroPos
= strstr(line
, macroName
)) // we would replace all occurrences
334 ReplaceSubstr(line
, len
, macroPos
- line
, macroNameLen
, substStr
);
338 ProcessMacros(char*& line
, int& len
)
340 SubstituteMacro(line
, len
, "${service_name}", service_name
.c_str());
341 SubstituteMacro(line
, len
, "${process_name}", TheKidName
);
342 SubstituteMacro(line
, len
, "${process_number}", xitoa(KidIdentifier
));
346 trim_trailing_ws(char* str
)
349 unsigned i
= strlen(str
);
350 while ((i
> 0) && xisspace(str
[i
- 1]))
356 FindStatement(const char* line
, const char* statement
)
358 assert(line
!= NULL
);
359 assert(statement
!= NULL
);
361 const char* str
= skip_ws(line
);
362 unsigned len
= strlen(statement
);
363 if (strncmp(str
, statement
, len
) == 0) {
367 else if (xisspace(*str
))
375 StrToInt(const char* str
, long& number
)
380 number
= strtol(str
, &end
, 0);
382 return (end
!= str
) && (*end
== '\0'); // returns true if string contains nothing except number
386 EvalBoolExpr(const char* expr
)
388 assert(expr
!= NULL
);
389 if (strcmp(expr
, "true") == 0) {
391 } else if (strcmp(expr
, "false") == 0) {
393 } else if (const char* equation
= strchr(expr
, '=')) {
394 const char* rvalue
= skip_ws(equation
+ 1);
395 char* lvalue
= (char*)xmalloc(equation
- expr
+ 1);
396 xstrncpy(lvalue
, expr
, equation
- expr
+ 1);
397 trim_trailing_ws(lvalue
);
400 if (!StrToInt(lvalue
, number1
))
401 fatalf("String is not a integer number: '%s'\n", lvalue
);
403 if (!StrToInt(rvalue
, number2
))
404 fatalf("String is not a integer number: '%s'\n", rvalue
);
407 return number1
== number2
;
409 fatalf("Unable to evaluate expression '%s'\n", expr
);
410 return false; // this place cannot be reached
414 parseOneConfigFile(const char *file_name
, unsigned int depth
)
417 const char *orig_cfg_filename
= cfg_filename
;
418 const int orig_config_lineno
= config_lineno
;
420 char *tmp_line
= NULL
;
421 int tmp_line_len
= 0;
425 debugs(3, DBG_IMPORTANT
, "Processing Configuration File: " << file_name
<< " (depth " << depth
<< ")");
427 fatalf("WARNING: can't include %s: includes are nested too deeply (>16)!\n", file_name
);
431 if (file_name
[0] == '!' || file_name
[0] == '|') {
432 fp
= popen(file_name
+ 1, "r");
435 fp
= fopen(file_name
, "r");
440 fatalf("Unable to open configuration file: %s: %s", file_name
, xstrerr(xerrno
));
444 setmode(fileno(fp
), O_TEXT
);
447 SetConfigFilename(file_name
, bool(is_pipe
));
449 memset(config_input_line
, '\0', BUFSIZ
);
453 std::vector
<bool> if_states
;
454 while (fgets(config_input_line
, BUFSIZ
, fp
)) {
457 if ((token
= strchr(config_input_line
, '\n')))
460 if ((token
= strchr(config_input_line
, '\r')))
463 // strip any prefix whitespace off the line.
464 const char *p
= skip_ws(config_input_line
);
465 if (config_input_line
!= p
)
466 memmove(config_input_line
, p
, strlen(p
)+1);
468 if (strncmp(config_input_line
, "#line ", 6) == 0) {
469 static char new_file_name
[1024];
471 static char new_lineno
;
472 token
= config_input_line
+ 6;
473 new_lineno
= strtol(token
, &file
, 0) - 1;
476 continue; /* Not a valid #line directive, may be a comment */
478 while (*file
&& xisspace((unsigned char) *file
))
483 continue; /* Not a valid #line directive, may be a comment */
485 xstrncpy(new_file_name
, file
+ 1, sizeof(new_file_name
));
487 if ((token
= strchr(new_file_name
, '"')))
490 SetConfigFilename(new_file_name
, false);
493 config_lineno
= new_lineno
;
496 if (config_input_line
[0] == '#')
499 if (config_input_line
[0] == '\0')
502 const char* append
= tmp_line_len
? skip_ws(config_input_line
) : config_input_line
;
504 size_t append_len
= strlen(append
);
506 tmp_line
= (char*)xrealloc(tmp_line
, tmp_line_len
+ append_len
+ 1);
508 strcpy(tmp_line
+ tmp_line_len
, append
);
510 tmp_line_len
+= append_len
;
512 if (tmp_line
[tmp_line_len
-1] == '\\') {
513 debugs(3, 5, "parseConfigFile: tmp_line='" << tmp_line
<< "'");
514 tmp_line
[--tmp_line_len
] = '\0';
518 trim_trailing_ws(tmp_line
);
519 ProcessMacros(tmp_line
, tmp_line_len
);
520 debugs(3, (opt_parse_cfg_only
?1:5), "Processing: " << tmp_line
);
522 if (const char* expr
= FindStatement(tmp_line
, "if")) {
523 if_states
.push_back(EvalBoolExpr(expr
)); // store last if-statement meaning
524 } else if (FindStatement(tmp_line
, "endif")) {
525 if (!if_states
.empty())
526 if_states
.pop_back(); // remove last if-statement meaning
528 fatalf("'endif' without 'if'\n");
529 } else if (FindStatement(tmp_line
, "else")) {
530 if (!if_states
.empty())
531 if_states
.back() = !if_states
.back();
533 fatalf("'else' without 'if'\n");
534 } else if (if_states
.empty() || if_states
.back()) { // test last if-statement meaning if present
535 /* Handle includes here */
536 if (tmp_line_len
>= 9 && strncmp(tmp_line
, "include", 7) == 0 && xisspace(tmp_line
[7])) {
537 err_count
+= parseManyConfigFiles(tmp_line
+ 8, depth
+ 1);
538 } else if (!parse_line(tmp_line
)) {
539 debugs(3, DBG_CRITICAL
, HERE
<< cfg_filename
<< ":" << config_lineno
<< " unrecognized: '" << tmp_line
<< "'");
548 if (!if_states
.empty())
549 fatalf("if-statement without 'endif'\n");
552 int ret
= pclose(fp
);
555 fatalf("parseConfigFile: '%s' failed with exit code %d\n", file_name
, ret
);
560 SetConfigFilename(orig_cfg_filename
, false);
561 config_lineno
= orig_config_lineno
;
569 parseConfigFileOrThrow(const char *file_name
)
577 ACLMethodData::ThePurgeCount
= 0;
580 err_count
= parseOneConfigFile(file_name
, 0);
584 defaults_postscriptum();
587 * We must call configDoConfigure() before leave_suid() because
588 * configDoConfigure() is where we turn username strings into
593 if (!Config
.chroot_dir
) {
595 setUmask(Config
.umask
);
596 _db_init(Debug::cache_log
, Debug::debugOptions
);
600 if (opt_send_signal
== -1) {
601 Mgr::RegisterAction("config",
602 "Current Squid Configuration",
610 // TODO: Refactor main.cc to centrally handle (and report) all exceptions.
612 parseConfigFile(const char *file_name
)
615 return parseConfigFileOrThrow(file_name
);
617 catch (const std::exception
&ex
) {
618 debugs(3, DBG_CRITICAL
, "FATAL: bad configuration: " << ex
.what());
620 return 1; // not reached
625 configDoConfigure(void)
628 /* init memory as early as possible */
632 Config
.cacheSwap
.n_strands
= 0; // no diskers by default
633 if (Config
.cacheSwap
.swapDirs
== NULL
) {
634 /* Memory-only cache probably in effect. */
635 /* turn off the cache rebuild delays... */
636 StoreController::store_dirs_rebuilding
= 0;
637 } else if (InDaemonMode()) { // no diskers in non-daemon mode
638 for (int i
= 0; i
< Config
.cacheSwap
.n_configured
; ++i
) {
639 const RefCount
<SwapDir
> sd
= Config
.cacheSwap
.swapDirs
[i
];
640 if (sd
->needsDiskStrand())
641 sd
->disker
= Config
.workers
+ (++Config
.cacheSwap
.n_strands
);
645 if (Debug::rotateNumber
< 0) {
646 Debug::rotateNumber
= Config
.Log
.rotateNumber
;
649 #if SIZEOF_OFF_T <= 4
650 if (Config
.Store
.maxObjectSize
> 0x7FFF0000) {
651 debugs(3, DBG_CRITICAL
, "WARNING: This Squid binary can not handle files larger than 2GB. Limiting maximum_object_size to just below 2GB");
652 Config
.Store
.maxObjectSize
= 0x7FFF0000;
656 if (Config
.Announce
.period
> 0) {
657 Config
.onoff
.announce
= 1;
659 Config
.Announce
.period
= 86400 * 365; /* one year */
660 Config
.onoff
.announce
= 0;
663 if (Config
.onoff
.httpd_suppress_version_string
)
664 visible_appname_string
= (char *)appname_string
;
666 visible_appname_string
= (char const *)APP_FULLNAME
;
668 if (Config
.Program
.redirect
) {
669 if (Config
.redirectChildren
.n_max
< 1) {
670 Config
.redirectChildren
.n_max
= 0;
671 wordlistDestroy(&Config
.Program
.redirect
);
675 if (Config
.Program
.store_id
) {
676 if (Config
.storeIdChildren
.n_max
< 1) {
677 Config
.storeIdChildren
.n_max
= 0;
678 wordlistDestroy(&Config
.Program
.store_id
);
682 if (Config
.appendDomain
)
683 if (*Config
.appendDomain
!= '.')
684 fatal("append_domain must begin with a '.'");
686 if (Config
.errHtmlText
== NULL
)
687 Config
.errHtmlText
= xstrdup(null_string
);
689 #if !HAVE_SETRLIMIT || !defined(RLIMIT_NOFILE)
690 if (Config
.max_filedescriptors
> 0) {
691 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors disabled. Operating System setrlimit(RLIMIT_NOFILE) is missing.");
693 #elif USE_SELECT || USE_SELECT_WIN32
694 if (Config
.max_filedescriptors
> FD_SETSIZE
) {
695 debugs(0, DBG_IMPORTANT
, "WARNING: max_filedescriptors limited to " << FD_SETSIZE
<< " by select() algorithm.");
701 snprintf(ThisCache
, sizeof(ThisCache
), "%s (%s)",
703 visible_appname_string
);
706 * the extra space is for loop detection in client_side.c -- we search
707 * for substrings in the Via header.
709 snprintf(ThisCache2
, sizeof(ThisCache
), " %s (%s)",
711 visible_appname_string
);
713 /* Use visible_hostname as default surrogate_id */
714 if (!Config
.Accel
.surrogate_id
) {
715 const char *t
= getMyHostname();
716 Config
.Accel
.surrogate_id
= xstrdup( (t
?t
:"unset-id") );
719 if (!Config
.udpMaxHitObjsz
|| Config
.udpMaxHitObjsz
> SQUID_UDP_SO_SNDBUF
)
720 Config
.udpMaxHitObjsz
= SQUID_UDP_SO_SNDBUF
;
722 if (Config
.appendDomain
)
723 Config
.appendDomainLen
= strlen(Config
.appendDomain
);
725 Config
.appendDomainLen
= 0;
727 if (Config
.connect_retries
> 10) {
728 debugs(0,DBG_CRITICAL
, "WARNING: connect_retries cannot be larger than 10. Resetting to 10.");
729 Config
.connect_retries
= 10;
732 requirePathnameExists("MIME Config Table", Config
.mimeTablePathname
);
735 requirePathnameExists("unlinkd_program", Config
.Program
.unlinkd
);
737 requirePathnameExists("logfile_daemon", Log::TheConfig
.logfile_daemon
);
738 if (Config
.Program
.redirect
)
739 requirePathnameExists("redirect_program", Config
.Program
.redirect
->key
);
741 if (Config
.Program
.store_id
)
742 requirePathnameExists("store_id_program", Config
.Program
.store_id
->key
);
744 requirePathnameExists("Icon Directory", Config
.icons
.directory
);
746 if (Config
.errorDirectory
)
747 requirePathnameExists("Error Directory", Config
.errorDirectory
);
749 #if USE_HTTP_VIOLATIONS
752 const RefreshPattern
*R
;
754 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
755 if (!R
->flags
.override_expire
)
758 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-expire' in 'refresh_pattern' violates HTTP");
763 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
764 if (!R
->flags
.override_lastmod
)
767 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'override-lastmod' in 'refresh_pattern' violates HTTP");
772 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
773 if (!R
->flags
.reload_into_ims
)
776 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'reload-into-ims' in 'refresh_pattern' violates HTTP");
781 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
782 if (!R
->flags
.ignore_reload
)
785 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-reload' in 'refresh_pattern' violates HTTP");
790 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
791 if (!R
->flags
.ignore_no_store
)
794 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-no-store' in 'refresh_pattern' violates HTTP");
799 for (R
= Config
.Refresh
; R
; R
= R
->next
) {
800 if (!R
->flags
.ignore_private
)
803 debugs(22, DBG_IMPORTANT
, "WARNING: use of 'ignore-private' in 'refresh_pattern' violates HTTP");
809 #if !USE_HTTP_VIOLATIONS
810 Config
.onoff
.via
= 1;
813 if (!Config
.onoff
.via
)
814 debugs(22, DBG_IMPORTANT
, "WARNING: HTTP requires the use of Via");
818 // we enable runtime PURGE checks if there is at least one PURGE method ACL
819 // TODO: replace with a dedicated "purge" ACL option?
820 Config2
.onoff
.enable_purge
= (ACLMethodData::ThePurgeCount
> 0);
822 if (geteuid() == 0) {
823 if (NULL
!= Config
.effectiveUser
) {
825 struct passwd
*pwd
= getpwnam(Config
.effectiveUser
);
829 * Andres Kroonmaa <andre@online.ee>:
830 * Some getpwnam() implementations (Solaris?) require
831 * an available FD < 256 for opening a FILE* to the
834 * This should be safe at startup, but might still fail
835 * during reconfigure.
837 fatalf("getpwnam failed to find userid for effective user '%s'",
838 Config
.effectiveUser
);
842 Config2
.effectiveUserID
= pwd
->pw_uid
;
844 Config2
.effectiveGroupID
= pwd
->pw_gid
;
847 if (pwd
->pw_dir
&& *pwd
->pw_dir
) {
848 // putenv() leaks by design; avoid leaks when nothing changes
850 if (lastDir
.isEmpty() || lastDir
.cmp(pwd
->pw_dir
) != 0) {
851 lastDir
= pwd
->pw_dir
;
852 int len
= strlen(pwd
->pw_dir
) + 6;
853 char *env_str
= (char *)xcalloc(len
, 1);
854 snprintf(env_str
, len
, "HOME=%s", pwd
->pw_dir
);
861 Config2
.effectiveUserID
= geteuid();
862 Config2
.effectiveGroupID
= getegid();
865 if (NULL
!= Config
.effectiveGroup
) {
867 struct group
*grp
= getgrnam(Config
.effectiveGroup
);
870 fatalf("getgrnam failed to find groupid for effective group '%s'",
871 Config
.effectiveGroup
);
875 Config2
.effectiveGroupID
= grp
->gr_gid
;
879 if (Config
.ssl_client
.foreignIntermediateCertsPath
)
880 Ssl::loadSquidUntrusted(Config
.ssl_client
.foreignIntermediateCertsPath
);
883 if (Security::ProxyOutgoingConfig
.encryptTransport
) {
884 debugs(3, DBG_IMPORTANT
, "Initializing https:// proxy context");
885 Config
.ssl_client
.sslContext
= Security::ProxyOutgoingConfig
.createClientContext(false);
886 if (!Config
.ssl_client
.sslContext
) {
888 fatal("ERROR: Could not initialize https:// proxy context");
890 debugs(3, DBG_IMPORTANT
, "ERROR: proxying https:// currently still requires --with-openssl");
894 Ssl::useSquidUntrusted(Config
.ssl_client
.sslContext
.get());
898 for (CachePeer
*p
= Config
.peers
; p
!= NULL
; p
= p
->next
) {
900 // default value for ssldomain= is the peer host/IP
901 if (p
->secure
.sslDomain
.isEmpty())
902 p
->secure
.sslDomain
= p
->host
;
904 if (p
->secure
.encryptTransport
) {
905 debugs(3, DBG_IMPORTANT
, "Initializing cache_peer " << p
->name
<< " TLS context");
906 p
->sslContext
= p
->secure
.createClientContext(true);
907 if (!p
->sslContext
) {
908 debugs(3, DBG_CRITICAL
, "ERROR: Could not initialize cache_peer " << p
->name
<< " TLS context");
915 for (AnyP::PortCfgPointer s
= HttpPortList
; s
!= NULL
; s
= s
->next
) {
916 if (!s
->secure
.encryptTransport
)
918 debugs(3, DBG_IMPORTANT
, "Initializing " << AnyP::UriScheme(s
->transport
.protocol
) << "_port " << s
->s
<< " TLS contexts");
919 s
->secure
.initServerContexts(*s
);
922 // prevent infinite fetch loops in the request parser
923 // due to buffer full but not enough data recived to finish parse
924 if (Config
.maxRequestBufferSize
<= Config
.maxRequestHeaderSize
) {
925 fatalf("Client request buffer of %u bytes cannot hold a request with %u bytes of headers." \
926 " Change client_request_buffer_max or request_header_max_size limits.",
927 (uint32_t)Config
.maxRequestBufferSize
, (uint32_t)Config
.maxRequestHeaderSize
);
931 * Disable client side request pipelining if client_persistent_connections OFF.
932 * Waste of resources queueing any pipelined requests when the first will close the connection.
934 if (Config
.pipeline_max_prefetch
> 0 && !Config
.onoff
.client_pconns
) {
935 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch " << Config
.pipeline_max_prefetch
<<
936 " requires client_persistent_connections ON. Forced pipeline_prefetch 0.");
937 Config
.pipeline_max_prefetch
= 0;
942 * disable client side request pipelining. There is a race with
943 * Negotiate and NTLM when the client sends a second request on an
944 * connection before the authenticate challenge is sent. With
945 * pipelining OFF, the client may fail to authenticate, but squid's
946 * state will be preserved.
948 if (Config
.pipeline_max_prefetch
> 0) {
949 Auth::SchemeConfig
*nego
= Auth::SchemeConfig::Find("Negotiate");
950 Auth::SchemeConfig
*ntlm
= Auth::SchemeConfig::Find("NTLM");
951 if ((nego
&& nego
->active()) || (ntlm
&& ntlm
->active())) {
952 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: pipeline_prefetch breaks NTLM and Negotiate authentication. Forced pipeline_prefetch 0.");
953 Config
.pipeline_max_prefetch
= 0;
957 for (auto &authSchemes
: Auth::TheConfig
.schemeLists
) {
958 authSchemes
.expand();
959 if (authSchemes
.authConfigs
.empty()) {
960 debugs(3, DBG_CRITICAL
, "auth_schemes: at least one scheme name is required; got: " << authSchemes
.rawSchemes
);
967 /** Parse a line containing an obsolete directive.
968 * To upgrade it where possible instead of just "Bungled config" for
969 * directives which cannot be marked as simply aliases of the some name.
970 * For example if the parameter order and content has changed.
971 * Or if the directive has been completely removed.
974 parse_obsolete(const char *name
)
976 // Directives which have been radically changed rather than removed
977 if (!strcmp(name
, "url_rewrite_concurrency")) {
980 debugs(3, DBG_CRITICAL
, "WARNING: url_rewrite_concurrency upgrade overriding url_rewrite_children settings.");
981 Config
.redirectChildren
.concurrency
= cval
;
984 if (!strcmp(name
, "log_access")) {
989 if (!strcmp(name
, "log_icap")) {
994 if (!strcmp(name
, "ignore_ims_on_miss")) {
995 // the replacement directive cache_revalidate_on_miss has opposite meanings for ON/OFF value
996 // than the 2.7 directive. We need to parse and invert the configured value.
999 Config
.onoff
.cache_miss_revalidate
= !temp
;
1002 if (!strncmp(name
, "sslproxy_", 9)) {
1003 // the replacement directive tls_outgoing_options uses options instead of whole-line input
1005 if (!strcmp(name
, "sslproxy_cafile"))
1006 tmp
.append("cafile=");
1007 else if (!strcmp(name
, "sslproxy_capath"))
1008 tmp
.append("capath=");
1009 else if (!strcmp(name
, "sslproxy_cipher"))
1010 tmp
.append("cipher=");
1011 else if (!strcmp(name
, "sslproxy_client_certificate"))
1012 tmp
.append("cert=");
1013 else if (!strcmp(name
, "sslproxy_client_key"))
1015 else if (!strcmp(name
, "sslproxy_flags"))
1016 tmp
.append("flags=");
1017 else if (!strcmp(name
, "sslproxy_options"))
1018 tmp
.append("options=");
1019 else if (!strcmp(name
, "sslproxy_version"))
1020 tmp
.append("version=");
1022 debugs(3, DBG_CRITICAL
, "ERROR: unknown directive: " << name
);
1027 // add the value as unquoted-string because the old values did not support whitespace
1028 const char *token
= ConfigParser::NextQuotedOrToEol();
1029 tmp
.append(token
, strlen(token
));
1030 Security::ProxyOutgoingConfig
.parse(tmp
.c_str());
1034 /* Parse a time specification from the config file. Store the
1035 * result in 'tptr', after converting it to 'units' */
1037 parseTimeLine(time_msec_t
* tptr
, const char *units
, bool allowMsec
, bool expectMoreArguments
= false)
1039 time_msec_t u
= parseTimeUnits(units
, allowMsec
);
1045 char *token
= ConfigParser::NextToken();;
1051 double d
= xatof(token
);
1053 time_msec_t m
= u
; /* default to 'units' if none specified */
1056 if ((token
= ConfigParser::PeekAtToken()) && (m
= parseTimeUnits(token
, allowMsec
))) {
1057 (void)ConfigParser::NextToken();
1059 } else if (!expectMoreArguments
) {
1064 token
= NULL
; // show default units if dying below
1065 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" << config_input_line
<< "', assuming " << d
<< " " << units
);
1068 token
= NULL
; // show default units if dying below.
1070 *tptr
= static_cast<time_msec_t
>(m
* d
);
1072 if (static_cast<double>(*tptr
) * 2 != m
* d
* 2) {
1073 debugs(3, DBG_CRITICAL
, "FATAL: Invalid value '" <<
1074 d
<< " " << (token
? token
: units
) << ": integer overflow (time_msec_t).");
1080 parseTimeUnits(const char *unit
, bool allowMsec
)
1082 if (allowMsec
&& !strncasecmp(unit
, T_MILLISECOND_STR
, strlen(T_MILLISECOND_STR
)))
1085 if (!strncasecmp(unit
, T_SECOND_STR
, strlen(T_SECOND_STR
)))
1088 if (!strncasecmp(unit
, T_MINUTE_STR
, strlen(T_MINUTE_STR
)))
1091 if (!strncasecmp(unit
, T_HOUR_STR
, strlen(T_HOUR_STR
)))
1094 if (!strncasecmp(unit
, T_DAY_STR
, strlen(T_DAY_STR
)))
1095 return 86400 * 1000;
1097 if (!strncasecmp(unit
, T_WEEK_STR
, strlen(T_WEEK_STR
)))
1098 return 86400 * 7 * 1000;
1100 if (!strncasecmp(unit
, T_FORTNIGHT_STR
, strlen(T_FORTNIGHT_STR
)))
1101 return 86400 * 14 * 1000;
1103 if (!strncasecmp(unit
, T_MONTH_STR
, strlen(T_MONTH_STR
)))
1104 return static_cast<uint64_t>(86400) * 30 * 1000;
1106 if (!strncasecmp(unit
, T_YEAR_STR
, strlen(T_YEAR_STR
)))
1107 return static_cast<uint64_t>(86400 * 1000 * 365.2522);
1109 if (!strncasecmp(unit
, T_DECADE_STR
, strlen(T_DECADE_STR
)))
1110 return static_cast<uint64_t>(86400 * 1000 * 365.2522 * 10);
1112 debugs(3, DBG_IMPORTANT
, "parseTimeUnits: unknown time unit '" << unit
<< "'");
1118 parseBytesLine64(int64_t * bptr
, const char *units
)
1125 if ((u
= parseBytesUnits(units
)) == 0) {
1130 if ((token
= ConfigParser::NextToken()) == NULL
) {
1135 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1142 m
= u
; /* default to 'units' if none specified */
1146 else if ((token
= ConfigParser::NextToken()) == NULL
)
1147 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1148 config_input_line
<< "', assuming " <<
1149 d
<< " " << units
);
1150 else if ((m
= parseBytesUnits(token
)) == 0) {
1155 *bptr
= static_cast<int64_t>(m
* d
/ u
);
1157 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1158 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1159 d
<< " " << token
<< ": integer overflow (int64_t).");
1165 parseBytesLine(size_t * bptr
, const char *units
)
1172 if ((u
= parseBytesUnits(units
)) == 0) {
1177 if ((token
= ConfigParser::NextToken()) == NULL
) {
1182 if (strcmp(token
, "none") == 0 || strcmp(token
, "-1") == 0) {
1183 *bptr
= static_cast<size_t>(-1);
1189 m
= u
; /* default to 'units' if none specified */
1193 else if ((token
= ConfigParser::NextToken()) == NULL
)
1194 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1195 config_input_line
<< "', assuming " <<
1196 d
<< " " << units
);
1197 else if ((m
= parseBytesUnits(token
)) == 0) {
1202 *bptr
= static_cast<size_t>(m
* d
/ u
);
1204 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1205 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1206 d
<< " " << token
<< ": integer overflow (size_t).");
1212 parseBytesLineSigned(ssize_t
* bptr
, const char *units
)
1219 if ((u
= parseBytesUnits(units
)) == 0) {
1224 if ((token
= ConfigParser::NextToken()) == NULL
) {
1229 if (strcmp(token
, "none") == 0 || token
[0] == '-' /* -N */) {
1236 m
= u
; /* default to 'units' if none specified */
1240 else if ((token
= ConfigParser::NextToken()) == NULL
)
1241 debugs(3, DBG_CRITICAL
, "WARNING: No units on '" <<
1242 config_input_line
<< "', assuming " <<
1243 d
<< " " << units
);
1244 else if ((m
= parseBytesUnits(token
)) == 0) {
1249 *bptr
= static_cast<ssize_t
>(m
* d
/ u
);
1251 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2) {
1252 debugs(3, DBG_CRITICAL
, "ERROR: Invalid value '" <<
1253 d
<< " " << token
<< ": integer overflow (ssize_t).");
1259 * Parse bytes from a string.
1260 * Similar to the parseBytesLine function but parses the string value instead of
1261 * the current token value.
1264 parseBytesOptionValue(size_t * bptr
, const char *units
, char const * value
)
1267 if ((u
= parseBytesUnits(units
)) == 0) {
1272 // Find number from string beginning.
1273 char const * number_begin
= value
;
1274 char const * number_end
= value
;
1276 while ((*number_end
>= '0' && *number_end
<= '9')) {
1281 number
.limitInit(number_begin
, number_end
- number_begin
);
1283 int d
= xatoi(number
.termedBuf());
1285 if ((m
= parseBytesUnits(number_end
)) == 0) {
1290 *bptr
= static_cast<size_t>(m
* d
/ u
);
1291 if (static_cast<double>(*bptr
) * 2 != (m
* d
/ u
) * 2)
1296 parseBytesUnits(const char *unit
)
1298 if (!strncasecmp(unit
, B_BYTES_STR
, strlen(B_BYTES_STR
)))
1301 if (!strncasecmp(unit
, B_KBYTES_STR
, strlen(B_KBYTES_STR
)))
1304 if (!strncasecmp(unit
, B_MBYTES_STR
, strlen(B_MBYTES_STR
)))
1307 if (!strncasecmp(unit
, B_GBYTES_STR
, strlen(B_GBYTES_STR
)))
1310 debugs(3, DBG_CRITICAL
, "WARNING: Unknown bytes unit '" << unit
<< "'");
1316 parse_SBufList(SBufList
* list
)
1318 while (char *token
= ConfigParser::NextQuotedToken())
1319 list
->push_back(SBuf(token
));
1322 // just dump a list, no directive name
1324 dump_SBufList(StoreEntry
* entry
, const SBufList
&words
)
1326 for (const auto &i
: words
) {
1327 entry
->append(i
.rawContent(), i
.length());
1328 entry
->append(" ",1);
1330 entry
->append("\n",1);
1333 // dump a SBufList type directive with name
1335 dump_SBufList(StoreEntry
* entry
, const char *name
, SBufList
&list
)
1337 if (!list
.empty()) {
1338 entry
->append(name
, strlen(name
));
1339 entry
->append(" ", 1);
1340 dump_SBufList(entry
, list
);
1345 free_SBufList(SBufList
*list
)
1352 dump_acl(StoreEntry
* entry
, const char *name
, ACL
* ae
)
1354 while (ae
!= NULL
) {
1355 debugs(3, 3, "dump_acl: " << name
<< " " << ae
->name
);
1356 storeAppendPrintf(entry
, "%s %s %s ",
1361 tail
.splice(tail
.end(), ae
->dumpOptions());
1362 tail
.splice(tail
.end(), ae
->dump()); // ACL parameters
1363 dump_SBufList(entry
, tail
);
1369 parse_acl(ACL
** ae
)
1371 ACL::ParseAclLine(LegacyParser
, ae
);
1381 dump_acl_list(StoreEntry
* entry
, ACLList
* head
)
1383 dump_SBufList(entry
, head
->dump());
1387 dump_acl_access(StoreEntry
* entry
, const char *name
, acl_access
* head
)
1390 dump_SBufList(entry
, head
->treeDump(name
, &Acl::AllowOrDeny
));
1394 parse_acl_access(acl_access
** head
)
1396 aclParseAccessLine(cfg_directive
, LegacyParser
, head
);
1400 free_acl_access(acl_access
** head
)
1402 aclDestroyAccessList(head
);
1406 dump_address(StoreEntry
* entry
, const char *name
, Ip::Address
&addr
)
1408 char buf
[MAX_IPSTRLEN
];
1409 storeAppendPrintf(entry
, "%s %s\n", name
, addr
.toStr(buf
,MAX_IPSTRLEN
) );
1413 parse_address(Ip::Address
*addr
)
1415 char *token
= ConfigParser::NextToken();
1422 if (!strcmp(token
,"any_addr"))
1424 else if ( (!strcmp(token
,"no_addr")) || (!strcmp(token
,"full_mask")) )
1426 else if ( (*addr
= token
) ) // try parse numeric/IPA
1428 else if (addr
->GetHostByName(token
)) // dont use ipcache
1430 else { // not an IP and not a hostname
1431 debugs(3, DBG_CRITICAL
, "FATAL: invalid IP address or domain name '" << token
<< "'");
1437 free_address(Ip::Address
*addr
)
1443 dump_acl_address(StoreEntry
* entry
, const char *name
, Acl::Address
* head
)
1445 char buf
[MAX_IPSTRLEN
];
1447 for (Acl::Address
*l
= head
; l
; l
= l
->next
) {
1448 if (!l
->addr
.isAnyAddr())
1449 storeAppendPrintf(entry
, "%s %s", name
, l
->addr
.toStr(buf
,MAX_IPSTRLEN
));
1451 storeAppendPrintf(entry
, "%s autoselect", name
);
1453 dump_acl_list(entry
, l
->aclList
);
1455 storeAppendPrintf(entry
, "\n");
1460 parse_acl_address(Acl::Address
** head
)
1462 Acl::Address
*l
= new Acl::Address
;
1463 parse_address(&l
->addr
);
1464 aclParseAclList(LegacyParser
, &l
->aclList
, l
->addr
);
1466 Acl::Address
**tail
= head
;
1468 tail
= &(*tail
)->next
;
1474 free_acl_address(Acl::Address
** head
)
1481 dump_acl_tos(StoreEntry
* entry
, const char *name
, acl_tos
* head
)
1485 for (l
= head
; l
; l
= l
->next
) {
1487 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->tos
);
1489 storeAppendPrintf(entry
, "%s none", name
);
1491 dump_acl_list(entry
, l
->aclList
);
1493 storeAppendPrintf(entry
, "\n");
1498 parse_acl_tos(acl_tos
** head
)
1500 unsigned int tos
; /* Initially uint for strtoui. Casted to tos_t before return */
1501 char *token
= ConfigParser::NextToken();
1508 if (!xstrtoui(token
, NULL
, &tos
, 0, std::numeric_limits
<tos_t
>::max())) {
1513 const unsigned int chTos
= tos
& 0xFC;
1515 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: Tos value '" << tos
<< "' adjusted to '" << chTos
<< "'");
1519 acl_tos
*l
= new acl_tos
;
1521 l
->tos
= (tos_t
)tos
;
1523 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1525 acl_tos
**tail
= head
; /* sane name below */
1527 tail
= &(*tail
)->next
;
1533 free_acl_tos(acl_tos
** head
)
1539 #if SO_MARK && USE_LIBCAP
1542 dump_acl_nfmark(StoreEntry
* entry
, const char *name
, acl_nfmark
* head
)
1544 for (acl_nfmark
*l
= head
; l
; l
= l
->next
) {
1546 storeAppendPrintf(entry
, "%s 0x%02X", name
, l
->nfmark
);
1548 storeAppendPrintf(entry
, "%s none", name
);
1550 dump_acl_list(entry
, l
->aclList
);
1552 storeAppendPrintf(entry
, "\n");
1557 parse_acl_nfmark(acl_nfmark
** head
)
1560 char *token
= ConfigParser::NextToken();
1567 if (!xstrtoui(token
, NULL
, &mark
, 0, std::numeric_limits
<nfmark_t
>::max())) {
1572 acl_nfmark
*l
= new acl_nfmark
;
1576 aclParseAclList(LegacyParser
, &l
->aclList
, token
);
1578 acl_nfmark
**tail
= head
; /* sane name below */
1580 tail
= &(*tail
)->next
;
1586 free_acl_nfmark(acl_nfmark
** head
)
1591 #endif /* SO_MARK */
1594 dump_acl_b_size_t(StoreEntry
* entry
, const char *name
, AclSizeLimit
* head
)
1596 for (AclSizeLimit
*l
= head
; l
; l
= l
->next
) {
1598 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) l
->size
, B_BYTES_STR
);
1600 storeAppendPrintf(entry
, "%s none", name
);
1602 dump_acl_list(entry
, l
->aclList
);
1604 storeAppendPrintf(entry
, "\n");
1609 parse_acl_b_size_t(AclSizeLimit
** head
)
1611 AclSizeLimit
*l
= new AclSizeLimit
;
1613 parse_b_int64_t(&l
->size
);
1615 aclParseAclList(LegacyParser
, &l
->aclList
, l
->size
);
1617 AclSizeLimit
**tail
= head
; /* sane name below */
1619 tail
= &(*tail
)->next
;
1625 free_acl_b_size_t(AclSizeLimit
** head
)
1633 #include "DelayConfig.h"
1634 #include "DelayPools.h"
1635 /* do nothing - free_delay_pool_count is the magic free function.
1636 * this is why delay_pool_count isn't just marked TYPE: u_short
1638 #define free_delay_pool_class(X)
1639 #define free_delay_pool_access(X)
1640 #define free_delay_pool_rates(X)
1641 #define dump_delay_pool_class(X, Y, Z)
1642 #define dump_delay_pool_access(X, Y, Z)
1643 #define dump_delay_pool_rates(X, Y, Z)
1646 free_delay_pool_count(DelayConfig
* cfg
)
1648 cfg
->freePoolCount();
1652 dump_delay_pool_count(StoreEntry
* entry
, const char *name
, DelayConfig
&cfg
)
1654 cfg
.dumpPoolCount (entry
, name
);
1658 parse_delay_pool_count(DelayConfig
* cfg
)
1660 cfg
->parsePoolCount();
1664 parse_delay_pool_class(DelayConfig
* cfg
)
1666 cfg
->parsePoolClass();
1670 parse_delay_pool_rates(DelayConfig
* cfg
)
1672 cfg
->parsePoolRates();
1676 parse_delay_pool_access(DelayConfig
* cfg
)
1678 cfg
->parsePoolAccess(LegacyParser
);
1684 #include "ClientDelayConfig.h"
1685 /* do nothing - free_client_delay_pool_count is the magic free function.
1686 * this is why client_delay_pool_count isn't just marked TYPE: u_short
1689 #define free_client_delay_pool_access(X)
1690 #define free_client_delay_pool_rates(X)
1691 #define dump_client_delay_pool_access(X, Y, Z)
1692 #define dump_client_delay_pool_rates(X, Y, Z)
1695 free_client_delay_pool_count(ClientDelayConfig
* cfg
)
1701 dump_client_delay_pool_count(StoreEntry
* entry
, const char *name
, ClientDelayConfig
&cfg
)
1703 cfg
.dumpPoolCount (entry
, name
);
1707 parse_client_delay_pool_count(ClientDelayConfig
* cfg
)
1709 cfg
->parsePoolCount();
1713 parse_client_delay_pool_rates(ClientDelayConfig
* cfg
)
1715 cfg
->parsePoolRates();
1719 parse_client_delay_pool_access(ClientDelayConfig
* cfg
)
1721 cfg
->parsePoolAccess(LegacyParser
);
1725 #if USE_HTTP_VIOLATIONS
1727 dump_http_header_access(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1730 manglers
->dumpAccess(entry
, name
);
1734 parse_http_header_access(HeaderManglers
**pm
)
1738 if ((t
= ConfigParser::NextToken()) == NULL
) {
1739 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1740 debugs(3, DBG_CRITICAL
, "parse_http_header_access: missing header name.");
1745 *pm
= new HeaderManglers
;
1746 HeaderManglers
*manglers
= *pm
;
1747 headerMangler
*mangler
= manglers
->track(t
);
1750 std::string directive
= "http_header_access ";
1752 aclParseAccessLine(directive
.c_str(), LegacyParser
, &mangler
->access_list
);
1756 free_HeaderManglers(HeaderManglers
**pm
)
1758 // we delete the entire http_header_* mangler configuration at once
1759 if (const HeaderManglers
*manglers
= *pm
) {
1766 dump_http_header_replace(StoreEntry
* entry
, const char *name
, const HeaderManglers
*manglers
)
1769 manglers
->dumpReplacement(entry
, name
);
1773 parse_http_header_replace(HeaderManglers
**pm
)
1777 if ((t
= ConfigParser::NextToken()) == NULL
) {
1778 debugs(3, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
1779 debugs(3, DBG_CRITICAL
, "parse_http_header_replace: missing header name.");
1783 const char *value
= ConfigParser::NextQuotedOrToEol();
1786 *pm
= new HeaderManglers
;
1787 HeaderManglers
*manglers
= *pm
;
1788 manglers
->setReplacement(t
, value
);
1794 dump_cachedir(StoreEntry
* entry
, const char *name
, const Store::DiskConfig
&swap
)
1800 for (i
= 0; i
< swap
.n_configured
; ++i
) {
1801 s
= dynamic_cast<SwapDir
*>(swap
.swapDirs
[i
].getRaw());
1803 storeAppendPrintf(entry
, "%s %s %s", name
, s
->type(), s
->path
);
1805 storeAppendPrintf(entry
, "\n");
1810 check_null_string(char *s
)
1817 parse_authparam(Auth::ConfigVector
* config
)
1819 char *type_str
= ConfigParser::NextToken();
1825 char *param_str
= ConfigParser::NextToken();
1831 /* find a configuration for the scheme in the currently parsed configs... */
1832 Auth::SchemeConfig
*schemeCfg
= Auth::SchemeConfig::Find(type_str
);
1834 if (schemeCfg
== NULL
) {
1835 /* Create a configuration based on the scheme info */
1836 Auth::Scheme::Pointer theScheme
= Auth::Scheme::Find(type_str
);
1838 if (theScheme
== NULL
) {
1839 debugs(3, DBG_CRITICAL
, "Parsing Config File: Unknown authentication scheme '" << type_str
<< "'.");
1844 config
->push_back(theScheme
->createConfig());
1845 schemeCfg
= Auth::SchemeConfig::Find(type_str
);
1846 if (schemeCfg
== NULL
) {
1847 debugs(3, DBG_CRITICAL
, "Parsing Config File: Corruption configuring authentication scheme '" << type_str
<< "'.");
1853 schemeCfg
->parse(schemeCfg
, config
->size(), param_str
);
1857 free_authparam(Auth::ConfigVector
* cfg
)
1859 /* Wipe the Auth globals and Detach/Destruct component config + state. */
1862 /* on reconfigure initialize new auth schemes for the new config. */
1863 if (reconfiguring
) {
1869 dump_authparam(StoreEntry
* entry
, const char *name
, Auth::ConfigVector cfg
)
1871 for (auto *scheme
: cfg
)
1872 scheme
->dump(entry
, name
, scheme
);
1876 parse_AuthSchemes(acl_access
**authSchemes
)
1878 const char *tok
= ConfigParser::NextQuotedToken();
1880 debugs(29, DBG_CRITICAL
, "FATAL: auth_schemes missing the parameter");
1884 Auth::TheConfig
.schemeLists
.emplace_back(tok
, ConfigParser::LastTokenWasQuoted());
1885 const allow_t action
= allow_t(ACCESS_ALLOWED
, Auth::TheConfig
.schemeLists
.size() - 1);
1886 ParseAclWithAction(authSchemes
, action
, "auth_schemes");
1890 free_AuthSchemes(acl_access
**authSchemes
)
1892 Auth::TheConfig
.schemeLists
.clear();
1893 free_acl_access(authSchemes
);
1897 dump_AuthSchemes(StoreEntry
*entry
, const char *name
, acl_access
*authSchemes
)
1900 dump_SBufList(entry
, authSchemes
->treeDump(name
, [](const allow_t
&action
) {
1901 return Auth::TheConfig
.schemeLists
.at(action
.kind
).rawSchemes
;
1905 #endif /* USE_AUTH */
1908 ParseAclWithAction(acl_access
**access
, const allow_t
&action
, const char *desc
, ACL
*acl
)
1913 *access
= new Acl::Tree
;
1914 name
.Printf("(%s rules)", desc
);
1915 (*access
)->context(name
.c_str(), config_input_line
);
1917 Acl::AndNode
*rule
= new Acl::AndNode
;
1918 name
.Printf("(%s rule)", desc
);
1919 rule
->context(name
.c_str(), config_input_line
);
1920 acl
? rule
->add(acl
) : rule
->lineParse();
1921 (*access
)->add(rule
, action
);
1924 /* TODO: just return the object, the # is irrelevant */
1926 find_fstype(char *type
)
1928 for (size_t i
= 0; i
< StoreFileSystem::FileSystems().size(); ++i
)
1929 if (strcasecmp(type
, StoreFileSystem::FileSystems().at(i
)->type()) == 0)
1936 parse_cachedir(Store::DiskConfig
*swap
)
1938 char *type_str
= ConfigParser::NextToken();
1944 char *path_str
= ConfigParser::NextToken();
1950 int fs
= find_fstype(type_str
);
1952 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: This proxy does not support the '" << type_str
<< "' cache type. Ignoring.");
1956 /* reconfigure existing dir */
1958 RefCount
<SwapDir
> sd
;
1959 for (int i
= 0; i
< swap
->n_configured
; ++i
) {
1960 assert (swap
->swapDirs
[i
].getRaw());
1962 if ((strcasecmp(path_str
, dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw())->path
)) == 0) {
1963 /* this is specific to on-fs Stores. The right
1964 * way to handle this is probably to have a mapping
1965 * from paths to stores, and have on-fs stores
1966 * register with that, and lookip in that in their
1967 * own setup logic. RBC 20041225. TODO.
1970 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[i
].getRaw());
1972 if (strcmp(sd
->type(), StoreFileSystem::FileSystems().at(fs
)->type()) != 0) {
1973 debugs(3, DBG_CRITICAL
, "ERROR: Can't change type of existing cache_dir " <<
1974 sd
->type() << " " << sd
->path
<< " to " << type_str
<< ". Restart required");
1984 if (swap
->n_configured
> 63) {
1985 /* 7 bits, signed */
1986 debugs(3, DBG_CRITICAL
, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle.");
1987 debugs(3, DBG_CRITICAL
, "WARNING: '" << path_str
<< "' is one to many.");
1992 allocate_new_swapdir(swap
);
1994 swap
->swapDirs
[swap
->n_configured
] = StoreFileSystem::FileSystems().at(fs
)->createSwapDir();
1996 sd
= dynamic_cast<SwapDir
*>(swap
->swapDirs
[swap
->n_configured
].getRaw());
1998 /* parse the FS parameters and options */
1999 sd
->parse(swap
->n_configured
, path_str
);
2001 ++swap
->n_configured
;
2005 peer_type_str(const peer_t type
)
2007 const char * result
;
2019 case PEER_MULTICAST
:
2020 result
= "multicast";
2032 dump_peer(StoreEntry
* entry
, const char *name
, CachePeer
* p
)
2034 NeighborTypeDomainList
*t
;
2035 LOCAL_ARRAY(char, xname
, 128);
2038 storeAppendPrintf(entry
, "%s %s %s %d %d name=%s",
2045 dump_peer_options(entry
, p
);
2048 snprintf(xname
, 128, "cache_peer_access %s", p
->name
);
2049 dump_acl_access(entry
, xname
, p
->access
);
2052 for (t
= p
->typelist
; t
; t
= t
->next
) {
2053 storeAppendPrintf(entry
, "neighbor_type_domain %s %s %s\n",
2055 peer_type_str(t
->type
),
2064 * utility function to prevent getservbyname() being called with a numeric value
2065 * on Windows at least it returns garage results.
2068 isUnsignedNumeric(const char *str
, size_t len
)
2070 if (len
< 1) return false;
2072 for (; len
>0 && *str
; ++str
, --len
) {
2073 if (! isdigit(*str
))
2080 \param proto 'tcp' or 'udp' for protocol
2081 \returns Port the named service is supposed to be listening on.
2083 static unsigned short
2084 GetService(const char *proto
)
2086 struct servent
*port
= NULL
;
2087 /** Parses a port number or service name from the squid.conf */
2088 char *token
= ConfigParser::NextToken();
2089 if (token
== NULL
) {
2091 return 0; /* NEVER REACHED */
2093 /** Returns either the service port number from /etc/services */
2094 if ( !isUnsignedNumeric(token
, strlen(token
)) )
2095 port
= getservbyname(token
, proto
);
2097 return ntohs((unsigned short)port
->s_port
);
2099 /** Or a numeric translation of the config text. */
2100 return xatos(token
);
2104 \returns Port the named TCP service is supposed to be listening on.
2105 \copydoc GetService(const char *proto)
2107 inline unsigned short
2110 return GetService("tcp");
2114 \returns Port the named UDP service is supposed to be listening on.
2115 \copydoc GetService(const char *proto)
2117 inline unsigned short
2120 return GetService("udp");
2124 parse_peer(CachePeer
** head
)
2126 char *host_str
= ConfigParser::NextToken();
2132 char *token
= ConfigParser::NextToken();
2138 CachePeer
*p
= new CachePeer
;
2139 p
->host
= xstrdup(host_str
);
2140 p
->name
= xstrdup(host_str
);
2141 p
->type
= parseNeighborType(token
);
2143 if (p
->type
== PEER_MULTICAST
) {
2144 p
->options
.no_digest
= true;
2145 p
->options
.no_netdb_exchange
= true;
2148 p
->http_port
= GetTcpService();
2150 if (!p
->http_port
) {
2156 p
->icp
.port
= GetUdpService();
2158 while ((token
= ConfigParser::NextToken())) {
2159 if (!strcmp(token
, "proxy-only")) {
2160 p
->options
.proxy_only
= true;
2161 } else if (!strcmp(token
, "no-query")) {
2162 p
->options
.no_query
= true;
2163 } else if (!strcmp(token
, "background-ping")) {
2164 p
->options
.background_ping
= true;
2165 } else if (!strcmp(token
, "no-digest")) {
2166 p
->options
.no_digest
= true;
2167 } else if (!strcmp(token
, "no-tproxy")) {
2168 p
->options
.no_tproxy
= true;
2169 } else if (!strcmp(token
, "multicast-responder")) {
2170 p
->options
.mcast_responder
= true;
2171 #if PEER_MULTICAST_SIBLINGS
2172 } else if (!strcmp(token
, "multicast-siblings")) {
2173 p
->options
.mcast_siblings
= true;
2175 } else if (!strncmp(token
, "weight=", 7)) {
2176 p
->weight
= xatoi(token
+ 7);
2177 } else if (!strncmp(token
, "basetime=", 9)) {
2178 p
->basetime
= xatoi(token
+ 9);
2179 } else if (!strcmp(token
, "closest-only")) {
2180 p
->options
.closest_only
= true;
2181 } else if (!strncmp(token
, "ttl=", 4)) {
2182 p
->mcast
.ttl
= xatoi(token
+ 4);
2184 if (p
->mcast
.ttl
< 0)
2187 if (p
->mcast
.ttl
> 128)
2189 } else if (!strcmp(token
, "default")) {
2190 p
->options
.default_parent
= true;
2191 } else if (!strcmp(token
, "round-robin")) {
2192 p
->options
.roundrobin
= true;
2193 } else if (!strcmp(token
, "weighted-round-robin")) {
2194 p
->options
.weighted_roundrobin
= true;
2196 } else if (!strcmp(token
, "htcp")) {
2197 p
->options
.htcp
= true;
2198 } else if (!strncmp(token
, "htcp=", 5) || !strncmp(token
, "htcp-", 5)) {
2199 /* Note: The htcp- form is deprecated, replaced by htcp= */
2200 p
->options
.htcp
= true;
2201 char *tmp
= xstrdup(token
+5);
2202 char *mode
, *nextmode
;
2203 for (mode
= nextmode
= tmp
; mode
; mode
= nextmode
) {
2204 nextmode
= strchr(mode
, ',');
2209 if (!strcmp(mode
, "no-clr")) {
2210 if (p
->options
.htcp_only_clr
)
2211 fatalf("parse_peer: can't set htcp-no-clr and htcp-only-clr simultaneously");
2212 p
->options
.htcp_no_clr
= true;
2213 } else if (!strcmp(mode
, "no-purge-clr")) {
2214 p
->options
.htcp_no_purge_clr
= true;
2215 } else if (!strcmp(mode
, "only-clr")) {
2216 if (p
->options
.htcp_no_clr
)
2217 fatalf("parse_peer: can't set htcp no-clr and only-clr simultaneously");
2218 p
->options
.htcp_only_clr
= true;
2219 } else if (!strcmp(mode
, "forward-clr")) {
2220 p
->options
.htcp_forward_clr
= true;
2221 } else if (!strcmp(mode
, "oldsquid")) {
2222 p
->options
.htcp_oldsquid
= true;
2224 fatalf("invalid HTCP mode '%s'", mode
);
2229 } else if (!strcmp(token
, "no-netdb-exchange")) {
2230 p
->options
.no_netdb_exchange
= true;
2232 } else if (!strcmp(token
, "carp")) {
2233 if (p
->type
!= PEER_PARENT
)
2234 fatalf("parse_peer: non-parent carp peer %s/%d\n", p
->host
, p
->http_port
);
2236 p
->options
.carp
= true;
2237 } else if (!strncmp(token
, "carp-key=", 9)) {
2238 if (p
->options
.carp
!= true)
2239 fatalf("parse_peer: carp-key specified on non-carp peer %s/%d\n", p
->host
, p
->http_port
);
2240 p
->options
.carp_key
.set
= true;
2241 char *nextkey
=token
+strlen("carp-key="), *key
=nextkey
;
2242 for (; key
; key
= nextkey
) {
2243 nextkey
=strchr(key
,',');
2244 if (nextkey
) ++nextkey
; // skip the comma, any
2245 if (0==strncmp(key
,"scheme",6)) {
2246 p
->options
.carp_key
.scheme
= true;
2247 } else if (0==strncmp(key
,"host",4)) {
2248 p
->options
.carp_key
.host
= true;
2249 } else if (0==strncmp(key
,"port",4)) {
2250 p
->options
.carp_key
.port
= true;
2251 } else if (0==strncmp(key
,"path",4)) {
2252 p
->options
.carp_key
.path
= true;
2253 } else if (0==strncmp(key
,"params",6)) {
2254 p
->options
.carp_key
.params
= true;
2256 fatalf("invalid carp-key '%s'",key
);
2259 } else if (!strcmp(token
, "userhash")) {
2261 if (p
->type
!= PEER_PARENT
)
2262 fatalf("parse_peer: non-parent userhash peer %s/%d\n", p
->host
, p
->http_port
);
2264 p
->options
.userhash
= true;
2266 fatalf("parse_peer: userhash requires authentication. peer %s/%d\n", p
->host
, p
->http_port
);
2268 } else if (!strcmp(token
, "sourcehash")) {
2269 if (p
->type
!= PEER_PARENT
)
2270 fatalf("parse_peer: non-parent sourcehash peer %s/%d\n", p
->host
, p
->http_port
);
2272 p
->options
.sourcehash
= true;
2274 } else if (!strcmp(token
, "no-delay")) {
2276 p
->options
.no_delay
= true;
2278 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option 'no-delay' requires --enable-delay-pools");
2280 } else if (!strncmp(token
, "login=", 6)) {
2281 p
->login
= xstrdup(token
+ 6);
2282 rfc1738_unescape(p
->login
);
2283 } else if (!strcmp(token
, "auth-no-keytab")) {
2284 p
->options
.auth_no_keytab
= 1;
2285 } else if (!strncmp(token
, "connect-timeout=", 16)) {
2286 p
->connect_timeout_raw
= xatoi(token
+ 16);
2287 } else if (!strncmp(token
, "connect-fail-limit=", 19)) {
2288 p
->connect_fail_limit
= xatoi(token
+ 19);
2289 #if USE_CACHE_DIGESTS
2290 } else if (!strncmp(token
, "digest-url=", 11)) {
2291 p
->digest_url
= xstrdup(token
+ 11);
2294 } else if (!strcmp(token
, "allow-miss")) {
2295 p
->options
.allow_miss
= true;
2296 } else if (!strncmp(token
, "max-conn=", 9)) {
2297 p
->max_conn
= xatoi(token
+ 9);
2298 } else if (!strncmp(token
, "standby=", 8)) {
2299 p
->standby
.limit
= xatoi(token
+ 8);
2300 } else if (!strcmp(token
, "originserver")) {
2301 p
->options
.originserver
= true;
2302 } else if (!strncmp(token
, "name=", 5)) {
2306 p
->name
= xstrdup(token
+ 5);
2307 } else if (!strncmp(token
, "forceddomain=", 13)) {
2308 safe_free(p
->domain
);
2310 p
->domain
= xstrdup(token
+ 13);
2312 } else if (strncmp(token
, "ssl", 3) == 0) {
2314 debugs(0, DBG_CRITICAL
, "WARNING: cache_peer option '" << token
<< "' requires --with-openssl");
2316 p
->secure
.parse(token
+3);
2318 } else if (strncmp(token
, "tls-", 4) == 0) {
2319 p
->secure
.parse(token
+4);
2320 } else if (strncmp(token
, "tls", 3) == 0) {
2321 p
->secure
.parse(token
+3);
2322 } else if (strcmp(token
, "front-end-https") == 0) {
2323 p
->front_end_https
= 1;
2324 } else if (strcmp(token
, "front-end-https=on") == 0) {
2325 p
->front_end_https
= 1;
2326 } else if (strcmp(token
, "front-end-https=auto") == 0) {
2327 p
->front_end_https
= 2;
2328 } else if (strcmp(token
, "connection-auth=off") == 0) {
2329 p
->connection_auth
= 0;
2330 } else if (strcmp(token
, "connection-auth") == 0) {
2331 p
->connection_auth
= 1;
2332 } else if (strcmp(token
, "connection-auth=on") == 0) {
2333 p
->connection_auth
= 1;
2334 } else if (strcmp(token
, "connection-auth=auto") == 0) {
2335 p
->connection_auth
= 2;
2336 } else if (token
[0] == '#') {
2337 // start of a text comment. stop reading this line.
2340 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Ignoring unknown cache_peer option '" << token
<< "'");
2344 if (peerFindByName(p
->name
))
2345 fatalf("ERROR: cache_peer %s specified twice\n", p
->name
);
2347 if (p
->max_conn
> 0 && p
->max_conn
< p
->standby
.limit
)
2348 fatalf("ERROR: cache_peer %s max-conn=%d is lower than its standby=%d\n", p
->host
, p
->max_conn
, p
->standby
.limit
);
2353 if (p
->connect_fail_limit
< 1)
2354 p
->connect_fail_limit
= 10;
2356 #if USE_CACHE_DIGESTS
2358 if (!p
->options
.no_digest
) {
2359 /* XXX This looks odd.. who has the original pointer
2362 PeerDigest
*pd
= peerDigestCreate(p
);
2363 p
->digest
= cbdataReference(pd
);
2368 p
->index
= ++Config
.npeers
;
2370 while (*head
!= NULL
)
2371 head
= &(*head
)->next
;
2379 free_peer(CachePeer
** P
)
2387 dump_cachemgrpasswd(StoreEntry
* entry
, const char *name
, Mgr::ActionPasswordList
* list
)
2390 if (strcmp(list
->passwd
, "none") && strcmp(list
->passwd
, "disable"))
2391 storeAppendPrintf(entry
, "%s XXXXXXXXXX", name
);
2393 storeAppendPrintf(entry
, "%s %s", name
, list
->passwd
);
2395 for (auto w
: list
->actions
)
2396 entry
->appendf(" " SQUIDSBUFPH
, SQUIDSBUFPRINT(w
));
2398 storeAppendPrintf(entry
, "\n");
2404 parse_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2406 char *passwd
= nullptr;
2407 parse_string(&passwd
);
2409 Mgr::ActionPasswordList
*p
= new Mgr::ActionPasswordList
;
2412 while (char *token
= ConfigParser::NextQuotedToken())
2413 p
->actions
.push_back(SBuf(token
));
2415 Mgr::ActionPasswordList
**P
;
2416 for (P
= head
; *P
; P
= &(*P
)->next
) {
2418 * See if any of the actions from this line already have a
2419 * password from previous lines. The password checking
2420 * routines in cache_manager.c take the the password from
2421 * the first Mgr::ActionPasswordList that contains the
2422 * requested action. Thus, we should warn users who might
2423 * think they can have two passwords for the same action.
2425 for (const auto &w
: (*P
)->actions
) {
2426 for (const auto &u
: p
->actions
) {
2430 debugs(0, DBG_PARSE_NOTE(1), "ERROR: action '" << u
<< "' (line " << config_lineno
<< ") already has a password");
2439 free_cachemgrpasswd(Mgr::ActionPasswordList
** head
)
2446 dump_denyinfo(StoreEntry
* entry
, const char *name
, AclDenyInfoList
* var
)
2448 while (var
!= NULL
) {
2449 storeAppendPrintf(entry
, "%s %s", name
, var
->err_page_name
);
2451 for (auto *a
= var
->acl_list
; a
!= NULL
; a
= a
->next
)
2452 storeAppendPrintf(entry
, " %s", a
->name
);
2454 storeAppendPrintf(entry
, "\n");
2461 parse_denyinfo(AclDenyInfoList
** var
)
2463 aclParseDenyInfoLine(var
);
2467 free_denyinfo(AclDenyInfoList
** list
)
2474 parse_peer_access(void)
2476 char *host
= ConfigParser::NextToken();
2482 CachePeer
*p
= peerFindByName(host
);
2484 debugs(15, DBG_CRITICAL
, "ERROR: " << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2488 std::string directive
= "peer_access ";
2490 aclParseAccessLine(directive
.c_str(), LegacyParser
, &p
->access
);
2494 parse_hostdomaintype(void)
2496 char *host
= ConfigParser::NextToken();
2502 char *type
= ConfigParser::NextToken();
2508 char *domain
= nullptr;
2509 while ((domain
= ConfigParser::NextToken())) {
2510 CachePeer
*p
= peerFindByName(host
);
2512 debugs(15, DBG_CRITICAL
, "" << cfg_filename
<< ", line " << config_lineno
<< ": No cache_peer '" << host
<< "'");
2516 auto *l
= static_cast<NeighborTypeDomainList
*>(xcalloc(1, sizeof(NeighborTypeDomainList
)));
2517 l
->type
= parseNeighborType(type
);
2518 l
->domain
= xstrdup(domain
);
2520 NeighborTypeDomainList
**L
= nullptr;
2521 for (L
= &(p
->typelist
); *L
; L
= &((*L
)->next
));
2527 dump_int(StoreEntry
* entry
, const char *name
, int var
)
2529 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
2547 dump_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
2549 storeAppendPrintf(entry
, "%s %" PRId64
"\n", name
, var
);
2553 parse_int64_t(int64_t *var
)
2561 free_int64_t(int64_t *var
)
2567 dump_onoff(StoreEntry
* entry
, const char *name
, int var
)
2569 storeAppendPrintf(entry
, "%s %s\n", name
, var
? "on" : "off");
2573 parse_onoff(int *var
)
2575 char *token
= ConfigParser::NextToken();
2581 if (!strcmp(token
, "on")) {
2583 } else if (!strcmp(token
, "enable")) {
2584 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use 'on'.");
2586 } else if (!strcmp(token
, "off")) {
2588 } else if (!strcmp(token
, "disable")) {
2589 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use 'off'.");
2592 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Boolean options can only be 'on' or 'off'.");
2597 #define free_onoff free_int
2600 dump_tristate(StoreEntry
* entry
, const char *name
, int var
)
2611 storeAppendPrintf(entry
, "%s %s\n", name
, state
);
2615 parse_tristate(int *var
)
2617 char *token
= ConfigParser::NextToken();
2623 if (!strcmp(token
, "on")) {
2625 } else if (!strcmp(token
, "enable")) {
2626 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'enable' is deprecated. Please update to use value 'on'.");
2628 } else if (!strcmp(token
, "warn")) {
2630 } else if (!strcmp(token
, "off")) {
2632 } else if (!strcmp(token
, "disable")) {
2633 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'disable' is deprecated. Please update to use value 'off'.");
2636 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Invalid option: Tristate options can only be 'on', 'off', or 'warn'.");
2641 #define free_tristate free_int
2644 parse_pipelinePrefetch(int *var
)
2646 char *token
= ConfigParser::PeekAtToken();
2652 if (!strcmp(token
, "on")) {
2653 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: 'pipeline_prefetch on' is deprecated. Please update to use 1 (or a higher number).");
2656 (void)ConfigParser::NextToken();
2657 } else if (!strcmp(token
, "off")) {
2658 debugs(0, DBG_PARSE_NOTE(2), "WARNING: 'pipeline_prefetch off' is deprecated. Please update to use '0'.");
2661 (void)ConfigParser::NextToken();
2666 #define free_pipelinePrefetch free_int
2667 #define dump_pipelinePrefetch dump_int
2670 dump_refreshpattern(StoreEntry
* entry
, const char *name
, RefreshPattern
* head
)
2672 while (head
!= NULL
) {
2673 storeAppendPrintf(entry
, "%s%s %s %d %d%% %d",
2675 head
->pattern
.flags
®_ICASE
? " -i" : null_string
,
2676 head
->pattern
.c_str(),
2677 (int) head
->min
/ 60,
2678 (int) (100.0 * head
->pct
+ 0.5),
2679 (int) head
->max
/ 60);
2681 if (head
->max_stale
>= 0)
2682 storeAppendPrintf(entry
, " max-stale=%d", head
->max_stale
);
2684 if (head
->flags
.refresh_ims
)
2685 storeAppendPrintf(entry
, " refresh-ims");
2687 if (head
->flags
.store_stale
)
2688 storeAppendPrintf(entry
, " store-stale");
2690 #if USE_HTTP_VIOLATIONS
2692 if (head
->flags
.override_expire
)
2693 storeAppendPrintf(entry
, " override-expire");
2695 if (head
->flags
.override_lastmod
)
2696 storeAppendPrintf(entry
, " override-lastmod");
2698 if (head
->flags
.reload_into_ims
)
2699 storeAppendPrintf(entry
, " reload-into-ims");
2701 if (head
->flags
.ignore_reload
)
2702 storeAppendPrintf(entry
, " ignore-reload");
2704 if (head
->flags
.ignore_no_store
)
2705 storeAppendPrintf(entry
, " ignore-no-store");
2707 if (head
->flags
.ignore_private
)
2708 storeAppendPrintf(entry
, " ignore-private");
2711 storeAppendPrintf(entry
, "\n");
2718 parse_refreshpattern(RefreshPattern
** head
)
2725 int refresh_ims
= 0;
2726 int store_stale
= 0;
2729 #if USE_HTTP_VIOLATIONS
2731 int override_expire
= 0;
2732 int override_lastmod
= 0;
2733 int reload_into_ims
= 0;
2734 int ignore_reload
= 0;
2735 int ignore_no_store
= 0;
2736 int ignore_private
= 0;
2743 int flags
= REG_EXTENDED
| REG_NOSUB
;
2745 if ((token
= ConfigParser::RegexPattern()) != NULL
) {
2747 if (strcmp(token
, "-i") == 0) {
2749 token
= ConfigParser::RegexPattern();
2750 } else if (strcmp(token
, "+i") == 0) {
2751 flags
&= ~REG_ICASE
;
2752 token
= ConfigParser::RegexPattern();
2757 if (token
== NULL
) {
2758 debugs(3, DBG_CRITICAL
, "FATAL: refresh_pattern missing the regex pattern parameter");
2763 pattern
= xstrdup(token
);
2765 i
= GetInteger(); /* token: min */
2767 /* catch negative and insanely huge values close to 32-bit wrap */
2769 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age negative. Cropped back to zero.");
2772 if (i
> 60*24*365) {
2773 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern minimum age too high. Cropped back to 1 year.");
2777 min
= (time_t) (i
* 60); /* convert minutes to seconds */
2779 pct
= GetPercentage(false); /* token: pct . with no limit on size */
2781 i
= GetInteger(); /* token: max */
2783 /* catch negative and insanely huge values close to 32-bit wrap */
2785 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age negative. Cropped back to zero.");
2788 if (i
> 60*24*365) {
2789 debugs(3, DBG_IMPORTANT
, "WARNING: refresh_pattern maximum age too high. Cropped back to 1 year.");
2793 max
= (time_t) (i
* 60); /* convert minutes to seconds */
2796 while ((token
= ConfigParser::NextToken()) != NULL
) {
2797 if (!strcmp(token
, "refresh-ims")) {
2799 } else if (!strcmp(token
, "store-stale")) {
2801 } else if (!strncmp(token
, "max-stale=", 10)) {
2802 max_stale
= xatoi(token
+ 10);
2804 #if USE_HTTP_VIOLATIONS
2806 } else if (!strcmp(token
, "override-expire"))
2807 override_expire
= 1;
2808 else if (!strcmp(token
, "override-lastmod"))
2809 override_lastmod
= 1;
2810 else if (!strcmp(token
, "ignore-no-store"))
2811 ignore_no_store
= 1;
2812 else if (!strcmp(token
, "ignore-private"))
2814 else if (!strcmp(token
, "reload-into-ims")) {
2815 reload_into_ims
= 1;
2816 refresh_nocache_hack
= 1;
2817 /* tell client_side.c that this is used */
2818 } else if (!strcmp(token
, "ignore-reload")) {
2820 refresh_nocache_hack
= 1;
2821 /* tell client_side.c that this is used */
2824 } else if (!strcmp(token
, "ignore-no-cache") ||
2825 !strcmp(token
, "ignore-must-revalidate") ||
2826 !strcmp(token
, "ignore-auth")
2828 debugs(22, DBG_PARSE_NOTE(2), "UPGRADE: refresh_pattern option '" << token
<< "' is obsolete. Remove it.");
2830 debugs(22, DBG_CRITICAL
, "refreshAddToList: Unknown option '" << pattern
<< "': " << token
);
2833 if ((errcode
= regcomp(&comp
, pattern
, flags
)) != 0) {
2835 regerror(errcode
, &comp
, errbuf
, sizeof errbuf
);
2836 debugs(22, DBG_CRITICAL
, "" << cfg_filename
<< " line " << config_lineno
<< ": " << config_input_line
);
2837 debugs(22, DBG_CRITICAL
, "refreshAddToList: Invalid regular expression '" << pattern
<< "': " << errbuf
);
2842 pct
= pct
< 0.0 ? 0.0 : pct
;
2843 max
= max
< 0 ? 0 : max
;
2844 t
= new RefreshPattern(pattern
, flags
);
2845 t
->pattern
.regex
= comp
;
2851 t
->flags
.refresh_ims
= true;
2854 t
->flags
.store_stale
= true;
2856 t
->max_stale
= max_stale
;
2858 #if USE_HTTP_VIOLATIONS
2860 if (override_expire
)
2861 t
->flags
.override_expire
= true;
2863 if (override_lastmod
)
2864 t
->flags
.override_lastmod
= true;
2866 if (reload_into_ims
)
2867 t
->flags
.reload_into_ims
= true;
2870 t
->flags
.ignore_reload
= true;
2872 if (ignore_no_store
)
2873 t
->flags
.ignore_no_store
= true;
2876 t
->flags
.ignore_private
= true;
2882 head
= &(*head
)->next
;
2890 free_refreshpattern(RefreshPattern
** head
)
2895 #if USE_HTTP_VIOLATIONS
2896 refresh_nocache_hack
= 0;
2902 dump_string(StoreEntry
* entry
, const char *name
, char *var
)
2905 storeAppendPrintf(entry
, "%s %s\n", name
, var
);
2909 parse_string(char **var
)
2913 char *token
= ConfigParser::NextToken();
2919 *var
= xstrdup(token
);
2923 free_string(char **var
)
2929 parse_eol(char *volatile *var
)
2936 unsigned char *token
= (unsigned char *) ConfigParser::NextQuotedOrToEol();
2944 while (*token
&& xisspace(*token
))
2952 *var
= xstrdup((char *) token
);
2955 #define dump_eol dump_string
2956 #define free_eol free_string
2959 parse_TokenOrQuotedString(char **var
)
2963 char *token
= ConfigParser::NextQuotedToken();
2969 *var
= xstrdup(token
);
2972 #define dump_TokenOrQuotedString dump_string
2973 #define free_TokenOrQuotedString free_string
2976 dump_time_t(StoreEntry
* entry
, const char *name
, time_t var
)
2978 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int) var
);
2982 parse_time_t(time_t * var
)
2985 parseTimeLine(&tval
, T_SECOND_STR
, false);
2986 *var
= static_cast<time_t>(tval
/1000);
2990 free_time_t(time_t * var
)
2996 dump_time_msec(StoreEntry
* entry
, const char *name
, time_msec_t var
)
2999 storeAppendPrintf(entry
, "%s %" PRId64
" milliseconds\n", name
, var
);
3001 storeAppendPrintf(entry
, "%s %d seconds\n", name
, (int)(var
/1000) );
3005 parse_time_msec(time_msec_t
* var
)
3007 parseTimeLine(var
, T_SECOND_STR
, true);
3011 free_time_msec(time_msec_t
* var
)
3018 dump_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
3020 storeAppendPrintf(entry
, "%s %d\n", name
, (int) var
);
3025 dump_b_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
3027 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
3031 dump_b_ssize_t(StoreEntry
* entry
, const char *name
, ssize_t var
)
3033 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_BYTES_STR
);
3038 dump_kb_size_t(StoreEntry
* entry
, const char *name
, size_t var
)
3040 storeAppendPrintf(entry
, "%s %d %s\n", name
, (int) var
, B_KBYTES_STR
);
3045 dump_b_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
3047 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_BYTES_STR
);
3051 dump_kb_int64_t(StoreEntry
* entry
, const char *name
, int64_t var
)
3053 storeAppendPrintf(entry
, "%s %" PRId64
" %s\n", name
, var
, B_KBYTES_STR
);
3058 parse_size_t(size_t * var
)
3067 parse_b_size_t(size_t * var
)
3069 parseBytesLine(var
, B_BYTES_STR
);
3073 parse_b_ssize_t(ssize_t
* var
)
3075 parseBytesLineSigned(var
, B_BYTES_STR
);
3080 parse_kb_size_t(size_t * var
)
3082 parseBytesLine(var
, B_KBYTES_STR
);
3087 parse_b_int64_t(int64_t * var
)
3089 parseBytesLine64(var
, B_BYTES_STR
);
3093 parse_kb_int64_t(int64_t * var
)
3095 parseBytesLine64(var
, B_KBYTES_STR
);
3099 free_size_t(size_t * var
)
3105 free_ssize_t(ssize_t
* var
)
3111 free_b_int64_t(int64_t * var
)
3116 #define free_b_size_t free_size_t
3117 #define free_b_ssize_t free_ssize_t
3118 #define free_kb_size_t free_size_t
3119 #define free_mb_size_t free_size_t
3120 #define free_gb_size_t free_size_t
3121 #define free_kb_int64_t free_b_int64_t
3124 dump_u_short(StoreEntry
* entry
, const char *name
, unsigned short var
)
3126 storeAppendPrintf(entry
, "%s %d\n", name
, var
);
3130 free_u_short(unsigned short * u
)
3136 parse_u_short(unsigned short * var
)
3138 ConfigParser::ParseUShort(var
);
3142 ConfigParser::ParseUShort(unsigned short *var
)
3148 ConfigParser::ParseBool(bool *var
)
3150 int i
= GetInteger();
3161 dump_wordlist(StoreEntry
* entry
, const char *name
, wordlist
* list
)
3163 while (list
!= NULL
) {
3164 storeAppendPrintf(entry
, "%s %s\n", name
, list
->key
);
3170 ConfigParser::ParseWordList(wordlist
** list
)
3172 parse_wordlist(list
);
3176 parse_wordlist(wordlist
** list
)
3179 while ((token
= ConfigParser::NextQuotedToken()))
3180 wordlistAdd(list
, token
);
3183 #if 0 /* now unused */
3185 check_null_wordlist(wordlist
* w
)
3192 check_null_acl_access(acl_access
* a
)
3197 #define free_wordlist wordlistDestroy
3199 #define free_uri_whitespace free_int
3202 parse_uri_whitespace(int *var
)
3204 char *token
= ConfigParser::NextToken();
3210 if (!strcmp(token
, "strip"))
3211 *var
= URI_WHITESPACE_STRIP
;
3212 else if (!strcmp(token
, "deny"))
3213 *var
= URI_WHITESPACE_DENY
;
3214 else if (!strcmp(token
, "allow"))
3215 *var
= URI_WHITESPACE_ALLOW
;
3216 else if (!strcmp(token
, "encode"))
3217 *var
= URI_WHITESPACE_ENCODE
;
3218 else if (!strcmp(token
, "chop"))
3219 *var
= URI_WHITESPACE_CHOP
;
3221 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'uri_whitespace' accepts 'strip', 'deny', 'allow', 'encode', and 'chop'.");
3227 dump_uri_whitespace(StoreEntry
* entry
, const char *name
, int var
)
3231 if (var
== URI_WHITESPACE_ALLOW
)
3233 else if (var
== URI_WHITESPACE_ENCODE
)
3235 else if (var
== URI_WHITESPACE_CHOP
)
3237 else if (var
== URI_WHITESPACE_DENY
)
3242 storeAppendPrintf(entry
, "%s %s\n", name
, s
);
3246 free_removalpolicy(RemovalPolicySettings
** settings
)
3251 free_string(&(*settings
)->type
);
3253 free_wordlist(&(*settings
)->args
);
3261 parse_removalpolicy(RemovalPolicySettings
** settings
)
3264 free_removalpolicy(settings
);
3266 *settings
= new RemovalPolicySettings
;
3268 parse_string(&(*settings
)->type
);
3270 parse_wordlist(&(*settings
)->args
);
3274 dump_removalpolicy(StoreEntry
* entry
, const char *name
, RemovalPolicySettings
* settings
)
3277 storeAppendPrintf(entry
, "%s %s", name
, settings
->type
);
3278 args
= settings
->args
;
3281 storeAppendPrintf(entry
, " %s", args
->key
);
3285 storeAppendPrintf(entry
, "\n");
3289 free_YesNoNone(YesNoNone
*)
3293 parse_YesNoNone(YesNoNone
*option
)
3296 parse_onoff(&value
);
3297 option
->configure(value
> 0);
3301 dump_YesNoNone(StoreEntry
* entry
, const char *name
, YesNoNone
&option
)
3303 if (option
.configured())
3304 dump_onoff(entry
, name
, option
? 1 : 0);
3308 free_memcachemode(SquidConfig
*)
3312 parse_memcachemode(SquidConfig
*)
3314 char *token
= ConfigParser::NextToken();
3320 if (strcmp(token
, "always") == 0) {
3321 Config
.onoff
.memory_cache_first
= 1;
3322 Config
.onoff
.memory_cache_disk
= 1;
3323 } else if (strcmp(token
, "disk") == 0) {
3324 Config
.onoff
.memory_cache_first
= 0;
3325 Config
.onoff
.memory_cache_disk
= 1;
3326 } else if (strncmp(token
, "net", 3) == 0) {
3327 Config
.onoff
.memory_cache_first
= 1;
3328 Config
.onoff
.memory_cache_disk
= 0;
3329 } else if (strcmp(token
, "never") == 0) {
3330 Config
.onoff
.memory_cache_first
= 0;
3331 Config
.onoff
.memory_cache_disk
= 0;
3333 debugs(0, DBG_PARSE_NOTE(2), "ERROR: Invalid option '" << token
<< "': 'memory_cache_mode' accepts 'always', 'disk', 'network', and 'never'.");
3339 dump_memcachemode(StoreEntry
* entry
, const char *name
, SquidConfig
&)
3341 storeAppendPrintf(entry
, "%s ", name
);
3342 if (Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3343 storeAppendPrintf(entry
, "always");
3344 else if (!Config
.onoff
.memory_cache_first
&& Config
.onoff
.memory_cache_disk
)
3345 storeAppendPrintf(entry
, "disk");
3346 else if (Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3347 storeAppendPrintf(entry
, "network");
3348 else if (!Config
.onoff
.memory_cache_first
&& !Config
.onoff
.memory_cache_disk
)
3349 storeAppendPrintf(entry
, "none");
3350 storeAppendPrintf(entry
, "\n");
3353 #include "cf_parser.cci"
3356 parseNeighborType(const char *s
)
3358 if (!strcmp(s
, "parent"))
3361 if (!strcmp(s
, "neighbor"))
3362 return PEER_SIBLING
;
3364 if (!strcmp(s
, "neighbour"))
3365 return PEER_SIBLING
;
3367 if (!strcmp(s
, "sibling"))
3368 return PEER_SIBLING
;
3370 if (!strcmp(s
, "multicast"))
3371 return PEER_MULTICAST
;
3373 debugs(15, DBG_CRITICAL
, "WARNING: Unknown neighbor type: " << s
);
3375 return PEER_SIBLING
;
3380 parse_IpAddress_list(Ip::Address_list
** head
)
3383 Ip::Address_list
*s
;
3386 while ((token
= ConfigParser::NextToken())) {
3387 if (GetHostWithPort(token
, &ipa
)) {
3390 head
= &(*head
)->next
;
3392 s
= static_cast<Ip::Address_list
*>(xcalloc(1, sizeof(*s
)));
3404 dump_IpAddress_list(StoreEntry
* e
, const char *n
, const Ip::Address_list
* s
)
3406 char ntoabuf
[MAX_IPSTRLEN
];
3409 storeAppendPrintf(e
, "%s %s\n",
3411 s
->s
.toStr(ntoabuf
,MAX_IPSTRLEN
));
3417 free_IpAddress_list(Ip::Address_list
** head
)
3419 if (*head
) delete *head
;
3423 #if CURRENTLY_UNUSED
3424 /* This code was previously used by http_port. Left as it really should
3425 * be used by icp_port and htcp_port
3428 check_null_IpAddress_list(const Ip::Address_list
* s
)
3433 #endif /* CURRENTLY_UNUSED */
3434 #endif /* USE_WCCPv2 */
3437 parsePortSpecification(const AnyP::PortCfgPointer
&s
, char *token
)
3440 unsigned short port
= 0;
3444 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3445 s
->name
= xstrdup(token
);
3446 s
->connection_auth_disabled
= false;
3448 const SBuf
&portType
= AnyP::UriScheme(s
->transport
.protocol
).image();
3450 if (*token
== '[') {
3453 t
= strchr(host
, ']');
3455 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing ']' on IPv6 address: " << token
);
3462 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port in: " << token
);
3466 if (!Ip::EnableIpv6
) {
3467 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: IPv6 is not available.");
3471 port
= xatos(t
+ 1);
3472 } else if ((t
= strchr(token
, ':'))) {
3477 port
= xatos(t
+ 1);
3479 } else if (strtol(token
, &junk
, 10) && !*junk
) {
3480 port
= xatos(token
);
3481 debugs(3, 3, portType
<< "_port: found Listen on Port: " << port
);
3483 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: missing Port: " << token
);
3488 if (port
== 0 && host
!= NULL
) {
3489 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: Port cannot be 0: " << token
);
3497 if (!Ip::EnableIpv6
)
3499 debugs(3, 3, portType
<< "_port: found Listen on wildcard address: *:" << s
->s
.port());
3500 } else if ( (s
->s
= host
) ) { /* check/parse numeric IPA */
3502 if (!Ip::EnableIpv6
)
3504 debugs(3, 3, portType
<< "_port: Listen on Host/IP: " << host
<< " --> " << s
->s
);
3505 } else if ( s
->s
.GetHostByName(host
) ) { /* check/parse for FQDN */
3506 /* dont use ipcache */
3507 s
->defaultsite
= xstrdup(host
);
3509 if (!Ip::EnableIpv6
)
3511 debugs(3, 3, portType
<< "_port: found Listen as Host " << s
->defaultsite
<< " on IP: " << s
->s
);
3513 debugs(3, DBG_CRITICAL
, "FATAL: " << portType
<< "_port: failed to resolve Host/IP: " << host
);
3518 /// parses the protocol= option of the *_port directive, returning parsed value
3519 /// unsupported option values result in a fatal error message
3520 /// upper case values required; caller may convert for backward compatibility
3521 static AnyP::ProtocolVersion
3522 parsePortProtocol(const SBuf
&value
)
3524 // HTTP/1.0 not supported because we are version 1.1 which contains a superset of 1.0
3525 // and RFC 2616 requires us to upgrade 1.0 to 1.1
3526 if (value
.cmp("HTTP") == 0 || value
.cmp("HTTP/1.1") == 0)
3527 return Http::ProtocolVersion(1,1);
3529 if (value
.cmp("HTTPS") == 0 || value
.cmp("HTTPS/1.1") == 0)
3530 return AnyP::ProtocolVersion(AnyP::PROTO_HTTPS
, 1,1);
3532 if (value
.cmp("FTP") == 0)
3533 return Ftp::ProtocolVersion();
3535 fatalf("%s directive does not support protocol=" SQUIDSBUFPH
"\n", cfg_directive
, SQUIDSBUFPRINT(value
));
3536 return AnyP::ProtocolVersion(); // not reached
3540 parse_port_option(AnyP::PortCfgPointer
&s
, char *token
)
3544 if (strcmp(token
, "accel") == 0) {
3545 if (s
->flags
.isIntercepted()) {
3546 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Accelerator mode requires its own port. It cannot be shared with other modes.");
3550 s
->flags
.accelSurrogate
= true;
3552 } else if (strcmp(token
, "transparent") == 0 || strcmp(token
, "intercept") == 0) {
3553 if (s
->flags
.accelSurrogate
|| s
->flags
.tproxyIntercept
) {
3554 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": Intercept mode requires its own interception port. It cannot be shared with other modes.");
3558 s
->flags
.natIntercept
= true;
3559 Ip::Interceptor
.StartInterception();
3560 /* Log information regarding the port modes under interception. */
3561 debugs(3, DBG_IMPORTANT
, "Starting Authentication on port " << s
->s
);
3562 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (interception enabled)");
3563 } else if (strcmp(token
, "tproxy") == 0) {
3564 if (s
->flags
.natIntercept
|| s
->flags
.accelSurrogate
) {
3565 debugs(3,DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY option requires its own interception port. It cannot be shared with other modes.");
3569 s
->flags
.tproxyIntercept
= true;
3570 Ip::Interceptor
.StartTransparency();
3571 /* Log information regarding the port modes under transparency. */
3572 debugs(3, DBG_IMPORTANT
, "Disabling Authentication on port " << s
->s
<< " (TPROXY enabled)");
3574 if (s
->flags
.proxySurrogate
) {
3575 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3578 if (!Ip::Interceptor
.ProbeForTproxy(s
->s
)) {
3579 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": TPROXY support in the system does not work.");
3584 } else if (strcmp(token
, "require-proxy-header") == 0) {
3585 s
->flags
.proxySurrogate
= true;
3586 if (s
->flags
.tproxyIntercept
) {
3587 // receiving is still permitted, so we do not unset the TPROXY flag
3588 // spoofing access control override takes care of the spoof disable later
3589 debugs(3, DBG_IMPORTANT
, "Disabling TPROXY Spoofing on port " << s
->s
<< " (require-proxy-header enabled)");
3592 } else if (strncmp(token
, "defaultsite=", 12) == 0) {
3593 if (!s
->flags
.accelSurrogate
) {
3594 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": defaultsite option requires Acceleration mode flag.");
3598 safe_free(s
->defaultsite
);
3599 s
->defaultsite
= xstrdup(token
+ 12);
3600 } else if (strcmp(token
, "vhost") == 0) {
3601 if (!s
->flags
.accelSurrogate
) {
3602 debugs(3, DBG_CRITICAL
, "WARNING: " << cfg_directive
<< ": vhost option is deprecated. Use 'accel' mode flag instead.");
3604 s
->flags
.accelSurrogate
= true;
3606 } else if (strcmp(token
, "no-vhost") == 0) {
3607 if (!s
->flags
.accelSurrogate
) {
3608 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": no-vhost option requires Acceleration mode flag.");
3611 } else if (strcmp(token
, "vport") == 0) {
3612 if (!s
->flags
.accelSurrogate
) {
3613 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3618 } else if (strncmp(token
, "vport=", 6) == 0) {
3619 if (!s
->flags
.accelSurrogate
) {
3620 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": vport option requires Acceleration mode flag.");
3624 s
->vport
= xatos(token
+ 6);
3625 } else if (strncmp(token
, "protocol=", 9) == 0) {
3626 if (!s
->flags
.accelSurrogate
) {
3627 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": protocol option requires Acceleration mode flag.");
3631 s
->transport
= parsePortProtocol(ToUpper(SBuf(token
+ 9)));
3632 } else if (strcmp(token
, "allow-direct") == 0) {
3633 if (!s
->flags
.accelSurrogate
) {
3634 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": allow-direct option requires Acceleration mode flag.");
3638 s
->allow_direct
= true;
3639 } else if (strcmp(token
, "act-as-origin") == 0) {
3640 if (!s
->flags
.accelSurrogate
) {
3641 debugs(3, DBG_IMPORTANT
, "ERROR: " << cfg_directive
<< ": act-as-origin option requires Acceleration mode flag.");
3643 s
->actAsOrigin
= true;
3644 } else if (strcmp(token
, "ignore-cc") == 0) {
3645 #if !USE_HTTP_VIOLATIONS
3646 if (!s
->flags
.accelSurrogate
) {
3647 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": ignore-cc option requires Acceleration mode flag.");
3652 s
->ignore_cc
= true;
3653 } else if (strncmp(token
, "name=", 5) == 0) {
3655 s
->name
= xstrdup(token
+ 5);
3656 } else if (strcmp(token
, "no-connection-auth") == 0) {
3657 s
->connection_auth_disabled
= true;
3658 } else if (strcmp(token
, "connection-auth=off") == 0) {
3659 s
->connection_auth_disabled
= true;
3660 } else if (strcmp(token
, "connection-auth") == 0) {
3661 s
->connection_auth_disabled
= false;
3662 } else if (strcmp(token
, "connection-auth=on") == 0) {
3663 s
->connection_auth_disabled
= false;
3664 } else if (strncmp(token
, "disable-pmtu-discovery=", 23) == 0) {
3665 if (!strcmp(token
+ 23, "off"))
3666 s
->disable_pmtu_discovery
= DISABLE_PMTU_OFF
;
3667 else if (!strcmp(token
+ 23, "transparent"))
3668 s
->disable_pmtu_discovery
= DISABLE_PMTU_TRANSPARENT
;
3669 else if (!strcmp(token
+ 23, "always"))
3670 s
->disable_pmtu_discovery
= DISABLE_PMTU_ALWAYS
;
3675 } else if (strcmp(token
, "ipv4") == 0) {
3676 if ( !s
->s
.setIPv4() ) {
3677 debugs(3, DBG_CRITICAL
, "FATAL: " << cfg_directive
<< ": IPv6 addresses cannot be used as IPv4-Only. " << s
->s
);
3681 } else if (strcmp(token
, "tcpkeepalive") == 0) {
3682 s
->tcp_keepalive
.enabled
= true;
3683 } else if (strncmp(token
, "tcpkeepalive=", 13) == 0) {
3684 char *t
= token
+ 13;
3685 s
->tcp_keepalive
.enabled
= true;
3686 s
->tcp_keepalive
.idle
= xatoui(t
,',');
3690 s
->tcp_keepalive
.interval
= xatoui(t
,',');
3695 s
->tcp_keepalive
.timeout
= xatoui(t
);
3698 } else if (strcmp(token
, "sslBump") == 0) {
3699 debugs(3, DBG_PARSE_NOTE(1), "WARNING: '" << token
<< "' is deprecated " <<
3700 "in " << cfg_directive
<< ". Use 'ssl-bump' instead.");
3701 s
->flags
.tunnelSslBumping
= true;
3702 } else if (strcmp(token
, "ssl-bump") == 0) {
3703 s
->flags
.tunnelSslBumping
= true;
3704 } else if (strncmp(token
, "cert=", 5) == 0) {
3705 s
->secure
.parse(token
);
3706 } else if (strncmp(token
, "key=", 4) == 0) {
3707 s
->secure
.parse(token
);
3708 } else if (strncmp(token
, "version=", 8) == 0) {
3709 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3710 "in " << cfg_directive
<< ". Use 'options=' instead.");
3711 s
->secure
.parse(token
);
3712 } else if (strncmp(token
, "options=", 8) == 0) {
3713 s
->secure
.parse(token
);
3714 } else if (strncmp(token
, "cipher=", 7) == 0) {
3715 s
->secure
.parse(token
);
3716 } else if (strncmp(token
, "clientca=", 9) == 0) {
3717 s
->secure
.parse(token
);
3718 } else if (strncmp(token
, "cafile=", 7) == 0) {
3719 debugs(3, DBG_PARSE_NOTE(1), "UPGRADE WARNING: '" << token
<< "' is deprecated " <<
3720 "in " << cfg_directive
<< ". Use 'tls-cafile=' instead.");
3721 s
->secure
.parse(token
);
3722 } else if (strncmp(token
, "capath=", 7) == 0) {
3723 s
->secure
.parse(token
);
3724 } else if (strncmp(token
, "crlfile=", 8) == 0) {
3725 s
->secure
.parse(token
);
3726 } else if (strncmp(token
, "dhparams=", 9) == 0) {
3727 debugs(3, DBG_PARSE_NOTE(DBG_IMPORTANT
), "WARNING: '" << token
<< "' is deprecated " <<
3728 "in " << cfg_directive
<< ". Use 'tls-dh=' instead.");
3729 s
->secure
.parse(token
);
3730 } else if (strncmp(token
, "sslflags=", 9) == 0) {
3731 // NP: deprecation warnings output by secure.parse() when relevant
3732 s
->secure
.parse(token
+3);
3733 } else if (strncmp(token
, "sslcontext=", 11) == 0) {
3734 // NP: deprecation warnings output by secure.parse() when relevant
3735 s
->secure
.parse(token
+3);
3736 } else if (strncmp(token
, "generate-host-certificates", 26) == 0) {
3737 s
->secure
.parse(token
);
3739 } else if (strncmp(token
, "dynamic_cert_mem_cache_size=", 28) == 0) {
3740 s
->secure
.parse(token
);
3741 } else if (strncmp(token
, "tls-", 4) == 0) {
3742 s
->secure
.parse(token
+4);
3743 } else if (strcmp(token
, "ftp-track-dirs") == 0) {
3744 s
->ftp_track_dirs
= true;
3746 debugs(3, DBG_CRITICAL
, "FATAL: Unknown " << cfg_directive
<< " option '" << token
<< "'.");
3752 add_http_port(char *portspec
)
3754 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3755 s
->transport
= parsePortProtocol(SBuf("HTTP"));
3756 parsePortSpecification(s
, portspec
);
3757 // we may need to merge better if the above returns a list with clones
3758 assert(s
->next
== NULL
);
3759 s
->next
= HttpPortList
;
3764 parsePortCfg(AnyP::PortCfgPointer
*head
, const char *optionName
)
3767 if (strcmp(optionName
, "http_port") == 0 ||
3768 strcmp(optionName
, "ascii_port") == 0)
3770 else if (strcmp(optionName
, "https_port") == 0)
3771 protoName
= "HTTPS";
3772 else if (strcmp(optionName
, "ftp_port") == 0)
3774 if (protoName
.isEmpty()) {
3779 char *token
= ConfigParser::NextToken();
3786 AnyP::PortCfgPointer s
= new AnyP::PortCfg();
3787 s
->transport
= parsePortProtocol(protoName
); // default; protocol=... overwrites
3788 parsePortSpecification(s
, token
);
3790 /* parse options ... */
3791 while ((token
= ConfigParser::NextToken())) {
3792 parse_port_option(s
, token
);
3795 s
->secure
.syncCaFiles();
3797 if (s
->transport
.protocol
== AnyP::PROTO_HTTPS
) {
3798 s
->secure
.encryptTransport
= true;
3800 /* ssl-bump on https_port configuration requires either tproxy or intercept, and vice versa */
3801 const bool hijacked
= s
->flags
.isIntercepted();
3802 if (s
->flags
.tunnelSslBumping
&& !hijacked
) {
3803 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump on https_port requires tproxy/intercept which is missing.");
3807 if (hijacked
&& !s
->flags
.tunnelSslBumping
) {
3808 debugs(3, DBG_CRITICAL
, "FATAL: tproxy/intercept on https_port requires ssl-bump which is missing.");
3813 if (s
->flags
.proxySurrogate
) {
3814 debugs(3,DBG_CRITICAL
, "FATAL: https_port: require-proxy-header option is not supported on HTTPS ports.");
3818 } else if (protoName
.cmp("FTP") == 0) {
3819 /* ftp_port does not support ssl-bump */
3820 if (s
->flags
.tunnelSslBumping
) {
3821 debugs(3, DBG_CRITICAL
, "FATAL: ssl-bump is not supported for ftp_port.");
3825 if (s
->flags
.proxySurrogate
) {
3826 // Passive FTP data channel does not work without deep protocol inspection in the frontend.
3827 debugs(3,DBG_CRITICAL
, "FATAL: require-proxy-header option is not supported on ftp_port.");
3833 if (Ip::EnableIpv6
&IPV6_SPECIAL_SPLITSTACK
&& s
->s
.isAnyAddr()) {
3834 // clone the port options from *s to *(s->next)
3835 s
->next
= s
->clone();
3836 s
->next
->s
.setIPv4();
3837 debugs(3, 3, AnyP::UriScheme(s
->transport
.protocol
).image() << "_port: clone wildcard address for split-stack: " << s
->s
<< " and " << s
->next
->s
);
3840 while (*head
!= NULL
)
3841 head
= &((*head
)->next
);
3847 dump_generic_port(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3849 char buf
[MAX_IPSTRLEN
];
3851 storeAppendPrintf(e
, "%s %s",
3853 s
->s
.toUrl(buf
,MAX_IPSTRLEN
));
3855 // MODES and specific sub-options.
3856 if (s
->flags
.natIntercept
)
3857 storeAppendPrintf(e
, " intercept");
3859 else if (s
->flags
.tproxyIntercept
)
3860 storeAppendPrintf(e
, " tproxy");
3862 else if (s
->flags
.proxySurrogate
)
3863 storeAppendPrintf(e
, " require-proxy-header");
3865 else if (s
->flags
.accelSurrogate
) {
3866 storeAppendPrintf(e
, " accel");
3869 storeAppendPrintf(e
, " vhost");
3872 storeAppendPrintf(e
, " vport");
3873 else if (s
->vport
> 0)
3874 storeAppendPrintf(e
, " vport=%d", s
->vport
);
3877 storeAppendPrintf(e
, " defaultsite=%s", s
->defaultsite
);
3879 // TODO: compare against prefix of 'n' instead of assuming http_port
3880 if (s
->transport
.protocol
!= AnyP::PROTO_HTTP
)
3881 storeAppendPrintf(e
, " protocol=%s", AnyP::ProtocolType_str
[s
->transport
.protocol
]);
3883 if (s
->allow_direct
)
3884 storeAppendPrintf(e
, " allow-direct");
3887 storeAppendPrintf(e
, " ignore-cc");
3891 // Generic independent options
3894 storeAppendPrintf(e
, " name=%s", s
->name
);
3896 #if USE_HTTP_VIOLATIONS
3897 if (!s
->flags
.accelSurrogate
&& s
->ignore_cc
)
3898 storeAppendPrintf(e
, " ignore-cc");
3901 if (s
->connection_auth_disabled
)
3902 storeAppendPrintf(e
, " connection-auth=off");
3904 storeAppendPrintf(e
, " connection-auth=on");
3906 if (s
->disable_pmtu_discovery
!= DISABLE_PMTU_OFF
) {
3909 if (s
->disable_pmtu_discovery
== DISABLE_PMTU_ALWAYS
)
3912 pmtu
= "transparent";
3914 storeAppendPrintf(e
, " disable-pmtu-discovery=%s", pmtu
);
3917 if (s
->s
.isAnyAddr() && !s
->s
.isIPv6())
3918 storeAppendPrintf(e
, " ipv4");
3920 if (s
->tcp_keepalive
.enabled
) {
3921 if (s
->tcp_keepalive
.idle
|| s
->tcp_keepalive
.interval
|| s
->tcp_keepalive
.timeout
) {
3922 storeAppendPrintf(e
, " tcpkeepalive=%d,%d,%d", s
->tcp_keepalive
.idle
, s
->tcp_keepalive
.interval
, s
->tcp_keepalive
.timeout
);
3924 storeAppendPrintf(e
, " tcpkeepalive");
3929 if (s
->flags
.tunnelSslBumping
)
3930 storeAppendPrintf(e
, " ssl-bump");
3933 s
->secure
.dumpCfg(e
, "tls-");
3937 dump_PortCfg(StoreEntry
* e
, const char *n
, const AnyP::PortCfgPointer
&s
)
3939 for (AnyP::PortCfgPointer p
= s
; p
!= NULL
; p
= p
->next
) {
3940 dump_generic_port(e
, n
, p
);
3941 storeAppendPrintf(e
, "\n");
3946 configFreeMemory(void)
3949 Config
.ssl_client
.sslContext
.reset();
3951 Ssl::unloadSquidUntrusted();
3956 requirePathnameExists(const char *name
, const char *path
)
3960 char pathbuf
[BUFSIZ
];
3961 assert(path
!= NULL
);
3963 if (Config
.chroot_dir
&& (geteuid() == 0)) {
3964 snprintf(pathbuf
, BUFSIZ
, "%s/%s", Config
.chroot_dir
, path
);
3968 if (stat(path
, &sb
) < 0) {
3970 debugs(0, DBG_CRITICAL
, (opt_parse_cfg_only
?"FATAL: ":"ERROR: ") << name
<< " " << path
<< ": " << xstrerr(xerrno
));
3971 // keep going to find more issues if we are only checking the config file with "-k parse"
3972 if (opt_parse_cfg_only
)
3974 // this is fatal if it is found during startup or reconfigure
3975 if (opt_send_signal
== -1 || opt_send_signal
== SIGHUP
)
3976 fatalf("%s %s: %s", name
, path
, xstrerr(xerrno
));
3980 #include "AccessLogEntry.h"
3983 * We support several access_log configuration styles:
3985 * #1: Deprecated ancient style without an explicit logging module:
3986 * access_log /var/log/access.log
3988 * #2: The "none" logging module (i.e., no logging [of matching transactions]):
3989 * access_log none [acl ...]
3991 * #3: Configurable logging module without named options:
3992 * Logformat or the first ACL name, whichever comes first, may not contain '='.
3993 * If no explicit logformat name is given, the first ACL name, if any,
3994 * should not be an existing logformat name or it will be treated as such.
3995 * access_log module:place [logformat_name] [acl ...]
3997 * #4: Configurable logging module with name=value options such as logformat=x:
3998 * The first ACL name may not contain '='.
3999 * access_log module:place [option ...] [acl ...]
4003 parse_access_log(CustomLog
** logs
)
4005 const char *filename
= ConfigParser::NextToken();
4011 CustomLog
*cl
= (CustomLog
*)xcalloc(1, sizeof(*cl
));
4013 cl
->filename
= xstrdup(filename
);
4014 // default buffer size and fatal settings
4015 cl
->bufferSize
= 8*MAX_URL
;
4018 if (strcmp(filename
, "none") == 0) {
4019 cl
->type
= Log::Format::CLF_NONE
;
4020 aclParseAclList(LegacyParser
, &cl
->aclList
, filename
);
4022 logs
= &(*logs
)->next
;
4027 cl
->type
= Log::Format::CLF_UNKNOWN
;
4028 cl
->rotateCount
= -1; // default: use global logfile_rotate setting.
4030 const char *token
= ConfigParser::PeekAtToken();
4031 if (!token
) { // style #1
4032 // no options to deal with
4033 } else if (!strchr(token
, '=')) { // style #3
4034 // if logformat name is recognized,
4035 // pop the previewed token; Else it must be an ACL name
4036 if (setLogformat(cl
, token
, false))
4037 (void)ConfigParser::NextToken();
4038 } else { // style #4
4040 if (strncasecmp(token
, "on-error=", 9) == 0) {
4041 if (strncasecmp(token
+9, "die", 3) == 0) {
4043 } else if (strncasecmp(token
+9, "drop", 4) == 0) {
4046 debugs(3, DBG_CRITICAL
, "Unknown value for on-error '" <<
4047 token
<< "' expected 'drop' or 'die'");
4048 xfree(cl
->filename
);
4053 } else if (strncasecmp(token
, "buffer-size=", 12) == 0) {
4054 parseBytesOptionValue(&cl
->bufferSize
, B_BYTES_STR
, token
+12);
4055 } else if (strncasecmp(token
, "rotate=", 7) == 0) {
4056 cl
->rotateCount
= xatoi(token
+ 7);
4057 } else if (strncasecmp(token
, "logformat=", 10) == 0) {
4058 setLogformat(cl
, token
+10, true);
4059 } else if (!strchr(token
, '=')) {
4060 // Do not pop the token; it must be an ACL name
4061 break; // done with name=value options, now to ACLs
4063 debugs(3, DBG_CRITICAL
, "Unknown access_log option " << token
);
4064 xfree(cl
->filename
);
4069 // Pop the token, it was a valid "name=value" option
4070 (void)ConfigParser::NextToken();
4071 // Get next with preview ConfigParser::NextToken call.
4072 } while ((token
= ConfigParser::PeekAtToken()) != NULL
);
4075 // set format if it has not been specified explicitly
4076 if (cl
->type
== Log::Format::CLF_UNKNOWN
)
4077 setLogformat(cl
, "squid", true);
4079 aclParseAclList(LegacyParser
, &cl
->aclList
, cl
->filename
);
4082 logs
= &(*logs
)->next
;
4087 /// sets CustomLog::type and, if needed, CustomLog::lf
4088 /// returns false iff there is no named log format
4090 setLogformat(CustomLog
*cl
, const char *logdef_name
, const bool dieWhenMissing
)
4093 assert(logdef_name
);
4095 debugs(3, 9, "possible " << cl
->filename
<< " logformat: " << logdef_name
);
4097 if (cl
->type
!= Log::Format::CLF_UNKNOWN
) {
4098 debugs(3, DBG_CRITICAL
, "FATAL: Second logformat name in one access_log: " <<
4099 logdef_name
<< " " << cl
->type
<< " ? " << Log::Format::CLF_NONE
);
4104 /* look for the definition pointer corresponding to this name */
4105 Format::Format
*lf
= Log::TheConfig
.logformats
;
4107 while (lf
!= NULL
) {
4108 debugs(3, 9, "Comparing against '" << lf
->name
<< "'");
4110 if (strcmp(lf
->name
, logdef_name
) == 0)
4117 cl
->type
= Log::Format::CLF_CUSTOM
;
4119 } else if (strcmp(logdef_name
, "auto") == 0) {
4120 debugs(0, DBG_CRITICAL
, "WARNING: Log format 'auto' no longer exists. Using 'squid' instead.");
4121 cl
->type
= Log::Format::CLF_SQUID
;
4122 } else if (strcmp(logdef_name
, "squid") == 0) {
4123 cl
->type
= Log::Format::CLF_SQUID
;
4124 } else if (strcmp(logdef_name
, "common") == 0) {
4125 cl
->type
= Log::Format::CLF_COMMON
;
4126 } else if (strcmp(logdef_name
, "combined") == 0) {
4127 cl
->type
= Log::Format::CLF_COMBINED
;
4129 } else if (strcmp(logdef_name
, "icap_squid") == 0) {
4130 cl
->type
= Log::Format::CLF_ICAP_SQUID
;
4132 } else if (strcmp(logdef_name
, "useragent") == 0) {
4133 cl
->type
= Log::Format::CLF_USERAGENT
;
4134 } else if (strcmp(logdef_name
, "referrer") == 0) {
4135 cl
->type
= Log::Format::CLF_REFERER
;
4136 } else if (dieWhenMissing
) {
4137 debugs(3, DBG_CRITICAL
, "FATAL: Log format '" << logdef_name
<< "' is not defined");
4148 check_null_access_log(CustomLog
*customlog_definitions
)
4150 return customlog_definitions
== NULL
;
4154 dump_access_log(StoreEntry
* entry
, const char *name
, CustomLog
* logs
)
4158 for (log
= logs
; log
; log
= log
->next
) {
4159 storeAppendPrintf(entry
, "%s ", name
);
4161 switch (log
->type
) {
4163 case Log::Format::CLF_CUSTOM
:
4164 storeAppendPrintf(entry
, "%s logformat=%s", log
->filename
, log
->logFormat
->name
);
4167 case Log::Format::CLF_NONE
:
4168 storeAppendPrintf(entry
, "logformat=none");
4171 case Log::Format::CLF_SQUID
:
4172 // this is the default, no need to add to the dump
4173 //storeAppendPrintf(entry, "%s logformat=squid", log->filename);
4176 case Log::Format::CLF_COMBINED
:
4177 storeAppendPrintf(entry
, "%s logformat=combined", log
->filename
);
4180 case Log::Format::CLF_COMMON
:
4181 storeAppendPrintf(entry
, "%s logformat=common", log
->filename
);
4185 case Log::Format::CLF_ICAP_SQUID
:
4186 storeAppendPrintf(entry
, "%s logformat=icap_squid", log
->filename
);
4189 case Log::Format::CLF_USERAGENT
:
4190 storeAppendPrintf(entry
, "%s logformat=useragent", log
->filename
);
4193 case Log::Format::CLF_REFERER
:
4194 storeAppendPrintf(entry
, "%s logformat=referrer", log
->filename
);
4197 case Log::Format::CLF_UNKNOWN
:
4201 // default is on-error=die
4203 storeAppendPrintf(entry
, " on-error=drop");
4206 if (log
->bufferSize
!= 64*1024)
4207 storeAppendPrintf(entry
, " buffer-size=%" PRIuSIZE
, log
->bufferSize
);
4209 if (log
->rotateCount
>= 0)
4210 storeAppendPrintf(entry
, " rotate=%d", log
->rotateCount
);
4213 dump_acl_list(entry
, log
->aclList
);
4215 storeAppendPrintf(entry
, "\n");
4220 free_access_log(CustomLog
** definitions
)
4222 while (*definitions
) {
4223 CustomLog
*log
= *definitions
;
4224 *definitions
= log
->next
;
4226 log
->logFormat
= NULL
;
4227 log
->type
= Log::Format::CLF_UNKNOWN
;
4230 aclDestroyAclList(&log
->aclList
);
4232 safe_free(log
->filename
);
4238 #if HAVE_CPU_AFFINITY /* until somebody else needs this general code */
4239 /// parses list of integers form name=N1,N2,N3,...
4241 parseNamedIntList(const char *data
, const String
&name
, std::vector
<int> &list
)
4243 if (data
&& (strncmp(data
, name
.rawBuf(), name
.size()) == 0)) {
4244 data
+= name
.size();
4249 if (!StringToInt(data
, value
, &data
, 10))
4251 list
.push_back(value
);
4252 if (*data
== '\0' || *data
!= ',')
4257 return data
&& *data
== '\0';
4262 parse_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4264 #if !HAVE_CPU_AFFINITY
4265 debugs(3, DBG_CRITICAL
, "FATAL: Squid built with no CPU affinity " <<
4266 "support, do not set 'cpu_affinity_map'");
4269 #else /* HAVE_CPU_AFFINITY */
4270 if (!*cpuAffinityMap
)
4271 *cpuAffinityMap
= new CpuAffinityMap
;
4273 const char *const pToken
= ConfigParser::NextToken();
4274 const char *const cToken
= ConfigParser::NextToken();
4275 std::vector
<int> processes
, cores
;
4276 if (!parseNamedIntList(pToken
, "process_numbers", processes
)) {
4277 debugs(3, DBG_CRITICAL
, "FATAL: bad 'process_numbers' parameter " <<
4278 "in 'cpu_affinity_map'");
4280 } else if (!parseNamedIntList(cToken
, "cores", cores
)) {
4281 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cores' parameter in " <<
4282 "'cpu_affinity_map'");
4284 } else if (!(*cpuAffinityMap
)->add(processes
, cores
)) {
4285 debugs(3, DBG_CRITICAL
, "FATAL: bad 'cpu_affinity_map'; " <<
4286 "process_numbers and cores lists differ in length or " <<
4287 "contain numbers <= 0");
4294 dump_CpuAffinityMap(StoreEntry
*const entry
, const char *const name
, const CpuAffinityMap
*const cpuAffinityMap
)
4296 if (cpuAffinityMap
) {
4297 storeAppendPrintf(entry
, "%s process_numbers=", name
);
4298 for (size_t i
= 0; i
< cpuAffinityMap
->processes().size(); ++i
) {
4299 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4300 cpuAffinityMap
->processes()[i
]);
4302 storeAppendPrintf(entry
, " cores=");
4303 for (size_t i
= 0; i
< cpuAffinityMap
->cores().size(); ++i
) {
4304 storeAppendPrintf(entry
, "%s%i", (i
? "," : ""),
4305 cpuAffinityMap
->cores()[i
]);
4307 storeAppendPrintf(entry
, "\n");
4312 free_CpuAffinityMap(CpuAffinityMap
**const cpuAffinityMap
)
4314 delete *cpuAffinityMap
;
4315 *cpuAffinityMap
= NULL
;
4321 parse_adaptation_service_set_type()
4323 Adaptation::Config::ParseServiceSet();
4327 parse_adaptation_service_chain_type()
4329 Adaptation::Config::ParseServiceChain();
4333 parse_adaptation_access_type()
4335 Adaptation::Config::ParseAccess(LegacyParser
);
4337 #endif /* USE_ADAPTATION */
4342 parse_icap_service_type(Adaptation::Icap::Config
* cfg
)
4344 cfg
->parseService();
4348 free_icap_service_type(Adaptation::Icap::Config
* cfg
)
4354 dump_icap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4356 cfg
.dumpService(entry
, name
);
4360 parse_icap_class_type()
4362 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_class' is depricated. " <<
4363 "Use 'adaptation_service_set' instead");
4364 Adaptation::Config::ParseServiceSet();
4368 parse_icap_access_type()
4370 debugs(93, DBG_CRITICAL
, "WARNING: 'icap_access' is depricated. " <<
4371 "Use 'adaptation_access' instead");
4372 Adaptation::Config::ParseAccess(LegacyParser
);
4380 parse_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4382 cfg
->parseService();
4386 free_ecap_service_type(Adaptation::Ecap::Config
* cfg
)
4392 dump_ecap_service_type(StoreEntry
* entry
, const char *name
, const Adaptation::Ecap::Config
&cfg
)
4394 cfg
.dumpService(entry
, name
);
4397 #endif /* USE_ECAP */
4400 static void parse_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4405 cfg
->service_failure_limit
= GetInteger();
4407 if ((token
= ConfigParser::NextToken()) == NULL
)
4410 if (strcmp(token
,"in") != 0) {
4411 debugs(3, DBG_CRITICAL
, "expecting 'in' on'" << config_input_line
<< "'");
4416 if ((token
= ConfigParser::NextToken()) == NULL
) {
4421 d
= static_cast<time_t> (xatoi(token
));
4423 m
= static_cast<time_t> (1);
4427 else if ((token
= ConfigParser::NextToken()) == NULL
) {
4428 debugs(3, DBG_CRITICAL
, "No time-units on '" << config_input_line
<< "'");
4431 } else if ((m
= parseTimeUnits(token
, false)) == 0) {
4436 cfg
->oldest_service_failure
= (m
* d
);
4439 static void dump_icap_service_failure_limit(StoreEntry
*entry
, const char *name
, const Adaptation::Icap::Config
&cfg
)
4441 storeAppendPrintf(entry
, "%s %d", name
, cfg
.service_failure_limit
);
4442 if (cfg
.oldest_service_failure
> 0) {
4443 storeAppendPrintf(entry
, " in %d seconds", (int)cfg
.oldest_service_failure
);
4445 storeAppendPrintf(entry
, "\n");
4448 static void free_icap_service_failure_limit(Adaptation::Icap::Config
*cfg
)
4450 cfg
->oldest_service_failure
= 0;
4451 cfg
->service_failure_limit
= 0;
4456 static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4459 sslproxy_cert_adapt
*ca
= (sslproxy_cert_adapt
*) xcalloc(1, sizeof(sslproxy_cert_adapt
));
4460 if ((al
= ConfigParser::NextToken()) == NULL
) {
4467 if ( char *s
= strchr(al
, '{')) {
4468 *s
= '\0'; // terminate the al string
4481 if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidAfter
]) == 0) {
4482 ca
->alg
= Ssl::algSetValidAfter
;
4483 ca
->param
= xstrdup("on");
4484 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetValidBefore
]) == 0) {
4485 ca
->alg
= Ssl::algSetValidBefore
;
4486 ca
->param
= xstrdup("on");
4487 } else if (strcmp(al
, Ssl::CertAdaptAlgorithmStr
[Ssl::algSetCommonName
]) == 0) {
4488 ca
->alg
= Ssl::algSetCommonName
;
4490 if (strlen(param
) > 64) {
4491 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: setCommonName{" <<param
<< "} : using common name longer than 64 bytes is not supported");
4496 ca
->param
= xstrdup(param
);
4499 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_adapt: unknown cert adaptation algorithm: " << al
);
4505 aclParseAclList(LegacyParser
, &ca
->aclList
, al
);
4508 cert_adapt
= &(*cert_adapt
)->next
;
4513 static void dump_sslproxy_cert_adapt(StoreEntry
*entry
, const char *name
, sslproxy_cert_adapt
*cert_adapt
)
4515 for (sslproxy_cert_adapt
*ca
= cert_adapt
; ca
!= NULL
; ca
= ca
->next
) {
4516 storeAppendPrintf(entry
, "%s ", name
);
4517 storeAppendPrintf(entry
, "%s{%s} ", Ssl::sslCertAdaptAlgoritm(ca
->alg
), ca
->param
);
4519 dump_acl_list(entry
, ca
->aclList
);
4520 storeAppendPrintf(entry
, "\n");
4524 static void free_sslproxy_cert_adapt(sslproxy_cert_adapt
**cert_adapt
)
4526 while (*cert_adapt
) {
4527 sslproxy_cert_adapt
*ca
= *cert_adapt
;
4528 *cert_adapt
= ca
->next
;
4529 safe_free(ca
->param
);
4532 aclDestroyAclList(&ca
->aclList
);
4538 static void parse_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4541 sslproxy_cert_sign
*cs
= (sslproxy_cert_sign
*) xcalloc(1, sizeof(sslproxy_cert_sign
));
4542 if ((al
= ConfigParser::NextToken()) == NULL
) {
4548 if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignTrusted
]) == 0)
4549 cs
->alg
= Ssl::algSignTrusted
;
4550 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignUntrusted
]) == 0)
4551 cs
->alg
= Ssl::algSignUntrusted
;
4552 else if (strcmp(al
, Ssl::CertSignAlgorithmStr
[Ssl::algSignSelf
]) == 0)
4553 cs
->alg
= Ssl::algSignSelf
;
4555 debugs(3, DBG_CRITICAL
, "FATAL: sslproxy_cert_sign: unknown cert signing algorithm: " << al
);
4561 aclParseAclList(LegacyParser
, &cs
->aclList
, al
);
4564 cert_sign
= &(*cert_sign
)->next
;
4569 static void dump_sslproxy_cert_sign(StoreEntry
*entry
, const char *name
, sslproxy_cert_sign
*cert_sign
)
4571 sslproxy_cert_sign
*cs
;
4572 for (cs
= cert_sign
; cs
!= NULL
; cs
= cs
->next
) {
4573 storeAppendPrintf(entry
, "%s ", name
);
4574 storeAppendPrintf(entry
, "%s ", Ssl::certSignAlgorithm(cs
->alg
));
4576 dump_acl_list(entry
, cs
->aclList
);
4577 storeAppendPrintf(entry
, "\n");
4581 static void free_sslproxy_cert_sign(sslproxy_cert_sign
**cert_sign
)
4583 while (*cert_sign
) {
4584 sslproxy_cert_sign
*cs
= *cert_sign
;
4585 *cert_sign
= cs
->next
;
4588 aclDestroyAclList(&cs
->aclList
);
4594 class sslBumpCfgRr
: public ::RegisteredRunner
4597 static Ssl::BumpMode lastDeprecatedRule
;
4598 /* RegisteredRunner API */
4599 virtual void finalizeConfig();
4602 Ssl::BumpMode
sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4604 RunnerRegistrationEntry(sslBumpCfgRr
);
4607 sslBumpCfgRr::finalizeConfig()
4609 if (lastDeprecatedRule
!= Ssl::bumpEnd
) {
4610 assert( lastDeprecatedRule
== Ssl::bumpClientFirst
|| lastDeprecatedRule
== Ssl::bumpNone
);
4611 static char buf
[1024];
4612 if (lastDeprecatedRule
== Ssl::bumpClientFirst
) {
4613 strcpy(buf
, "ssl_bump deny all");
4614 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated implicit "
4615 "\"ssl_bump deny all\" to \"ssl_bump none all\". New ssl_bump configurations "
4616 "must not use implicit rules. Update your ssl_bump rules.");
4618 strcpy(buf
, "ssl_bump allow all");
4619 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated implicit "
4620 "\"ssl_bump allow all\" to \"ssl_bump client-first all\" which is usually "
4621 "inferior to the newer server-first bumping mode. New ssl_bump"
4622 " configurations must not use implicit rules. Update your ssl_bump rules.");
4628 static void parse_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4630 typedef const char *BumpCfgStyle
;
4631 BumpCfgStyle bcsNone
= NULL
;
4632 BumpCfgStyle bcsNew
= "new client/server-first/none";
4633 BumpCfgStyle bcsOld
= "deprecated allow/deny";
4634 static BumpCfgStyle bumpCfgStyleLast
= bcsNone
;
4635 BumpCfgStyle bumpCfgStyleNow
= bcsNone
;
4637 if ((bm
= ConfigParser::NextToken()) == NULL
) {
4642 // if this is the first rule proccessed
4643 if (*ssl_bump
== NULL
) {
4644 bumpCfgStyleLast
= bcsNone
;
4645 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpEnd
;
4648 allow_t action
= allow_t(ACCESS_ALLOWED
);
4650 if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpClientFirst
]) == 0) {
4651 action
.kind
= Ssl::bumpClientFirst
;
4652 bumpCfgStyleNow
= bcsNew
;
4653 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpServerFirst
]) == 0) {
4654 action
.kind
= Ssl::bumpServerFirst
;
4655 bumpCfgStyleNow
= bcsNew
;
4656 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpPeek
]) == 0) {
4657 action
.kind
= Ssl::bumpPeek
;
4658 bumpCfgStyleNow
= bcsNew
;
4659 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpStare
]) == 0) {
4660 action
.kind
= Ssl::bumpStare
;
4661 bumpCfgStyleNow
= bcsNew
;
4662 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpSplice
]) == 0) {
4663 action
.kind
= Ssl::bumpSplice
;
4664 bumpCfgStyleNow
= bcsNew
;
4665 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpBump
]) == 0) {
4666 action
.kind
= Ssl::bumpBump
;
4667 bumpCfgStyleNow
= bcsNew
;
4668 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpTerminate
]) == 0) {
4669 action
.kind
= Ssl::bumpTerminate
;
4670 bumpCfgStyleNow
= bcsNew
;
4671 } else if (strcmp(bm
, Ssl::BumpModeStr
[Ssl::bumpNone
]) == 0) {
4672 action
.kind
= Ssl::bumpNone
;
4673 bumpCfgStyleNow
= bcsNew
;
4674 } else if (strcmp(bm
, "allow") == 0) {
4675 debugs(3, DBG_CRITICAL
, "SECURITY NOTICE: auto-converting deprecated "
4676 "\"ssl_bump allow <acl>\" to \"ssl_bump client-first <acl>\" which "
4677 "is usually inferior to the newer server-first "
4678 "bumping mode. Update your ssl_bump rules.");
4679 action
.kind
= Ssl::bumpClientFirst
;
4680 bumpCfgStyleNow
= bcsOld
;
4681 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpClientFirst
;
4682 } else if (strcmp(bm
, "deny") == 0) {
4683 debugs(3, DBG_CRITICAL
, "WARNING: auto-converting deprecated "
4684 "\"ssl_bump deny <acl>\" to \"ssl_bump none <acl>\". Update "
4685 "your ssl_bump rules.");
4686 action
.kind
= Ssl::bumpNone
;
4687 bumpCfgStyleNow
= bcsOld
;
4688 sslBumpCfgRr::lastDeprecatedRule
= Ssl::bumpNone
;
4690 debugs(3, DBG_CRITICAL
, "FATAL: unknown ssl_bump mode: " << bm
);
4695 if (bumpCfgStyleLast
!= bcsNone
&& bumpCfgStyleNow
!= bumpCfgStyleLast
) {
4696 debugs(3, DBG_CRITICAL
, "FATAL: do not mix " << bumpCfgStyleNow
<< " actions with " <<
4697 bumpCfgStyleLast
<< " actions. Update your ssl_bump rules.");
4702 bumpCfgStyleLast
= bumpCfgStyleNow
;
4705 ParseAclWithAction(ssl_bump
, action
, "ssl_bump");
4708 static void dump_sslproxy_ssl_bump(StoreEntry
*entry
, const char *name
, acl_access
*ssl_bump
)
4711 dump_SBufList(entry
, ssl_bump
->treeDump(name
, [](const allow_t
&action
) {
4712 return Ssl::BumpModeStr
.at(action
.kind
);
4716 static void free_sslproxy_ssl_bump(acl_access
**ssl_bump
)
4718 free_acl_access(ssl_bump
);
4723 static void dump_HeaderWithAclList(StoreEntry
* entry
, const char *name
, HeaderWithAclList
*headers
)
4728 for (HeaderWithAclList::iterator hwa
= headers
->begin(); hwa
!= headers
->end(); ++hwa
) {
4729 storeAppendPrintf(entry
, "%s %s %s", name
, hwa
->fieldName
.c_str(), hwa
->fieldValue
.c_str());
4731 dump_acl_list(entry
, hwa
->aclList
);
4732 storeAppendPrintf(entry
, "\n");
4736 static void parse_HeaderWithAclList(HeaderWithAclList
**headers
)
4740 *headers
= new HeaderWithAclList
;
4742 if ((fn
= ConfigParser::NextToken()) == NULL
) {
4748 hwa
.fieldId
= Http::HeaderLookupTable
.lookup(hwa
.fieldName
).id
;
4749 if (hwa
.fieldId
== Http::HdrType::BAD_HDR
)
4750 hwa
.fieldId
= Http::HdrType::OTHER
;
4752 Format::Format
*nlf
= new ::Format::Format("hdrWithAcl");
4753 ConfigParser::EnableMacros();
4754 String buf
= ConfigParser::NextQuotedToken();
4755 ConfigParser::DisableMacros();
4756 hwa
.fieldValue
= buf
.termedBuf();
4757 hwa
.quoted
= ConfigParser::LastTokenWasQuoted();
4759 if (!nlf
->parse(hwa
.fieldValue
.c_str())) {
4763 hwa
.valueFormat
= nlf
;
4766 aclParseAclList(LegacyParser
, &hwa
.aclList
, (hwa
.fieldName
+ ':' + hwa
.fieldValue
).c_str());
4767 (*headers
)->push_back(hwa
);
4770 static void free_HeaderWithAclList(HeaderWithAclList
**header
)
4775 for (HeaderWithAclList::iterator hwa
= (*header
)->begin(); hwa
!= (*header
)->end(); ++hwa
) {
4777 aclDestroyAclList(&hwa
->aclList
);
4779 if (hwa
->valueFormat
) {
4780 delete hwa
->valueFormat
;
4781 hwa
->valueFormat
= NULL
;
4788 static void parse_note(Notes
*notes
)
4791 notes
->parse(LegacyParser
);
4794 static void dump_note(StoreEntry
*entry
, const char *name
, Notes
¬es
)
4796 notes
.dump(entry
, name
);
4799 static void free_note(Notes
*notes
)
4804 static bool FtpEspvDeprecated
= false;
4805 static void parse_ftp_epsv(acl_access
**ftp_epsv
)
4807 allow_t ftpEpsvDeprecatedAction
;
4808 bool ftpEpsvIsDeprecatedRule
= false;
4810 char *t
= ConfigParser::PeekAtToken();
4816 if (!strcmp(t
, "off")) {
4817 (void)ConfigParser::NextToken();
4818 ftpEpsvIsDeprecatedRule
= true;
4819 ftpEpsvDeprecatedAction
= allow_t(ACCESS_DENIED
);
4820 } else if (!strcmp(t
, "on")) {
4821 (void)ConfigParser::NextToken();
4822 ftpEpsvIsDeprecatedRule
= true;
4823 ftpEpsvDeprecatedAction
= allow_t(ACCESS_ALLOWED
);
4826 // Check for mixing "ftp_epsv on|off" and "ftp_epsv allow|deny .." rules:
4827 // 1) if this line is "ftp_epsv allow|deny ..." and already exist rules of "ftp_epsv on|off"
4828 // 2) if this line is "ftp_epsv on|off" and already exist rules of "ftp_epsv allow|deny ..."
4830 if ((!ftpEpsvIsDeprecatedRule
&& FtpEspvDeprecated
) ||
4831 (ftpEpsvIsDeprecatedRule
&& !FtpEspvDeprecated
&& *ftp_epsv
!= NULL
)) {
4832 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.");
4837 if (ftpEpsvIsDeprecatedRule
) {
4838 // overwrite previous ftp_epsv lines
4840 *ftp_epsv
= nullptr;
4842 if (ftpEpsvDeprecatedAction
== allow_t(ACCESS_DENIED
)) {
4843 if (ACL
*a
= ACL::FindByName("all"))
4844 ParseAclWithAction(ftp_epsv
, ftpEpsvDeprecatedAction
, "ftp_epsv", a
);
4850 FtpEspvDeprecated
= true;
4852 aclParseAccessLine(cfg_directive
, LegacyParser
, ftp_epsv
);
4856 static void dump_ftp_epsv(StoreEntry
*entry
, const char *name
, acl_access
*ftp_epsv
)
4859 dump_SBufList(entry
, ftp_epsv
->treeDump(name
, Acl::AllowOrDeny
));
4862 static void free_ftp_epsv(acl_access
**ftp_epsv
)
4864 free_acl_access(ftp_epsv
);
4865 FtpEspvDeprecated
= false;
4869 parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4872 parseTimeLine(&tval
, T_SECOND_STR
, false, true);
4873 Config
.Timeout
.urlRewrite
= static_cast<time_t>(tval
/1000);
4876 while(ConfigParser::NextKvPair(key
, value
)) {
4877 if (strcasecmp(key
, "on_timeout") == 0) {
4878 if (strcasecmp(value
, "bypass") == 0)
4879 config
->action
= toutActBypass
;
4880 else if (strcasecmp(value
, "fail") == 0)
4881 config
->action
= toutActFail
;
4882 else if (strcasecmp(value
, "retry") == 0)
4883 config
->action
= toutActRetry
;
4884 else if (strcasecmp(value
, "use_configured_response") == 0) {
4885 config
->action
= toutActUseConfiguredResponse
;
4887 debugs(3, DBG_CRITICAL
, "FATAL: unsuported \"on_timeout\" action:" << value
);
4891 } else if (strcasecmp(key
, "response") == 0) {
4892 config
->response
= xstrdup(value
);
4894 debugs(3, DBG_CRITICAL
, "FATAL: unsuported option " << key
);
4900 if (config
->action
== toutActUseConfiguredResponse
&& !config
->response
) {
4901 debugs(3, DBG_CRITICAL
, "FATAL: Expected 'response=' option after 'on_timeout=use_configured_response' option");
4905 if (config
->action
!= toutActUseConfiguredResponse
&& config
->response
) {
4906 debugs(3, DBG_CRITICAL
, "FATAL: 'response=' option is valid only when used with the 'on_timeout=use_configured_response' option");
4912 dump_UrlHelperTimeout(StoreEntry
*entry
, const char *name
, SquidConfig::UrlHelperTimeout
&config
)
4914 const char *onTimedOutActions
[] = {"bypass", "fail", "retry", "use_configured_response"};
4915 assert(config
.action
>= 0 && config
.action
<= toutActUseConfiguredResponse
);
4917 dump_time_t(entry
, name
, Config
.Timeout
.urlRewrite
);
4918 storeAppendPrintf(entry
, " on_timeout=%s", onTimedOutActions
[config
.action
]);
4920 if (config
.response
)
4921 storeAppendPrintf(entry
, " response=\"%s\"", config
.response
);
4923 storeAppendPrintf(entry
, "\n");
4927 free_UrlHelperTimeout(SquidConfig::UrlHelperTimeout
*config
)
4929 Config
.Timeout
.urlRewrite
= 0;
4931 safe_free(config
->response
);
4935 parse_configuration_includes_quoted_values(bool *)
4940 // If quoted values is set to on then enable new strict mode parsing
4942 ConfigParser::RecognizeQuotedValues
= true;
4943 ConfigParser::StrictMode
= true;
4945 ConfigParser::RecognizeQuotedValues
= false;
4946 ConfigParser::StrictMode
= false;
4951 dump_configuration_includes_quoted_values(StoreEntry
*const entry
, const char *const name
, bool)
4953 int val
= ConfigParser::RecognizeQuotedValues
? 1 : 0;
4954 dump_onoff(entry
, name
, val
);
4958 free_configuration_includes_quoted_values(bool *)
4960 ConfigParser::RecognizeQuotedValues
= false;
4961 ConfigParser::StrictMode
= false;
4965 parse_on_unsupported_protocol(acl_access
**access
)
4968 if ((tm
= ConfigParser::NextToken()) == NULL
) {
4973 allow_t action
= allow_t(ACCESS_ALLOWED
);
4974 if (strcmp(tm
, "tunnel") == 0)
4976 else if (strcmp(tm
, "respond") == 0)
4979 debugs(3, DBG_CRITICAL
, "FATAL: unknown on_unsupported_protocol mode: " << tm
);
4985 ParseAclWithAction(access
, action
, "on_unsupported_protocol");
4989 dump_on_unsupported_protocol(StoreEntry
*entry
, const char *name
, acl_access
*access
)
4991 static const std::vector
<const char *> onErrorTunnelMode
= {
4997 SBufList lines
= access
->treeDump(name
, [](const allow_t
&action
) {
4998 return onErrorTunnelMode
.at(action
.kind
);
5000 dump_SBufList(entry
, lines
);
5005 free_on_unsupported_protocol(acl_access
**access
)
5007 free_acl_access(access
);