Browse code

CMake: fix broken daemonization and syslog functionality

While CMake is not the official way to build OpenVPN on Linux,
it still make sense to support it. Turns out that

HAVE_SETSID, HAVE_OPENLOG and HAVE_SYSLOG

were not set by CMake configure, and --daemon and syslog
functionality was broken.

While on it, fix compiler error on unused return value of chdir().

Change-Id: I171d55da2be868d961caa1d4491e6f1ed10ebe8a
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230920121519.177949-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27045.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Lev Stipakov authored on 2023/09/20 21:15:19
Showing 3 changed files
... ...
@@ -150,6 +150,7 @@ check_symbol_exists(execve unistd.h HAVE_EXECVE)
150 150
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
151 151
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
152 152
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
153
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
153 154
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
154 155
 
155 156
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
... ...
@@ -218,7 +218,7 @@ don't. */
218 218
 #undef HAVE_NICE
219 219
 
220 220
 /* Define to 1 if you have the `openlog' function. */
221
-#undef HAVE_OPENLOG
221
+#cmakedefine HAVE_OPENLOG
222 222
 
223 223
 /* OpenSSL engine support available */
224 224
 #undef HAVE_OPENSSL_ENGINE
... ...
@@ -258,7 +258,7 @@ don't. */
258 258
 #undef HAVE_SETGROUPS
259 259
 
260 260
 /* Define to 1 if you have the `setsid' function. */
261
-#undef HAVE_SETSID
261
+#cmakedefine HAVE_SETSID
262 262
 
263 263
 /* Define to 1 if you have the `setsockopt' function. */
264 264
 #define HAVE_SETSOCKOPT 1
... ...
@@ -303,7 +303,7 @@ don't. */
303 303
 #undef HAVE_STRSEP
304 304
 
305 305
 /* Define to 1 if you have the `syslog' function. */
306
-#undef HAVE_SYSLOG
306
+#cmakedefine HAVE_SYSLOG
307 307
 
308 308
 /* Define to 1 if you have the <syslog.h> header file. */
309 309
 #cmakedefine HAVE_SYSLOG_H
... ...
@@ -70,7 +70,10 @@ daemon(int nochdir, int noclose)
70 70
 
71 71
     if (!nochdir)
72 72
     {
73
-        chdir("/");
73
+        if (chdir("/") == -1)
74
+        {
75
+            return (-1);
76
+        }
74 77
     }
75 78
 
76 79
     if (!noclose)