Check initgroups with AC_CHECK_DECLS for cygwin
This commit is contained in:
parent
685f1772fc
commit
8919c8c139
|
@ -604,7 +604,6 @@ AC_CHECK_FUNCS([ \
|
|||
dup2 \
|
||||
getcwd \
|
||||
getpwnam \
|
||||
initgroups \
|
||||
localtime_r \
|
||||
memchr \
|
||||
memmove \
|
||||
|
@ -626,6 +625,10 @@ AC_CHECK_FUNCS([ \
|
|||
AC_CHECK_FUNC([timerfd_create],
|
||||
[have_timerfd_create=yes], [have_timerfd_create=no])
|
||||
|
||||
# For cygwin: we can link initgroups, so AC_CHECK_FUNCS succeeds, but
|
||||
# cygwin disables initgroups due to feature test macro magic with our
|
||||
# configuration.
|
||||
AC_CHECK_DECLS([initgroups], [], [], [[#include <grp.h>]])
|
||||
|
||||
# Checks for epoll availability, primarily for examples/tiny-nghttpd
|
||||
AX_HAVE_EPOLL([have_epoll=yes], [have_epoll=no])
|
||||
|
|
|
@ -44,4 +44,8 @@
|
|||
|
||||
#define DIE() _Exit(EXIT_FAILURE)
|
||||
|
||||
#if defined(HAVE_DECL_INITGROUPS) && !HAVE_DECL_INITGROUPS
|
||||
inline int initgroups(const char *user, gid_t group) { return 0; }
|
||||
#endif // defined(HAVE_DECL_INITGROUPS) && !HAVE_DECL_INITGROUPS
|
||||
|
||||
#endif // SHRPX_H
|
||||
|
|
|
@ -64,14 +64,12 @@ 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);
|
||||
|
|
Loading…
Reference in New Issue