Index: squid/src/acl.c diff -u squid/src/acl.c:1.1.1.28 squid/src/acl.c:1.1.1.28.2.1 --- squid/src/acl.c:1.1.1.28 Sun Jan 24 09:34:02 1999 +++ squid/src/acl.c Mon Feb 1 01:01:13 1999 @@ -627,7 +627,7 @@ aclParseAclLine(acl ** head) { /* we're already using strtok() to grok the line */ - char *t = NULL; + char *t = NULL, *c, *l; acl *A = NULL; LOCAL_ARRAY(char, aclname, ACL_NAME_SZ); squid_acl acltype; @@ -668,7 +668,22 @@ } debug(28, 3) ("aclParseAclLine: Appending to '%s'\n", aclname); new_acl = 0; - } + l=config_input_line; + l+=strspn(l, w_space); /* leading whitespace */ + l+=strcspn(l, w_space); /* acl */ + l+=strspn(l, w_space); + l+=strcspn(l, w_space); /* name */ + l+=strspn(l, w_space); + l+=strcspn(l, w_space); /* type */ + c=xmalloc(strlen(A->cfgline) + strlen(l) + 1); + strcpy(c,A->cfgline); + strcat(c,l); + safe_free(A->cfgline); + A->cfgline = c; + } + /* Strip tabs. They break cachemgr */ + while(strchr(A->cfgline,'\t')) + *strchr(A->cfgline,'\t') = ' '; switch (A->type) { case ACL_SRC_IP: case ACL_DST_IP: @@ -1742,14 +1757,9 @@ memFree(p, MEM_ACL_IP_DATA); } -void -aclDestroyAcls(acl ** head) +static void +aclClearAcl(acl * a) { - acl *a = NULL; - acl *next = NULL; - for (a = *head; a; a = next) { - next = a->next; - debug(28, 3) ("aclDestroyAcls: '%s'\n", a->cfgline); switch (a->type) { case ACL_SRC_IP: case ACL_DST_IP: @@ -1791,8 +1801,20 @@ assert(0); break; } + a->data = NULL; safe_free(a->cfgline); +} + +void +aclDestroyAcls(acl ** head) +{ + acl *a = NULL; + acl *next = NULL; + for (a = *head; a; a = next) { + next = a->next; + aclClearAcl(a); memFree(a, MEM_ACL); + debug(28, 3) ("aclDestroyAcls: '%s'\n", a->cfgline); } *head = NULL; } @@ -2358,3 +2380,69 @@ /* ==== END ARP ACL SUPPORT =============================================== */ #endif /* USE_ARP_ACL */ + +/* Reparse a ACL line */ +void aclRefreshAcl(char *name) +{ + char *cfgline; + char *t; + + acl *a = aclFindByName(name); + + assert(a != NULL); + assert(strlen(a->cfgline) < BUFSIZ); + + xstrncpy(config_input_line, a->cfgline, BUFSIZ); + cfgline = xstrdup(a->cfgline); + + /* Free previous ACL contents */ + aclClearAcl(a); + + /* Reconstruct the head of the cfgline */ + t = cfgline; + t += strspn(t, w_space); /* leading whitespace */ + t += strcspn(t, w_space); /* acl */ + t += strspn(t, w_space); + t += strcspn(t, w_space); /* name */ + t += strspn(t, w_space); + t += strcspn(t, w_space); /* type */ + a->cfgline = xmalloc( t - cfgline + 1 ); + xstrncpy(a->cfgline, cfgline, t - cfgline + 1); + + /* Fill it up again */ + strtok(cfgline, w_space); /* Skip "acl" */ + aclParseAclLine(&Config.aclList); /* Reparse */ + + xfree(cfgline); +} + +static void +aclMgrRefreshAclMenu(StoreEntry *sentry) +{ + acl *a; + for (a = Config.aclList; a; a = a->next) + storeAppendPrintf(sentry, " aclrefreshmenu+%s\t%s\t%s\n", + a->name, a->cfgline, "protected"); +} + +static void +aclMgrRefreshAcl(StoreEntry *sentry) +{ + char *name = cachemgrArgument(sentry); + if (!name) { + aclMgrRefreshAclMenu(sentry); + } else { + aclRefreshAcl(name); + storeAppendPrintf(sentry, "Refreshed acl %s", name); + } + safe_free(name); +} + +void +aclInit(void) +{ + cachemgrRegister("aclrefreshmenu", + "Refresh a ACL list", + aclMgrRefreshAcl, + 1, 1); +} Index: squid/src/cache_cf.c diff -u squid/src/cache_cf.c:1.1.1.27 squid/src/cache_cf.c:1.1.1.27.2.1 --- squid/src/cache_cf.c:1.1.1.27 Sun Jan 24 09:34:04 1999 +++ squid/src/cache_cf.c Mon Feb 1 01:01:13 1999 @@ -919,21 +919,9 @@ } void -free_denyinfo(acl_deny_info_list ** list) +free_denyinfo(acl_deny_info_list ** head) { - acl_deny_info_list *a = NULL; - acl_deny_info_list *a_next = NULL; - acl_name_list *l = NULL; - acl_name_list *l_next = NULL; - for (a = *list; a; a = a_next) { - for (l = a->acl_list; l; l = l_next) { - l_next = l->next; - safe_free(l); - } - a_next = a->next; - safe_free(a); - } - *list = NULL; + aclDestroyDenyInfoList(head); } static void Index: squid/src/cache_manager.c diff -u squid/src/cache_manager.c:1.1.1.6 squid/src/cache_manager.c:1.1.1.6.2.1 --- squid/src/cache_manager.c:1.1.1.6 Sun Jan 24 09:34:04 1999 +++ squid/src/cache_manager.c Mon Feb 1 01:01:14 1999 @@ -91,6 +91,12 @@ cachemgrFindAction(const char *action) { action_table *a; + LOCAL_ARRAY(char, tmp, MAX_URL); + if (strchr(action, '+')) { + strncpy(tmp, action, MAX_URL); + *strchr(tmp, '+') = '\0'; + action = tmp; + } for (a = ActionTable; a != NULL; a = a->next) { if (0 == strcmp(a->action, action)) return a; @@ -309,6 +315,13 @@ cachemgrPasswdGet(cachemgr_passwd * a, const char *action) { wordlist *w; + LOCAL_ARRAY(char, tmp, MAX_URL); + if (strchr(action, '+')) { + strncpy(tmp, action, MAX_URL); + *strchr(tmp, '+') = '\0'; + action = tmp; + } + while (a != NULL) { for (w = a->actions; w != NULL; w = w->next) { if (0 == strcmp(w->key, action)) @@ -331,3 +344,26 @@ "Shut Down the Squid Process", cachemgrShutdown, 1, 1); } + +char * +cachemgrArgument(StoreEntry *sentry) +{ + char *d; + LOCAL_ARRAY(char, args, MAX_URL); + + assert(sentry->mem_obj); + assert(sentry->mem_obj->url); + + d = strchr(sentry->mem_obj->url, '+'); + if (!d) + return NULL; + + xstrncpy(args, d+1, MAX_URL); + + d=strrchr(args, '@'); + if (d) + *d='@'; + + return *args ? xstrdup(args) : NULL; +} + Index: squid/src/cachemgr.c diff -u squid/src/cachemgr.c:1.1.1.14 squid/src/cachemgr.c:1.1.1.14.2.1 --- squid/src/cachemgr.c:1.1.1.14 Sun Jan 24 09:34:04 1999 +++ squid/src/cachemgr.c Mon Feb 1 01:01:14 1999 @@ -165,7 +165,7 @@ static const char *safe_str(const char *str); static char *xstrtok(char **str, char del); static void print_trailer(void); -static void auth_html(char *host, int port, const char *user_name); +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); @@ -226,7 +226,7 @@ } static void -auth_html(char *host, int port, const char *user_name) +auth_html(const char *host, int port, const char *user_name) { if (!user_name) user_name = ""; @@ -407,16 +407,16 @@ const char *action = req->action; const char *statusStr = NULL; int status = -1; - if (0 == strlen(req->action)) + if (0 == strlen(action)) { parse_menu = 1; - else if (0 == strcasecmp(req->action, "menu")) + action = "menu"; + } else if (strlen(action) >= 4 && + 0 == strcasecmp(action + strlen(action) -4, "menu")) parse_menu = 1; if (fp == NULL) { perror("fdopen"); return 1; } - if (parse_menu) - action = "menu"; /* read reply interpreting one line at a time depending on state */ while (istate < isEof) { if (!fgets(buf, sizeof(buf), fp)) @@ -450,8 +450,8 @@ printf("
%s\n