Re: [ rdesktop-Bugs-2817779 ] Can't connect to WinServ 2008 SP2: "internal license error"
Thomas Uhle <[email protected]> Fri, 23 Sep 2011 19:55:48 +0200 (CEST)
| Newsgroups | gmane.network.rdesktop.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 22 Sep 2011, Peter Åstrand wrote: > This looks very good, thanks for your work on this! We will try this patch and > assuming there are no problems we will commit it. > > Best regards, > Peter Thank you, I am pleased to read this. Anyway, there was still a minor protocol issue and, additionally, an issue with the local licence store in ~/.rdesktop/ when connecting to a second terminal server. Both issues can be fixed by the patch that is attached to this e-mail. This patch has to be applied in addition to my patch from Tuesday, i.e., after the "old" patch has been applied. The minor issue is that the licence protocol version is no longer 2 but 3 since RDP 5.0 and newer. Therefore, I let g_use_rdp5 decide which version number is set. The other issue arises if there is already a CAL for the current client stored in ~/.rdesktop/ and you are trying to connect to another terminal server than the one from whom you have got the present CAL. In this case rdesktop presents the wrong licence to the terminal server. My suggestion is to have separate subdirectories for all the CALs of every terminal server, e.g., ~/.rdesktop/licences/win2008r2-ts1/cal_rdpclient1 ~/.rdesktop/licences/win2008r2-ts1/cal_rdpclient2 ~/.rdesktop/licences/win2008r2-ts2/cal_rdpclient1 ~/.rdesktop/licences/win2008r2-ts2/cal_rdpclient2 and so on and so forth. Therefore, I had to amend the functions load_licence() and save_licence(), in which the terminal server's name is now needed in addition. To have only a few changes in the code, I decided to change the scope of the variable 'server' in main() to be globally accessible, renamed it to 'g_server' and, finally, exchanged 'server' by 'g_server' wherever 'server' had been used before. I hope this closes these licensing issues now. Best regards, Thomas ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 _______________________________________________ rdesktop-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdesktop-devel
rdesktop-licence-patch2.diff
(text/x-patch, 5.3 KB)
--- licence.c~ 2011-09-20 22:58:37 +0200
+++ licence.c 2011-09-22 20:36:17 +0200
@@ -23,6 +23,7 @@
extern char *g_username;
extern char g_hostname[16];
+extern RD_BOOL g_use_rdp5;
static uint8 g_licence_key[16];
static uint8 g_licence_sign_key[16];
@@ -68,7 +69,7 @@
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_PRESENT);
- out_uint8(s, 2); /* version */
+ out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint32_le(s, 1);
@@ -108,7 +109,7 @@
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_REQUEST);
- out_uint8(s, 2); /* version */
+ out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint32_le(s, 1);
@@ -190,7 +191,7 @@
s = sec_init(sec_flags, length + 2);
out_uint8(s, LICENCE_TAG_AUTHRESP);
- out_uint8(s, 2); /* version */
+ out_uint8(s, (g_use_rdp5? 3 : 2)); /* version */
out_uint16_le(s, length);
out_uint16_le(s, 1);
--- rdesktop.c~ 2011-04-18 13:21:57 +0200
+++ rdesktop.c 2011-09-22 20:30:10 +0200
@@ -4,6 +4,7 @@
Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
Copyright 2002-2011 Peter Astrand <[email protected]> for Cendio AB
Copyright 2010-2011 Henrik Andersson <[email protected]> for Cendio AB
+ Copyright (C) Thomas Uhle <[email protected]> 2011
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -50,6 +51,7 @@
#include "ssl.h"
char g_title[64] = "";
+char g_server[64];
char *g_username;
char g_hostname[16];
char g_keymapname[PATH_MAX] = "";
@@ -320,7 +322,7 @@
break;
case exDiscReasonLicenseErrClientEncryption:
- text = "Incorrect client license enryption";
+ text = "Incorrect client license encryption";
retval = EXRD_LIC_ENC;
break;
@@ -451,7 +453,6 @@
int
main(int argc, char *argv[])
{
- char server[64];
char fullhostname[64];
char domain[256];
char password[64];
@@ -851,8 +852,8 @@
return EX_USAGE;
}
- STRNCPY(server, argv[optind], sizeof(server));
- parse_server_and_port(server);
+ STRNCPY(g_server, argv[optind], sizeof(g_server));
+ parse_server_and_port(g_server);
if (g_seamless_rdp)
{
@@ -955,11 +956,11 @@
if (g_title[0] == 0)
{
strcpy(g_title, "rdesktop - ");
- strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - "));
+ strncat(g_title, g_server, sizeof(g_title) - sizeof("rdesktop - "));
}
#ifdef RDP2VNC
- rdp2vnc_connect(server, flags, domain, password, shell, directory);
+ rdp2vnc_connect(g_server, flags, domain, password, shell, directory);
return EX_OK;
#else
@@ -990,12 +991,12 @@
g_username = (char *) xmalloc(strlen(g_redirect_username) + 1);
STRNCPY(g_username, g_redirect_username, sizeof(g_username));
STRNCPY(password, g_redirect_password, sizeof(password));
- STRNCPY(server, g_redirect_server, sizeof(server));
+ STRNCPY(g_server, g_redirect_server, sizeof(g_server));
flags |= RDP_LOGON_AUTO;
}
ui_init_connection();
- if (!rdp_connect(server, flags, domain, password, shell, directory, g_redirect))
+ if (!rdp_connect(g_server, flags, domain, password, shell, directory, g_redirect))
return EX_PROTOCOL;
/* By setting encryption to False here, we have an encrypted login
@@ -1505,15 +1506,22 @@
if (home == NULL)
return -1;
- path = (char *) xmalloc(strlen(home) + strlen(g_hostname) + sizeof("/.rdesktop/licence."));
- sprintf(path, "%s/.rdesktop/licence.%s", home, g_hostname);
+ path = (char *) xmalloc(strlen(home) + strlen(g_server) + strlen(g_hostname) + sizeof("/.rdesktop/licences//cal_") + 1);
+ sprintf(path, "%s/.rdesktop/licences/%s/cal_%s", home, g_server, g_hostname);
fd = open(path, O_RDONLY);
if (fd == -1)
+ {
+ xfree(path);
return -1;
+ }
if (fstat(fd, &st))
+ {
+ close(fd);
+ xfree(path);
return -1;
+ }
*data = (uint8 *) xmalloc(st.st_size);
length = read(fd, *data, st.st_size);
@@ -1532,18 +1540,35 @@
if (home == NULL)
return;
- path = (char *) xmalloc(strlen(home) + strlen(g_hostname) + sizeof("/.rdesktop/licence."));
+ path = (char *) xmalloc(strlen(home) + strlen(g_server) + strlen(g_hostname) + sizeof("/.rdesktop/licences//cal_") + 1);
sprintf(path, "%s/.rdesktop", home);
if ((mkdir(path, 0700) == -1) && errno != EEXIST)
{
perror(path);
+ xfree(path);
+ return;
+ }
+
+ strcat(path, "/licences");
+ if ((mkdir(path, 0700) == -1) && errno != EEXIST)
+ {
+ perror(path);
+ xfree(path);
+ return;
+ }
+
+ sprintf(path, "%s/.rdesktop/licences/%s", home, g_server);
+ if ((mkdir(path, 0700) == -1) && errno != EEXIST)
+ {
+ perror(path);
+ xfree(path);
return;
}
- /* write licence to licence.hostname.new, then atomically rename to licence.hostname */
+ /* write licence to cal_hostname.new, then atomically rename to cal_hostname */
- sprintf(path, "%s/.rdesktop/licence.%s", home, g_hostname);
+ sprintf(path, "%s/.rdesktop/licences/%s/cal_%s", home, g_server, g_hostname);
tmppath = (char *) xmalloc(strlen(path) + sizeof(".new"));
strcpy(tmppath, path);
strcat(tmppath, ".new");
@@ -1552,6 +1577,7 @@
if (fd == -1)
{
perror(tmppath);
+ xfree(tmppath);
return;
}