Skip to content

Commit

Permalink
Merge pull request neutrinolabs#2909 from matt335672/add_clearenv
Browse files Browse the repository at this point in the history
Improve portability
  • Loading branch information
matt335672 authored Jan 11, 2024
2 parents a547a8b + b80f07d commit ec8dd8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 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
8 changes: 4 additions & 4 deletions sesman/tools/sesrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
# define DEFAULT_BPP 32
#endif

#ifndef DEFAULT_TYPE
# define DEFAULT_TYPE "Xorg"
#ifndef DEFAULT_SESSION_TYPE
# define DEFAULT_SESSION_TYPE "Xorg"
#endif

/**
Expand Down Expand Up @@ -176,7 +176,7 @@ usage(void)
g_printf(" -g <geometry> Default:%dx%d\n",
DEFAULT_WIDTH, DEFAULT_HEIGHT);
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"
" -S <shell> Default: Defined window manager\n"
" -p <password> TESTING ONLY - DO NOT USE IN PRODUCTION\n"
Expand Down Expand Up @@ -290,7 +290,7 @@ parse_program_args(int argc, char *argv[], struct session_params *sp,
sp->width = DEFAULT_WIDTH;
sp->height = DEFAULT_HEIGHT;
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->shell = "";
Expand Down

0 comments on commit ec8dd8a

Please sign in to comment.