summaryrefslogtreecommitdiff
path: root/src/anytun-controld.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2010-02-06 18:12:12 +0000
committerChristian Pointner <equinox@anytun.org>2010-02-06 18:12:12 +0000
commit346ef768b1b911a89e3d9bc1b03b442fd85d3739 (patch)
treeb9ff225ea1093c155adcac548a1387fd5bcd860e /src/anytun-controld.cpp
parentremoved NO_EXEC (diff)
introduced posixDaemon as DaemonService for posix targets
some dependency cleanups
Diffstat (limited to 'src/anytun-controld.cpp')
-rw-r--r--src/anytun-controld.cpp21
1 files changed, 10 insertions, 11 deletions
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 <vector>
std::list<std::string> 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;