From 5de2c7a8c137f5d71c4a23533cd6bcd59920f554 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 23 Dec 2015 14:21:31 +0900 Subject: [PATCH] Detect availability of initgroups --- configure.ac | 1 + src/shrpx_worker_process.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index d2aaa651..152a30e0 100644 --- a/configure.ac +++ b/configure.ac @@ -604,6 +604,7 @@ AC_CHECK_FUNCS([ \ dup2 \ getcwd \ getpwnam \ + initgroups \ localtime_r \ memchr \ memmove \ diff --git a/src/shrpx_worker_process.cc b/src/shrpx_worker_process.cc index c2358c58..04ff2698 100644 --- a/src/shrpx_worker_process.cc +++ b/src/shrpx_worker_process.cc @@ -64,12 +64,14 @@ void drop_privileges( #endif // HAVE_NEVERBLEED ) { if (getuid() == 0 && get_config()->uid != 0) { +#ifdef HAVE_INITGROUPS if (initgroups(get_config()->user.get(), get_config()->gid) != 0) { auto error = errno; LOG(FATAL) << "Could not change supplementary groups: " << strerror(error); exit(EXIT_FAILURE); } +#endif // HAVE_INITGROUPS if (setgid(get_config()->gid) != 0) { auto error = errno; LOG(FATAL) << "Could not change gid: " << strerror(error);