errorpage.cc
Go to the documentation of this file.
119 BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *anErrorLocation):
147 static void ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation);
357 TemplateFile::TemplateFile(const char *name, const err_type code): silent(false), wasLoaded(false), templateName(name), templateCode(code)
379 debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "ERROR: Unable to load default error language files. Reset to backups.");
391 debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "WARNING: failed to find or read error text file " << templateName);
453 debugs(4, DBG_CRITICAL, MYNAME << "ERROR: failed to fully read: '" << path << "': " << xstrerr(xerrno));
484 * - IFF a tag contains only two characters we can wildcard ANY translations matching: <it> '-'? .*
489 while (pos < hdr.size() && hdr[pos] != ';' && hdr[pos] != ',' && !xisspace(hdr[pos]) && dt < (lang + (langLen -1)) ) {
516 debugs(4, 9, "STATE: lang=" << lang << ", pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'");
567 ErrorDynamicPageInfo::ErrorDynamicPageInfo(const int anId, const char *aName, const SBuf &aCfgLocation):
611 * - current result is Squid crashing or XSS problems as dynamic deny_info load random disk files.
612 * - a future redesign of the file loading may result in loading remote objects sent inline as local body.
618 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " is not valid on '" << page_name << "'");
622 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a template on '" << page_name << "'");
624 } else if (info->page_redirect >= 300 && info->page_redirect <= 399 && !strchr(&(page_name[4]), ':')) {
626 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a URL on '" << page_name << "'");
630 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a template on '" << page_name << "'");
691 ErrorState::NewForwarding(err_type type, HttpRequestPointer &request, const AccessLogEntry::Pointer &ale)
706 ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req, const AccessLogEntry::Pointer &anAle) :
722 ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply, const AccessLogEntry::Pointer &anAle):
816 errorSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int, void *data)
1173 debugs(0, DBG_CRITICAL, "WARNING: deny_info now accepts coded tags. Use %u to get the full URL instead of %s");
1343 if (request && request->method != Http::METHOD_GET && request->method != Http::METHOD_HEAD && request->http_ver >= Http::ProtocolVersion(1,1))
1354 httpHeaderPutStrf(&rep->header, Http::HdrType::X_SQUID_ERROR, "%d %s", httpStatus, "Access Denied");
1431 debugs(4, 2, "No existing error page language negotiated for " << this << ". Using default error file.");
1478 ErrorState::noteBuildError_(const char *const msg, const char * const errorLocation, const bool forceBypass)
1497 debugs(4, debugLevel, "WARNING: The following configuration error will be fatal in future Squid versions");
1499 debugs(4, debugLevel, "ERROR: " << BuildErrorPrinter(inputLocation, page_id, msg, errorLocation));
1545 ErrorPage::ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation)
an error page created from admin-configurable metadata (e.g. deny_info)
Definition: errorpage.cc:72
std::ostream & printLocation(std::ostream &os) const
print() helper to report where the error was found
Definition: errorpage.cc:1508
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
static std::ostream & operator<<(std::ostream &os, const BuildErrorPrinter &context)
Definition: errorpage.cc:140
err_type errorReservePageId(const char *page_name, const SBuf &cfgLocation)
allocates a new slot for the error page
Definition: errorpage.cc:654
static const std::array< HardCodedError, 7 > HardCodedErrors
error messages that cannot be configured/customized externally
Definition: errorpage.cc:162
void setDefault() override
recover from loadDefault() failure to load or parse() a template
Definition: errorpage.cc:228
static std::vector< ErrorDynamicPageInfo * > ErrorDynamicPages
Definition: errorpage.cc:201
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:738
Definition: errorpage.cc:103
bool loaded() const
return true if the data loaded from disk without any problem
Definition: errorpage.h:287
bool wasLoaded
True if the template data read from disk without any problem.
Definition: errorpage.h:334
const char * external_acl_message
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
Definition: AccessLogEntry.cc:198
Definition: errorpage.cc:219
const char * ProtocolType_str[]
const char * filename
admin-configured name for the error page template (custom or standard)
Definition: errorpage.cc:89
struct SquidConfig::@97 onoff
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
void updateOrAddStr(Http::HdrType, const SBuf &)
Definition: HttpHeader.cc:1083
Definition: PackableStream.h:75
Definition: forward.h:17
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
Definition: HttpHeaderTools.cc:54
static void ValidateStaticError(const int page_id, const SBuf &inputLocation)
validate static error page
Definition: errorpage.cc:1554
size_t AssembleOne(const char *start, MemBuf &buf, const AccessLogEntryPointer &ale)
Definition: Format.cc:99
an error page (or a part of an error page) with hard-coded template text
Definition: errorpage.cc:155
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:812
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:63
Definition: errorpage.h:280
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
ErrorPageFile(const char *name, const err_type code)
Definition: errorpage.cc:222
void compileLogformatCode(Build &build)
compile @Squid{code} sequence containing a single logformat code
Definition: errorpage.cc:913
TemplateFile(const char *name, const err_type code)
Definition: errorpage.cc:357
bool silent
Whether to print error messages on cache.log file or not. It is user defined.
Definition: errorpage.h:317
Definition: HttpRequest.h:48
virtual void setDefault()
recover from loadDefault() failure to load or parse() a template
Definition: errorpage.h:324
void errorSend(const Comm::ConnectionPointer &conn, ErrorState *err)
Definition: errorpage.cc:792
ErrorState()=delete
Http::StatusCode status() const
retrieve the status code for this status line
Definition: StatusLine.h:45
static ErrorDetail::Pointer NewIfAny(const int errorNo)
Definition: SysErrorDetail.h:22
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos)
Definition: errorpage.cc:472
void noteBuildError_(const char *msg, const char *errorLocation, bool forceBypass)
Definition: errorpage.cc:1478
Definition: MemBuf.h:23
void bypassBuildErrorXXX(const char *const msg, const char *const errorLocation)
Definition: errorpage.h:158
SBuf text("GET http://resource.com/path HTTP/1.1\r\n" "Host: resource.com\r\n" "Cookie: laijkpk3422r j1noin \r\n" "\r\n")
BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *anErrorLocation)
Definition: errorpage.cc:119
SBuf cfgLocation
deny_info directive position in squid.conf (for reporting)
Definition: errorpage.cc:92
int starting_up
pretty-prints error page/deny_info building error
Definition: errorpage.cc:116
void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data)
Definition: CommCalls.h:34
void validate()
ensures that a future BuildHttpReply() is likely to succeed
Definition: errorpage.cc:1303
int reconfiguring
const char * visible_appname_string
state and parameters shared by several ErrorState::compile*() methods
Definition: errorpage.cc:106
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:312
virtual SBuf brief() const =0
Definition: SquidString.h:25
SBuf compileBody(const char *text, bool allowRecursion)
Definition: errorpage.cc:1436
auto & delimitedBy(const char *const d)
a c-string to print between consecutive items (if any). Caller must ensure lifetime.
Definition: IoManip.h:188
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
Definition: TextException.cc:88
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:539
static std::ostream & operator<<(std::ostream &os, const ErrorState &err)
compactly prints top-level ErrorState information (for debugging)
Definition: errorpage.cc:682
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:33
ErrorDynamicPageInfo(const int anId, const char *aName, const SBuf &aCfgLocation)
Definition: errorpage.cc:567
const char * uri
admin-configured HTTP Location header value for redirection responses
Definition: errorpage.cc:86
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:863
Definition: Stream.h:20
const char * urlCanonicalFakeHttps(const HttpRequest *request)
Definition: Uri.cc:776
Comm::ConnectionPointer tcpServer
TCP/IP level details of the last peer/server connection.
Definition: HierarchyLogEntry.h:59
Definition: HttpReply.h:24
SBuf inputLocation
the source of the error template (for reporting purposes)
Definition: errorpage.h:117
const char * denyMessage(char const *const default_message=nullptr) const
Definition: UserRequest.cc:127
Definition: Store.h:37
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:279
static int operator-(err_type const &anErr, err_type const &anErr2)
Definition: errorpage.cc:245
static ErrorState * NewForwarding(err_type, HttpRequestPointer &, const AccessLogEntryPointer &)
Creates a general request forwarding error with the right http_status.
Definition: errorpage.cc:691
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
static const CharacterSet & RFC3986_UNRESERVED()
allowed URI characters that do not have a reserved purpose, RFC 3986
Definition: CharacterSet.cc:164
SBuf buildBody()
locates the right error page template for this error and compiles it
Definition: errorpage.cc:1400
void update(const Error &)
if necessary, stores the given error information (if any)
Definition: Error.cc:51
Definition: errorpage.h:88
int id
error_text[] index for response body (unused in redirection responses)
Definition: errorpage.cc:78
static void ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation)
add error page template to the global index
Definition: errorpage.cc:1545
std::ostream & print(std::ostream &) const
reports error details (for admin-visible exceptions and debugging)
Definition: errorpage.cc:1522
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:170
static const char * IsDenyInfoUri(const int page_id)
Definition: errorpage.cc:253
virtual SBuf verbose(const HttpRequestPointer &) const =0
RawPointerT< Pointer > RawPointer(const char *label, const Pointer &ptr)
convenience wrapper for creating RawPointerT<> objects
Definition: IoManip.h:73
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:744
SBuf compile(const char *input, bool building_deny_info_url, bool allowRecursion)
Definition: errorpage.cc:1442
struct ErrorState::@54 ftp
Definition: CommCalls.h:229
void noteBuildError(const char *const msg, const char *const errorLocation)
Definition: errorpage.h:149
static SBuf Encode(const SBuf &, const CharacterSet &expected)
Definition: Uri.cc:57
void storeErrorResponse(HttpReply *reply)
Store a prepared error response. MemObject locks the reply object.
Definition: store.cc:1688
Auth::UserRequest::Pointer auth_user_request
Definition: errorpage.h:175
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
Definition: ProtocolVersion.h:19
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products