cachemgr.cc File Reference
#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>
Include dependency graph for cachemgr.cc:

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_requestread_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 void auth_html ( const char *  host,
int  port,
const char *  user_name 
)
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()

static int check_target_acl ( const char *  hostname,
int  port 
)
static

◆ decode_pub_auth()

◆ error_html()

static void error_html ( const char *  msg)
static

Definition at line 402 of file cachemgr.cc.

References html_quote(), and print_trailer().

Referenced by process_request().

◆ hostname_check()

static bool hostname_check ( const char *  uri)
static

Definition at line 220 of file cachemgr.cc.

References CharacterSet::ALPHA, and CharacterSet::DIGIT.

Referenced by process_request().

◆ is_number()

static int is_number ( const char *  str)
static

Definition at line 186 of file cachemgr.cc.

Referenced by munge_other_line().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ make_auth_header()

static const char * make_auth_header ( const cachemgr_request req)
static

◆ make_pub_auth()

◆ menu_url()

static char * menu_url ( cachemgr_request req,
const char *  action 
)
static

◆ munge_action_line()

static const char * munge_action_line ( const char *  _buf,
cachemgr_request req 
)
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 void munge_menu_line ( MemBuf out,
const char *  buf,
cachemgr_request req 
)
static

◆ munge_other_line()

static void munge_other_line ( MemBuf out,
const char *  buf,
cachemgr_request  
)
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 int parse_status_line ( const char *  sline,
const char **  statusStr 
)
static

Definition at line 415 of file cachemgr.cc.

References xisdigit, and xisspace.

Referenced by read_reply().

◆ print_trailer()

static void print_trailer ( void  )
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()

◆ read_get_request()

static char * read_get_request ( void  )
static

Definition at line 990 of file cachemgr.cc.

References xstrdup.

Referenced by read_request().

◆ read_post_request()

static char * read_post_request ( void  )
static

Definition at line 944 of file cachemgr.cc.

References strtoll(), xfree, and xmalloc.

Referenced by read_request().

◆ read_reply()

◆ read_request()

◆ reset_auth()

static void reset_auth ( cachemgr_request req)
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 const char * safe_str ( const char *  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 const char * xstrtok ( char **  str,
char  del 
)
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

◆ passwd_ttl

const time_t passwd_ttl = 60 * 60 * 3
static

Definition at line 106 of file cachemgr.cc.

Referenced by decode_pub_auth().

◆ progname

const char* progname = nullptr
static

Definition at line 108 of file cachemgr.cc.

Referenced by main(), and print_trailer().

◆ script_name

const char* script_name = "/cgi-bin/cachemgr.cgi"
static

Definition at line 107 of file cachemgr.cc.

Referenced by auth_html(), main(), menu_url(), and read_reply().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors