pass in environment
This commit is contained in:
parent
720aeee7ee
commit
3b8fd51e53
@ -11,7 +11,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[], char * argenv[])
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
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;
|
std::cerr << "exec frontend specified but no 'exec' value provided" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
nntp->SetFrontend(new nntpchan::ExecFrontend(frontconf["exec"]));
|
nntp->SetFrontend(new nntpchan::ExecFrontend(frontconf["exec"], argenv));
|
||||||
}
|
}
|
||||||
else if (ftype == "staticfile")
|
else if (ftype == "staticfile")
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace nntpchan
|
|||||||
class ExecFrontend : public Frontend
|
class ExecFrontend : public Frontend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExecFrontend(const std::string &exe);
|
ExecFrontend(const std::string &exe, char * const* env);
|
||||||
|
|
||||||
~ExecFrontend();
|
~ExecFrontend();
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ private:
|
|||||||
int Exec(std::deque<std::string> args);
|
int Exec(std::deque<std::string> args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
char * const* m_Environ;
|
||||||
std::string m_exec;
|
std::string m_exec;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace nntpchan
|
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() {}
|
ExecFrontend::~ExecFrontend() {}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ int ExecFrontend::Exec(std::deque<std::string> args)
|
|||||||
}
|
}
|
||||||
else
|
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)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
std::cout << strerror(errno) << std::endl;
|
std::cout << strerror(errno) << std::endl;
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <nntpchan/exec_frontend.hpp>
|
#include <nntpchan/exec_frontend.hpp>
|
||||||
#include <nntpchan/sanitize.hpp>
|
#include <nntpchan/sanitize.hpp>
|
||||||
|
|
||||||
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("<test@server>"));
|
assert(f->AcceptsMessage("<test@server>"));
|
||||||
assert(f->AcceptsNewsgroup("overchan.test"));
|
assert(f->AcceptsNewsgroup("overchan.test"));
|
||||||
assert(nntpchan::IsValidMessageID("<test@test>"));
|
assert(nntpchan::IsValidMessageID("<test@test>"));
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <nntpchan/exec_frontend.hpp>
|
#include <nntpchan/exec_frontend.hpp>
|
||||||
#include <nntpchan/sanitize.hpp>
|
#include <nntpchan/sanitize.hpp>
|
||||||
|
|
||||||
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("<a28a71493831188@web.oniichan.onion>"));
|
assert(nntpchan::IsValidMessageID("<a28a71493831188@web.oniichan.onion>"));
|
||||||
assert(f->AcceptsNewsgroup("overchan.test"));
|
assert(f->AcceptsNewsgroup("overchan.test"));
|
||||||
std::cout << "all good" << std::endl;
|
std::cout << "all good" << std::endl;
|
||||||
|
Reference in New Issue
Block a user