From 977a8617a2d0f5be533f20d75a9ddb0f9e3777e2 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Tue, 14 Aug 2012 20:42:35 +0200
Subject: [PATCH] Fix Config::activate to not check nonexistant options.

---
 lib/config.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/config.cpp b/lib/config.cpp
index 0a2327f0..194d85c2 100644
--- a/lib/config.cpp
+++ b/lib/config.cpp
@@ -248,13 +248,17 @@ bool Util::Config::getBool(std::string optname){
 }
 
 /// Activated the stored config. This will:
-/// - Drop permissions to the stored "username".
-/// - Daemonize the process if "daemonize" is true.
+/// - Drop permissions to the stored "username", if any.
+/// - Daemonize the process if "daemonize" exists and is true.
 /// - Set is_active to true.
 /// - Set up a signal handler to set is_active to false for the SIGINT, SIGHUP and SIGTERM signals.
 void Util::Config::activate(){
-  setUser(getString("username"));
-  if (getBool("daemonize")){Daemonize();}
+  if (vals.isMember("username")){
+    setUser(getString("username"));
+  }
+  if (vals.isMember("daemonize") && getBool("daemonize")){
+    Daemonize();
+  }
   struct sigaction new_action;
   new_action.sa_handler = signal_handler;
   sigemptyset (&new_action.sa_mask);