summaryrefslogtreecommitdiff
path: root/src/anytun.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-10-04 14:27:58 +0000
committerChristian Pointner <equinox@anytun.org>2009-10-04 14:27:58 +0000
commit5f82116f51ffe2fc4b44abe606f87d576b9b4c9d (patch)
tree058b671e55827f23951a1af0dc5442dab1fd943e /src/anytun.cpp
parentfixed spelling error (diff)
added improved script execution
Diffstat (limited to 'src/anytun.cpp')
-rw-r--r--src/anytun.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index 6789b85..7e009ac 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -29,13 +29,12 @@
* along with anytun. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <boost/bind.hpp>
+#include <boost/thread.hpp>
+#include <boost/assign.hpp>
#include <iostream>
#include <fstream>
-
-#include <boost/bind.hpp>
-#include <cerrno> // for ENOMEM
-
#include "datatypes.h"
#include "log.h"
@@ -76,7 +75,7 @@
#include "cryptinit.hpp"
#include "daemon.hpp"
-#include "sysexec.hpp"
+#include "sysExec.h"
bool disableRouting = false;
@@ -313,14 +312,6 @@ void receiver(TunDevice* dev, PacketSource* src)
}
}
-#ifndef NO_EXEC
-void startPostUpScript(TunDevice* dev)
-{
- cLog.msg(Log::PRIO_NOTICE) << "executing post-up script '" << gOpt.getPostUpScript() << "'";
- execScript(gOpt.getPostUpScript(), dev->getActualName(), dev->getActualNode());
-}
-#endif
-
#ifndef NO_DAEMON
void startSendRecvThreads(PrivInfo& privs, TunDevice* dev, PacketSource* src)
#else
@@ -451,8 +442,11 @@ int main(int argc, char* argv[])
cLog.msg(Log::PRIO_NOTICE) << "dev opened - name '" << dev.getActualName() << "', node '" << dev.getActualNode() << "'";
cLog.msg(Log::PRIO_NOTICE) << "dev type is '" << dev.getTypeString() << "'";
#ifndef NO_EXEC
- if(gOpt.getPostUpScript() != "")
- boost::thread(boost::bind(startPostUpScript, &dev));
+ if(gOpt.getPostUpScript() != "") {
+ cLog.msg(Log::PRIO_NOTICE) << "executing post-up script '" << gOpt.getPostUpScript() << "'";
+ StringVector args = boost::assign::list_of(dev.getActualName())(dev.getActualNode());
+ anytun_exec(gOpt.getPostUpScript(), args);
+ }
#endif
PacketSource* src = new UDPPacketSource(gOpt.getLocalAddr(), gOpt.getLocalPort());