Changeset 1463 for trunk/server/common


Ignore:
Timestamp:
Feb 12, 2010, 2:47:59 AM (14 years ago)
Author:
andersk
Message:
mod_vhost_ldap: Copy the server_rec instead of corrupting it in place.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/httpdmods/mod_vhost_ldap.c

    r688 r1463  
    9696  { "apacheServerName", "apacheDocumentRoot", "apacheScriptAlias", "apacheSuexecUid", "apacheSuexecGid", "apacheServerAdmin", 0 };
    9797
     98static int total_modules;
     99
    98100#if (APR_MAJOR_VERSION >= 1)
    99101static APR_OPTIONAL_FN_TYPE(uldap_connection_close) *util_ldap_connection_close;
     
    119121static int mod_vhost_ldap_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
    120122{
     123    module **m;
     124
     125    /* Stolen from modules/generators/mod_cgid.c */
     126    total_modules = 0;
     127    for (m = ap_preloaded_modules; *m != NULL; m++)
     128        total_modules++;
     129
    121130    /* make sure that mod_ldap (util_ldap) is loaded */
    122131    if (ap_find_linked_module("util_ldap.c") == NULL) {
     
    423432static int mod_vhost_ldap_translate_name(request_rec *r)
    424433{
    425     request_rec *top = (r->main)?r->main:r;
    426434    mod_vhost_ldap_request_t *reqc;
    427435    apr_table_t *e;
     
    621629    }
    622630
    623     top->server->server_hostname = apr_pstrdup (top->pool, reqc->name);
     631    if ((r->server = apr_pmemdup(r->pool, r->server,
     632                                 sizeof(*r->server))) == NULL)
     633        return HTTP_INTERNAL_SERVER_ERROR;
     634
     635    r->server->server_hostname = reqc->name;
    624636
    625637    if (reqc->admin) {
    626         top->server->server_admin = apr_pstrdup (top->pool, reqc->admin);
     638        r->server->server_admin = reqc->admin;
    627639    }
    628640
    629641    // set environment variables
    630     e = top->subprocess_env;
     642    e = r->subprocess_env;
    631643    apr_table_addn (e, "SERVER_ROOT", reqc->docroot);
    632644
    633     core->ap_document_root = apr_pstrdup(top->pool, reqc->docroot);
     645    if ((r->server->module_config =
     646         apr_pmemdup(r->pool, r->server->module_config,
     647                     sizeof(void *) *
     648                     (total_modules + DYNAMIC_MODULE_LIMIT))) == NULL)
     649        return HTTP_INTERNAL_SERVER_ERROR;
     650
     651    if ((core = apr_pmemdup(r->pool, core, sizeof(*core))) == NULL)
     652        return HTTP_INTERNAL_SERVER_ERROR;
     653    ap_set_module_config(r->server->module_config, &core_module, core);
     654
     655    core->ap_document_root = reqc->docroot;
    634656
    635657    ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
Note: See TracChangeset for help on using the changeset viewer.