From 4b91b6003cc6b6a50426e327f4b69ee6e4eb7a48 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sat, 23 Jan 2010 22:58:51 +0000 Subject: fixed init script for differend Config dirs and multiconnection with no default key derivation important: fixed priviledge dropping with multi connection (anytun-controlld), was not working with default config files --- src/anytun-controld.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index c70f770..dd9be12 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -47,17 +47,15 @@ #include "syncServer.h" #include "daemon.hpp" +#include + +std::list config_; void syncOnConnect(SyncTcpConnection * connptr) { - std::ifstream file(gOpt.getFileName().c_str()); - if(file.is_open()) { - std::string line; - while (!file.eof()) { - getline (file,line); - connptr->Send(line); - } - file.close(); + for(std::list::const_iterator it=config_.begin(); it!=config_.end();++it) + { + connptr->Send(*it); } } @@ -106,8 +104,14 @@ int main(int argc, char* argv[]) std::ifstream file( gOpt.getFileName().c_str() ); if( file.is_open() ) + { + std::string line; + while (!file.eof()) { + getline (file,line); + config_.push_back(line); + } file.close(); - else { + } else { std::cout << "ERROR: unable to open file!" << std::endl; exit(-1); } @@ -118,13 +122,11 @@ int main(int argc, char* argv[]) daemonized = true; } - gSignalController.init(); - gResolver.init(); - if(gOpt.getChrootDir() != "") do_chroot(gOpt.getChrootDir()); - privs.drop(); + gSignalController.init(); + gResolver.init(); boost::thread * syncListenerThread; syncListenerThread = new boost::thread(boost::bind(syncListener)); -- cgit v1.2.3