Skip to content

Commit

Permalink
Improve portability
Browse files Browse the repository at this point in the history
- Use clearenv() if it exists
- Don't rely on <limits.h> being pulled in by <sys/param.h>
  • Loading branch information
matt335672 committed Jan 9, 2024
1 parent a547a8b commit 06af612
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <linux/unistd.h>
#endif
Expand Down Expand Up @@ -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
}

/*****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06af612

Please sign in to comment.