Skip to content

Commit

Permalink
CMake: fix broken daemonization and syslog functionality
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Arne Schwabe <[email protected]>
Acked-by: Frank Lichtenheld <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg27045.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
lstipakov authored and cron2 committed Sep 20, 2023
1 parent 0793eb1 commit 8ae6c48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/compat/compat-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ daemon(int nochdir, int noclose)

if (!nochdir)
{
chdir("/");
if (chdir("/") == -1)
{
return (-1);
}
}

if (!noclose)
Expand Down

0 comments on commit 8ae6c48

Please sign in to comment.