diff --git a/common/os_calls.c b/common/os_calls.c index 6739a647c4..05d3aa91eb 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -32,10 +32,6 @@ #include #include #else -/* fix for solaris 10 with gcc 3.3.2 problem */ -#if defined(sun) || defined(__sun) -#define ctid_t id_t -#endif #include #include #include @@ -55,6 +51,7 @@ struct sockaddr_hvs }; #endif #endif +#include #include #include #include @@ -111,8 +108,11 @@ extern char **environ; /* sys/ucred.h needs to be included to use struct xucred * in FreeBSD and OS X. No need for other BSDs except GNU/kFreeBSD */ +/* Solaris uses __sun and needs .h */ #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) #include +#elif defined(__sun) +#include #endif /* for solaris */ @@ -164,11 +164,14 @@ g_mk_socket_path(void) LOG(LOG_LEVEL_ERROR, "g_mk_socket_path: g_create_path(%s) failed", XRDP_SOCKET_PATH); + + LOG(LOG_LEVEL_TRACE, "g_mk_socket_path() returned 1"); return 1; } } g_chmod_hex(XRDP_SOCKET_PATH, 0x1777); } + return 0; } @@ -616,6 +619,7 @@ g_sck_vsock_socket(void) int g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { + LOG_DEVEL(LOG_LEVEL_TRACE, "g_sck_get_peer_cred(%d)", sck); #if defined(SO_PEERCRED) socklen_t ucred_length; struct myucred @@ -628,6 +632,7 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) ucred_length = sizeof(credentials); if (getsockopt(sck, SOL_SOCKET, SO_PEERCRED, &credentials, &ucred_length)) { + LOG_DEVEL(LOG_LEVEL_TRACE, "g_sck_get_peer_cred() returned 1"); return 1; } if (pid != 0) @@ -651,6 +656,7 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) if (getsockopt(sck, SOL_LOCAL, LOCAL_PEERCRED, &xucred, &xucred_length)) { + LOG(LOG_LEVEL_ERROR, "getsockopt() failed: %s", strerror(errno)); return 1; } if (pid != 0) @@ -665,8 +671,66 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { *gid = xucred.cr_gid; } + + LOG_DEVEL(LOG_LEVEL_TRACE, "g_sck_get_peer_cred() returned 0"); + return 0; +#elif defined(LOCAL_PEEREID) + /* Net BSD */ +#ifndef SOL_LOCAL +#define SOL_LOCAL 0 +#endif + struct unpcbid xucred; + unsigned int xucred_length; + xucred_length = sizeof(xucred); + if (getsockopt(sck, SOL_LOCAL, LOCAL_PEEREID, &xucred, &xucred_length)) + { + LOG(LOG_LEVEL_ERROR, "getsockopt() failed: %s", strerror(errno)); + return 1; + } + + if (pid != 0) + { + *pid = xucred.unp_pid; + } + if (uid != 0) + { + *uid = xucred.unp_euid; + } + if (gid != 0) + { + *gid = xucred.unp_egid; + } + + LOG_DEVEL(LOG_LEVEL_TRACE, "g_sck_get_peer_cred() returned 0"); + return 0; +#elif defined(__sun) + /* Solaris, OpenIndiana */ + ucred_t *xucred = NULL; + + if (getpeerucred(sck, &xucred)) + { + LOG(LOG_LEVEL_ERROR, "getsockopt() failed: %s", strerror(errno)); + return 1; + } + + if (pid != 0) + { + *pid = ucred_getpid(xucred); + } + if (uid != 0) + { + *uid = ucred_geteuid(xucred); + } + if (gid != 0) + { + *gid = ucred_getegid(xucred); + } + + ucred_free(xucred); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_sck_get_peer_cred() returned 0"); return 0; #else + LOG(LOG_LEVEL_ERROR, "g_sck_get_peer_cred() has no implementation."); return 1; #endif } @@ -1404,7 +1468,14 @@ g_sleep(int msecs) #if defined(_WIN32) Sleep(msecs); #else - usleep(msecs * 1000); + struct timespec tv; + tv.tv_sec = msecs / 1000; + tv.tv_nsec = ( msecs % 1000 ) * 1000000; + if ( nanosleep(&tv, NULL) == -1 ) + { + LOG(LOG_LEVEL_ERROR, "nanosleep returned error %s", g_get_strerror()); + } + #endif } @@ -3009,6 +3080,7 @@ g_set_alarm(void (*func)(int), unsigned int secs) { (void)alarm(secs); } + return rv; #endif } @@ -3019,6 +3091,7 @@ void g_signal_child_stop(void (*func)(int)) { #if defined(_WIN32) + return; #else struct sigaction action; @@ -3197,6 +3270,7 @@ g_fork(void) #if defined(_WIN32) return 0; #else + LOG_DEVEL(LOG_LEVEL_TRACE, "g_fork()"); int rv; rv = fork(); @@ -3208,6 +3282,7 @@ g_fork(void) g_get_errno(), g_get_strerror()); } + LOG_DEVEL(LOG_LEVEL_TRACE, "g_fork() returned %d", rv); return rv; #endif } @@ -3220,7 +3295,10 @@ g_setgid(int pid) #if defined(_WIN32) return 0; #else - return setgid(pid); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_setgid(%d)", pid); + int retval = setgid(pid); + LOG_DEVEL(LOG_LEVEL_TRACE, "--g_setgid()"); + return retval; #endif } @@ -3233,12 +3311,15 @@ g_initgroups(const char *username) #if defined(_WIN32) return 0; #else + LOG_DEVEL(LOG_LEVEL_TRACE, "g_initgroups(%s)", username); int gid; int error = g_getuser_info_by_name(username, NULL, &gid, NULL, NULL, NULL); if (error == 0) { error = initgroups(username, gid); } + + LOG_DEVEL(LOG_LEVEL_TRACE, "g_initgroups() returned %d", error); return error; #endif } @@ -3364,7 +3445,7 @@ g_waitchild(struct exit_status *e) e->reason = E_XR_UNEXPECTED; e->val = 0; - rv = waitpid(-1, &wstat, WNOHANG); + rv = g_waitpid(-1, &wstat, WNOHANG); if (rv == -1) { @@ -3396,20 +3477,34 @@ g_waitchild(struct exit_status *e) Note that signal handlers are established with BSD-style semantics, so this call is NOT interrupted by a signal */ int -g_waitpid(int pid) +g_waitpid(int pid, int *stat_loc, int options) { #if defined(_WIN32) return 0; #else int rv = 0; - - if (pid < 0) +#if defined(__NetBSD__) || defined(__sun) +again: +#endif + rv = waitpid(pid, stat_loc, options); +#if defined(__NetBSD__) || defined(__sun) + //Retry EINTR for NetBSD and OpenIndiana. + if ( rv == -1 && errno == EINTR ) { - rv = -1; + goto again; } - else +#endif + + if ( rv == -1 ) { - rv = waitpid(pid, 0, 0); + if ( errno == ECHILD ) + { + LOG(LOG_LEVEL_INFO, "waitpid returned %s", g_get_strerror()); + } + else + { + LOG(LOG_LEVEL_ERROR, "waitpid returned %s", g_get_strerror()); + } } return rv; @@ -3434,7 +3529,7 @@ g_waitpid_status(int pid) int status; LOG(LOG_LEVEL_DEBUG, "waiting for pid %d to exit", pid); - rv = waitpid(pid, &status, 0); + rv = g_waitpid(pid, &status, 0); if (rv != -1) { @@ -3451,7 +3546,7 @@ g_waitpid_status(int pid) } else { - LOG(LOG_LEVEL_WARNING, "wait for pid %d returned unknown result", pid); + LOG(LOG_LEVEL_WARNING, "wait for pid %d returned unknown result %s", pid, g_get_strerror()); } } @@ -3482,14 +3577,16 @@ g_setpgid(int pid, int pgid) void g_clearenv(void) { + LOG_DEVEL(LOG_LEVEL_TRACE, "g_clearenv()"); #if defined(_WIN32) #else -#if defined(BSD) +#if defined(BSD) || defined(__sun) || defined(__APPLE__) environ[0] = 0; #else environ = 0; #endif #endif + LOG_DEVEL(LOG_LEVEL_TRACE, "--g_clearenv()"); } /*****************************************************************************/ @@ -3500,7 +3597,10 @@ g_setenv(const char *name, const char *value, int rewrite) #if defined(_WIN32) return 0; #else - return setenv(name, value, rewrite); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_setenv(%s, %s, %d)", name, value, rewrite); + int retval = setenv(name, value, rewrite); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_setenv() returned %d", retval); + return retval; #endif } @@ -3604,7 +3704,14 @@ g_getuser_info_by_name(const char *username, int *uid, int *gid, if (gecos != 0) { - *gecos = g_strdup(pwd_1->pw_gecos); + if ( pwd_1->pw_gecos == NULL ) + { + *gecos = g_strdup(""); + } + else + { + *gecos = g_strdup(pwd_1->pw_gecos); + } } } } @@ -3652,7 +3759,14 @@ g_getuser_info_by_uid(int uid, char **username, int *gid, if (gecos != 0) { - *gecos = g_strdup(pwd_1->pw_gecos); + if ( pwd_1->pw_gecos == NULL ) + { + *gecos = g_strdup(""); + } + else + { + *gecos = g_strdup(pwd_1->pw_gecos); + } } return 0; @@ -4013,7 +4127,10 @@ g_shmdt(const void *shmaddr) int g_gethostname(char *name, int len) { - return gethostname(name, len); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_gethostname(name, %d)", len); + int retval = gethostname(name, len); + LOG_DEVEL(LOG_LEVEL_TRACE, "g_gethostname(%s, %d) returned %d", name, len, retval); + return retval; } static unsigned char g_reverse_byte[0x100] = diff --git a/common/os_calls.h b/common/os_calls.h index 6579d1163a..e5f37547bc 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -351,7 +351,7 @@ int g_setlogin(const char *name); int g_set_allusercontext(int uid); #endif int g_waitchild(struct exit_status *e); -int g_waitpid(int pid); +int g_waitpid(int pid, int *stat_loc, int options); struct exit_status g_waitpid_status(int pid); /* * Sets the process group ID of the indicated process to the specified value. diff --git a/configure.ac b/configure.ac index 2f3d69384d..28a6f35dc3 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,9 @@ case $host_os in *darwin*) macos=yes ;; + *solaris*) + solaris=yes + ;; esac AM_CONDITIONAL(LINUX, [test "x$linux" = xyes]) @@ -46,6 +49,7 @@ AM_CONDITIONAL(FREEBSD, [test "x$freebsd" = xyes]) AM_CONDITIONAL(OPENBSD, [test "x$openbsd" = xyes]) AM_CONDITIONAL(NETBSD, [test "x$netbsd" = xyes]) AM_CONDITIONAL(MACOS, [test "x$macos" = xyes]) +AM_CONDITIONAL(SOLARIS, [test "x$solaris" = xyes]) AC_CHECK_SIZEOF([int]) AC_CHECK_SIZEOF([long]) @@ -85,10 +89,10 @@ AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests], [Ensure dependencies for the tests are installed]), [ensure_tests_deps=yes], []) -AC_ARG_ENABLE(pam, AS_HELP_STRING([--enable-pam], - [Build PAM support (default: yes)]), - [], [enable_pam=yes]) -AM_CONDITIONAL(SESMAN_NOPAM, [test x$enable_pam != xyes]) +AC_ARG_ENABLE(nopam, AS_HELP_STRING([--enable-nopam], + [Build PAM support (default: no)]), + [enable_nopam=yes], [enable_nopam=no]) +AM_CONDITIONAL(SESMAN_NOPAM, [test x$enable_nopam = xyes]) AC_ARG_ENABLE(vsock, AS_HELP_STRING([--enable-vsock], [Build AF_VSOCK support (default: no)]), [], [enable_vsock=no]) @@ -99,7 +103,7 @@ AC_ARG_ENABLE(ipv6only, AS_HELP_STRING([--enable-ipv6only], [Build IPv6-only (default: no)]), [], [enable_ipv6only=no]) AC_ARG_ENABLE(kerberos, AS_HELP_STRING([--enable-kerberos], - [Build kerberos support (prefer --enable-pam if available) (default: no)]), + [Build kerberos support (default: no)]), [], [enable_kerberos=no]) AC_ARG_ENABLE(bsd, AS_HELP_STRING([--enable-bsd], [Build BSD auth support (default: no)]), @@ -289,6 +293,11 @@ if test x$use_imlib2 = xyes; then AC_DEFINE([USE_IMLIB2],1, [Compile with imlib2 support]) fi +if test x$solaris = xyes; then + CFLAGS="${CFLAGS} -D_XOPEN_SOURCE=600" + AC_SUBST(CFLAGS) +fi + # Find freetype2 # # The modversion used by pkgcheck does not correspond to the @@ -336,12 +345,12 @@ auth_cnt=0 auth_mech="Builtin" AUTHMOD_OBJ=verify_user.lo AUTHMOD_LIB=-lcrypt -if test x$enable_pam = xyes +if test x$enable_nopam = xyes then auth_cnt=`expr $auth_cnt + 1` - auth_mech="PAM" - AUTHMOD_OBJ=verify_user_pam.lo - AUTHMOD_LIB=-lpam + auth_mech="No PAM" + AUTHMOD_OBJ=verify_user.lo + AUTHMOD_LIB= fi if test x$bsd = xtrue then @@ -364,17 +373,23 @@ then AUTHMOD_OBJ=verify_user_pam_userpass.lo AUTHMOD_LIB="-lpam -lpam_userpass" fi - +if test $auth_cnt -eq 0 +then + auth_cnt=`expr $auth_cnt + 1` + auth_mech="Enable PAM" + AUTHMOD_OBJ=verify_user_pam.lo + AUTHMOD_LIB=-lpam +fi if test $auth_cnt -gt 1 then - AC_MSG_ERROR([--enable-pam, --enable-bsd, --enable-pamuserpass and --enable-kerberos are mutually exclusive]) + AC_MSG_ERROR([--enable-nopam, --enable-bsd, --enable-pamuserpass and --enable-kerberos are mutually exclusive]) fi AC_SUBST([AUTHMOD_OBJ]) AC_SUBST([AUTHMOD_LIB]) # checking if pam should be autodetected. -if test "x$enable_pam" = "xyes" +if test "x$enable_nopam" = "xno" then if test -z "$enable_bsd" then @@ -583,6 +598,8 @@ AC_CONFIG_FILES([ instfiles/pam.d/Makefile instfiles/pulse/Makefile instfiles/rc.d/Makefile + instfiles/method/Makefile + instfiles/manifest/Makefile keygen/Makefile waitforx/Makefile libipm/Makefile @@ -661,6 +678,7 @@ echo " unit tests performable $perform_unit_tests" echo "" echo " CFLAGS = $CFLAGS" echo " LDFLAGS = $LDFLAGS" +echo " CPPFLAGS = $CPPFLAGS" # xrdp_configure_options.h will be written to the build directory, not the source directory echo '#define XRDP_CONFIGURE_OPTIONS \' > ./xrdp_configure_options.h diff --git a/instfiles/Makefile.am b/instfiles/Makefile.am index a318ed8f92..947217b986 100644 --- a/instfiles/Makefile.am +++ b/instfiles/Makefile.am @@ -79,6 +79,19 @@ SUBDIRS += \ pulse endif +if NETBSD +SUBDIRS += \ + pam.d \ + rc.d \ + pulse +endif + +if SOLARIS +SUBDIRS += \ + manifest \ + method +endif + if MACOS SUBDIRS += pam.d endif @@ -101,3 +114,12 @@ install-data-hook: sed -i '' 's|%%PREFIX%%|$(prefix)|g' $(DESTDIR)$(sysconfdir)/rc.d/xrdp \ $(DESTDIR)$(sysconfdir)/rc.d/xrdp-sesman endif + +if NETBSD +# must be tab below +install-data-hook: + sed -i 's|%%PREFIX%%/sbin|$(prefix)/sbin|g' $(DESTDIR)$(sysconfdir)/rc.d/xrdp \ + $(DESTDIR)$(sysconfdir)/rc.d/xrdp-sesman + sed -i 's|%%PREFIX%%||g' $(DESTDIR)$(sysconfdir)/rc.d/xrdp \ + $(DESTDIR)$(sysconfdir)/rc.d/xrdp-sesman +endif diff --git a/instfiles/manifest/Makefile.am b/instfiles/manifest/Makefile.am new file mode 100644 index 0000000000..e702630df4 --- /dev/null +++ b/instfiles/manifest/Makefile.am @@ -0,0 +1,3 @@ +startscriptdir = /lib/svc/manifest/site + +dist_startscript_SCRIPTS = xrdp.xml xrdp-sesman.xml diff --git a/instfiles/manifest/xrdp-sesman.xml b/instfiles/manifest/xrdp-sesman.xml new file mode 100644 index 0000000000..b8f0ae6ad5 --- /dev/null +++ b/instfiles/manifest/xrdp-sesman.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/instfiles/manifest/xrdp.xml b/instfiles/manifest/xrdp.xml new file mode 100644 index 0000000000..e687eaa825 --- /dev/null +++ b/instfiles/manifest/xrdp.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/instfiles/method/Makefile.am b/instfiles/method/Makefile.am new file mode 100644 index 0000000000..89c9d98f7a --- /dev/null +++ b/instfiles/method/Makefile.am @@ -0,0 +1,3 @@ +startscriptdir = /lib/svc/method + +dist_startscript_SCRIPTS = xrdp xrdp-sesman diff --git a/instfiles/method/xrdp b/instfiles/method/xrdp new file mode 100755 index 0000000000..4b4d0e9cba --- /dev/null +++ b/instfiles/method/xrdp @@ -0,0 +1,85 @@ +#!/bin/bash +. /lib/svc/share/smf_include.sh + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib +export PATH=$PATH:$ORACLE_HOME/bin + +VERBOSE= +NAME=xrdp +FULLNAME=/usr/local/sbin/$NAME +TIMEOUT=15 + +log_if_verbose() +{ + if [ -n "$VERBOSE" ]; then + echo $@ + fi +} + +waitFor() { + name=$1 + timeout=$2 + + let i=0 + + # Loop until we are certain that the process has been stopped + while [ $i -lt $timeout ]; do + pgrep -xf $name > /dev/null + if [ $? -ne 0 ]; then + break; + fi + + let i=i+1 + sleep 1 + log_if_verbose "$i seconds" + done + + pgrep -xf $name > /dev/null + return $? +} + +function start +{ + $FULLNAME +} + +function stop +{ + log_if_verbose "Sending TERM to $NAME" + pkill -TERM -xf $FULLNAME + + waitFor $FULLNAME $TIMEOUT + + if [ $? -eq 0 ]; then + log_if_verbose "Sending KILL to $NAME" + pkill -KILL -xf $FULLNAME + waitFor $FULLNAME 1 + rm -f /var/run/$NAME.pid + fi + + return $? +} + +function refresh +{ + log_if_verbose "Refresh not implemented." + return 1; +} + +case $1 in + start) start ;; + stop) stop ;; + refresh) refresh;; + + *) echo "Usage: $0 { start | stop | refresh }" >&2 + exit $SMF_EXIT_ERR_FATAL + ;; +esac + +retval=$? + +if [ $? -eq 0 ]; then + retval=$SMF_EXIT_OK +fi; + +exit $SMF_EXIT_OK diff --git a/instfiles/method/xrdp-sesman b/instfiles/method/xrdp-sesman new file mode 100755 index 0000000000..07c8d7ce44 --- /dev/null +++ b/instfiles/method/xrdp-sesman @@ -0,0 +1,87 @@ +#!/bin/bash +. /lib/svc/share/smf_include.sh + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib +export PATH=$PATH:$ORACLE_HOME/bin + +VERBOSE=true +NAME=xrdp-sesman +FULLNAME=/usr/local/sbin/$NAME +TIMEOUT=5 + +log_if_verbose() +{ + if [ -n "$VERBOSE" ]; then + echo $@ + fi +} + +waitFor() { + name=$1 + timeout=$2 + + let i=0 + + # Loop until we are certain that the process has been stopped + while [ $i -lt $timeout ]; do + pgrep -xf $name > /dev/null + if [ $? -eq 0 ]; then + break; + fi + + let i=i+1 + sleep 1 + log_if_verbose "$i seconds" + done + + pgrep -xf $name > /dev/null + return $? +} + +function start +{ + $FULLNAME +} + +function stop +{ + log_if_verbose "Sending TERM to $NAME" + pkill -TERM -xf $FULLNAME + + waitFor $FULLNAME $TIMEOUT + retval=$? + + if [ $? -ne 0 ]; then + log_if_verbose "Sending KILL to $NAME" + pkill -KILL -xf $FULLNAME + waitFor $FULLNAME 1 + retval=$? + rm -f /var/run/$NAME.pid + fi + + return $retval +} + +function refresh +{ + log_if_verbose "Refresh not implemented." + return 1; +} + +case $1 in + start) start ;; + stop) stop ;; + refresh) refresh;; + + *) echo "Usage: $0 { start | stop | refresh }" >&2 + exit $SMF_EXIT_ERR_FATAL + ;; +esac + +retval=$? + +if [ $? -eq 0 ]; then + retval=$SMF_EXIT_OK +fi; + +exit $SMF_EXIT_OK diff --git a/sesman/Makefile.am b/sesman/Makefile.am index 542186d87d..5acb834403 100644 --- a/sesman/Makefile.am +++ b/sesman/Makefile.am @@ -65,3 +65,10 @@ SUBDIRS = \ sesexec \ tools \ chansrv + +if SOLARIS +# must be tab below. SOLARIS Xorg does not allow logfile parameter. +install-data-hook: + sed -i 's|param=-logfile|;param=-logfile|g' $(DESTDIR)$(sysconfdir)/xrdp/sesman.ini + sed -i 's|param=.xorgxrdp.%s.log|;param=.xorgxrdp.%s.log|g' $(DESTDIR)$(sysconfdir)/xrdp/sesman.ini +endif diff --git a/sesman/libsesman/verify_user_pam.c b/sesman/libsesman/verify_user_pam.c index ca5136688d..34b37917a5 100644 --- a/sesman/libsesman/verify_user_pam.c +++ b/sesman/libsesman/verify_user_pam.c @@ -503,9 +503,10 @@ auth_end(struct auth_info *auth_info) pam_end(auth_info->ph, PAM_SUCCESS); auth_info->ph = 0; } + + g_free(auth_info); } - g_free(auth_info); return 0; } diff --git a/sesman/sesexec/sesexec.c b/sesman/sesexec/sesexec.c index 563a0695dd..95501b49f3 100644 --- a/sesman/sesexec/sesexec.c +++ b/sesman/sesexec/sesexec.c @@ -220,6 +220,11 @@ set_sigchld_event(int sig) { g_set_wait_obj(g_sigchld_event); } + +#ifdef __sun + /* On solaris we need to re-register for the signal hander. */ + g_signal_child_stop(set_sigchld_event); +#endif } /******************************************************************************/ @@ -241,6 +246,7 @@ sesexec_terminate_main_loop(int status) static void process_sigchld_event(void) { + LOG(LOG_LEVEL_TRACE, "process_sigchld_event()"); struct exit_status e; int pid; @@ -249,6 +255,7 @@ process_sigchld_event(void) { session_process_child_exit(g_session_data, pid, &e); } + LOG(LOG_LEVEL_TRACE, "process_sigchld_event() returned"); } /******************************************************************************/ diff --git a/sesman/sesexec/session.c b/sesman/sesexec/session.c index 900b394333..0ac2cdf76c 100644 --- a/sesman/sesexec/session.c +++ b/sesman/sesexec/session.c @@ -641,7 +641,7 @@ session_start_wrapped(struct login_info *login_info, /* Kill it anyway in case it did start and we just failed to * pick up on it */ g_sigterm(display_pid); - g_waitpid(display_pid); + g_waitpid(display_pid, 0, 0); } else { @@ -654,7 +654,7 @@ session_start_wrapped(struct login_info *login_info, if (window_manager_pid < 0) { g_sigterm(display_pid); - g_waitpid(display_pid); + g_waitpid(display_pid, 0, 0); } else { diff --git a/sesman/sesexec/xwait.c b/sesman/sesexec/xwait.c index 9a7bd376f6..44010561b0 100644 --- a/sesman/sesexec/xwait.c +++ b/sesman/sesexec/xwait.c @@ -56,18 +56,20 @@ log_waitforx_messages(FILE *dp) * Contruct the command to run to check the X server */ static struct list * -make_xwait_command(int display) +make_xwait_command(int display, int wait) { const char exe[] = XRDP_LIBEXEC_PATH "/waitforx"; char displaystr[64]; + char waitstr[64]; struct list *cmd = list_create(); if (cmd != NULL) { cmd->auto_free = 1; g_snprintf(displaystr, sizeof(displaystr), ":%d", display); + g_snprintf(waitstr, sizeof(waitstr), "%d", wait); - if (!list_add_strdup_multi(cmd, exe, "-d", displaystr, NULL)) + if (!list_add_strdup_multi(cmd, exe, "-d", displaystr, "-w", waitstr, NULL)) { list_delete(cmd); cmd = NULL; @@ -86,7 +88,7 @@ wait_for_xserver(uid_t uid, { enum xwait_status rv = XW_STATUS_MISC_ERROR; int fd[2] = {-1, -1}; - struct list *cmd = make_xwait_command(display); + struct list *cmd = make_xwait_command(display, 10); // Construct the command to execute to check the display diff --git a/sesman/tools/Makefile.am b/sesman/tools/Makefile.am index a6803bb3f1..ce19b63067 100644 --- a/sesman/tools/Makefile.am +++ b/sesman/tools/Makefile.am @@ -32,6 +32,10 @@ xrdp_dis_SOURCES = \ xrdp_dis_LDADD = \ $(top_builddir)/common/libcommon.la +if SOLARIS + xrdp_dis_LDADD += -lsocket +endif + xrdp_xcon_SOURCES = \ xcon.c @@ -43,6 +47,10 @@ xrdp_sesrun_LDADD = \ $(top_builddir)/common/libcommon.la \ $(top_builddir)/libipm/libipm.la +if SOLARIS + xrdp_sesrun_LDADD += -lsocket +endif + xrdp_sesadmin_LDADD = \ $(top_builddir)/sesman/libsesman/libsesman.la \ $(top_builddir)/common/libcommon.la \ diff --git a/tools/devel/tcp_proxy/Makefile.am b/tools/devel/tcp_proxy/Makefile.am index 6c1e534336..85ab24e0c0 100644 --- a/tools/devel/tcp_proxy/Makefile.am +++ b/tools/devel/tcp_proxy/Makefile.am @@ -11,3 +11,7 @@ tcp_proxy_SOURCES = \ tcp_proxy_LDADD = \ $(top_builddir)/common/libcommon.la \ $(DLOPEN_LIBS) + +if SOLARIS + tcp_proxy_LDADD += -lsocket +endif diff --git a/waitforx/waitforx.c b/waitforx/waitforx.c index b9dabedfe2..963c113de6 100644 --- a/waitforx/waitforx.c +++ b/waitforx/waitforx.c @@ -21,20 +21,23 @@ alarm_handler(int signal_num) * * Prefix the message with a newline in case another message * has been partly output */ - const char msg[] = "\nTimed out waiting for RandR outputs\n"; - g_file_write(1, msg, g_strlen(msg)); - exit(XW_STATUS_TIMED_OUT); + + if ( signal_num == SIGALRM ) + { + const char msg[] = "\nTimed out waiting for RandR outputs\n"; + g_file_write(1, msg, g_strlen(msg)); + exit(XW_STATUS_TIMED_OUT); + } } /*****************************************************************************/ static Display * -open_display(const char *display) +open_display(const char *display, const unsigned int wait) { Display *dpy = NULL; - unsigned int wait = ATTEMPTS; unsigned int n; - for (n = 1; n <= ATTEMPTS; ++n) + for (n = 1; n <= wait; ++n) { printf("Opening display %s. Attempt %u of %u\n", display, n, wait); dpy = XOpenDisplay(display); @@ -57,12 +60,11 @@ open_display(const char *display) * @return 0 if/when outputs are available, 1 otherwise */ static int -wait_for_r_and_r(Display *dpy) +wait_for_r_and_r(Display *dpy, unsigned int wait) { int error_base = 0; int event_base = 0; unsigned int outputs = 0; - unsigned int wait = ATTEMPTS; unsigned int n; XRRScreenResources *res = NULL; @@ -104,7 +106,7 @@ wait_for_r_and_r(Display *dpy) static void usage(const char *argv0, int status) { - printf("Usage: %s -d display\n", argv0); + printf("Usage: %s -d display [-w waittime]\n", argv0); exit(status); } @@ -115,19 +117,23 @@ main(int argc, char **argv) const char *display_name = NULL; int opt; int status = XW_STATUS_MISC_ERROR; + unsigned int wait = ATTEMPTS; Display *dpy = NULL; /* Disable stdout buffering so any messages are passed immediately * to sesman */ setvbuf(stdout, NULL, _IONBF, 0); - while ((opt = getopt(argc, argv, "d:")) != -1) + while ((opt = getopt(argc, argv, "d:w:")) != -1) { switch (opt) { case 'd': display_name = optarg; break; + case 'w': + wait = atoi(optarg); + break; default: /* '?' */ usage(argv[0], status); } @@ -140,7 +146,7 @@ main(int argc, char **argv) g_set_alarm(alarm_handler, ALARM_WAIT); - dpy = open_display(display_name); + dpy = open_display(display_name, wait); if (!dpy) { printf("Unable to open display %s\n", display_name); @@ -148,7 +154,7 @@ main(int argc, char **argv) } else { - if (wait_for_r_and_r(dpy) == 0) + if (wait_for_r_and_r(dpy, wait) == 0) { status = XW_STATUS_OK; } diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am index 432fdf2da0..f5e332f43a 100644 --- a/xrdp/Makefile.am +++ b/xrdp/Makefile.am @@ -110,3 +110,4 @@ dist_xrdppkgdata_DATA = \ sans-18.fv1 \ cursor0.cur \ cursor1.cur +