From 320f69a3b577c662a88b06ab5701970f7ea0d6a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eckl=2C=20M=C3=A1t=C3=A9?= <ecklm94@gmail.com>
Date: Fri, 27 May 2016 09:45:34 +0200
Subject: [PATCH] =?UTF-8?q?F=C5=91leg=20man=20=20de=20p=C3=A1r=20kieg?=
 =?UTF-8?q?=C3=A9sz=C3=ADt=C3=A9s=20is?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 main.cpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/main.cpp b/main.cpp
index da36dbd..536665d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -22,6 +22,7 @@
 #include "include/command.h"
 
 #define COMM_SOCK_PATH "/var/run/ecklm-dns/"
+#define RUNNING_USER "dnsuser"
 
 logger log_on_demand;
 bool verbose = false;
@@ -97,7 +98,12 @@ int main(int argc, char *argv[])
 	if(verbose)
 			log_on_demand(LOG_DEBUG, "Current working directory is %s.", working_dir);
 
-	struct passwd *new_uid = getpwnam("dnsuser");
+	passwd *new_uid = getpwnam(RUNNING_USER);
+	if(new_uid == NULL)
+	{
+		log_on_demand(LOG_ERR, "There is no such user as %s.", RUNNING_USER);
+		exit(EXIT_FAILURE);
+	}
 
 	if(chroot(working_dir) < 0)
 	{
@@ -183,7 +189,11 @@ int main(int argc, char *argv[])
 
 void print_help() {
 	printf(R"(Usage: Runs in foreground mode by default.
-For more info look at the man page.
+There must be a working directory which needs to be available
+through the whole life of the process and to which the process will chroot.
+Therefore and some other reason the server must be run with root privileges.
+
+In daemon mode, the working directory must contain the dns.db file.
 
 Options:
 	-d Run as daemon
@@ -191,7 +201,7 @@ Options:
 	-s Statistics from daemon
 	-k Kill daemon
 	-w workind_dir Set working directory. Absolute path needed.
-		If not the actual PWD will be used.
+		If not set, the actual PWD will be used.
 	-v Verbose
 	-h help
 )");
-- 
GitLab