From e8538651accc12d6fc4ce1d4828d60be0bf816fc Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Thu, 17 Aug 2023 18:52:56 -0400 Subject: [PATCH] in plugins, pass through environment and use /bin/sh to interpret command so you can have arguments, shell pipelines, etc --- src/PluginEventSifter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PluginEventSifter.h b/src/PluginEventSifter.h index 9ba7541..485ccb7 100644 --- a/src/PluginEventSifter.h +++ b/src/PluginEventSifter.h @@ -155,7 +155,7 @@ struct PluginEventSifter { Pipe inPipe; pid_t pid; - char *argv[] = { nullptr, }; + const char * const argv[] = { "/bin/sh", "-c", pluginCmd.c_str(), nullptr, }; posix_spawn_file_actions_t file_actions; @@ -169,7 +169,7 @@ struct PluginEventSifter { posix_spawn_file_actions_addclose(&file_actions, inPipe.fds[1]) ) throw herr("posix_span_file_actions failed: ", strerror(errno)); - auto ret = posix_spawn(&pid, pluginCmd.c_str(), &file_actions, nullptr, argv, nullptr); + auto ret = posix_spawnp(&pid, "sh", &file_actions, nullptr, (char* const*)(&argv[0]), environ); if (ret) throw herr("posix_spawn failed to invoke '", pluginCmd, "': ", strerror(errno)); running = make_unique(pid, inPipe.saveFd(0), outPipe.saveFd(1), pluginCmd);