Add support for passing parameters to Pipe and Remote backend command #714

Closed
Habbie opened this Issue Apr 26, 2013 · 1 comment

Projects

None yet

1 participant

@Habbie
Member
Habbie commented Apr 26, 2013

It is very convenient to pass parameters to Pipe and Remote backend command.

Example patch for this functional

--- a/modules/pipebackend/coprocess.cc
+++ b/modules/pipebackend/coprocess.cc
@@ -9,12 +9,20 @@
 #include <sys/wait.h>
 #include <pdns/misc.hh>
 #include <pdns/ahuexception.hh>
+#include <boost/algorithm/string.hpp>
+#include <vector>

 CoProcess::CoProcess(const string &command,int timeout, int infd, int outfd)
 {
-  const char *argv[2];
-  argv[0]=strdup(command.c_str());
-  argv[1]=0;
+  vector <string> v;
+
+  split(v, command, is_any_of(" "));
+
+  const char *argv[v.size()+1];
+
+  for (size_t n = 0; n < v.size(); n++)
+    argv[n]=strdup(v[n].c_str());
+  argv[v.size()]=0;

   launch(argv,timeout,infd,outfd);
 }

This is a very simple implementation that does not support parameters in quotes and parameters with spaces.

After making these changes it is possible to set one of the following parameter in the configuration file for different backends.

For Remote backend

remote-connection-string=pipe:command=/usr/bin/socat stdio unix-connect:/var/run/pdns/remote.sock

For Pipe backend

pipe-command=/usr/bin/socat stdio unix-connect:/var/run/pdns/pipe.sock

For details please read http://mailman.powerdns.com/pipermail/pdns-users/2013-March/009705.html

@Habbie Habbie was assigned Apr 26, 2013
@Habbie Habbie closed this Apr 26, 2013
@Habbie
Member
Habbie commented Apr 26, 2013

Author: ahu
fixed in 3111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment