StorageExecutable fix small issues

This commit is contained in:
Maksim Kita 2021-10-19 01:04:07 +03:00
parent 75c16b8f89
commit fb91b1d92b

View File

@ -3,6 +3,8 @@
#include <filesystem>
#include <Common/ShellCommand.h>
#include <Common/filesystemHelpers.h>
#include <Core/Block.h>
#include <IO/ReadHelpers.h>
@ -111,9 +113,16 @@ Pipe StorageExecutable::read(
{
auto user_scripts_path = context->getUserScriptsPath();
auto script_path = user_scripts_path + '/' + script_name;
if (!std::filesystem::exists(std::filesystem::path(script_path)))
if (!pathStartsWith(script_path, user_scripts_path))
throw Exception(ErrorCodes::UNSUPPORTED_METHOD,
"Executable file {} does not exists inside {}",
"Executable file {} must be inside user scripts folder {}",
script_name,
user_scripts_path);
if (!std::filesystem::exists(std::filesystem::path(script_path)))
throw Exception(ErrorCodes::UNSUPPORTED_METHOD,
"Executable file {} does not exists inside user scripts folder {}",
script_name,
user_scripts_path);
@ -139,9 +148,9 @@ Pipe StorageExecutable::read(
bool result = process_pool->tryBorrowObject(process, [&config, this]()
{
config.terminate_in_destructor_strategy = ShellCommand::DestructorStrategy{ true /*terminate_in_destructor*/, settings.command_termination_timeout };
auto shell_command = ShellCommand::execute(config);
auto shell_command = ShellCommand::executeDirect(config);
return shell_command;
}, settings.max_command_execution_time * 1000);
}, settings.max_command_execution_time * 10000);
if (!result)
throw Exception(ErrorCodes::TIMEOUT_EXCEEDED,