41 |
#endif |
#endif |
42 |
|
|
43 |
char title[32] = ""; |
char title[32] = ""; |
44 |
char username[16]; |
char g_username[16]; |
45 |
char hostname[16]; |
char hostname[16]; |
46 |
char keymapname[16]; |
char keymapname[16]; |
47 |
int keylayout = 0x409; /* Defaults to US keyboard layout */ |
int keylayout = 0x409; /* Defaults to US keyboard layout */ |
51 |
int tcp_port_rdp = TCP_PORT_RDP; |
int tcp_port_rdp = TCP_PORT_RDP; |
52 |
int server_bpp = 8; |
int server_bpp = 8; |
53 |
int win_button_size = 0; /* If zero, disable single app mode */ |
int win_button_size = 0; /* If zero, disable single app mode */ |
54 |
BOOL bitmap_compression = True; |
BOOL g_bitmap_compression = True; |
55 |
BOOL sendmotion = True; |
BOOL sendmotion = True; |
56 |
BOOL orders = True; |
BOOL g_orders = True; |
57 |
BOOL encryption = True; |
BOOL g_encryption = True; |
58 |
|
BOOL packet_encryption = True; |
59 |
BOOL desktop_save = True; |
BOOL desktop_save = True; |
60 |
BOOL fullscreen = False; |
BOOL fullscreen = False; |
61 |
BOOL grab_keyboard = True; |
BOOL grab_keyboard = True; |
95 |
fprintf(stderr, " -f: full-screen mode\n"); |
fprintf(stderr, " -f: full-screen mode\n"); |
96 |
fprintf(stderr, " -b: force bitmap updates\n"); |
fprintf(stderr, " -b: force bitmap updates\n"); |
97 |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
98 |
|
fprintf(stderr, " -E: disable encryption of everything but the logon packet\n"); |
99 |
fprintf(stderr, " -m: do not send motion events\n"); |
fprintf(stderr, " -m: do not send motion events\n"); |
100 |
fprintf(stderr, " -C: use private colour map\n"); |
fprintf(stderr, " -C: use private colour map\n"); |
101 |
fprintf(stderr, " -K: keep window manager key bindings\n"); |
fprintf(stderr, " -K: keep window manager key bindings\n"); |
151 |
char password[16]; |
char password[16]; |
152 |
char shell[128]; |
char shell[128]; |
153 |
char directory[32]; |
char directory[32]; |
154 |
BOOL prompt_password; |
BOOL prompt_password, rdp_retval = False; |
155 |
struct passwd *pw; |
struct passwd *pw; |
156 |
uint32 flags; |
uint32 flags; |
157 |
char *p; |
char *p; |
169 |
#define VNCOPT |
#define VNCOPT |
170 |
#endif |
#endif |
171 |
|
|
172 |
while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbemCKT:Dh?54")) != -1) |
while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbeEmCKT:Dh?54")) != -1) |
173 |
{ |
{ |
174 |
switch (c) |
switch (c) |
175 |
{ |
{ |
188 |
#endif |
#endif |
189 |
|
|
190 |
case 'u': |
case 'u': |
191 |
STRNCPY(username, optarg, sizeof(username)); |
STRNCPY(g_username, optarg, sizeof(g_username)); |
192 |
username_option = 1; |
username_option = 1; |
193 |
break; |
break; |
194 |
|
|
268 |
break; |
break; |
269 |
|
|
270 |
case 'b': |
case 'b': |
271 |
orders = False; |
g_orders = False; |
272 |
break; |
break; |
273 |
|
|
274 |
case 'e': |
case 'e': |
275 |
encryption = False; |
g_encryption = False; |
276 |
|
break; |
277 |
|
case 'E': |
278 |
|
packet_encryption = False; |
279 |
break; |
break; |
|
|
|
280 |
case 'm': |
case 'm': |
281 |
sendmotion = False; |
sendmotion = False; |
282 |
break; |
break; |
341 |
return 1; |
return 1; |
342 |
} |
} |
343 |
|
|
344 |
STRNCPY(username, pw->pw_name, sizeof(username)); |
STRNCPY(g_username, pw->pw_name, sizeof(g_username)); |
345 |
} |
} |
346 |
|
|
347 |
if (hostname[0] == 0) |
if (hostname[0] == 0) |
370 |
|
|
371 |
#ifdef RDP2VNC |
#ifdef RDP2VNC |
372 |
rdp2vnc_connect(server, flags, domain, password, shell, directory); |
rdp2vnc_connect(server, flags, domain, password, shell, directory); |
373 |
|
return 0; |
374 |
#else |
#else |
375 |
|
|
376 |
if (!ui_init()) |
if (!ui_init()) |
377 |
return 1; |
return 1; |
378 |
|
|
379 |
|
/* rdpsnd_init(); */ |
380 |
|
/* rdpdr_init(); */ |
381 |
|
|
382 |
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
383 |
return 1; |
return 1; |
384 |
|
|
385 |
|
/* By setting encryption to False here, we have an encrypted login |
386 |
|
packet but unencrypted transfer of other packets */ |
387 |
|
if (!packet_encryption) |
388 |
|
g_encryption = False; |
389 |
|
|
390 |
|
|
391 |
DEBUG(("Connection successful.\n")); |
DEBUG(("Connection successful.\n")); |
392 |
memset(password, 0, sizeof(password)); |
memset(password, 0, sizeof(password)); |
393 |
|
|
394 |
if (ui_create_window()) |
if (ui_create_window()) |
395 |
{ |
{ |
396 |
rdp_main_loop(); |
rdp_retval = rdp_main_loop(); |
397 |
ui_destroy_window(); |
ui_destroy_window(); |
398 |
} |
} |
399 |
|
|
401 |
rdp_disconnect(); |
rdp_disconnect(); |
402 |
ui_deinit(); |
ui_deinit(); |
403 |
|
|
404 |
|
if (True == rdp_retval) |
405 |
|
return 0; |
406 |
|
else |
407 |
|
return 2; |
408 |
|
|
409 |
#endif |
#endif |
410 |
|
|
|
return 0; |
|
411 |
} |
} |
412 |
|
|
413 |
#ifdef EGD_SOCKET |
#ifdef EGD_SOCKET |
606 |
if (home == NULL) |
if (home == NULL) |
607 |
return -1; |
return -1; |
608 |
|
|
609 |
path = (char*)xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
path = (char *) xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
610 |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
611 |
|
|
612 |
fd = open(path, O_RDONLY); |
fd = open(path, O_RDONLY); |
616 |
if (fstat(fd, &st)) |
if (fstat(fd, &st)) |
617 |
return -1; |
return -1; |
618 |
|
|
619 |
*data = (uint8*)xmalloc(st.st_size); |
*data = (uint8 *) xmalloc(st.st_size); |
620 |
length = read(fd, *data, st.st_size); |
length = read(fd, *data, st.st_size); |
621 |
close(fd); |
close(fd); |
622 |
xfree(path); |
xfree(path); |
633 |
if (home == NULL) |
if (home == NULL) |
634 |
return; |
return; |
635 |
|
|
636 |
path = (char*)xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
path = (char *) xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); |
637 |
|
|
638 |
sprintf(path, "%s/.rdesktop", home); |
sprintf(path, "%s/.rdesktop", home); |
639 |
if ((mkdir(path, 0700) == -1) && errno != EEXIST) |
if ((mkdir(path, 0700) == -1) && errno != EEXIST) |
645 |
/* write licence to licence.hostname.new, then atomically rename to licence.hostname */ |
/* write licence to licence.hostname.new, then atomically rename to licence.hostname */ |
646 |
|
|
647 |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); |
648 |
tmppath = (char*)xmalloc(strlen(path) + sizeof(".new")); |
tmppath = (char *) xmalloc(strlen(path) + sizeof(".new")); |
649 |
strcpy(tmppath, path); |
strcpy(tmppath, path); |
650 |
strcat(tmppath, ".new"); |
strcat(tmppath, ".new"); |
651 |
|
|
652 |
fd = open(tmppath, O_WRONLY|O_CREAT|O_TRUNC, 0600); |
fd = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0600); |
653 |
if (fd == -1) |
if (fd == -1) |
654 |
{ |
{ |
655 |
perror(tmppath); |
perror(tmppath); |