|
21 |
*/ |
21 |
*/ |
22 |
|
22 |
|
23 |
#include "rdp.h" |
23 |
#include "rdp.h" |
|
|
24 |
#include <sys/stat.h> |
25 |
#include <signal.h> |
24 |
|
26 |
|
25 |
/******************************************************************************/ |
27 |
/******************************************************************************/ |
26 |
/* return error */ |
28 |
/* return error */ |
|
43 |
int DEFAULT_CC |
45 |
int DEFAULT_CC |
44 |
lib_mod_connect(struct mod* mod) |
46 |
lib_mod_connect(struct mod* mod) |
45 |
{ |
47 |
{ |
|
|
48 |
FILE *fdpass; |
49 |
char tmpdir[] = "/tmp"; |
50 |
char script_path[] = "/usr/bin/univention-dvs-sessionbroker-client"; |
51 |
char *passpath; |
52 |
char *command; |
53 |
mode_t cmask; |
54 |
size_t len; |
55 |
|
46 |
DEBUG(("in lib_mod_connect")); |
56 |
DEBUG(("in lib_mod_connect")); |
47 |
/* clear screen */ |
57 |
/* clear screen */ |
48 |
mod->server_begin_update(mod); |
58 |
mod->server_begin_update(mod); |
|
50 |
mod->server_fill_rect(mod, 0, 0, mod->width, mod->height); |
60 |
mod->server_fill_rect(mod, 0, 0, mod->width, mod->height); |
51 |
mod->server_end_update(mod); |
61 |
mod->server_end_update(mod); |
52 |
/* connect */ |
62 |
/* connect */ |
|
|
63 |
len = g_strlen(tmpdir) + 1 + g_strlen(mod->username); |
64 |
passpath = (char*)g_malloc(len + 1, 0); |
65 |
g_snprintf(passpath, len + 2, "%s/%s", tmpdir, mod->username); |
66 |
cmask = umask(S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); |
67 |
fdpass = fopen(passpath,"w"); |
68 |
umask(cmask); |
69 |
fprintf(fdpass, "%s\n",mod->password); |
70 |
fclose(fdpass); |
71 |
len = g_strlen(script_path) + 4 + g_strlen(mod->username) + 4 + g_strlen(passpath) + 3; |
72 |
command = (char*)g_malloc(len + 1, 0); |
73 |
g_snprintf(command, len + 1, "%s -x -u %s -y %s", script_path, mod->username, passpath); |
74 |
mod->pid = (pid_t*) g_malloc(sizeof(pid_t),0); |
75 |
mod->fdpipe = popen(command, "r"); |
76 |
fscanf(mod->fdpipe,"%i\n",mod->pid); |
77 |
fscanf(mod->fdpipe,"%s",mod->ip); |
78 |
g_free(command); command = NULL; |
79 |
// the file passpath has been read at this point, so it may be removed now |
80 |
g_file_delete(passpath); |
81 |
g_free(passpath); |
82 |
passpath = NULL; |
53 |
if (rdp_rdp_connect(mod->rdp_layer, mod->ip, mod->port) == 0) |
83 |
if (rdp_rdp_connect(mod->rdp_layer, mod->ip, mod->port) == 0) |
54 |
{ |
84 |
{ |
55 |
mod->sck = mod->rdp_layer->sec_layer->mcs_layer->iso_layer->tcp_layer->sck; |
85 |
mod->sck = mod->rdp_layer->sec_layer->mcs_layer->iso_layer->tcp_layer->sck; |
|
326 |
int EXPORT_CC |
356 |
int EXPORT_CC |
327 |
mod_exit(struct mod* mod) |
357 |
mod_exit(struct mod* mod) |
328 |
{ |
358 |
{ |
|
|
359 |
kill(*(mod->pid),SIGUSR1); |
360 |
g_free(mod->pid); |
361 |
sleep(2); |
362 |
pclose(mod->fdpipe); |
329 |
DEBUG(("in mod_exit")); |
363 |
DEBUG(("in mod_exit")); |
330 |
g_free(mod); |
364 |
g_free(mod); |
331 |
DEBUG(("out mod_exit")); |
365 |
DEBUG(("out mod_exit")); |