changeset 1016:3b583965087a

daemon: make use of priv.h conditional Non-illumos operating systems don't have it. Eventually, it'd be good to implement alternatives to setppriv on systems that don't have it. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 15 Mar 2019 12:02:15 -0400
parents ece307245ba9
children 173eaab07272
files config.cmake config.h.in daemon.c
diffstat 3 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/config.cmake	Mon Oct 28 12:18:28 2019 -0400
+++ b/config.cmake	Fri Mar 15 12:02:15 2019 -0400
@@ -20,7 +20,9 @@
 # SOFTWARE.
 #
 
-include(CheckFunctionExists)
+include(CheckIncludeFiles)
+
+check_include_files(priv.h HAVE_PRIV_H)
 
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 find_package(jeffpc)
--- a/config.h.in	Mon Oct 28 12:18:28 2019 -0400
+++ b/config.h.in	Fri Mar 15 12:02:15 2019 -0400
@@ -23,6 +23,8 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
+#cmakedefine HAVE_PRIV_H 1
+
 /* settings */
 #cmakedefine DEFAULT_SCGI_PORT		${DEFAULT_SCGI_PORT}
 
--- a/daemon.c	Mon Oct 28 12:18:28 2019 -0400
+++ b/daemon.c	Fri Mar 15 12:02:15 2019 -0400
@@ -20,8 +20,12 @@
  * SOFTWARE.
  */
 
+#include "config.h"
+
 #include <syslog.h>
+#ifdef HAVE_PRIV_H
 #include <priv.h>
+#endif
 
 #include <jeffpc/jeffpc.h>
 #include <jeffpc/version.h>
@@ -68,6 +72,7 @@
 
 static int drop_privs()
 {
+#ifdef HAVE_PRIV_H
 	static const char *privs[] = {
 		"file_read",
 		"file_write",
@@ -110,6 +115,11 @@
 	priv_freeset(wanted);
 
 	return ret;
+#else
+	cmn_err(CE_WARN, "No supported way to drop privileges");
+
+	return 0;
+#endif
 }
 
 /* the main daemon process */