httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: httpd-2.0/modules/ssl ssl_engine_config.c
Date Thu, 27 Mar 2003 23:32:43 GMT
wrowe       2003/03/27 15:32:43

  Modified:    modules/ssl ssl_engine_config.c
  Log:
    Allow any mutex to accept a 'filename' ... and always root it to the
    server root unless we are using posixsem, which can't handle big paths.
    This reorganization should make the code much more readable because
    all of the common code is at the beginning and end of the function,
    simplifing the long conditional test case block.
  
    This patch allows SSLMutex default:logs/ssl_mutex syntax.  It also
    removes the mod_ssl historical '.pid' suffixes - that isn't how Apache2
    specifies files.
  
  Revision  Changes    Path
  1.74      +56 -57    httpd-2.0/modules/ssl/ssl_engine_config.c
  
  Index: ssl_engine_config.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_engine_config.c,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- ssl_engine_config.c	23 Feb 2003 17:12:43 -0000	1.73
  +++ ssl_engine_config.c	27 Mar 2003 23:32:42 -0000	1.74
  @@ -368,11 +368,20 @@
   
   const char *ssl_cmd_SSLMutex(cmd_parms *cmd,
                                void *dcfg,
  -                             const char *arg)
  +                             const char *arg_)
   {
       const char *err;
       SSLModConfigRec *mc = myModConfig(cmd->server);
  -
  +    /* Split arg_ into meth and file */
  +    char *meth = apr_pstrdup(cmd->server->process->pool, arg_);
  +    char *file = strchr(meth, ':');
  +    if (file) {
  +        *(file++) = '\0';
  +        if (!*file) {
  +            file = NULL;
  +        }
  +    }
  +    
       if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) {
           return err;
       }
  @@ -380,97 +389,87 @@
       if (ssl_config_global_isfixed(mc)) {
           return NULL;
       }
  -
  -    if (strcEQ(arg, "none") || strcEQ(arg, "no")) {
  +    if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
           mc->nMutexMode  = SSL_MUTEXMODE_NONE;
  +        return NULL;
       }
  +
  +    /* APR determines temporary filename unless overridden below,
  +     * we presume file indicates an szMutexFile is a file path
  +     * unless the method sets szMutexFile=file and NULLs file
  +     */
  +    mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    mc->szMutexFile = NULL;
  +
       /* NOTE: previously, 'yes' implied 'sem' */
  -    else if (strcEQ(arg, "default") || strcEQ(arg, "yes")) {
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
           mc->nMutexMech = APR_LOCK_DEFAULT;
  -        mc->szMutexFile = NULL; /* APR determines temporary filename */
       }
   #if APR_HAS_FLOCK_SERIALIZE
  -    else if (strlen(arg) > 6 && strcEQn(arg, "flock:", 6)) {
  -        const char *file = ap_server_root_relative(cmd->pool, arg+6);
  -        if (!file) {
  -            return apr_pstrcat(cmd->pool, "Invalid SSLMutex flock: path ", 
  -                               arg+6, NULL);
  -        }
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    else if (!strcasecmp(meth, "flock") && file) {
           mc->nMutexMech = APR_LOCK_FLOCK;
  -        mc->szMutexFile = apr_psprintf(mc->pPool, "%s.%lu",
  -                                       file, (unsigned long)getpid());
       }
   #endif
   #if APR_HAS_FCNTL_SERIALIZE
  -    else if (strlen(arg) > 6 && strcEQn(arg, "fcntl:", 6)) {
  -        const char *file = ap_server_root_relative(cmd->pool, arg+6);
  -        if (!file) {
  -            return apr_pstrcat(cmd->pool, "Invalid SSLMutex fcntl: path ", 
  -                               arg+6, NULL);
  -        }
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    else if (!strcasecmp(meth, "fcntl") && file) {
           mc->nMutexMech = APR_LOCK_FCNTL;
  -        mc->szMutexFile = apr_psprintf(mc->pPool, "%s.%lu",
  -                                       file, (unsigned long)getpid());
       }
   #endif
   #if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
  -    else if (strcEQ(arg, "sysvsem")) {
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    else if (!strcasecmp(meth, "sysvsem") && file) {
           mc->nMutexMech = APR_LOCK_SYSVSEM;
  -        mc->szMutexFile = NULL; /* APR determines temporary filename */
       }
   #endif
   #if APR_HAS_POSIXSEM_SERIALIZE
  -    else if (strcEQ(arg, "posixsem")) {
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    else if (!strcasecmp(meth, "posixsem")) {
           mc->nMutexMech = APR_LOCK_POSIXSEM;
  -        mc->szMutexFile = NULL; /* APR determines temporary filename */
  +        mc->szMutexFile = file;
  +        file = NULL;
       }
   #endif
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
  -    else if (strcEQ(arg, "pthread")) {
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
  +    else if (!strcasecmp(meth, "pthread")) {
           mc->nMutexMech = APR_LOCK_PROC_PTHREAD;
  -        mc->szMutexFile = NULL; /* APR determines temporary filename */
       }
   #endif
  -#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
  -    else if (strlen(arg) > 5 && strcEQn(arg, "file:", 5)) {
  -        const char *file = ap_server_root_relative(cmd->pool, arg+5);
  -        if (!file) {
  -            return apr_pstrcat(cmd->pool, "Invalid SSLMutex file: path ", 
  -                               arg+5, NULL);
  -        }
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
   #if APR_HAS_FLOCK_SERIALIZE
  +    else if (!strcasecmp(meth, "file") && file) {
           mc->nMutexMech  = APR_LOCK_FLOCK;
  -#endif
  -#if APR_HAS_FCNTL_SERIALIZE
  +    }
  +#elif APR_HAS_FCNTL_SERIALIZE
  +    else if (!strcasecmp(meth, "file") && file) {
           mc->nMutexMech  = APR_LOCK_FCNTL;
  -#endif
  -        mc->szMutexFile =
  -            apr_psprintf(mc->pPool, "%s.%lu",
  -                         file, (unsigned long)getpid());
       }
   #endif
  -#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
  -    else if (strcEQ(arg, "sem")) {
  -        mc->nMutexMode  = SSL_MUTEXMODE_USED;
   #if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
  +    else if (!strcasecmp(meth, "sem")) {
           mc->nMutexMech  = APR_LOCK_SYSVSEM;
  -#endif
  -#if APR_HAS_POSIXSEM_SERIALIZE
  +    }
  +#elif APR_HAS_POSIXSEM_SERIALIZE
  +    else if (!strcasecmp(meth, "sem")) {
           mc->nMutexMech  = APR_LOCK_POSIXSEM;
  -#endif
  -        mc->szMutexFile = NULL; /* APR determines temporary filename */
  +        /* Posix/SysV semaphores aren't file based, use the literal name 
  +         * if provided and fall back on APR's default if not.
  +         */
  +        mc->szMutexFile = file;
  +        file = NULL;
       }
   #endif
       else {
  -        return apr_pstrcat(cmd->pool, "Invalid SSLMutex argument ", 
  -                           arg, " (", ssl_valid_ssl_mutex_string, ")", NULL);
  +        return apr_pstrcat(cmd->pool, "Invalid SSLMutex argument ", arg_,
  +                           " (", ssl_valid_ssl_mutex_string, ")", NULL);
  +    }
  +
  +    /* Unless the method above assumed responsibility for setting up
  +     * mc->szMutexFile and NULLing out file, presume it is a file we
  +     * are looking to use
  +     */
  +    if (file) {
  +        mc->szMutexFile = ap_server_root_relative(cmd->pool, file);
  +        if (!mc->szMutexFile) {
  +            return apr_pstrcat(cmd->pool, "Invalid SSLMutex ", meth, 
  +                               ": filepath ", file, NULL);
  +        }
       }
   
       return NULL;
  
  
  

Mime
View raw message