litespeedtech / openlitespeed

Our high-performance, lightweight, open source HTTP server
https://openlitespeed.org
GNU General Public License v3.0
1.2k stars 194 forks source link

HttpVHost::addRailsApp system default env can override custom env #409

Open climatebrad opened 3 months ago

climatebrad commented 3 months ago

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());
    }
}
litespeedtech commented 2 months ago

It will be fixed in 1.8.2 .