diff --git a/CMakeLists.txt b/CMakeLists.txt index 91e2711a..fec3fbf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ target_link_libraries(hpcore add_custom_command(TARGET hpcore POST_BUILD # COMMAND strip ./build/hpcore - COMMAND cp ./test/bin/hpws ./test/bin/hpfs ./build/ + COMMAND cp ./test/bin/hpws ./test/bin/hpfs ./test/bin/hpsh ./build/ ) target_precompile_headers(hpcore PUBLIC src/pchheader.hpp) @@ -87,7 +87,7 @@ target_precompile_headers(hpcore PUBLIC src/pchheader.hpp) add_custom_target(docker COMMAND mkdir -p ./test/local-cluster/bin COMMAND cp ./build/hpcore ./test/local-cluster/bin/ - COMMAND cp ./test/bin/libblake3.so ./test/bin/hpws ./test/bin/hpfs ./test/local-cluster/bin/ + COMMAND cp ./test/bin/libblake3.so ./test/bin/hpws ./test/bin/hpfs ./test/bin/hpsh ./test/local-cluster/bin/ COMMAND docker build -t hpcore:latest -t hpcore:0.6.4 -f ./test/local-cluster/Dockerfile ./test/local-cluster/bin/ ) set_target_properties(docker PROPERTIES EXCLUDE_FROM_ALL TRUE) diff --git a/src/conf.cpp b/src/conf.cpp index 47e6e696..68d1dd01 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -242,6 +242,7 @@ namespace conf ctx.hpws_exe_path = ctx.exe_dir + "/" + "hpws"; ctx.hpfs_exe_path = ctx.exe_dir + "/" + "hpfs"; + ctx.hpsh_exe_path = ctx.exe_dir + "/" + "hpsh"; ctx.contract_dir = basedir; ctx.config_dir = basedir + "/cfg"; @@ -709,7 +710,7 @@ namespace conf */ int validate_contract_dir_paths() { - const std::string paths[8] = { + const std::string paths[9] = { ctx.contract_dir, ctx.config_file, ctx.contract_hpfs_dir, @@ -717,7 +718,8 @@ namespace conf ctx.tls_key_file, ctx.tls_cert_file, ctx.hpfs_exe_path, - ctx.hpws_exe_path}; + ctx.hpws_exe_path, + ctx.hpsh_exe_path}; for (const std::string &path : paths) { @@ -729,7 +731,7 @@ namespace conf << "openssl req -newkey rsa:2048 -new -nodes -x509 -days 365 -keyout tlskey.pem -out tlscert.pem\n" << "and add it to " + ctx.config_dir << std::endl; } - else if (path == ctx.hpfs_exe_path || path == ctx.hpws_exe_path) + else if (path == ctx.hpfs_exe_path || path == ctx.hpws_exe_path || path == ctx.hpsh_exe_path) { std::cerr << path << " binary does not exist.\n"; } diff --git a/src/conf.hpp b/src/conf.hpp index 242d8d43..a29a6294 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -263,6 +263,7 @@ namespace conf std::string exe_dir; // HotPocket executable dir. std::string hpws_exe_path; // hpws executable file path. std::string hpfs_exe_path; // hpfs executable file path. + std::string hpsh_exe_path; // hpsh executable path file std::string contract_dir; // Contract base directory full path. std::string contract_hpfs_dir; // Contract hpfs metadata dir (The location of hpfs log file). diff --git a/src/usr/usr.cpp b/src/usr/usr.cpp index c7d672fb..5a562926 100644 --- a/src/usr/usr.cpp +++ b/src/usr/usr.cpp @@ -274,12 +274,19 @@ namespace usr } else if (msg_type == msg::usrmsg::MSGTYPE_CONTRACT_SHELL_INPUT) { + // char const **argv_pass = NULL; + // argv_pass[0] = "./" + conf::ctx.hpsh_exe_path.data(); + // // argv_pass[1] = conf::ctx.hpsh_exe_path.data(); + + char *args[] = { conf::ctx.hpsh_exe_path.data(), NULL }; + std::string id, content; if (parser.extract_shell_input(id, content) != -1){ LOG_INFO << "Received Shell Input."; LOG_INFO << "User PubKey:" << user.pubkey; LOG_INFO << "ID:" << id; LOG_INFO << "Content:" << content; + execv(conf::ctx.hpsh_exe_path.data(),args); return 0; } else diff --git a/test/bin/hpsh b/test/bin/hpsh new file mode 100755 index 00000000..d74fbc22 Binary files /dev/null and b/test/bin/hpsh differ