--------------------- PatchSet 1569 Date: 2001/02/14 13:40:58 Author: rbcollins Branch: generic_modules Tag: (none) Log: authentication modules now using mod_register Members: src/Makefile.in:1.7.4.1->1.7.4.2 src/auth_modules.sh:1.2->1.2.18.1(DEAD) src/authenticate.c:1.12->1.12.4.1 src/cache_cf.c:1.18.4.1->1.18.4.2 src/main.c:1.19->1.19.4.1 src/protos.h:1.18.4.1->1.18.4.2 src/structs.h:1.24.4.1->1.24.4.2 src/typedefs.h:1.15.4.1->1.15.4.2 src/auth/basic/auth_basic.c:1.9->1.9.4.1 src/auth/digest/auth_digest.c:1.4->1.4.4.1 src/auth/ntlm/auth_ntlm.c:1.7->1.7.6.1 Index: squid/src/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/Makefile.in,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -u -r1.7.4.1 -r1.7.4.2 --- squid/src/Makefile.in 14 Feb 2001 11:57:27 -0000 1.7.4.1 +++ squid/src/Makefile.in 14 Feb 2001 13:40:58 -0000 1.7.4.2 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.7.4.1 2001/02/14 11:57:27 rbcollins Exp $ +# $Id: Makefile.in,v 1.7.4.2 2001/02/14 13:40:58 rbcollins Exp $ # # Uncomment and customize the following to suit your needs: # @@ -94,7 +94,6 @@ access_log.o \ acl.o \ asn.o \ - auth_modules.o \ authenticate.o \ cache_cf.o \ CacheDigest.o \ @@ -304,17 +303,11 @@ repl_modules repl/stamp: @sh -c "cd repl && $(MAKE) all" -auth_modules.c: auth_modules.sh Makefile - sh $(srcdir)/auth_modules.sh $(AUTH_MODULES) >auth_modules.c - -auth_modules.o: auth_modules.c - $(CC) -c auth_modules.c $(CFLAGS) -I$(srcdir) - $(AUTH_OBJS): @sh -c "cd `dirname $@` && $(MAKE) $(MFLAGS) `basename $@`" conf_modules.c: conf_modules.sh Makefile - sh $(srcdir)/conf_modules.sh $(CONF_MODULES) >conf_modules.c + sh $(srcdir)/conf_modules.sh $(CONF_MODULES) $(AUTH_MODULES) >conf_modules.c conf_modules.o: conf_modules.c $(CC) -c conf_modules.c $(CFLAGS) -I$(srcdir) @@ -430,7 +423,7 @@ clean: -rm -rf *.o *pure_* core $(PROGS) $(UTILS) $(CGIPROGS) $(SUID_UTILS) -rm -f cf_gen cf_gen_defines.h cf_parser.c cf.data globals.c string_arrays.c - -rm -f store_modules.c repl_modules.c auth_modules.c conf_modules.c squid.conf + -rm -f store_modules.c repl_modules.c conf_modules.c squid.conf @for dir in $(SUBDIRS); do \ echo "Making $@ in $$dir..."; \ (cd $$dir ; $(MAKE) $(MFLAGS) prefix="$(prefix)" $@) || exit 1; \ --- squid/src/auth_modules.sh Wed Feb 14 00:50:26 2007 +++ /dev/null Wed Feb 14 00:50:05 2007 @@ -1,15 +0,0 @@ -#!/bin/sh -echo "/* automatically generated by $0 $*" -echo " * do not edit" -echo " */" -echo "#include \"squid.h\"" -echo "" -for module in "$@"; do - echo "extern AUTHSSETUP authSchemeSetup_${module};" -done -echo "void authSchemeSetup(void)" -echo "{" -for module in "$@"; do - echo " authSchemeAdd(\"$module\", authSchemeSetup_${module});" -done -echo "}" Index: squid/src/authenticate.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/authenticate.c,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -u -r1.12 -r1.12.4.1 --- squid/src/authenticate.c 7 Feb 2001 19:11:48 -0000 1.12 +++ squid/src/authenticate.c 14 Feb 2001 13:40:58 -0000 1.12.4.1 @@ -1,6 +1,6 @@ /* - * $Id: authenticate.c,v 1.12 2001/02/07 19:11:48 hno Exp $ + * $Id: authenticate.c,v 1.12.4.1 2001/02/14 13:40:58 rbcollins Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Duane Wessels @@ -343,12 +343,6 @@ } void -authenticateSchemeInit(void) -{ - authSchemeSetup(); -} - -void authenticateInit(authConfig * config) { int i; @@ -633,7 +627,7 @@ * called to add another auth scheme module */ void -authSchemeAdd(char *type, AUTHSSETUP * setup) +authSchemeAdd(const char *type, AUTHSSETUP * setup) { int i; debug(29, 4) ("authSchemeAdd: adding %s", type); Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18.4.1 retrieving revision 1.18.4.2 diff -u -r1.18.4.1 -r1.18.4.2 --- squid/src/cache_cf.c 14 Feb 2001 11:57:27 -0000 1.18.4.1 +++ squid/src/cache_cf.c 14 Feb 2001 13:40:58 -0000 1.18.4.2 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18.4.1 2001/02/14 11:57:27 rbcollins Exp $ + * $Id: cache_cf.c,v 1.18.4.2 2001/02/14 13:40:58 rbcollins Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -1029,45 +1029,60 @@ char *type_str=NULL, *name_str=NULL; mod_t type=MOD_NONE; modNode *node= NULL; + dlink_node *linknode; + int rv; + linknode=cfg->modules.head; + if (!linknode) + /* first run */ + CBDATA_INIT_TYPE(modNode); + if ((type_str = strtok(NULL, w_space)) == NULL) self_destruct(); if ((name_str = strtok(NULL, w_space)) == NULL) self_destruct(); + /* find the module if it's currently configured */ + while (linknode && strcasecmp((*(modNode *)(linknode->data)).namestr, name_str)) { + linknode=linknode->next; + } + if (linknode == NULL) { + /* ignore the type if it is already configured. */ + if (strcasecmp(type_str,"internal")==0) { + /* internal module */ + type=MOD_INTERNAL; + } else if (strcasecmp(type_str,"external")==0) { + /* external module */ + debug(3,0)("external modules not supported yet\n"); + } + if (type==MOD_NONE) + self_destruct(); - if (strcasecmp(type_str,"internal")==0) { - /* internal module */ - type=MOD_INTERNAL; - } else if (strcasecmp(type_str,"external")==0) { - /* external module */ - debug(3,0)("external modules not supported yet\n"); - } - if (type==MOD_NONE) - self_destruct(); - - CBDATA_INIT_TYPE(modNode); - node=CBDATA_ALLOC(modNode, NULL); - assert(node); - node->type=type; - node->namestr=xstrdup(name_str); - if (type==MOD_INTERNAL) - rv = mod_internal_install(node->namestr, node); + node=CBDATA_ALLOC(modNode, NULL); + assert(node); + node->type=type; + node->namestr=xstrdup(name_str); + if (type==MOD_INTERNAL) + rv = mod_internal_install(node->namestr, node); #if 0 else if (type==MOD_EXTERNAL) rv = mod_external_install(node->namestr, node); #endif - else - rv=0; - if (rv) - dlinkAddTail(node,&node->node,&cfg->modules); - else { - safe_free(node->namestr); - cbdataFree(node); + else + rv=0; + if (rv) + dlinkAddTail(node,&node->node,&cfg->modules); + else { + safe_free(node->namestr); + cbdataFree(node); + } + } else { + node=linknode->data; } + /* call the modules configuration routine, if any */ } @@ -1080,12 +1095,11 @@ tmpnode=node; module=node->data; node=node->next; - dlinkDelete(tmpnode,&cfg->modules); - module->uninstall(module->namestr); - cbdataFree(module); + if (module->uninstall(module->namestr)) { + dlinkDelete(tmpnode,&cfg->modules); + cbdataFree(module); + } } - cfg->modules.head=NULL; - cfg->modules.tail=NULL; } static void Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.19 retrieving revision 1.19.4.1 diff -u -r1.19 -r1.19.4.1 --- squid/src/main.c 31 Jan 2001 00:27:46 -0000 1.19 +++ squid/src/main.c 14 Feb 2001 13:40:59 -0000 1.19.4.1 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.19 2001/01/31 00:27:46 hno Exp $ + * $Id: main.c,v 1.19.4.1 2001/02/14 13:40:59 rbcollins Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -623,7 +623,6 @@ cbdataInit(); eventInit(); /* eventInit() is required for config parsing */ storeFsInit(); /* required for config parsing */ - authenticateSchemeInit(); /* required for config parsign */ parse_err = parseConfigFile(ConfigFile); if (opt_parse_cfg_only) Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.18.4.1 retrieving revision 1.18.4.2 diff -u -r1.18.4.1 -r1.18.4.2 --- squid/src/protos.h 14 Feb 2001 11:57:27 -0000 1.18.4.1 +++ squid/src/protos.h 14 Feb 2001 13:40:59 -0000 1.18.4.2 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.18.4.1 2001/02/14 11:57:27 rbcollins Exp $ + * $Id: protos.h,v 1.18.4.2 2001/02/14 13:40:59 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -719,15 +719,11 @@ extern void redirectInit(void); extern void redirectShutdown(void); -/* auth_modules.c */ -extern void authSchemeSetup(void); - /* authenticate.c */ extern void authenticateAuthUserMerge(auth_user_t *, auth_user_t *); extern auth_user_t *authenticateAuthUserNew(const char *); extern int authenticateAuthSchemeId(const char *typestr); extern void authenticateStart(auth_user_request_t *, RH *, void *); -extern void authenticateSchemeInit(void); extern void authenticateInit(authConfig *); extern void authenticateShutdown(void); extern void authenticateFixHeader(HttpReply *, auth_user_request_t *, request_t *, int); @@ -756,7 +752,7 @@ extern char *authenticateUserRequestUsername(auth_user_request_t *); extern int authenticateValidateUser(auth_user_request_t *); extern void authenticateOnCloseConnection(ConnStateData * conn); -extern void authSchemeAdd(char *type, AUTHSSETUP * setup); +extern void authSchemeAdd(const char *type, AUTHSSETUP * setup); extern void refreshAddToList(const char *, int, time_t, int, time_t); extern int refreshIsCachable(const StoreEntry *); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.24.4.1 retrieving revision 1.24.4.2 diff -u -r1.24.4.1 -r1.24.4.2 --- squid/src/structs.h 14 Feb 2001 11:57:27 -0000 1.24.4.1 +++ squid/src/structs.h 14 Feb 2001 13:40:59 -0000 1.24.4.2 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.24.4.1 2001/02/14 11:57:27 rbcollins Exp $ + * $Id: structs.h,v 1.24.4.2 2001/02/14 13:40:59 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -133,7 +133,7 @@ */ struct _authscheme_entry { - char *typestr; + const char *typestr; AUTHSACTIVE *Active; AUTHSADDHEADER *AddHeader; AUTHSADDTRAILER *AddTrailer; @@ -163,7 +163,7 @@ /* private data types */ struct _authScheme { /* pointer to the authscheme_list's string entry */ - char *typestr; + const char *typestr; /* the scheme id in the authscheme_list */ int Id; /* the scheme's configuration details. */ Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.15.4.1 retrieving revision 1.15.4.2 diff -u -r1.15.4.1 -r1.15.4.2 --- squid/src/typedefs.h 14 Feb 2001 11:57:27 -0000 1.15.4.1 +++ squid/src/typedefs.h 14 Feb 2001 13:40:59 -0000 1.15.4.2 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.15.4.1 2001/02/14 11:57:27 rbcollins Exp $ + * $Id: typedefs.h,v 1.15.4.2 2001/02/14 13:40:59 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -359,7 +359,7 @@ /* name to register under */ typedef void MOD_INSTALL(const char *); -typedef void MOD_UNINSTALL(const char *); +typedef unsigned int MOD_UNINSTALL(const char *); #endif /* _TYPEDEFS_H_ */ Index: squid/src/auth/basic/auth_basic.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/basic/auth_basic.c,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -u -r1.9 -r1.9.4.1 --- squid/src/auth/basic/auth_basic.c 10 Feb 2001 17:31:47 -0000 1.9 +++ squid/src/auth/basic/auth_basic.c 14 Feb 2001 13:40:59 -0000 1.9.4.1 @@ -81,9 +81,24 @@ * */ -AUTHSSETUP authSchemeSetup_basic; +static AUTHSSETUP authSchemeSetup_basic; +/* register as a module */ void +mod_install_basic (const char *namestr) +{ + authSchemeAdd(namestr, authSchemeSetup_basic); +} + +/* deregister as a module */ +unsigned int +mod_uninstall_basic(const char *namestr) { + /* deregistration not supported for this module */ + return 0; +} + + +static void authSchemeSetup_basic(authscheme_entry_t * authscheme) { assert(!authbasic_initialised); Index: squid/src/auth/digest/auth_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/digest/auth_digest.c,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -u -r1.4 -r1.4.4.1 --- squid/src/auth/digest/auth_digest.c 10 Feb 2001 17:31:47 -0000 1.4 +++ squid/src/auth/digest/auth_digest.c 14 Feb 2001 13:40:59 -0000 1.4.4.1 @@ -48,6 +48,9 @@ cbdataFree(r); } +/* register with the authentication framework */ +static AUTHSSETUP authSchemeSetup_digest; + /* Digest Scheme */ static HLPCB authenticateDigestHandleReply; @@ -571,7 +574,21 @@ name, "digest", config->nonceGCInterval); } +/* register as a module */ void +mod_install_digest (const char *namestr) +{ + authSchemeAdd(namestr, authSchemeSetup_digest); +} + +/* deregister as a module */ +unsigned int +mod_uninstall_digest(const char *namestr) { + /* deregistration not supported for this module */ + return 0; +} + +static void authSchemeSetup_digest(authscheme_entry_t * authscheme) { assert(!authdigest_initialised); Index: squid/src/auth/ntlm/auth_ntlm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/auth_ntlm.c,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -u -r1.7 -r1.7.6.1 --- squid/src/auth/ntlm/auth_ntlm.c 31 Jan 2001 22:20:28 -0000 1.7 +++ squid/src/auth/ntlm/auth_ntlm.c 14 Feb 2001 13:41:00 -0000 1.7.6.1 @@ -47,6 +47,9 @@ cbdataFree(r); } +/* register with the authentication framework */ +static AUTHSSETUP authSchemeSetup_ntlm; + /* NTLM Scheme */ static HLPSCB authenticateNTLMHandleReply; static HLPSCB authenticateNTLMHandleplaceholder; @@ -86,6 +89,25 @@ static hash_table *proxy_auth_cache = NULL; +/* + * Module support + */ + +/* register as a module */ +void +mod_install_ntlm (const char *namestr) +{ + authSchemeAdd(namestr, authSchemeSetup_ntlm); +} + +/* deregister as a module */ +unsigned int +mod_uninstall_ntlm(const char *namestr) { + /* deregistration not supported for this module */ + return 0; +} + + /* * * Private Functions @@ -183,7 +205,7 @@ } -void +static void authSchemeSetup_ntlm(authscheme_entry_t * authscheme) { assert(!authntlm_initialised);