Cahill, Earl wrote: [...]
Second, I couldn't get this
$r->document_root(hostname2docroot($r->hostname));
To set the docroot. However, each of the following worked
my $new_docroot = hostname2docroot($r->hostname); $r->document_root($new_docroot);
And
$r->document_root("" . hostname2docroot($r->hostname));
And
$r->document_root($_ = hostname2docroot($r->hostname));
How very strange.
It's a bug. This patch which will go in shortly fixes it:
Index: xs/Apache/RequestUtil/Apache__RequestUtil.h =================================================================== --- xs/Apache/RequestUtil/Apache__RequestUtil.h (revision 154310) +++ xs/Apache/RequestUtil/Apache__RequestUtil.h (working copy) @@ -320,7 +320,7 @@ MP_CROAK_IF_THREADS_STARTED("setting $r->document_root"); conf = ap_get_module_config(r->server->module_config, &core_module); - conf->ap_document_root = SvPV_nolen(new_root); + conf->ap_document_root = apr_pstrdup(r->pool, SvPV_nolen(new_root)); }
return retval;
before it just happened to work in certain situation. Since the value wasn't copied, if you have changed the scalar after assigning it, it'd affect the doc root in an unpredictable way. You've detected it since you've passed a value returned by another function. In that case it returns a TMP scalar which is special, as perl reuses it whenever the function is re-invoked. That's why you weren't getting it to work. This patch does a proper copying of that string.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com