On Monday 27 November 2006 00:57, Mathieu CARBONNEAUX wrote:
> the idea is to fake document root after chrooting apache.
>
> after reading configuration and setting document root, in child init i make
> chroot to the actual document root, and after i whant to correct document
> root to reflect the new document root "/"...
>
> without that you must have document root that exist in chroot and outside
> the chroot... because apache check if document root is directory at
> configuration stage...

This is from mod_perl.

static apr_status_t restore_docroot(void *data)
{
    struct mp_docroot_info *di = (struct mp_docroot_info *)data;
    *di->docroot  = di->original;
    return APR_SUCCESS;
}

static MP_INLINE
const char *mpxs_Apache2__RequestRec_document_root(pTHX_ request_rec *r,
                                                  SV *new_root)
{
    const char *retval = ap_document_root(r);

    if (new_root) {
        struct mp_docroot_info *di;
        core_server_config *conf;
        MP_CROAK_IF_THREADS_STARTED("setting $r->document_root");
        conf = ap_get_module_config(r->server->module_config, 
                                    &core_module);
        di = apr_palloc(r->pool, sizeof *di);
        di->docroot = &conf->ap_document_root;
        di->original = conf->ap_document_root;
        apr_pool_cleanup_register(r->pool, di, restore_docroot,
                                  restore_docroot);

        conf->ap_document_root = apr_pstrdup(r->pool, SvPV_nolen(new_root));
    }

    return retval;
}

Torsten

Attachment: pgpgc2Pz3XVqo.pgp
Description: PGP signature

Reply via email to