From 346ef768b1b911a89e3d9bc1b03b442fd85d3739 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 6 Feb 2010 18:12:12 +0000 Subject: introduced posixDaemon as DaemonService for posix targets some dependency cleanups --- src/anytun-controld.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/anytun-controld.cpp') diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index 724296d..43196dc 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -46,7 +46,7 @@ #include "resolver.h" #include "syncServer.h" -#include "daemon.hpp" +#include "daemonService.h" #include std::list config_; @@ -77,7 +77,7 @@ void syncListener() int main(int argc, char* argv[]) { - bool daemonized=false; + DaemonService daemon; try { try @@ -114,15 +114,14 @@ int main(int argc, char* argv[]) exit(-1); } - PrivInfo privs(gOpt.getUsername(), gOpt.getGroupname()); - if(gOpt.getDaemonize()) { - daemonize(); - daemonized = true; - } + daemon.initPrivs(gOpt.getUsername(), gOpt.getGroupname()); + if(gOpt.getDaemonize()) + daemon.daemonize(); if(gOpt.getChrootDir() != "") - do_chroot(gOpt.getChrootDir()); - privs.drop(); + daemon.chroot(gOpt.getChrootDir()); + daemon.dropPrivs(); + gSignalController.init(); gResolver.init(); @@ -135,14 +134,14 @@ int main(int argc, char* argv[]) } catch(std::runtime_error& e) { - if(daemonized) + if(daemon.isDaemonized()) cLog.msg(Log::PRIO_ERROR) << "uncaught runtime error, exiting: " << e.what(); else std::cout << "uncaught runtime error, exiting: " << e.what() << std::endl; } catch(std::exception& e) { - if(daemonized) + if(daemon.isDaemonized()) cLog.msg(Log::PRIO_ERROR) << "uncaught exception, exiting: " << e.what(); else std::cout << "uncaught exception, exiting: " << e.what() << std::endl; -- cgit v1.2.3