You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2002/09/20 02:57:50 UTC

cvs commit: httpd-2.0/include ap_provider.h

jerenkrantz    2002/09/19 17:57:50

  Modified:    .        CHANGES
               modules/aaa config.m4 mod_auth.h mod_auth_basic.c
                        mod_auth_digest.c mod_authn_dbm.c mod_authn_file.c
               modules/dav/main providers.c
               server   Makefile.in
  Added:       server   provider.c
               include  ap_provider.h
  Log:
  Add ap_register_provider and ap_lookup_provider functions which resolve
  the DSO link problems for DAV and the new aaa modules by moving the
  provider code into the core of the server and generalizing them to be
  used by any code.
  
  Remove the auth{nz}_*_provider functions as they are no longer needed.
  
  Change the dav_*_provider functions to wrap the ap_*_provider functions
  as they have a bit more of a historical precedent that we should keep
  around.
  
  Reviewed by:	John K. Sterling <jo...@sterls.com> (in concept)
  
  Revision  Changes    Path
  1.935     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.934
  retrieving revision 1.935
  diff -u -u -r1.934 -r1.935
  --- CHANGES	19 Sep 2002 11:57:07 -0000	1.934
  +++ CHANGES	20 Sep 2002 00:57:49 -0000	1.935
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.43
   
  +  *) Add ap_register_provider/ap_lookup_provider API.
  +     [John K. Sterling <jo...@sterls.com>, Justin Erenkrantz]
  +
     *) Add -p option to apxs to allow programs to be compiled with apxs.
        [Justin Erenkrantz]
   
  
  
  
  1.57      +2 -6      httpd-2.0/modules/aaa/config.m4
  
  Index: config.m4
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/config.m4,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -u -r1.56 -r1.57
  --- config.m4	10 Sep 2002 06:57:02 -0000	1.56
  +++ config.m4	20 Sep 2002 00:57:49 -0000	1.57
  @@ -33,12 +33,8 @@
   
   dnl these are the front-end authentication modules
   
  -std_auth_provider_objects="auth_provider.lo"
  -
  -APACHE_MODULE(auth_basic, basic authentication,
  -              mod_auth_basic.lo $std_auth_provider_objects, , yes)
  -APACHE_MODULE(auth_digest, RFC2617 Digest authentication,
  -              mod_auth_digest.lo $std_auth_provider_objects , , most, [
  +APACHE_MODULE(auth_basic, basic authentication, , , yes)
  +APACHE_MODULE(auth_digest, RFC2617 Digest authentication, , , most, [
     ap_old_cppflags=$CPPFLAGS
     CPPFLAGS="$CPPFLAGS -I$APR_SOURCE_DIR/include -I$abs_builddir/srclib/apr/include"
     AC_TRY_COMPILE([#include <apr.h>], [
  
  
  
  1.5       +1 -24     httpd-2.0/modules/aaa/mod_auth.h
  
  Index: mod_auth.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_auth.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- mod_auth.h	18 Sep 2002 01:05:25 -0000	1.4
  +++ mod_auth.h	20 Sep 2002 00:57:49 -0000	1.5
  @@ -65,23 +65,7 @@
   extern "C" {
   #endif
   
  -/* Create a set of AAA_DECLARE(type) and AAA_DECLARE_DATA with 
  - * appropriate export and import tags for the platform
  - */
  -#if !defined(WIN32)
  -#define AAA_DECLARE(type)            type
  -#define AAA_DECLARE_DATA
  -#elif defined(AAA_DECLARE_STATIC)
  -#define AAA_DECLARE(type)            type __stdcall
  -#define AAA_DECLARE_DATA
  -#elif defined(AAA_DECLARE_EXPORT)
  -#define AAA_DECLARE(type)            __declspec(dllexport) type __stdcall
  -#define AAA_DECLARE_DATA             __declspec(dllexport)
  -#else
  -#define AAA_DECLARE(type)            __declspec(dllimport) type __stdcall
  -#define AAA_DECLARE_DATA             __declspec(dllimport)
  -#endif
  -
  +#define AUTHN_PROVIDER_GROUP "authn"
   #define AUTHN_DEFAULT_PROVIDER "file"
   
   typedef enum {
  @@ -115,18 +99,11 @@
       authn_provider_list *next;
   };
   
  -AAA_DECLARE(void) authn_register_provider(apr_pool_t *p, const char *name,
  -                                         const authn_provider *provider);
  -AAA_DECLARE(const authn_provider *) authn_lookup_provider(const char *name);
  -
   typedef struct {
       /* For a given user, return a hash of all groups the user belongs to.  */
       apr_hash_t * (*get_user_groups)(request_rec *r, const char *user);
   } authz_provider;
   
  -AAA_DECLARE(void) authz_register_provider(apr_pool_t *p, const char *name,
  -                                         const authz_provider *provider);
  -AAA_DECLARE(const authz_provider *) authz_lookup_provider(const char *name);
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.6       +5 -2      httpd-2.0/modules/aaa/mod_auth_basic.c
  
  Index: mod_auth_basic.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_auth_basic.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- mod_auth_basic.c	18 Sep 2002 01:05:25 -0000	1.5
  +++ mod_auth_basic.c	20 Sep 2002 00:57:49 -0000	1.6
  @@ -70,6 +70,7 @@
   #include "http_log.h"
   #include "http_protocol.h"
   #include "http_request.h"
  +#include "ap_provider.h"
   
   #include "mod_auth.h"
   
  @@ -113,7 +114,8 @@
       newp->provider_name = provider_name;
   
       /* lookup and cache the actual provider now */
  -    newp->provider = authn_lookup_provider(newp->provider_name);
  +    newp->provider = ap_lookup_provider(AUTHN_PROVIDER_GROUP,
  +                                        newp->provider_name);
   
       if (newp->provider == NULL) {
           /* by the time they use it, the provider should be loaded and
  @@ -253,7 +255,8 @@
            * provider.
            */
           if (!current_provider) {
  -            provider = authn_lookup_provider(AUTHN_DEFAULT_PROVIDER);
  +            provider = ap_lookup_provider(AUTHN_PROVIDER_GROUP,
  +                                          AUTHN_DEFAULT_PROVIDER);
           }
           else {
               provider = current_provider->provider;
  
  
  
  1.72      +5 -2      httpd-2.0/modules/aaa/mod_auth_digest.c
  
  Index: mod_auth_digest.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_auth_digest.c,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -u -r1.71 -r1.72
  --- mod_auth_digest.c	18 Sep 2002 01:05:25 -0000	1.71
  +++ mod_auth_digest.c	20 Sep 2002 00:57:49 -0000	1.72
  @@ -118,6 +118,7 @@
   #include "util_md5.h"
   #include "apr_shm.h"
   #include "apr_rmm.h"
  +#include "ap_provider.h"
   
   #include "mod_auth.h"
   
  @@ -504,7 +505,8 @@
       newp->provider_name = provider_name;
   
       /* lookup and cache the actual provider now */
  -    newp->provider = authn_lookup_provider(newp->provider_name);
  +    newp->provider = ap_lookup_provider(AUTHN_PROVIDER_GROUP,
  +                                        newp->provider_name);
   
       if (newp->provider == NULL) {
          /* by the time they use it, the provider should be loaded and
  @@ -1473,7 +1475,8 @@
            * provider.
            */
           if (!current_provider) {
  -            provider = authn_lookup_provider(AUTHN_DEFAULT_PROVIDER);
  +            provider = ap_lookup_provider(AUTHN_PROVIDER_GROUP,
  +                                          AUTHN_DEFAULT_PROVIDER);
           }
           else {
               provider = current_provider->provider;
  
  
  
  1.5       +1 -1      httpd-2.0/modules/aaa/mod_authn_dbm.c
  
  Index: mod_authn_dbm.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_authn_dbm.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- mod_authn_dbm.c	18 Sep 2002 00:33:13 -0000	1.4
  +++ mod_authn_dbm.c	20 Sep 2002 00:57:49 -0000	1.5
  @@ -190,7 +190,7 @@
   
   static void register_hooks(apr_pool_t *p)
   {
  -    authn_register_provider(p, "dbm", &authn_dbm_provider);
  +    ap_register_provider(p, AUTHN_PROVIDER_GROUP, "dbm", &authn_dbm_provider);
   }
   
   module AP_MODULE_DECLARE_DATA authn_dbm_module =
  
  
  
  1.4       +1 -1      httpd-2.0/modules/aaa/mod_authn_file.c
  
  Index: mod_authn_file.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_authn_file.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- mod_authn_file.c	18 Sep 2002 00:33:13 -0000	1.3
  +++ mod_authn_file.c	20 Sep 2002 00:57:49 -0000	1.4
  @@ -218,7 +218,7 @@
   
   static void register_hooks(apr_pool_t *p)
   {
  -    authn_register_provider(p, "file", &authn_file_provider);
  +    ap_register_provider(p, AUTHN_PROVIDER_GROUP, "file", &authn_file_provider);
   }
   
   module AP_MODULE_DECLARE_DATA authn_file_module =
  
  
  
  1.10      +4 -22     httpd-2.0/modules/dav/main/providers.c
  
  Index: providers.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/dav/main/providers.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -u -r1.9 -r1.10
  --- providers.c	28 Jun 2002 16:08:22 -0000	1.9
  +++ providers.c	20 Sep 2002 00:57:50 -0000	1.10
  @@ -54,36 +54,18 @@
   
   #include "apr_pools.h"
   #include "apr_hash.h"
  +#include "ap_provider.h"
   #include "mod_dav.h"
   
  -
  -static apr_hash_t *dav_repos_providers = NULL;
  -
  -
  -static apr_status_t dav_cleanup_providers(void *ctx)
  -{
  -    dav_repos_providers = NULL;
  -    return APR_SUCCESS;
  -}
  +#define DAV_PROVIDER_GROUP "dav"
   
   DAV_DECLARE(void) dav_register_provider(apr_pool_t *p, const char *name,
                                           const dav_provider *provider)
   {
  -    if (dav_repos_providers == NULL) {
  -        dav_repos_providers = apr_hash_make(p);
  -        apr_pool_cleanup_register(p, NULL, dav_cleanup_providers, apr_pool_cleanup_null);
  -    }
  -
  -    /* just set it. no biggy if it was there before. */
  -    apr_hash_set(dav_repos_providers, name, APR_HASH_KEY_STRING, provider);
  +    ap_register_provider(p, DAV_PROVIDER_GROUP, name, provider);
   }
   
   const dav_provider * dav_lookup_provider(const char *name)
   {
  -    /* Better watch out against no registered providers */
  -    if (dav_repos_providers == NULL) {
  -        return NULL;
  -    }
  -
  -    return apr_hash_get(dav_repos_providers, name, APR_HASH_KEY_STRING);
  +    return ap_lookup_provider(DAV_PROVIDER_GROUP, name);
   }
  
  
  
  1.72      +1 -1      httpd-2.0/server/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/Makefile.in,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -u -r1.71 -r1.72
  --- Makefile.in	20 Dec 2001 16:19:50 -0000	1.71
  +++ Makefile.in	20 Sep 2002 00:57:50 -0000	1.72
  @@ -14,7 +14,7 @@
   	rfc1413.c connection.c listen.c \
   	mpm_common.c util_charset.c util_debug.c util_xml.c \
   	util_filter.c exports.c buildmark.c scoreboard.c \
  -	error_bucket.c protocol.c core.c request.c
  +	error_bucket.c protocol.c core.c request.c provider.c
   
   TARGETS = delete-exports $(LTLIBRARY_NAME) $(CORE_IMPLIB_FILE) export_vars.h httpd.exp
   
  
  
  
  1.1                  httpd-2.0/server/provider.c
  
  Index: provider.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  #include "apr_pools.h"
  #include "apr_hash.h"
  
  #include "ap_provider.h"
  
  static apr_hash_t *global_providers = NULL;
  
  static apr_status_t cleanup_global_providers(void *ctx)
  {
      global_providers = NULL;
      return APR_SUCCESS;
  }
  
  AP_DECLARE(apr_status_t) ap_register_provider(apr_pool_t *pool,
                                                const char *provider_group,
                                                const char *provider_name,
                                                const void *provider)
  {
      apr_hash_t *provider_group_hash;
  
      if (global_providers == NULL) {
          global_providers = apr_hash_make(pool);
          apr_pool_cleanup_register(pool, NULL, cleanup_global_providers,
                                    apr_pool_cleanup_null);
      }
  
      provider_group_hash = apr_hash_get(global_providers, provider_group,
                                         APR_HASH_KEY_STRING);
  
      if (!provider_group_hash) {
          provider_group_hash = apr_hash_make(pool);
          apr_hash_set(global_providers, provider_group, APR_HASH_KEY_STRING,
                       provider_group_hash);
          
      }
  
      /* just set it. no biggy if it was there before. */
      apr_hash_set(provider_group_hash, provider_name, APR_HASH_KEY_STRING,
                   provider);
  
      return APR_SUCCESS;
  }
  
  AP_DECLARE(void *) ap_lookup_provider(const char *provider_group,
                                        const char *provider_name)
  {
      apr_hash_t *provider_group_hash;
  
      if (global_providers == NULL) {
          return NULL;
      }
  
      provider_group_hash = apr_hash_get(global_providers, provider_group,
                                         APR_HASH_KEY_STRING);
  
      if (provider_group_hash == NULL) {
          return NULL;
      }
  
      return apr_hash_get(provider_group_hash, provider_name,
                          APR_HASH_KEY_STRING);
  }
  
  
  
  1.1                  httpd-2.0/include/ap_provider.h
  
  Index: ap_provider.h
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #ifndef AP_PROVIDER_H
  #define AP_PROVIDER_H
  
  #include "ap_config.h"
  
  /**
   * @package Provider API
   */
  
  /**
   * This function is used to register a provider with the global
   * provider pool.
   * @param pool The pool to create any storage from
   * @param provider_group The group to store the provider in
   * @param provider_name The name for this provider
   * @param provider Opaque structure for this provider
   * @return APR_SUCCESS if all went well
   */
  AP_DECLARE(apr_status_t) ap_register_provider(apr_pool_t *pool,
                                                const char *provider_group,
                                                const char *provider_name,
                                                const void *provider);
  
  /**
   * This function is used to retrieve a provider from the global
   * provider pool.
   * @param provider_group The group to look for this provider in
   * @param provider_name The name for the provider
   * @return provider point if found, NULL otherwise
   */
  AP_DECLARE(void *) ap_lookup_provider(const char *provider_group,
                                        const char *provider_name);
  
  #endif
  
  
  

Re: cvs commit: httpd-2.0/include ap_provider.h

Posted by Justin Erenkrantz <je...@apache.org>.
On Fri, Sep 20, 2002 at 07:57:49AM +0200, Sebastian Bergmann wrote:
> jerenkrantz@apache.org wrote:
> >   Added:       server   provider.c
> >                include  ap_provider.h
> 
>   This patch adds provider.c to the MSVC project:

Both patches are committed.  Thanks!

(Can't really review them, but hey...)  -- justin

Re: cvs commit: httpd-2.0/include ap_provider.h

Posted by Sebastian Bergmann <li...@sebastian-bergmann.de>.
jerenkrantz@apache.org wrote:
>   Added:       server   provider.c
>                include  ap_provider.h

  This patch adds provider.c to the MSVC project:

Index: libhttpd.dsp
===================================================================
RCS file: /home/cvspublic/httpd-2.0/libhttpd.dsp,v
retrieving revision 1.50
diff -u -r1.50 libhttpd.dsp
--- libhttpd.dsp        29 Jul 2002 05:06:20 -0000      1.50
+++ libhttpd.dsp        20 Sep 2002 05:55:32 -0000
@@ -583,6 +583,10 @@
 # End Source File
 # Begin Source File

+SOURCE=.\server\provider.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\server\scoreboard.c
 # End Source File
 # Begin Source File

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/