diff --git a/common/os_calls.c b/common/os_calls.c index 765ad47284..d8062f7221 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -95,16 +95,11 @@ struct sockaddr_hvs #endif #include "os_calls.h" +#include "limits.h" #include "string_calls.h" #include "log.h" #include "xrdp_constants.h" -/* for clearenv() */ -#if defined(_WIN32) -#else -extern char **environ; -#endif - #if defined(__linux__) #include #endif @@ -3446,14 +3441,16 @@ g_setpgid(int pid, int pgid) void g_clearenv(void) { -#if defined(_WIN32) -#else -#if defined(BSD) +#if defined(HAVE_CLEARENV) + clearenv(); +#elif defined(_WIN32) +#elif defined(BSD) + extern char **environ; environ[0] = 0; #else + extern char **environ; environ = 0; #endif -#endif } /*****************************************************************************/ diff --git a/configure.ac b/configure.ac index c6cb5ef7c8..c21f68da94 100644 --- a/configure.ac +++ b/configure.ac @@ -211,7 +211,7 @@ AM_COND_IF([DEVEL_DEBUG], AC_SEARCH_LIBS([setusercontext], [util]) # Define HAVE_XXXXX macros for some system functions -AC_CHECK_FUNCS([setusercontext getgrouplist]) +AC_CHECK_FUNCS([setusercontext getgrouplist clearenv]) # The type used by getgrouplist() is the same type used by getgroups() AC_TYPE_GETGROUPS