httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] more contrib: mod_dynmod.c
Date Sat, 23 Aug 1997 03:41:48 GMT
And here's the second.

---------- Forwarded message ----------
Date: Tue, 5 Aug 1997 18:13:15 +0200
From: Pierre-Yves Kerembellec <Pierre-Yves.Kerembellec@vtcom.fr>
To: Dean Gaudet <dgaudet@arctic.org>
Subject: Re: Re: Re[2]: os-solaris/945: Related to PR#883 : when using NFS under a chroot-ed
environment, crash the network layers

Le [Fri, 1 Aug 1997 10:37:16 -0700 (PDT)], Dean Gaudet ecrivait :

>  On Fri, 1 Aug 1997, Pierre-Yves Kerembellec wrote:
>  
>  > >  Yep we should use sysv semaphores as well wherever available.
>  > 
>  > I think I can handle such a development, do you want me to provide
>  > you with a patch for that ?
>  
>  Certainly, that'd be great.  In http_main.c you need to provide the
>  accept_mutex_...() functions.  Thanks.

Hi Dean,

As planned, here is the code for the SYSV semaphore mutex (it's not
a patch, since my http_main.c is already patched with a lot of stuff,
but just the code to include as a new mutex method)

I also included 2 other things :

  - the log-resolve.c program (+ associated Makefile) is a 
    highly-conifgurable & optimized substitute for the currently 
    distributed logresolve.c (in the support/ folder)
    NOTE : you need the Berkeley DB package for this one
    
  - mod_dynmod.c is a substitute for mod_dld.c (which is clearly
    deprecated), using the "dlopen" API (works at least under
    Solaris 2.5.1 x86 & SPARC and FreeBSD)

Of course, all this code is completely rights-free ...
Please, feel free to ask any questions regarding these files ^_^

Regards,
Pierre-Yves

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Pierre-Yves KEREMBELLEC         Phone # +33 1 46 12 67 50
VTCOM                           Fax   # +33 1 46 12 67 00
40, rue Gabriel Crie            E-mail  pyk@vtcom.fr
92245 Malakoff Cedex, France    Systemes et Reseaux
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


/* ====================================================================
 * Copyright (c) 1995-1997 The Apache Group.  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. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment:
 *    "This product includes software developed by the Apache Group
 *    for use in the Apache HTTP server project (http://www.apache.org/)."
 *
 * 4. The names "Apache Server" and "Apache Group" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission.
 *
 * 5. Redistributions of any form whatsoever must retain the following
 *    acknowledgment:
 *    "This product includes software developed by the Apache Group
 *    for use in the Apache HTTP server project (http://www.apache.org/)."
 *
 * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``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 GROUP OR
 * IT'S 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 Group and was originally based
 * on public domain software written at the National Center for
 * Supercomputing Applications, University of Illinois, Urbana-Champaign.
 * For more information on the Apache Group and the Apache HTTP server
 * project, please see <http://www.apache.org/>.
 *
 */

/*
 * mod_dynmod.c
 * Pierre-Yves Kerembellec/VTCOM - 03/97
 */
#include <httpd.h>
#include <http_config.h>
#include <http_conf_globals.h>
#include <dlfcn.h>

static   int kbLoaded=0,kbFailed=0;

#ifndef  RTLD_LAZY
#define  RTLD_LAZY       1
#define  RTLD_GLOBAL     1
#endif

/* ========================================================================= */
/* kmcDynModLoad                                                             */ 
/* ========================================================================= */
static const char *kmcDynModLoad(cmd_parms *pstCommand, void *pstDirConfig,
                                 char *pcName, char *pcPath)
{
 void   *pvHandle;
 module *pstModule;
 char   tcName[256];

 if (kbLoaded != 0)
 {
     return(NULL);
 }
 pvHandle = dlopen(pcPath,RTLD_LAZY|RTLD_GLOBAL);
 if (pvHandle == NULL) 
 {
     kbFailed = -1;
     return(pstrcat(pstCommand->pool,"Loading dynamic module ",pcName,
                    " failed : ",dlerror(),NULL));
 }
 pstModule = (module *)dlsym(pvHandle,pcName);
 if (pstModule == NULL) 
 {
     tcName[0] = '_';
     strncpy(tcName+1,pcName,sizeof(tcName)-2);
     pstModule = (module *)dlsym(pvHandle,tcName);
     if (pstModule == NULL) 
     {
         kbFailed = -2;
         return(pstrcat(pstCommand->pool,"Loading symbol table in module ",
                        pcName," failed : ",dlerror(),NULL));
     }
 }
 add_module(pstModule);
 if (pstModule->create_server_config != NULL)
 {
     set_module_config(pstCommand->server->module_config,pstModule,
                       (*pstModule->create_server_config)
                       (pstCommand->pool,pstCommand->server));
 }
 else
 {
     set_module_config(pstCommand->server->module_config,pstModule,NULL);
 }
 if (pstModule->create_dir_config)
 {
     set_module_config(pstCommand->server->lookup_defaults,pstModule,
                       (*pstModule->create_dir_config)(pstCommand->pool,NULL));
 }
 else
 {
     set_module_config(pstCommand->server->lookup_defaults,pstModule,NULL);
 }
 return(NULL);
}

/* ========================================================================= */
/* kvDynModInitialize                                                        */ 
/* ========================================================================= */
static void kvDynModInitialize(server_rec *pstServer, pool *pstPool)
{
 if (kbLoaded != 0)
 {
     return;
 }
 if (kbFailed < 0 ) 
 {
     fprintf(stderr,"Dynamic modules load failed (%d)\n",kbFailed);
     exit(1);
 }
 kbLoaded = 1;
}

/* module command table */
static command_rec ktstDynModCommands[] = 
  {
     {"LoadModule",kmcDynModLoad,NULL,RSRC_CONF,TAKE2, 
      "a module (symbolic) name and a file path"},
     {NULL}
  };

/* this is the only non-static object in this module */
module dynmod_module = 
  {
   STANDARD_MODULE_STUFF,
   kvDynModInitialize,	/* initializer */
   NULL,		/* dir config creater */
   NULL,		/* dir merger */
   NULL,		/* server config */
   NULL, 		/* merge server configs */
   ktstDynModCommands,	/* command table */
   NULL,		/* handlers */
   NULL,		/* filename translation */
   NULL,		/* check user id */
   NULL,		/* check auth */
   NULL,		/* check access */
   NULL,		/* check type */
   NULL,		/* fixups */
   NULL,		/* logger */
   NULL,                /* header parsing */
  };

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message