From 2e615083e475c7390c667695b9e659fa5ba4da5f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 26 Jul 2012 16:43:36 +0400 Subject: [PATCH] Fix build on FreeBSD 9.1 and Current. Thanks to Anton Yuzjaninov for testing. --- CMakeLists.txt | 1 + config.h.in | 2 ++ src/util.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ffe3ae30..d01a66722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,6 +667,7 @@ FIND_LIBRARY(LIBUTIL_LIBRARY NAMES util PATHS PATH_SUFFIXES lib64 lib IF(LIBUTIL_LIBRARY) LIST(APPEND CMAKE_REQUIRED_LIBRARIES util) CHECK_FUNCTION_EXISTS(pidfile_open HAVE_PIDFILE) + CHECK_FUNCTION_EXISTS(pidfile_fileno HAVE_PIDFILE_FILENO) FIND_FILE(HAVE_LIBUTIL_H NAMES libutil.h PATHS /usr/include /opt/include diff --git a/config.h.in b/config.h.in index c1ac287cb..91c1277ee 100644 --- a/config.h.in +++ b/config.h.in @@ -104,6 +104,8 @@ #cmakedefine HAVE_PIDFILE 1 +#cmakedefine HAVE_PIDFILE_FILENO 1 + #cmakedefine HAVE_SETPROCTITLE 1 #cmakedefine HAVE_GETPAGESIZE 1 diff --git a/src/util.c b/src/util.c index ab81a28a5..a6c56ea95 100644 --- a/src/util.c +++ b/src/util.c @@ -408,7 +408,11 @@ write_pid (struct rspamd_main *main) if (main->is_privilleged) { /* Force root user as owner of pid file */ +#ifdef HAVE_PIDFILE_FILENO + if (fchown (pidfile_fileno (main->pfh), 0, 0) == -1) { +#else if (fchown (main->pfh->pf_fd, 0, 0) == -1) { +#endif msg_err ("cannot chown of pidfile %s to 0:0 user", main->cfg->pid_file); } } -- 2.39.5