Search code examples
c++boostboost-process

Boost Process 1.71 does not look in environment path anymore


I have been using boost 1.65, did not change the code, updated boost to version 1.71 and now suddenly boost::process::child("command-in-path") does not inherit the environment of the executing process. How can I recover the behavior, is it possible without parsing the command every time to find the executable in path?


Solution

  • I haven't checked whether the behaviour actually changed, but I know there's a way to explicitly allow Boost to search the path:

    Keep in mind that searching the path can easily be a security issue because it can be compromised, or attackers can leverage knowledge of the path setting to intercept executables. This is why you'd expect search_path to be OFF by default (except for the system interface, which is traditionally insecure)

    Live On Wandbox

    #include <boost/process.hpp>
    
    int main() {
        namespace bp = boost::process;
    
        bp::child c(
            bp::search_path("date"),
            std::vector<std::string> { "+%s" });
        c.wait();
    }