errorpage.cc
Go to the documentation of this file.
117 BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *aNear): inputLocation(anInputLocation), page_id(aPage), msg(aMsg), near(aNear) {}
140static void ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation);
350TemplateFile::TemplateFile(const char *name, const err_type code): silent(false), wasLoaded(false), templateName(name), templateCode(code)
372 debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "ERROR: Unable to load default error language files. Reset to backups.");
384 debugs(1, (templateCode < TCP_RESET ? DBG_CRITICAL : 3), "WARNING: failed to find or read error text file " << templateName);
446 debugs(4, DBG_CRITICAL, MYNAME << "ERROR: failed to fully read: '" << path << "': " << xstrerr(xerrno));
477 * - IFF a tag contains only two characters we can wildcard ANY translations matching: <it> '-'? .*
482 while (pos < hdr.size() && hdr[pos] != ';' && hdr[pos] != ',' && !xisspace(hdr[pos]) && dt < (lang + (langLen -1)) ) {
509 debugs(4, 9, "STATE: lang=" << lang << ", pos=" << pos << ", buf='" << ((pos < hdr.size()) ? hdr.substr(pos,hdr.size()) : "") << "'");
560ErrorDynamicPageInfo::ErrorDynamicPageInfo(const int anId, const char *aName, const SBuf &aCfgLocation):
604 * - current result is Squid crashing or XSS problems as dynamic deny_info load random disk files.
605 * - a future redesign of the file loading may result in loading remote objects sent inline as local body.
611 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " is not valid on '" << page_name << "'");
615 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a template on '" << page_name << "'");
617 } else if (info->page_redirect >= 300 && info->page_redirect <= 399 && !strchr(&(page_name[4]), ':')) {
619 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a URL on '" << page_name << "'");
623 debugs(0, DBG_CRITICAL, "FATAL: status " << info->page_redirect << " requires a template on '" << page_name << "'");
674ErrorState::NewForwarding(err_type type, HttpRequestPointer &request, const AccessLogEntry::Pointer &ale)
689ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req, const AccessLogEntry::Pointer &anAle) :
703ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply, const AccessLogEntry::Pointer &anAle):
772errorSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int, void *data)
1136 debugs(0, DBG_CRITICAL, "WARNING: deny_info now accepts coded tags. Use %u to get the full URL instead of %s");
1305 if (request && request->method != Http::METHOD_GET && request->method != Http::METHOD_HEAD && request->http_ver >= Http::ProtocolVersion(1,1))
1316 httpHeaderPutStrf(&rep->header, Http::HdrType::X_SQUID_ERROR, "%d %s", httpStatus, "Access Denied");
1393 debugs(4, 2, "No existing error page language negotiated for " << this << ". Using default error file.");
1459 debugs(4, debugLevel, "WARNING: The following configuration error will be fatal in future Squid versions");
1507ErrorPage::ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation)
1528std::ostream &
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:312
void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data)
Definition: CommCalls.h:34
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
Definition: HttpHeaderTools.cc:54
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:864
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
Definition: TextException.cc:88
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:63
const char * urlCanonicalFakeHttps(const HttpRequest *request)
Definition: Uri.cc:733
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
Definition: AccessLogEntry.cc:212
char const * denyMessage(char const *const default_message=nullptr) const
Definition: UserRequest.cc:127
Definition: CommCalls.h:231
virtual SBuf verbose(const HttpRequestPointer &) const =0
virtual SBuf brief() const =0
an error page created from admin-configurable metadata (e.g. deny_info)
Definition: errorpage.cc:70
const char * uri
admin-configured HTTP Location header value for redirection responses
Definition: errorpage.cc:84
ErrorDynamicPageInfo(ErrorDynamicPageInfo &&)=delete
SBuf cfgLocation
deny_info directive position in squid.conf (for reporting)
Definition: errorpage.cc:90
ErrorDynamicPageInfo(const int anId, const char *aName, const SBuf &aCfgLocation)
Definition: errorpage.cc:560
int id
error_text[] index for response body (unused in redirection responses)
Definition: errorpage.cc:76
const char * filename
admin-configured name for the error page template (custom or standard)
Definition: errorpage.cc:87
Definition: errorpage.cc:213
void setDefault() override
recover from loadDefault() failure to load or parse() a template
Definition: errorpage.cc:221
ErrorPageFile(const char *name, const err_type code)
Definition: errorpage.cc:215
pretty-prints error page/deny_info building error
Definition: errorpage.cc:115
std::ostream & printLocation(std::ostream &os) const
print() helper to report where the error was found
Definition: errorpage.cc:1470
BuildErrorPrinter(const SBuf &anInputLocation, int aPage, const char *aMsg, const char *aNear)
Definition: errorpage.cc:117
std::ostream & print(std::ostream &) const
reports error details (for admin-visible exceptions and debugging)
Definition: errorpage.cc:1484
state and parameters shared by several ErrorState::compile*() methods
Definition: errorpage.cc:105
Definition: errorpage.h:89
static ErrorState * NewForwarding(err_type, HttpRequestPointer &, const AccessLogEntryPointer &)
Creates a general request forwarding error with the right http_status.
Definition: errorpage.cc:674
void bypassBuildErrorXXX(const char *msg, const char *near)
Definition: errorpage.h:158
SBuf compile(const char *input, bool building_deny_info_url, bool allowRecursion)
Definition: errorpage.cc:1404
void validate()
ensures that a future BuildHttpReply() is likely to succeed
Definition: errorpage.cc:1265
void compileLogformatCode(Build &build)
compile @Squid{code} sequence containing a single logformat code
Definition: errorpage.cc:876
Auth::UserRequest::Pointer auth_user_request
Definition: errorpage.h:175
SBuf inputLocation
the source of the error template (for reporting purposes)
Definition: errorpage.h:117
void noteBuildError_(const char *msg, const char *near, const bool forceBypass)
Definition: errorpage.cc:1440
void noteBuildError(const char *msg, const char *near)
Definition: errorpage.h:149
SBuf compileBody(const char *text, bool allowRecursion)
Definition: errorpage.cc:1398
SBuf buildBody()
locates the right error page template for this error and compiles it
Definition: errorpage.cc:1362
ErrorState()=delete
struct ErrorState::@56 ftp
void update(const Error &)
if necessary, stores the given error information (if any)
Definition: Error.cc:51
an error page (or a part of an error page) with hard-coded template text
Definition: errorpage.cc:148
Comm::ConnectionPointer tcpServer
TCP/IP level details of the last peer/server connection.
Definition: HierarchyLogEntry.h:70
void updateOrAddStr(Http::HdrType, const SBuf &)
Definition: HttpHeader.cc:1084
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:540
Definition: HttpReply.h:25
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
Definition: HttpReply.cc:170
Definition: HttpRequest.h:49
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:744
Http::StatusCode status() const
retrieve the status code for this status line
Definition: StatusLine.h:45
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:792
Definition: MemBuf.h:24
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:275
struct SquidConfig::@106 onoff
Definition: Store.h:42
void storeErrorResponse(HttpReply *reply)
Store a prepared error response. MemObject locks the reply object.
Definition: store.cc:1674
Definition: SquidString.h:26
static ErrorDetail::Pointer NewIfAny(const int errorNo)
Definition: SysErrorDetail.h:22
Definition: errorpage.h:281
virtual void setDefault()
recover from loadDefault() failure to load or parse() a template
Definition: errorpage.h:324
bool loaded() const
return true if the data loaded from disk without any problem
Definition: errorpage.h:287
TemplateFile(const char *name, const err_type code)
Definition: errorpage.cc:350
bool wasLoaded
True if the template data read from disk without any problem.
Definition: errorpage.h:334
bool silent
Whether to print error messages on cache.log file or not. It is user defined.
Definition: errorpage.h:317
static const std::array< HardCodedError, 7 > HardCodedErrors
error messages that cannot be configured/customized externally
Definition: errorpage.cc:155
err_type errorReservePageId(const char *page_name, const SBuf &cfgLocation)
allocates a new slot for the error page
Definition: errorpage.cc:647
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos)
Definition: errorpage.cc:465
char const * visible_appname_string
const char * external_acl_message
int starting_up
int reconfiguring
void errorSend(const Comm::ConnectionPointer &conn, ErrorState *err)
Definition: errorpage.cc:748
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:717
static std::vector< ErrorDynamicPageInfo * > ErrorDynamicPages
Definition: errorpage.cc:194
static int operator-(err_type const &anErr, err_type const &anErr2)
Definition: errorpage.cc:238
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
const char * ProtocolType_str[]
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:33
Definition: errorpage.cc:101
static const char * IsDenyInfoUri(const int page_id)
Definition: errorpage.cc:246
static void ImportStaticErrorText(const int page_id, const char *text, const SBuf &inputLocation)
add error page template to the global index
Definition: errorpage.cc:1507
static void ValidateStaticError(const int page_id, const SBuf &inputLocation)
validate static error page
Definition: errorpage.cc:1516
static std::ostream & operator<<(std::ostream &os, const BuildErrorPrinter &context)
Definition: errorpage.cc:133
size_t AssembleOne(const char *start, MemBuf &buf, const AccessLogEntryPointer &ale)
Definition: Format.cc:99
Definition: forward.h:18
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
Definition: ProtocolVersion.h:19
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
SBuf text("GET http://resource.com/path HTTP/1.1\r\n" "Host: resource.com\r\n" "Cookie: laijkpk3422r j1noin \r\n" "\r\n")