diff -ru xrdp-0.5.0~20100303cvs.orig/rdp/rdp.c xrdp-0.5.0~20100303cvs/rdp/rdp.c --- xrdp-0.5.0~20100303cvs.orig/rdp/rdp.c 2010-03-04 08:16:34.000000000 +0100 +++ xrdp-0.5.0~20100303cvs/rdp/rdp.c 2010-11-08 14:11:56.000000000 +0100 @@ -21,6 +21,8 @@ */ #include "rdp.h" +#include +#include /******************************************************************************/ /* return error */ @@ -43,6 +45,14 @@ int DEFAULT_CC lib_mod_connect(struct mod* mod) { + FILE *fdpass; + char tmpdir[] = "/tmp"; + char script_path[] = "/usr/bin/univention-dvs-sessionbroker-client"; + char *passpath; + char *command; + mode_t cmask; + size_t len; + DEBUG(("in lib_mod_connect")); /* clear screen */ mod->server_begin_update(mod); @@ -50,6 +60,26 @@ mod->server_fill_rect(mod, 0, 0, mod->width, mod->height); mod->server_end_update(mod); /* connect */ + len = g_strlen(tmpdir) + 1 + g_strlen(mod->username); + passpath = (char*)g_malloc(len + 1, 0); + g_snprintf(passpath, len + 2, "%s/%s", tmpdir, mod->username); + cmask = umask(S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); + fdpass = fopen(passpath,"w"); + umask(cmask); + fprintf(fdpass, "%s\n",mod->password); + fclose(fdpass); + len = g_strlen(script_path) + 4 + g_strlen(mod->username) + 4 + g_strlen(passpath) + 3; + command = (char*)g_malloc(len + 1, 0); + g_snprintf(command, len + 1, "%s -x -u %s -y %s", script_path, mod->username, passpath); + mod->pid = (pid_t*) g_malloc(sizeof(pid_t),0); + mod->fdpipe = popen(command, "r"); + fscanf(mod->fdpipe,"%i\n",mod->pid); + fscanf(mod->fdpipe,"%s",mod->ip); + g_free(command); command = NULL; + // the file passpath has been read at this point, so it may be removed now + g_file_delete(passpath); + g_free(passpath); + passpath = NULL; if (rdp_rdp_connect(mod->rdp_layer, mod->ip, mod->port) == 0) { mod->sck = mod->rdp_layer->sec_layer->mcs_layer->iso_layer->tcp_layer->sck; @@ -326,6 +356,10 @@ int EXPORT_CC mod_exit(struct mod* mod) { + kill(*(mod->pid),SIGUSR1); + g_free(mod->pid); + sleep(2); + pclose(mod->fdpipe); DEBUG(("in mod_exit")); g_free(mod); DEBUG(("out mod_exit")); diff -ru xrdp-0.5.0~20100303cvs.orig/rdp/rdp.h xrdp-0.5.0~20100303cvs/rdp/rdp.h --- xrdp-0.5.0~20100303cvs.orig/rdp/rdp.h 2010-03-04 08:16:34.000000000 +0100 +++ xrdp-0.5.0~20100303cvs/rdp/rdp.h 2010-11-08 13:49:08.000000000 +0100 @@ -27,6 +27,8 @@ #include "ssl_calls.h" #include "xrdp_constants.h" #include "defines.h" +#include +#include struct rdp_brush { @@ -333,6 +335,8 @@ char program[256]; char directory[256]; int keylayout; + FILE * fdpipe; + pid_t * pid; int up_and_running; struct stream* in_s; tbus sck_obj;