]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
objcache and password cleanups
authorwessels <>
Tue, 5 Nov 1996 05:07:24 +0000 (05:07 +0000)
committerwessels <>
Tue, 5 Nov 1996 05:07:24 +0000 (05:07 +0000)
src/cache_cf.cc
src/cachemgr.cc
src/squid.h

index f75426696a1f37a6be511afd3f9ab8f202f72c9c..ad258b64ebc1449b7f6c6c6cdec1493a6472e4f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.126 1996/11/04 18:12:10 wessels Exp $
+ * $Id: cache_cf.cc,v 1.127 1996/11/04 22:07:24 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -211,6 +211,7 @@ static int ip_acl_match _PARAMS((struct in_addr, const ip_acl *));
 static void addToIPACL _PARAMS((ip_acl **, const char *, ip_access_type));
 static void parseOnOff _PARAMS((int *));
 static void parseIntegerValue _PARAMS((int *));
+static void parseString _PARAMS((char **));
 static void self_destruct _PARAMS((void));
 static void wordlistAdd _PARAMS((wordlist **, const char *));
 
@@ -246,6 +247,7 @@ static void parseVisibleHostnameLine _PARAMS((void));
 static void parseWAISRelayLine _PARAMS((void));
 static void parseMinutesLine _PARAMS((int *));
 static void ip_acl_destroy _PARAMS((ip_acl **));
+static void parseCachemgrPasswd _PARAMS((void));
 static void parsePathname _PARAMS((char **));
 
 static void
@@ -440,8 +442,10 @@ intlistDestroy(intlist ** list)
 }
 
 
-/* Use this #define in all the parse*() functions.  Assumes 
- * char *token is defined */
+/*
+ * Use this #define in all the parse*() functions.  Assumes char *token is
+ * defined
+ */
 
 #define GetInteger(var) \
        token = strtok(NULL, w_space); \
@@ -975,6 +979,16 @@ parseIntegerValue(int *iptr)
     *iptr = i;
 }
 
+static void
+parseString(char **sptr)
+{
+    char *token;
+    token = strtok(NULL, w_space);
+    if (token == NULL)
+       self_destruct();
+    *sptr = xstrdup(token);
+}
+
 static void
 parseErrHtmlLine(void)
 {
@@ -983,6 +997,17 @@ parseErrHtmlLine(void)
        Config.errHtmlText = xstrdup(token);
 }
 
+static void
+parseCachemgrPasswd(void)
+{
+    char *passwd = NULL;
+    wordlist *actions = NULL;
+    parseString(&passwd);
+    parseWordlist(&actions);
+    objcachePasswdAdd(&Config.passwd_list, passwd, actions);
+    wordlistDestroy(&actions);
+}
+
 int
 parseConfigFile(const char *file_name)
 {
@@ -1291,6 +1316,9 @@ parseConfigFile(const char *file_name)
        else if (!strcmp(token, "minimum_direct_hops"))
            parseIntegerValue(&Config.minDirectHops);
 
+       else if (!strcmp(token, "cachemgr_passwd"))
+           parseCachemgrPasswd();
+
        else if (!strcmp(token, "store_objects_per_bucket"))
            parseIntegerValue(&Config.Store.objectsPerBucket);
        else if (!strcmp(token, "store_avg_object_size"))
@@ -1410,6 +1438,8 @@ configFreeMemory(void)
     wordlistDestroy(&Config.dns_testname_list);
     ip_acl_destroy(&Config.local_ip_list);
     ip_acl_destroy(&Config.firewall_ip_list);
+    objcachePasswdDestroy(&Config.passwd_list);
+    ttlFreeList();
     refreshFreeMemory();
 }
 
index 7c94651548e904fdbb4ba093ead75811acfd45dc..b6ff5b734a70c38a38b3ba2e8e0665deec148049 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cachemgr.cc,v 1.39 1996/11/04 18:12:13 wessels Exp $
+ * $Id: cachemgr.cc,v 1.40 1996/11/04 22:07:25 wessels Exp $
  *
  * DEBUG: Section 0     CGI Cache Manager
  * AUTHOR: Harvest Derived
@@ -288,7 +288,7 @@ static char *op_cmds_descr[] =
     "HTTP Reply Headers",
     "Filedescriptor Usage",
     "Network Probe Database",
-    "Shutdown Cache (password required)",
+    "Shutdown Cache",
     "Refresh Object (URL required)",
 #ifdef REMOVE_OBJECT
     "Remove Object (URL required)",
@@ -709,7 +709,8 @@ main(int argc, char *argv[])
            hasTables = TRUE;
        }
     }
-    if (!operation[0] || !strcmp(operation, "empty")) {                /* prints HTML form if no args */
+    /* prints HTML form if no args */
+    if (!operation[0] || !strcmp(operation, "empty")) {
        noargs_html(hostname, portnum, url);
        exit(0);
     }
@@ -744,9 +745,6 @@ main(int argc, char *argv[])
     case STATS_HDRS:
     case STATS_FDS:
     case STATS_NETDB:
-       sprintf(msg, "GET cache_object://%s/%s HTTP/1.0\r\n\r\n",
-           hostname, op_cmds[op]);
-       break;
     case SHUTDOWN:
        sprintf(msg, "GET cache_object://%s/%s@%s HTTP/1.0\r\n\r\n",
            hostname, op_cmds[op], password);
@@ -871,7 +869,7 @@ main(int argc, char *argv[])
 
     p_state = 0;
     cpy_ind = 0;
-    n_loops = 0;               /* Keep track of the number of passes through while */
+    n_loops = 0;               /* Keep track of passes through loop */
     while ((len = read(conn, buf, sizeof(buf))) > 0) {
        n_loops++;
        /* Simple state machine for parsing a {{ } { } ...} style list */
@@ -981,7 +979,7 @@ main(int argc, char *argv[])
     return 0;
 }
 
-static int
+static int 
 client_comm_connect(int sock, char *dest_host, u_short dest_port)
 {
     const struct hostent *hp;
index 8ec2a0fdcbd85994cd403a491d64f07e57f6052d..9f7c843ae3f1a20190edaf79b5c1164040da35f8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.66 1996/11/04 18:13:02 wessels Exp $
+ * $Id: squid.h,v 1.67 1996/11/04 22:07:28 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -201,6 +201,7 @@ typedef struct _cacheinfo cacheinfo;
 typedef struct _aclCheck_t aclCheck_t;
 typedef struct _request request_t;
 typedef struct _MemObject MemObject;
+typedef struct _cachemgr_passwd cachemgr_passwd;
 
 /* 32 bit integer compatability hack */
 #if SIZEOF_INT == 4
@@ -263,6 +264,7 @@ typedef int (*QS) (const void *, const void *);
 #include "icmp.h"
 #include "net_db.h"
 #include "client_db.h"
+#include "objcache.h"
 #include "refresh.h"
 
 #if !HAVE_TEMPNAM