Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: fix the incorrect parameter parsing #382

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

zhixingchen0629
Copy link
Contributor

if i pass this params vector to launch process when the executor was nullptr:

        std::string executor;
        std::vector<std::string> params;
        params.push_back("powershell");
        params.push_back("-noprofile");
        params.push_back("-executionpolicy");
        params.push_back("bypass");
        params.push_back("-file");
        params.push_back(m_command);
        auto launcher = boost::process::v2::default_process_launcher();
        m_child = std::move(launcher(m_ioContext, ec, executor.c_str(), params, boost::process::v2::process_stdio{nullptr, m_wPipe, m_wPipe}));

The actual splicing command_line at the bottom level is:

"" powershell -noprofile -executionpolicy bypass -file c:aaa

"" It is superfluous, which cause create process error.

parameter splicing should take into account the situation where executor is empty

@klemens-morgenstern
Copy link
Collaborator

I assume you are trying to use CreateProcess with an empty lpApplicationName to get a command line execution?

This is disabled by default, because it's security risk and not portable. They way to do this is:

        auto executor = boost::process::v2::find_executable("powershell");
        std::vector<std::string> params;
        params.push_back("-noprofile");
        params.push_back("-executionpolicy");
        params.push_back("bypass");
        params.push_back("-file");
        params.push_back(m_command);
        auto launcher = boost::process::v2::default_process_launcher();
        m_child = std::move(launcher(m_ioContext, ec, executor, params, boost::process::v2::process_stdio{nullptr, m_wPipe, m_wPipe}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants