#include "squid.h"
#include "base/CharacterSet.h"
#include "base64.h"
#include "getfullhostname.h"
#include "html/Quoting.h"
#include "ip/Address.h"
#include "MemBuf.h"
#include "rfc1738.h"
#include "time/gadgets.h"
#include "util.h"
#include <cctype>
#include <cerrno>
#include <csignal>
#include <cstring>
#include <ctime>
Go to the source code of this file.
Classes | |
struct | cachemgr_request |
Macros | |
#define | DEFAULT_CACHEMGR_CONFIG "/etc/squid/cachemgr.conf" |
Functions | |
static const char * | safe_str (const char *str) |
static const char * | xstrtok (char **str, char del) |
static void | print_trailer (void) |
static void | auth_html (const char *host, int port, const char *user_name) |
static void | error_html (const char *msg) |
static char * | menu_url (cachemgr_request *req, const char *action) |
static int | parse_status_line (const char *sline, const char **statusStr) |
static cachemgr_request * | read_request (void) |
static char * | read_get_request (void) |
static char * | read_post_request (void) |
static void | make_pub_auth (cachemgr_request *req) |
static void | decode_pub_auth (cachemgr_request *req) |
static void | reset_auth (cachemgr_request *req) |
static const char * | make_auth_header (const cachemgr_request *req) |
static int | check_target_acl (const char *hostname, int port) |
static int | is_number (const char *str) |
static bool | hostname_check (const char *uri) |
static void | munge_menu_line (MemBuf &out, const char *buf, cachemgr_request *req) |
static void | munge_other_line (MemBuf &out, const char *buf, cachemgr_request *) |
static const char * | munge_action_line (const char *_buf, cachemgr_request *req) |
static int | read_reply (int s, cachemgr_request *req) |
static int | process_request (cachemgr_request *req) |
int | main (int argc, char *argv[]) |
Variables | |
static const time_t | passwd_ttl = 60 * 60 * 3 |
static const char * | script_name = "/cgi-bin/cachemgr.cgi" |
static const char * | progname = nullptr |
static time_t | now |
Macro Definition Documentation
◆ DEFAULT_CACHEMGR_CONFIG
#define DEFAULT_CACHEMGR_CONFIG "/etc/squid/cachemgr.conf" |
Definition at line 88 of file cachemgr.cc.
Function Documentation
◆ auth_html()
|
static |
Definition at line 245 of file cachemgr.cc.
References BUFSIZ, DEFAULT_CACHEMGR_CONFIG, port, print_trailer(), rfc1738_escape, script_name, and server.
Referenced by process_request().
◆ check_target_acl()
Definition at line 1244 of file cachemgr.cc.
References BUFSIZ, CACHE_HTTP_PORT, CACHEMGR_HOSTNAME, DEFAULT_CACHEMGR_CONFIG, getfullhostname(), and port.
Referenced by process_request().
◆ decode_pub_auth()
|
static |
Definition at line 1121 of file cachemgr.cc.
References base64_decode_final(), base64_decode_init(), BASE64_DECODE_LENGTH, base64_decode_update(), debug(), cachemgr_request::hostname, now, cachemgr_request::passwd, passwd_ttl, cachemgr_request::pub_auth, rfc1738_unescape(), safe_free, safe_str(), cachemgr_request::user_name, xfree, xmalloc, and xstrdup.
Referenced by read_request().
◆ error_html()
|
static |
Definition at line 402 of file cachemgr.cc.
References html_quote(), and print_trailer().
Referenced by process_request().
◆ hostname_check()
|
static |
Definition at line 220 of file cachemgr.cc.
References CharacterSet::ALPHA, and CharacterSet::DIGIT.
Referenced by process_request().
◆ is_number()
|
static |
Definition at line 186 of file cachemgr.cc.
Referenced by munge_other_line().
◆ main()
Definition at line 897 of file cachemgr.cc.
References debug_enabled, now, process_request(), progname, read_request(), script_name, Win32SockCleanup(), Win32SockInit(), and xstrdup.
◆ make_auth_header()
|
static |
Definition at line 1210 of file cachemgr.cc.
References assert, base64_encode_final(), base64_encode_init(), base64_encode_len, base64_encode_update(), cachemgr_request::passwd, cachemgr_request::user_name, xfree, and xmalloc.
Referenced by process_request().
◆ make_pub_auth()
|
static |
Definition at line 1087 of file cachemgr.cc.
References base64_encode_final(), base64_encode_init(), base64_encode_len, base64_encode_update(), debug(), cachemgr_request::hostname, now, cachemgr_request::passwd, cachemgr_request::pub_auth, rfc1738_escape, safe_free, safe_str(), cachemgr_request::user_name, xmalloc, and xstrdup.
Referenced by read_request().
◆ menu_url()
|
static |
Definition at line 436 of file cachemgr.cc.
References action(), cachemgr_request::hostname, cachemgr_request::port, cachemgr_request::pub_auth, rfc1738_escape, safe_str(), script_name, and cachemgr_request::user_name.
Referenced by munge_action_line(), munge_menu_line(), and read_reply().
◆ munge_action_line()
|
static |
Definition at line 570 of file cachemgr.cc.
References action(), menu_url(), xfree, xstrdup, and xstrtok().
Referenced by read_reply().
◆ munge_menu_line()
|
static |
Definition at line 450 of file cachemgr.cc.
References MemBuf::append(), Packable::appendf(), menu_url(), cachemgr_request::passwd, xfree, xstrdup, xstrndup(), and xstrtok().
Referenced by read_reply().
◆ munge_other_line()
|
static |
Definition at line 506 of file cachemgr.cc.
References MemBuf::append(), Packable::appendf(), html_quote(), is_number(), xfree, xstrdup, and xstrtok().
Referenced by read_reply().
◆ parse_status_line()
|
static |
Definition at line 415 of file cachemgr.cc.
References xisdigit, and xisspace.
Referenced by read_reply().
◆ print_trailer()
|
static |
Definition at line 235 of file cachemgr.cc.
References Time::FormatRfc1123(), getfullhostname(), now, progname, and VERSION.
Referenced by auth_html(), error_html(), and read_reply().
◆ process_request()
|
static |
Definition at line 788 of file cachemgr.cc.
References cachemgr_request::action, auth_html(), CACHE_HTTP_PORT, CACHEMGR_HOSTNAME, check_target_acl(), debug(), error_html(), Ip::Address::FreeAddr(), Ip::Address::getAddrInfo(), cachemgr_request::hostname, hostname_check(), Ip::Address::isAnyAddr(), make_auth_header(), MAX_IPSTRLEN, Ip::Address::port(), cachemgr_request::port, cachemgr_request::processes, read_reply(), Ip::Address::toUrl(), cachemgr_request::user_name, VERSION, cachemgr_request::workers, xstrdup, and xstrerr().
Referenced by main().
◆ read_get_request()
|
static |
◆ read_post_request()
|
static |
Definition at line 944 of file cachemgr.cc.
References strtoll(), xfree, and xmalloc.
Referenced by read_request().
◆ read_reply()
|
static |
Definition at line 594 of file cachemgr.cc.
References cachemgr_request::action, action(), MemBuf::buf, cachemgr_request::hostname, MemBuf::init(), menu_url(), munge_action_line(), munge_menu_line(), munge_other_line(), parse_status_line(), print_trailer(), reset_auth(), script_name, tempnam(), and xfree.
Referenced by process_request().
◆ read_request()
|
static |
Definition at line 1001 of file cachemgr.cc.
References cachemgr_request::action, debug(), decode_pub_auth(), cachemgr_request::hostname, make_pub_auth(), cachemgr_request::passwd, cachemgr_request::port, cachemgr_request::processes, cachemgr_request::pub_auth, read_get_request(), read_post_request(), rfc1738_unescape(), safe_free, safe_str(), cachemgr_request::server, cachemgr_request::user_name, cachemgr_request::workers, xcalloc(), xfree, and xstrdup.
Referenced by main().
◆ reset_auth()
|
static |
Definition at line 1203 of file cachemgr.cc.
References cachemgr_request::passwd, cachemgr_request::pub_auth, and safe_free.
Referenced by read_reply().
◆ safe_str()
|
static |
Definition at line 179 of file cachemgr.cc.
Referenced by decode_pub_auth(), make_pub_auth(), menu_url(), and read_request().
◆ xstrtok()
|
static |
Definition at line 192 of file cachemgr.cc.
References xisspace.
Referenced by munge_action_line(), munge_menu_line(), and munge_other_line().
Variable Documentation
◆ now
|
static |
Definition at line 109 of file cachemgr.cc.
Referenced by decode_pub_auth(), ConservativeTimer::expired(), LogTime(), main(), make_pub_auth(), Stopwatch::pause(), print_trailer(), processActivity(), Icmp4::Recv(), Icmp6::Recv(), Stopwatch::resume(), session_login(), time_since(), Stopwatch::total(), and vlog().
◆ passwd_ttl
|
static |
Definition at line 106 of file cachemgr.cc.
Referenced by decode_pub_auth().
◆ progname
|
static |
Definition at line 108 of file cachemgr.cc.
Referenced by main(), and print_trailer().
◆ script_name
|
static |
Definition at line 107 of file cachemgr.cc.
Referenced by auth_html(), main(), menu_url(), and read_reply().