From 3b8fd51e53b990fda6da9e8b73f1789f1f4c843c Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 6 May 2018 10:21:58 -0400 Subject: [PATCH] pass in environment --- contrib/backends/nntpchan-daemon/daemon/main.cpp | 4 ++-- .../nntpchan-daemon/include/nntpchan/exec_frontend.hpp | 3 ++- .../backends/nntpchan-daemon/libnntpchan/exec_frontend.cpp | 4 ++-- contrib/backends/nntpchan-daemon/test.cpp | 4 ++-- contrib/backends/nntpchan-daemon/tools/testtool.cpp | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/contrib/backends/nntpchan-daemon/daemon/main.cpp b/contrib/backends/nntpchan-daemon/daemon/main.cpp index 92e71e8..d3da67c 100644 --- a/contrib/backends/nntpchan-daemon/daemon/main.cpp +++ b/contrib/backends/nntpchan-daemon/daemon/main.cpp @@ -11,7 +11,7 @@ #include -int main(int argc, char *argv[]) +int main(int argc, char *argv[], char * argenv[]) { if (argc != 2) { @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) std::cerr << "exec frontend specified but no 'exec' value provided" << std::endl; return 1; } - nntp->SetFrontend(new nntpchan::ExecFrontend(frontconf["exec"])); + nntp->SetFrontend(new nntpchan::ExecFrontend(frontconf["exec"], argenv)); } else if (ftype == "staticfile") { diff --git a/contrib/backends/nntpchan-daemon/include/nntpchan/exec_frontend.hpp b/contrib/backends/nntpchan-daemon/include/nntpchan/exec_frontend.hpp index acf53e9..2930358 100644 --- a/contrib/backends/nntpchan-daemon/include/nntpchan/exec_frontend.hpp +++ b/contrib/backends/nntpchan-daemon/include/nntpchan/exec_frontend.hpp @@ -8,7 +8,7 @@ namespace nntpchan class ExecFrontend : public Frontend { public: - ExecFrontend(const std::string &exe); + ExecFrontend(const std::string &exe, char * const* env); ~ExecFrontend(); @@ -20,6 +20,7 @@ private: int Exec(std::deque args); private: + char * const* m_Environ; std::string m_exec; }; } diff --git a/contrib/backends/nntpchan-daemon/libnntpchan/exec_frontend.cpp b/contrib/backends/nntpchan-daemon/libnntpchan/exec_frontend.cpp index b0267be..ec54b78 100644 --- a/contrib/backends/nntpchan-daemon/libnntpchan/exec_frontend.cpp +++ b/contrib/backends/nntpchan-daemon/libnntpchan/exec_frontend.cpp @@ -7,7 +7,7 @@ namespace nntpchan { -ExecFrontend::ExecFrontend(const std::string &fname) : m_exec(fname) {} +ExecFrontend::ExecFrontend(const std::string &fname, char * const* env) : m_Environ(env), m_exec(fname) {} ExecFrontend::~ExecFrontend() {} @@ -37,7 +37,7 @@ int ExecFrontend::Exec(std::deque args) } else { - int r = execvpe(m_exec.c_str(), (char *const *)cargs, environ); + int r = execvpe(m_exec.c_str(), (char *const *)cargs, m_Environ); if (r == -1) { std::cout << strerror(errno) << std::endl; diff --git a/contrib/backends/nntpchan-daemon/test.cpp b/contrib/backends/nntpchan-daemon/test.cpp index 3b34862..df637cc 100644 --- a/contrib/backends/nntpchan-daemon/test.cpp +++ b/contrib/backends/nntpchan-daemon/test.cpp @@ -3,9 +3,9 @@ #include #include -int main(int, char *[]) +int main(int, char *[], char * argenv[]) { - nntpchan::Frontend_ptr f(new nntpchan::ExecFrontend("./contrib/nntpchan.sh")); + nntpchan::Frontend_ptr f(new nntpchan::ExecFrontend("./contrib/nntpchan.sh", argenv)); assert(f->AcceptsMessage("")); assert(f->AcceptsNewsgroup("overchan.test")); assert(nntpchan::IsValidMessageID("")); diff --git a/contrib/backends/nntpchan-daemon/tools/testtool.cpp b/contrib/backends/nntpchan-daemon/tools/testtool.cpp index f4d0bad..16671ca 100644 --- a/contrib/backends/nntpchan-daemon/tools/testtool.cpp +++ b/contrib/backends/nntpchan-daemon/tools/testtool.cpp @@ -3,9 +3,9 @@ #include #include -int main(int, char *[]) +int main(int, char *[], char * argenv[]) { - nntpchan::Frontend_ptr f(new nntpchan::ExecFrontend("./contrib/nntpchan.sh")); + nntpchan::Frontend_ptr f(new nntpchan::ExecFrontend("./contrib/nntpchan.sh", argenv)); assert(nntpchan::IsValidMessageID("")); assert(f->AcceptsNewsgroup("overchan.test")); std::cout << "all good" << std::endl;