]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
CMake: fix broken daemonization and syslog functionality
authorLev Stipakov <lev@openvpn.net>
Wed, 20 Sep 2023 12:15:19 +0000 (14:15 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 20 Sep 2023 20:30:37 +0000 (22:30 +0200)
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>
CMakeLists.txt
config.h.cmake.in
src/compat/compat-daemon.c

index 7dae6655d2e8ce639bd39943f169beb0f7ab76f6..9de6abab5cfbfd8921892e38b3971a39f9c54b9b 100644 (file)
@@ -150,6 +150,7 @@ check_symbol_exists(execve unistd.h HAVE_EXECVE)
 check_symbol_exists(ftruncate unistd.h HAVE_FTRUNCATE)
 check_symbol_exists(setgid unistd.h HAVE_SETGID)
 check_symbol_exists(setuid unistd.h HAVE_SETUID)
+check_symbol_exists(setsid unistd.h HAVE_SETSID)
 check_symbol_exists(getpeereid unistd.h HAVE_GETPEEREID)
 
 check_symbol_exists(epoll_create sys/epoll.h HAVE_EPOLL_CREATE)
index 4f28917ed51afe2f37c9e9a9cb5ff013b4d371bf..f2cdd393940fa3a809a5e8f3217258a7788c6463 100644 (file)
@@ -218,7 +218,7 @@ don't. */
 #undef HAVE_NICE
 
 /* Define to 1 if you have the `openlog' function. */
-#undef HAVE_OPENLOG
+#cmakedefine HAVE_OPENLOG
 
 /* OpenSSL engine support available */
 #undef HAVE_OPENSSL_ENGINE
@@ -258,7 +258,7 @@ don't. */
 #undef HAVE_SETGROUPS
 
 /* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
+#cmakedefine HAVE_SETSID
 
 /* Define to 1 if you have the `setsockopt' function. */
 #define HAVE_SETSOCKOPT 1
@@ -303,7 +303,7 @@ don't. */
 #undef HAVE_STRSEP
 
 /* Define to 1 if you have the `syslog' function. */
-#undef HAVE_SYSLOG
+#cmakedefine HAVE_SYSLOG
 
 /* Define to 1 if you have the <syslog.h> header file. */
 #cmakedefine HAVE_SYSLOG_H
index aebb8f4efe3adf5faf689d730fa61e688d8e6136..5c6d740865ed75659e541e64db19e25519edefc5 100644 (file)
@@ -70,7 +70,10 @@ daemon(int nochdir, int noclose)
 
     if (!nochdir)
     {
-        chdir("/");
+        if (chdir("/") == -1)
+        {
+            return (-1);
+        }
     }
 
     if (!noclose)