From: wessels <> Date: Fri, 6 Feb 1998 07:48:59 +0000 (+0000) Subject: Filling in some of the config dumping routines X-Git-Tag: SQUID_3_0_PRE1~4154 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56b63fa16de6e4ad08573a745688ebb08d7500a4;p=thirdparty%2Fsquid.git Filling in some of the config dumping routines --- diff --git a/src/acl.cc b/src/acl.cc index 4dbf1dbd73..200e777c70 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.133 1998/02/04 07:22:13 wessels Exp $ + * $Id: acl.cc,v 1.134 1998/02/06 00:48:59 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -50,7 +50,7 @@ static int aclMatchTime(struct _acl_time_data *data, time_t when); static int aclMatchIdent(wordlist * data, const char *ident); static int aclMatchIp(void *dataptr, struct in_addr c); static int aclMatchDomainList(void *dataptr, const char *); -static squid_acl aclType(const char *s); +static squid_acl aclStrToType(const char *s); static int decode_addr(const char *, struct in_addr *, struct in_addr *); static void aclCheck(aclCheck_t * checklist); static void aclCheckCallback(aclCheck_t * checklist, allow_t answer); @@ -59,11 +59,21 @@ static IPH aclLookupDstIPforASNDone; static FQDNH aclLookupSrcFQDNDone; static FQDNH aclLookupDstFQDNDone; static int aclReadProxyAuth(struct _acl_proxy_auth *p); +static wordlist * aclDumpIpList(acl_ip_data * ip); +static wordlist * aclDumpDomainList(void *data); +static wordlist * aclDumpTimeSpec(void *data); +static wordlist * aclDumpRegexList(void *data); +static wordlist * aclDumpIntlist(void *data); +static wordlist * aclDumpWordList(wordlist *data); +static wordlist * aclDumpProtoList(void *data); +static wordlist * aclDumpMethodList(void *data); +static wordlist * aclDumpProxyAuth(void *data); #if USE_ARP_ACL static int checkARP(u_long ip, char *eth); static int decode_eth(const char *asc, char *eth); static int aclMatchArp(void *dataptr, struct in_addr c); +static const char * aclDumpArpList(void *data); #endif #if defined(USE_SPLAY_TREE) @@ -86,7 +96,7 @@ static int bintreeArpNetworkCompare(void *, void *); #endif #else /* LINKED LIST */ -static void aclDestroyIpList(struct _acl_ip_data *data); +static void aclDestroyIpList(acl_ip_data *data); #endif /* USE_SPLAY_TREE */ @@ -151,7 +161,7 @@ strtokFile(void) } static squid_acl -aclType(const char *s) +aclStrToType(const char *s) { if (!strcmp(s, "src")) return ACL_SRC_IP; @@ -194,6 +204,46 @@ aclType(const char *s) return ACL_NONE; } +const char * +aclTypeToStr(squid_acl type) +{ + if (type == ACL_SRC_IP) + return "src"; + if (type == ACL_DST_IP) + return "dst"; + if (type == ACL_DST_DOMAIN) + return "dstdomain"; + if (type == ACL_SRC_DOMAIN) + return "srcdomain"; + if (type == ACL_TIME) + return "time"; + if (type == ACL_URLPATH_REGEX) + return "urlpath_regex"; + if (type == ACL_URL_REGEX) + return "url_regex"; + if (type == ACL_URL_PORT) + return "port"; + if (type == ACL_USER) + return "user"; + if (type == ACL_PROTO) + return "proto"; + if (type == ACL_METHOD) + return "method"; + if (type == ACL_BROWSER) + return "browser"; + if (type == ACL_PROXY_AUTH) + return "proxy_auth"; + if (type == ACL_SRC_ASN) + return "src_as"; + if (type == ACL_DST_ASN) + return "dst_as"; +#if USE_ARP_ACL + if (type == ACL_SRC_ARP) + return "arp"; +#endif + return "ERROR"; +} + struct _acl * aclFindByName(const char *name) { @@ -310,13 +360,13 @@ decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask) #define SCAN_ACL3 "%[0123456789.]/%[0123456789.]" #define SCAN_ACL4 "%[0123456789.]" -static struct _acl_ip_data * +static acl_ip_data * aclParseIpData(const char *t) { LOCAL_ARRAY(char, addr1, 256); LOCAL_ARRAY(char, addr2, 256); LOCAL_ARRAY(char, mask, 256); - struct _acl_ip_data *q = xcalloc(1, sizeof(struct _acl_ip_data)); + acl_ip_data *q = xcalloc(1, sizeof(acl_ip_data)); debug(28, 5) ("aclParseIpData: %s\n", t); if (!strcasecmp(t, "all")) { q->addr1.s_addr = 0; @@ -383,7 +433,7 @@ aclParseIpList(void *curlist) { char *t = NULL; splayNode **Top = curlist; - struct _acl_ip_data *q = NULL; + acl_ip_data *q = NULL; while ((t = strtokFile())) { if ((q = aclParseIpData(t)) == NULL) continue; @@ -397,7 +447,7 @@ aclParseIpList(void **curtree) { tree **Tree; char *t = NULL; - struct _acl_ip_data *q; + acl_ip_data *q; Tree = xmalloc(sizeof(tree *)); *curtree = Tree; tree_init(Tree); @@ -413,8 +463,8 @@ static void aclParseIpList(void *curlist) { char *t = NULL; - struct _acl_ip_data **Tail; - struct _acl_ip_data *q = NULL; + acl_ip_data **Tail; + acl_ip_data *q = NULL; for (Tail = curlist; *Tail; Tail = &((*Tail)->next)); while ((t = strtokFile())) { if ((q = aclParseIpData(t)) == NULL) @@ -665,7 +715,7 @@ aclParseAclLine(acl ** head) debug(28, 0) ("aclParseAclLine: missing ACL type.\n"); return; } - if ((acltype = aclType(t)) == ACL_NONE) { + if ((acltype = aclStrToType(t)) == ACL_NONE) { debug(28, 0) ("%s line %d: %s\n", cfg_filename, config_lineno, config_input_line); debug(28, 0) ("aclParseAclLine: Invalid ACL type '%s'\n", t); @@ -924,11 +974,11 @@ aclMatchIp(void *dataptr, struct in_addr c) static int aclMatchIp(void *dataptr, struct in_addr c) { - struct _acl_ip_data **D = dataptr; - struct _acl_ip_data *data = *D; + acl_ip_data **D = dataptr; + acl_ip_data *data = *D; struct in_addr h; unsigned long lh, la1, la2; - struct _acl_ip_data *first, *prev; + acl_ip_data *first, *prev; first = data; /* remember first element, this will never be moved */ prev = NULL; /* previous element in the list */ @@ -1542,9 +1592,9 @@ aclDestroyTree(tree ** data) #elif !defined(USE_SPLAY_TREE) static void -aclDestroyIpList(struct _acl_ip_data *data) +aclDestroyIpList(acl_ip_data *data) { - struct _acl_ip_data *next = NULL; + acl_ip_data *next = NULL; for (; data; data = next) { next = data->next; safe_free(data); @@ -1877,10 +1927,10 @@ aclHostDomainCompare(const char *h, const char *d) #if defined(USE_BIN_TREE) static int -networkCompare(struct _acl_ip_data *net, struct _acl_ip_data *data) +networkCompare(acl_ip_data *net, acl_ip_data *data) { struct in_addr addr; - struct _acl_ip_data acl_ip; + acl_ip_data acl_ip; int rc = 0; xmemcpy(&acl_ip, net, sizeof(acl_ip)); addr = acl_ip.addr1; @@ -1911,7 +1961,7 @@ static int aclIpNetworkCompare(const void *a, splayNode * n) { struct in_addr A = *(struct in_addr *) a; - struct _acl_ip_data *q = n->data; + acl_ip_data *q = n->data; struct in_addr B = q->addr1; struct in_addr C = q->addr2; int rc = 0; @@ -1936,7 +1986,7 @@ aclIpNetworkCompare(const void *a, splayNode * n) #elif defined(USE_BIN_TREE) static int -aclIpNetworkCompare(struct in_addr addr, struct _acl_ip_data *data) +aclIpNetworkCompare(struct in_addr addr, acl_ip_data *data) { int rc = 0; addr.s_addr &= data->mask.s_addr; /* apply netmask */ @@ -1980,22 +2030,170 @@ bintreeHostDomainCompare(void *t1, void *t2) static int bintreeNetworkCompare(void *t1, void *t2) { - return networkCompare((struct _acl_ip_data *) t1, - (struct _acl_ip_data *) t2); + return networkCompare((acl_ip_data *) t1, + (acl_ip_data *) t2); } static int bintreeIpNetworkCompare(void *t1, void *t2) { struct in_addr addr; - struct _acl_ip_data *data; + acl_ip_data *data; xmemcpy(&addr, t1, sizeof(addr)); - data = (struct _acl_ip_data *) t2; + data = (acl_ip_data *) t2; return aclIpNetworkCompare(addr, data); } #endif /* USE_BIN_TREE */ +static wordlist * +aclDumpIpList(acl_ip_data * ip) +{ + wordlist *W = NULL; + wordlist **T = &W; + wordlist *w; + char buf[128]; + off_t o; + while (ip != NULL) { + o = 0; + o += snprintf(buf + o, 128 - o, "%s", inet_ntoa(ip->addr1)); + if (ip->addr2.s_addr != any_addr.s_addr) + o += snprintf(buf + o, 128 - o, "-%s", inet_ntoa(ip->addr2)); + if (ip->mask.s_addr != no_addr.s_addr) + o += snprintf(buf + o, 128 - o, "/%s", inet_ntoa(ip->mask)); + w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup(buf); + *T = w; + T = &w->next; + ip = ip->next; + } + return W; +} + +static wordlist * +aclDumpDomainList(void *data) +{ +#if USE_BIN_TREE + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +#elif USE_SPLAY_TREE + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +#else + return aclDumpWordList(data); +#endif +} +static wordlist * +aclDumpTimeSpec(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} +static wordlist * +aclDumpRegexList(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} +static wordlist * +aclDumpIntlist(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} +static wordlist * +aclDumpWordList(wordlist *data) +{ + wordlist *W = NULL; + wordlist **T = &W; + wordlist *w; + while (data != NULL) { + w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup(data->key); + *T = w; + T = &w->next; + data = data->next; + } + return W; +} +static wordlist * +aclDumpProtoList(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} +static wordlist * +aclDumpMethodList(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} +static wordlist * +aclDumpProxyAuth(void *data) +{ + wordlist *w = xcalloc(1, sizeof(wordlist)); + w->key = xstrdup("UNIMPLEMENTED"); + return w; +} + + + +wordlist * +aclDumpGeneric(const acl * a) +{ + switch (a->type) { + case ACL_SRC_IP: + case ACL_DST_IP: + return aclDumpIpList(a->data); + break; + case ACL_SRC_DOMAIN: + case ACL_DST_DOMAIN: + return aclDumpDomainList(a->data); + break; + case ACL_TIME: + return aclDumpTimeSpec(a->data); + break; + case ACL_URL_REGEX: + case ACL_URLPATH_REGEX: + case ACL_BROWSER: + return aclDumpRegexList(a->data); + break; + case ACL_URL_PORT: + case ACL_SRC_ASN: + case ACL_DST_ASN: + return aclDumpIntlist(a->data); + break; + case ACL_USER: + return aclDumpWordList(a->data); + break; + case ACL_PROTO: + return aclDumpProtoList(a->data); + break; + case ACL_METHOD: + return aclDumpMethodList(a->data); + break; + case ACL_PROXY_AUTH: + return aclDumpProxyAuth(a->data); + break; +#if USE_ARP_ACL + case ACL_SRC_ARP: + return aclDumpArpList(a->data); + break; +#endif + case ACL_NONE: + default: + break; + } + return NULL; +} + @@ -2234,5 +2432,11 @@ checkARP(u_long ip, char *eth) return 0; } +static const char * +aclDumpArpList(void *data) +{ + return "UNIMPLEMENTED"; +} + /* ==== END ARP ACL SUPPORT =============================================== */ #endif /* USE_ARP_ACL */ diff --git a/src/asn.cc b/src/asn.cc index b509c441aa..5cca53d10b 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,5 +1,5 @@ /* - * $Id: asn.cc,v 1.18 1998/02/05 20:32:24 wessels Exp $ + * $Id: asn.cc,v 1.19 1998/02/06 00:49:00 wessels Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -133,7 +133,7 @@ asnAclInitialize(acl * acls) { acl *a; intlist *i; - debug(53, 1) ("asnAclInitialize: STARTING\n"); + debug(53, 3) ("asnAclInitialize\n"); for (a = acls; a; a = a->next) { if (a->type != ACL_DST_ASN && a->type != ACL_SRC_ASN) continue; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index f850482736..22e06c272e 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.244 1998/02/05 20:32:35 wessels Exp $ + * $Id: cache_cf.cc,v 1.245 1998/02/06 00:49:01 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -356,7 +356,21 @@ parseBytesUnits(const char *unit) static void dump_acl(StoreEntry * entry, const char *name, acl * acl) { - storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); + wordlist *w; + wordlist *v; + while (acl != NULL) { + v = w = aclDumpGeneric(acl); + while (v != NULL) { + storeAppendPrintf(entry, "%s %s %s %s\n", + name, + acl->name, + aclTypeToStr(acl->type), + v->key); + v = v->next; + } + wordlistDestroy(&w); + acl = acl->next; + } } #if SQUID_SNMP @@ -418,19 +432,29 @@ free_acl(acl ** acl) } static void -dump_acl_access(StoreEntry * entry, const char *name, struct _acl_access *head) +dump_acl_access(StoreEntry * entry, const char *name, acl_access *head) { - storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); + acl_list *l; + while (head != NULL) { + for (l=head->acl_list; l != NULL; l = l->next) { + storeAppendPrintf(entry, "%s %s %s%s\n", + name, + head->allow ? "Allow" : "Deny", + l->op ? "" : "!", + l->acl->name); + } + head = head->next; + } } static void -parse_acl_access(struct _acl_access **head) +parse_acl_access(acl_access **head) { aclParseAccessLine(head); } static void -free_acl_access(struct _acl_access **head) +free_acl_access(acl_access **head) { aclDestroyAccessList(head); } @@ -464,7 +488,7 @@ free_address(struct in_addr *addr) } static void -dump_cachedir(StoreEntry * entry, const char *name, struct _cacheSwap swap) +dump_cachedir(StoreEntry * entry, const char *name, cacheSwap swap) { SwapDir *s; int i; @@ -480,7 +504,7 @@ dump_cachedir(StoreEntry * entry, const char *name, struct _cacheSwap swap) } static int -check_null_cachedir(struct _cacheSwap swap) +check_null_cachedir(cacheSwap swap) { return swap.swapDirs == NULL; } @@ -492,7 +516,7 @@ check_null_string(char *s) } static void -parse_cachedir(struct _cacheSwap *swap) +parse_cachedir(cacheSwap *swap) { char *token; char *path; @@ -561,7 +585,7 @@ parse_cachedir(struct _cacheSwap *swap) } static void -free_cachedir(struct _cacheSwap *swap) +free_cachedir(cacheSwap *swap) { SwapDir *s; int i; @@ -699,13 +723,13 @@ free_cachemgrpasswd(cachemgr_passwd ** head) static void -dump_denyinfo(StoreEntry * entry, const char *name, struct _acl_deny_info_list *var) +dump_denyinfo(StoreEntry * entry, const char *name, acl_deny_info_list *var) { storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); } static void -parse_denyinfo(struct _acl_deny_info_list **var) +parse_denyinfo(acl_deny_info_list **var) { aclParseDenyInfoLine(var); } @@ -713,10 +737,10 @@ parse_denyinfo(struct _acl_deny_info_list **var) void free_denyinfo(acl_deny_info_list ** list) { - struct _acl_deny_info_list *a = NULL; - struct _acl_deny_info_list *a_next = NULL; - struct _acl_name_list *l = NULL; - struct _acl_name_list *l_next = NULL; + 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; @@ -746,7 +770,7 @@ parse_peeracl(void) cfg_filename, config_lineno, host); return; } - L = xcalloc(1, sizeof(struct _acl_list)); + L = xcalloc(1, sizeof(acl_list)); L->op = 1; if (*aclname == '!') { L->op = 0; @@ -783,7 +807,7 @@ parse_hostdomain(void) cfg_filename, config_lineno, host); continue; } - l = xcalloc(1, sizeof(struct _domain_ping)); + l = xcalloc(1, sizeof(domain_ping)); l->do_ping = 1; if (*domain == '!') { /* check for !.edu */ l->do_ping = 0; @@ -814,7 +838,7 @@ parse_hostdomaintype(void) cfg_filename, config_lineno, host); return; } - l = xcalloc(1, sizeof(struct _domain_type)); + l = xcalloc(1, sizeof(domain_type)); l->type = parseNeighborType(type); l->domain = xstrdup(domain); for (L = &(p->typelist); *L; L = &((*L)->next)); diff --git a/src/cf.data.pre b/src/cf.data.pre index 89e52ae478..4d79985663 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1984,54 +1984,6 @@ DOC_START The location of squid's mib. DOC_END -NAME: snmp_port -TYPE: ushort -LOC: Config.Port.snmp -DEFAULT: 3401 -IFDEF: SQUID_SNMP -DOC_START - Port for snmp. <=0 to disable. -DOC_END - -NAME: snmp_config_file -TYPE: string -LOC: Config.Snmp.configFile -DEFAULT: @DEFAULT_SNMP_CONF@ -IFDEF: SQUID_SNMP -DOC_START - External snmp configuration file, CMU-snmpd style. -DOC_END - -NAME: snmp_do_queueing -TYPE: onoff -LOC: Config.Snmp.do_queueing -DEFAULT: on -IFDEF: SQUID_SNMP -DOC_START - If disabled, snmp packets will not be queued but delivered - immediately. This could be performant when you want to monitor a - cache in trouble, but this could also bring squid to block. -DOC_END - -NAME: forward_snmpd_port -TYPE: ushort -LOC: Config.Snmp.localPort -DEFAULT: 0 -IFDEF: SQUID_SNMP -DOC_START - This configures whether we should be forwarding SNMP requests to - another snmpd. The reason for putting this piece of - functionality into squid was to enable access to the system's - installed snmpd with minimal changes. This option is turned off - by default, check with your /etc/services for your system's snmp - port (usually 161). We do not use getservbyname() to allow you - to set squid into port 161 and your system's snmpd to another - port by changing /etc/services. WARNING: Because of squid - acting as a proxy snmpd for system you have to do security - checks on THIS snmpd for all objects. Check your - snmp_config_file -DOC_END - NAME: trap_sink TYPE: string LOC: Config.Snmp.trap_sink diff --git a/src/protos.h b/src/protos.h index 3d8a317e46..0d06ad6c79 100644 --- a/src/protos.h +++ b/src/protos.h @@ -26,6 +26,8 @@ extern void aclDestroyDenyInfoList(struct _acl_deny_info_list **); extern void aclDestroyRegexList(struct _relist *data); extern int aclMatchRegex(relist * data, const char *word); extern void aclParseRegexList(void *curlist); +extern const char *aclTypeToStr(squid_acl); +extern wordlist *aclDumpGeneric(const acl *); #if USE_ASYNC_IO extern int aio_cancel(aio_result_t *); diff --git a/src/typedefs.h b/src/typedefs.h index 5c154ce5a6..50e9f09d0a 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -78,6 +78,7 @@ typedef struct _dlink_list dlink_list; typedef struct _StatCounters StatCounters; typedef struct _tlv tlv; typedef struct _storeSwapData storeSwapData; +typedef struct _cacheSwap cacheSwap; /* define AIOCB even without USE_ASYNC_IO */ typedef void AIOCB(void *, int aio_return, int aio_errno);