Merge pull request #2909 from matt335672/add_clearenv

Improve portability
This commit is contained in:
matt335672 2024-01-11 14:06:02 +00:00 committed by GitHub
commit ec8dd8ad33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 15 deletions

View File

@ -95,16 +95,11 @@ struct sockaddr_hvs
#endif #endif
#include "os_calls.h" #include "os_calls.h"
#include "limits.h"
#include "string_calls.h" #include "string_calls.h"
#include "log.h" #include "log.h"
#include "xrdp_constants.h" #include "xrdp_constants.h"
/* for clearenv() */
#if defined(_WIN32)
#else
extern char **environ;
#endif
#if defined(__linux__) #if defined(__linux__)
#include <linux/unistd.h> #include <linux/unistd.h>
#endif #endif
@ -3446,14 +3441,16 @@ g_setpgid(int pid, int pgid)
void void
g_clearenv(void) g_clearenv(void)
{ {
#if defined(_WIN32) #if defined(HAVE_CLEARENV)
#else clearenv();
#if defined(BSD) #elif defined(_WIN32)
#elif defined(BSD)
extern char **environ;
environ[0] = 0; environ[0] = 0;
#else #else
extern char **environ;
environ = 0; environ = 0;
#endif #endif
#endif
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -211,7 +211,7 @@ AM_COND_IF([DEVEL_DEBUG],
AC_SEARCH_LIBS([setusercontext], [util]) AC_SEARCH_LIBS([setusercontext], [util])
# Define HAVE_XXXXX macros for some system functions # 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() # The type used by getgrouplist() is the same type used by getgroups()
AC_TYPE_GETGROUPS AC_TYPE_GETGROUPS

View File

@ -68,8 +68,8 @@
# define DEFAULT_BPP 32 # define DEFAULT_BPP 32
#endif #endif
#ifndef DEFAULT_TYPE #ifndef DEFAULT_SESSION_TYPE
# define DEFAULT_TYPE "Xorg" # define DEFAULT_SESSION_TYPE "Xorg"
#endif #endif
/** /**
@ -176,7 +176,7 @@ usage(void)
g_printf(" -g <geometry> Default:%dx%d\n", g_printf(" -g <geometry> Default:%dx%d\n",
DEFAULT_WIDTH, DEFAULT_HEIGHT); DEFAULT_WIDTH, DEFAULT_HEIGHT);
g_printf(" -b <bits-per-pixel> Default:%d\n", DEFAULT_BPP); g_printf(" -b <bits-per-pixel> Default:%d\n", DEFAULT_BPP);
g_printf(" -t <type> Default:%s\n", DEFAULT_TYPE); g_printf(" -t <type> Default:%s\n", DEFAULT_SESSION_TYPE);
g_printf(" -D <directory> Default: $HOME\n" g_printf(" -D <directory> Default: $HOME\n"
" -S <shell> Default: Defined window manager\n" " -S <shell> Default: Defined window manager\n"
" -p <password> TESTING ONLY - DO NOT USE IN PRODUCTION\n" " -p <password> TESTING ONLY - DO NOT USE IN PRODUCTION\n"
@ -290,7 +290,7 @@ parse_program_args(int argc, char *argv[], struct session_params *sp,
sp->width = DEFAULT_WIDTH; sp->width = DEFAULT_WIDTH;
sp->height = DEFAULT_HEIGHT; sp->height = DEFAULT_HEIGHT;
sp->bpp = DEFAULT_BPP; sp->bpp = DEFAULT_BPP;
(void)string_to_session_type(DEFAULT_TYPE, &sp->session_type); (void)string_to_session_type(DEFAULT_SESSION_TYPE, &sp->session_type);
sp->directory = ""; sp->directory = "";
sp->shell = ""; sp->shell = "";