--- sourceforge.net/trunk/rdesktop/rdesktop.c 2003/04/16 13:04:15 367 +++ sourceforge.net/trunk/rdesktop/rdesktop.c 2003/08/01 17:01:58 438 @@ -41,7 +41,7 @@ #endif char title[32] = ""; -char username[16]; +char g_username[16]; char hostname[16]; char keymapname[16]; int keylayout = 0x409; /* Defaults to US keyboard layout */ @@ -49,17 +49,18 @@ be fetched from _NET_WORKAREA */ int height = 600; int tcp_port_rdp = TCP_PORT_RDP; -int server_bpp = 8; +int g_server_bpp = 8; int win_button_size = 0; /* If zero, disable single app mode */ -BOOL bitmap_compression = True; +BOOL g_bitmap_compression = True; BOOL sendmotion = True; -BOOL orders = True; -BOOL encryption = True; -BOOL desktop_save = True; +BOOL g_orders = True; +BOOL g_encryption = True; +BOOL packet_encryption = True; +BOOL g_desktop_save = True; BOOL fullscreen = False; BOOL grab_keyboard = True; BOOL hide_decorations = False; -BOOL use_rdp5 = False; +BOOL g_use_rdp5 = False; extern BOOL owncolmap; #ifdef RDP2VNC @@ -94,6 +95,7 @@ fprintf(stderr, " -f: full-screen mode\n"); fprintf(stderr, " -b: force bitmap updates\n"); fprintf(stderr, " -e: disable encryption (French TS)\n"); + fprintf(stderr, " -E: disable encryption of everything but the logon packet\n"); fprintf(stderr, " -m: do not send motion events\n"); fprintf(stderr, " -C: use private colour map\n"); fprintf(stderr, " -K: keep window manager key bindings\n"); @@ -149,7 +151,7 @@ char password[16]; char shell[128]; char directory[32]; - BOOL prompt_password; + BOOL prompt_password, rdp_retval = False; struct passwd *pw; uint32 flags; char *p; @@ -167,7 +169,7 @@ #define VNCOPT #endif - 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) { switch (c) { @@ -186,7 +188,7 @@ #endif case 'u': - STRNCPY(username, optarg, sizeof(username)); + STRNCPY(g_username, optarg, sizeof(g_username)); username_option = 1; break; @@ -266,13 +268,15 @@ break; case 'b': - orders = False; + g_orders = False; break; case 'e': - encryption = False; + g_encryption = False; + break; + case 'E': + packet_encryption = False; break; - case 'm': sendmotion = False; break; @@ -294,9 +298,9 @@ break; case 'a': - server_bpp = strtol(optarg, NULL, 10); - if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15 - && server_bpp != 24) + g_server_bpp = strtol(optarg, NULL, 10); + if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15 + && g_server_bpp != 24) { error("invalid server bpp\n"); return 1; @@ -304,7 +308,7 @@ break; case '5': - use_rdp5 = True; + g_use_rdp5 = True; break; case 'h': case '?': @@ -337,7 +341,7 @@ return 1; } - STRNCPY(username, pw->pw_name, sizeof(username)); + STRNCPY(g_username, pw->pw_name, sizeof(g_username)); } if (hostname[0] == 0) @@ -366,20 +370,30 @@ #ifdef RDP2VNC rdp2vnc_connect(server, flags, domain, password, shell, directory); + return 0; #else if (!ui_init()) return 1; + /* rdpsnd_init(); */ + /* rdpdr_init(); */ + if (!rdp_connect(server, flags, domain, password, shell, directory)) return 1; + /* By setting encryption to False here, we have an encrypted login + packet but unencrypted transfer of other packets */ + if (!packet_encryption) + g_encryption = False; + + DEBUG(("Connection successful.\n")); memset(password, 0, sizeof(password)); if (ui_create_window()) { - rdp_main_loop(); + rdp_retval = rdp_main_loop(); ui_destroy_window(); } @@ -387,9 +401,13 @@ rdp_disconnect(); ui_deinit(); + if (True == rdp_retval) + return 0; + else + return 2; + #endif - return 0; } #ifdef EGD_SOCKET @@ -549,11 +567,10 @@ /* produce a hex dump */ void -hexdump(unsigned char *p, unsigned int len) +hexdump(unsigned char *p, int len) { unsigned char *line = p; - unsigned int thisline, offset = 0; - int i; + int i, thisline, offset = 0; while (offset < len) { @@ -589,7 +606,7 @@ if (home == NULL) return -1; - path = xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); + path = (char *) xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); fd = open(path, O_RDONLY); @@ -599,7 +616,7 @@ if (fstat(fd, &st)) return -1; - *data = xmalloc(st.st_size); + *data = (uint8 *) xmalloc(st.st_size); length = read(fd, *data, st.st_size); close(fd); xfree(path); @@ -616,7 +633,7 @@ if (home == NULL) return; - path = xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); + path = (char *) xmalloc(strlen(home) + strlen(hostname) + sizeof("/.rdesktop/licence.")); sprintf(path, "%s/.rdesktop", home); if ((mkdir(path, 0700) == -1) && errno != EEXIST) @@ -628,11 +645,11 @@ /* write licence to licence.hostname.new, then atomically rename to licence.hostname */ sprintf(path, "%s/.rdesktop/licence.%s", home, hostname); - tmppath = xmalloc(strlen(path) + sizeof(".new")); + tmppath = (char *) xmalloc(strlen(path) + sizeof(".new")); strcpy(tmppath, path); strcat(tmppath, ".new"); - fd = open(tmppath, O_WRONLY|O_CREAT|O_TRUNC, 0600); + fd = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd == -1) { perror(tmppath);