summaryrefslogtreecommitdiff
path: root/src/anytun-controld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/anytun-controld.cpp')
-rw-r--r--src/anytun-controld.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp
index c73abbd..cff0932 100644
--- a/src/anytun-controld.cpp
+++ b/src/anytun-controld.cpp
@@ -120,12 +120,13 @@ int main(int argc, char* argv[])
std::ifstream file( gOpt.getFileName().c_str() );
if( file.is_open() )
file.close();
- else
- {
+ else {
std::cout << "ERROR: unable to open file!" << std::endl;
exit(-1);
}
+ PrivInfo privs(gOpt.getUsername(), gOpt.getGroupname());
+
std::ofstream pidFile;
if(gOpt.getPidFile() != "") {
pidFile.open(gOpt.getPidFile().c_str());
@@ -134,10 +135,12 @@ int main(int argc, char* argv[])
}
}
- if(gOpt.getChroot())
- chrootAndDrop(gOpt.getChrootDir(), gOpt.getUsername());
- if(gOpt.getDaemonize())
- {
+ if(gOpt.getChrootDir() != "")
+ do_chroot(gOpt.getChrootDir());
+
+ privs.drop();
+
+ if(gOpt.getDaemonize()) {
daemonize();
daemonized = true;
}