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

Remove popen feature in native builds #70

Open
kpu opened this issue Feb 8, 2022 · 0 comments
Open

Remove popen feature in native builds #70

kpu opened this issue Feb 8, 2022 · 0 comments

Comments

@kpu
Copy link
Member

kpu commented Feb 8, 2022

As we move towards repositories with models provided by other people, a yaml config file should not be able to execute arbitrary commands with a file name that begins with |

if (marian::utils::endsWith(file, "|")) {
#if defined(__unix__) && !defined(WASM_COMPATIBLE_SOURCE)
auto command = file.substr(0, file.size() - 1);
// open as a pipe
pipe_ = popen(command.c_str(), "r");
ABORT_IF(!pipe_, "Command failed to execute ({}): {}", errno, command);
// there is no official way to construct a filebuf from a FILE* or fd, so we use /proc/{pid}/fd/{fd}
// For now, this only works on Linux. There are similar workarounds for Windows.
file_ = "/proc/" + std::to_string(getpid()) + "/fd/" + std::to_string(fileno(pipe_));
#else
ABORT("Pipe syntax not supported in this build of Marian: {}", file);
#endif
} else {

That should be disabled in consumer-oriented compiles of Marian. The feature really only seems useful for training.

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

No branches or pull requests

1 participant