$OpenBSD: patch-config_cpp,v 1.3 2017/05/24 18:49:31 espie Exp $

Index: config.cpp
--- config.cpp.orig
+++ config.cpp
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 #include <fstream>
 #include <sstream>
 #include "config.h"
+#include <stdlib.h>
+#include <stdio.h>
 //------------------------------------------------------------------------------
 using namespace std;
 //-----------------------------------------------------------------------------
@@ -155,7 +157,18 @@ Config::~Config()
 //-----------------------------------------------------------------------------
 bool Config::save()
 {
-    std::ofstream file("vodovod.conf");
+    const char	*home;
+    char	 path[PATH_MAX];
+    int		 n;
+
+    if ((home = getenv("HOME")) == NULL)
+        return false;
+
+    if ((n = snprintf(path, PATH_MAX, "%s/.vodovod.conf", home) >= PATH_MAX) ||
+      n <= 0)
+        return false;
+
+    std::ofstream file(path);
     if (!file)
         return false;
 
@@ -171,7 +184,18 @@ bool Config::save()
 // this gets called from main() so we're sure config.ini is in the right place
 bool Config::load()
 {
-    std::ifstream file("vodovod.conf");
+    const char	*home;
+    char	 path[PATH_MAX];
+    int		 n;
+
+    if ((home = getenv("HOME")) == NULL)
+        return false;
+
+    if ((n = snprintf(path, PATH_MAX, "%s/.vodovod.conf", home) >= PATH_MAX) ||
+      n <= 0)
+        return false;
+
+    std::ifstream file(path);
     if (!file)
         return false;
 
