openlitespeed icon indicating copy to clipboard operation
openlitespeed copied to clipboard

HttpVHost::addRailsApp system default env can override custom env

Open climatebrad opened this issue 6 months ago • 1 comments

As written, the HttpVHost::addRailsApp function attaches the environment variables defined by pAppDefault->getEnv after the ones set by the options it's called with (and the ones it sets internally), which can cause failures in programs like RackRunner.rb to respect the custom environment. In particular, pAppDefault will have PATH set which will override any custom path set in a Virtual Host context, if I'm getting this right.

https://github.com/litespeedtech/openlitespeed/blob/d9610258f5c76ca204e1fd7074c23297b96a64de/src/http/httpvhost.cpp#L1712

could be replaced with something like

Env *pDefaultEnv = pAppDefault->getEnv();
if (pDefaultEnv)
{
    for (const auto &var : *pDefaultEnv)
    {
        config.addEnvIfNotExist(var.c_str(), var.c_str());
    }
}

climatebrad avatar Aug 04 '24 01:08 climatebrad