diff -Nuar 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-11-08 09:00:37.274313657 +0100 +++ xrdp-0.5.0~20100303cvs/rdp/rdp.c 2010-11-08 11:08:00.698313766 +0100 @@ -21,6 +21,13 @@ */ #include "rdp.h" +#include +#include +#include +#include +#include +#include +#include /******************************************************************************/ /* return error */ @@ -43,6 +50,12 @@ int DEFAULT_CC lib_mod_connect(struct mod* mod) { + FILE *fdpass; + char tmpdir[] = "/tmp"; + char script_path[] = "/usr/sbin/univention-dvs-sessionbroker-xrdp"; + char *passpath; + char *command; + mode_t cmask; DEBUG(("in lib_mod_connect")); /* clear screen */ mod->server_begin_update(mod); @@ -50,6 +63,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 + 1, "%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); + //strcat(command,cmd); + len = g_strlen(script_path) + 4 + g_strlen(mod->username), + 4 + g_strlen(passpath); + command = (char*)g_malloc(len + 1, 0); + g_snprintf(command, len + 1, "%s -u %s -y %s", script_path, mod->username, passpath); + mod->pid = (pid_t*) malloc(sizeof(pid_t)); + mod->fdpipe = popen(command, "r"); + fscanf(mod->fdpipe,"%i\n",mod->pid); + fscanf(mod->fdpipe,"%s",mod->ip); + free(command); command = NULL; + // the file passpath has been read at this point, so it may be removed now + remove(passpath); + 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 +359,10 @@ int EXPORT_CC mod_exit(struct mod* mod) { + kill(*(mod->pid),SIGUSR1); + free(mod->pid); + sleep(2); + pclose(mod->fdpipe); DEBUG(("in mod_exit")); g_free(mod); DEBUG(("out mod_exit"));