More cleanups - remove LWD and all references.

This commit is contained in:
Dan Bungert 2013-10-28 15:46:28 -06:00
parent 1dd2e649e3
commit f02daaa2d5
7 changed files with 12 additions and 162 deletions

View File

@ -49,7 +49,6 @@ struct rdp_tls
rdpSettings* settings;
SecPkgContext_Bindings* Bindings;
rdpCertificateStore* certificate_store;
char desc[20];
};
FREERDP_API BOOL tls_connect(rdpTls* tls);

View File

@ -274,7 +274,6 @@ BOOL rdp_client_connect(rdpRdp* rdp)
{
if (rdp_check_fds(rdp) < 0)
return FALSE;
usleep(100);
}
return TRUE;

View File

@ -43,8 +43,6 @@
#include "rpc.h"
#include "lwd.h"
/* Security Verification Trailer Signature */
rpc_sec_verification_trailer RPC_SEC_VERIFICATION_TRAILER =
@ -318,12 +316,8 @@ int rpc_out_read(rdpRpc* rpc, BYTE* data, int length)
{
int status;
LWD("len %d", length);
status = tls_read(rpc->TlsOut, data, length);
LWD("status %d", status);
return status;
}
@ -331,12 +325,8 @@ int rpc_out_write(rdpRpc* rpc, BYTE* data, int length)
{
int status;
LWD("len %d", length);
status = tls_write_all(rpc->TlsOut, data, length);
LWD("status %d", status);
return status;
}
@ -345,20 +335,14 @@ int rpc_in_write(rdpRpc* rpc, BYTE* data, int length)
int status;
#ifdef WITH_DEBUG_TSG
/*
fprintf(stderr, "Sending PDU (length: %d)\n", length);
rpc_pdu_header_print((rpcconn_hdr_t*) data);
winpr_HexDump(data, length);
fprintf(stderr, "\n");
*/
#endif
LWD("len %d", length);
status = tls_write_all(rpc->TlsIn, data, length);
LWD("status %d", status);
return status;
}
@ -376,12 +360,9 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
ntlm = rpc->ntlm;
LWD("len %d", length);
if (ntlm->table->QueryContextAttributes(&ntlm->context, SECPKG_ATTR_SIZES, &ntlm->ContextSizes) != SEC_E_OK)
{
fprintf(stderr, "QueryContextAttributes SECPKG_ATTR_SIZES failure\n");
LWD("status -1 query context");
return -1;
}
@ -453,7 +434,6 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
{
fprintf(stderr, "EncryptMessage status: 0x%08X\n", encrypt_status);
free(request_pdu);
LWD("status -1 encrypt_status fail");
return -1;
}
@ -464,8 +444,6 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum)
rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length);
free(request_pdu);
LWD("status %d", length);
return length;
}

View File

@ -37,7 +37,6 @@
#include <winpr/registry.h>
#include "nla.h"
#include "lwd.h"
/**
* TSRequest ::= SEQUENCE {
@ -202,14 +201,10 @@ int credssp_client_authenticate(rdpCredssp* credssp)
BOOL have_input_buffer;
BOOL have_pub_key_auth;
LWD("");
sspi_GlobalInit();
if (credssp_ntlm_client_init(credssp) == 0) {
LWD("ret 0 at init");
if (credssp_ntlm_client_init(credssp) == 0)
return 0;
}
#ifdef WITH_NATIVE_SSPI
{
@ -235,7 +230,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
if (status != SEC_E_OK)
{
fprintf(stderr, "QuerySecurityPackageInfo status: 0x%08X\n", status);
LWD("QSPI status 0x%X", status);
return 0;
}
@ -247,7 +241,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
if (status != SEC_E_OK)
{
fprintf(stderr, "AcquireCredentialsHandle status: 0x%08X\n", status);
LWD("ACH status 0x%X", status);
return 0;
}
@ -299,7 +292,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
if (credssp->table->QueryContextAttributes(&credssp->context, SECPKG_ATTR_SIZES, &credssp->ContextSizes) != SEC_E_OK)
{
fprintf(stderr, "QueryContextAttributes SECPKG_ATTR_SIZES failure\n");
LWD("QCA fail ret 0");
return 0;
}
@ -337,10 +329,8 @@ int credssp_client_authenticate(rdpCredssp* credssp)
input_buffer_desc.pBuffers = &input_buffer;
input_buffer.BufferType = SECBUFFER_TOKEN;
if (credssp_recv(credssp) < 0) {
LWD("credssp_recv ret -1 point 1");
if (credssp_recv(credssp) < 0)
return -1;
}
#ifdef WITH_DEBUG_CREDSSP
fprintf(stderr, "Receiving Authentication Token (%d)\n", (int) credssp->negoToken.cbBuffer);
@ -355,10 +345,9 @@ int credssp_client_authenticate(rdpCredssp* credssp)
}
/* Encrypted Public Key +1 */
if (credssp_recv(credssp) < 0) {
LWD("credssp_recv ret -1 point 2");
if (credssp_recv(credssp) < 0)
return -1;
}
/* Verify Server Public Key Echo */
@ -368,7 +357,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
if (status != SEC_E_OK)
{
fprintf(stderr, "Could not verify public key echo!\n");
LWD("verify fail public key ret -1");
return -1;
}
@ -379,7 +367,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
if (status != SEC_E_OK)
{
fprintf(stderr, "credssp_encrypt_ts_credentials status: 0x%08X\n", status);
LWD("credssp encrypt ts cred ret 0");
return 0;
}
@ -391,7 +378,6 @@ int credssp_client_authenticate(rdpCredssp* credssp)
credssp->table->FreeCredentialsHandle(&credentials);
credssp->table->FreeContextBuffer(pPackageInfo);
LWD("ret 1");
return 1;
}
@ -1094,10 +1080,6 @@ void credssp_send(rdpCredssp* credssp)
ts_request_length = credssp_sizeof_ts_request(length);
LWD("nego_len %d pub_len %d auth_len %d len %d ts_len %d",
nego_tokens_length, pub_key_auth_length, auth_info_length,
length, ts_request_length);
s = Stream_New(NULL, ber_sizeof_sequence(ts_request_length));
/* TSRequest */
@ -1140,11 +1122,8 @@ void credssp_send(rdpCredssp* credssp)
Stream_SealLength(s);
LWD("len %d", Stream_Length(s));
transport_write(credssp->transport, s);
winpr_HexDump(Stream_Buffer(s), Stream_Length(s));
Stream_Free(s, TRUE);
}

View File

@ -49,8 +49,6 @@
#define BUFFER_SIZE 16384
#include "lwd.h"
static void* transport_client_thread(void* arg);
wStream* transport_send_stream_init(rdpTransport* transport, int size)
@ -121,17 +119,9 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num)
int status;
rdpTsg* tsg;
LWD("len %d", num);
/* printf("transport_bio_tsg_write: %d\n", num); */
tsg = (rdpTsg*) bio->ptr;
status = tsg_write(tsg, (BYTE*) buf, num);
LWD("status %d", status);
/* printf("tsg_write: %d\n", status); */
BIO_clear_retry_flags(bio);
if (status <= 0)
@ -147,17 +137,9 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
int status;
rdpTsg* tsg;
LWD("len %d", size);
/* printf("transport_bio_tsg_read: %d\n", size); */
tsg = (rdpTsg*) bio->ptr;
status = tsg_read(bio->ptr, (BYTE*) buf, size);
LWD("status %d", status);
/* printf("tsg_read: %d\n", status); */
BIO_clear_retry_flags(bio);
if (status <= 0)
@ -233,8 +215,6 @@ BOOL transport_connect_tls(rdpTransport* transport)
if (transport->layer == TRANSPORT_LAYER_TSG)
{
transport->TsgTls = tls_new(transport->settings);
LWD("create TsgTls");
sprintf(transport->TsgTls->desc, "TsgTls");
transport->TsgTls->methods = BIO_s_tsg();
transport->TsgTls->tsg = (void*) transport->tsg;
@ -256,11 +236,8 @@ BOOL transport_connect_tls(rdpTransport* transport)
return TRUE;
}
if (transport->TlsIn == NULL) {
if (transport->TlsIn == NULL)
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
if (transport->TlsOut == NULL)
transport->TlsOut = transport->TlsIn;
@ -331,19 +308,13 @@ BOOL transport_tsg_connect(rdpTransport* transport, const char* hostname, UINT16
transport->tsg = tsg;
transport->SplitInputOutput = TRUE;
if (transport->TlsIn == NULL) {
if (transport->TlsIn == NULL)
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
transport->TlsIn->sockfd = transport->TcpIn->sockfd;
if (transport->TlsOut == NULL) {
if (transport->TlsOut == NULL)
transport->TlsOut = tls_new(transport->settings);
LWD("create TlsOut");
sprintf(transport->TlsOut->desc, "TlsOut");
}
transport->TlsOut->sockfd = transport->TcpOut->sockfd;
@ -407,11 +378,8 @@ BOOL transport_accept_rdp(rdpTransport* transport)
BOOL transport_accept_tls(rdpTransport* transport)
{
if (transport->TlsIn == NULL) {
if (transport->TlsIn == NULL)
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
if (transport->TlsOut == NULL)
transport->TlsOut = transport->TlsIn;
@ -430,11 +398,8 @@ BOOL transport_accept_nla(rdpTransport* transport)
freerdp* instance;
rdpSettings* settings;
if (transport->TlsIn == NULL) {
if (transport->TlsIn == NULL)
transport->TlsIn = tls_new(transport->settings);
LWD("create TlsIn");
sprintf(transport->TlsIn->desc, "TlsIn");
}
if (transport->TlsOut == NULL)
transport->TlsOut = transport->TlsIn;
@ -553,21 +518,9 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
{
int read = 0;
int status = -1;
char *layer = "UNKNOWN";
if (transport->layer == TRANSPORT_LAYER_TLS)
layer = "TLS";
else if (transport->layer == TRANSPORT_LAYER_TCP)
layer = "TCP";
else if (transport->layer == TRANSPORT_LAYER_TSG)
layer = "TSG";
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
layer = "TSG_TLS";
while (read < bytes)
{
LWD("layer %s bytes %d read %d", layer, bytes, read);
if (transport->layer == TRANSPORT_LAYER_TLS)
status = tls_read(transport->TlsIn, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TCP)
@ -575,25 +528,16 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
else if (transport->layer == TRANSPORT_LAYER_TSG)
status = tsg_read(transport->tsg, data + read, bytes - read);
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS) {
/*
LWD("TlsIn SSL pending %d want %s", SSL_pending(transport->TlsIn->ssl), want(transport->TlsIn));
LWD("TlsOut SSL pending %d want %s", SSL_pending(transport->TlsOut->ssl), want(transport->TlsOut));
LWD("TsgTls SSL pending %d want %s", SSL_pending(transport->TsgTls->ssl), want(transport->TlsIn));
*/
status = tls_read(transport->TsgTls, data + read, bytes - read);
}
/* blocking means that we can't continue until this is read */
if (!transport->blocking) {
LWD("layer %s return %d not blocking", layer, status);
if (!transport->blocking)
return status;
}
if (status < 0) {
LWD("layer %s return %d negative status", layer, status);
if (status < 0)
return status;
}
read += status;
@ -607,7 +551,6 @@ int transport_read_layer(rdpTransport* transport, UINT8* data, int bytes)
}
}
LWD("layer %s return %d normal", layer, status);
return read;
}
@ -720,7 +663,6 @@ int transport_write(rdpTransport* transport, wStream* s)
{
int length;
int status = -1;
char *layer = "UNKNOWN";
WaitForSingleObject(transport->WriteMutex, INFINITE);
@ -735,19 +677,8 @@ int transport_write(rdpTransport* transport, wStream* s)
}
#endif
if (transport->layer == TRANSPORT_LAYER_TLS)
layer = "TLS";
else if (transport->layer == TRANSPORT_LAYER_TCP)
layer = "TCP";
else if (transport->layer == TRANSPORT_LAYER_TSG)
layer = "TSG";
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
layer = "TSG_TLS";
while (length > 0)
{
LWD("layer %s length %d", layer, length);
if (transport->layer == TRANSPORT_LAYER_TLS)
status = tls_write(transport->TlsOut, Stream_Pointer(s), length);
else if (transport->layer == TRANSPORT_LAYER_TCP)
@ -757,15 +688,11 @@ int transport_write(rdpTransport* transport, wStream* s)
else if (transport->layer == TRANSPORT_LAYER_TSG_TLS)
status = tls_write(transport->TsgTls, Stream_Pointer(s), length);
if (status < 0) {
LWD("layer %s length %d break %d negative status",
layer, length, status);
if (status < 0)
break; /* error occurred */
}
if (status == 0)
{
LWD("layer %s status 0", layer);
/* when sending is blocked in nonblocking mode, the receiving buffer should be checked */
if (!transport->blocking)
{
@ -799,7 +726,6 @@ int transport_write(rdpTransport* transport, wStream* s)
ReleaseMutex(transport->WriteMutex);
LWD("layer %s return %d", layer, status);
return status;
}

View File

@ -31,8 +31,6 @@
#include <freerdp/crypto/tls.h>
#include <lwd.h>
static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer)
{
CryptoCert cert;
@ -375,8 +373,6 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
int error;
int status;
LWD("tls %s length %d", tls->desc, length);
status = SSL_read(tls->ssl, data, length);
if (status <= 0)
@ -415,8 +411,6 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
}
}
LWD("tls %s ret %d", tls->desc, status);
return status;
}
@ -440,8 +434,6 @@ int tls_write(rdpTls* tls, BYTE* data, int length)
int error;
int status;
LWD("tls %s length %d", tls->desc, length);
status = SSL_write(tls->ssl, data, length);
if (status <= 0)
@ -479,8 +471,6 @@ int tls_write(rdpTls* tls, BYTE* data, int length)
}
}
LWD("tls %s ret %d", tls->desc, status);
return status;
}

21
lwd.h
View File

@ -1,21 +0,0 @@
#ifndef __LWD_H__
#define __LWD_H__
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define LWD(fmt, ...) do { \
time_t tod = time(NULL); \
char buf[25]; \
struct tm* tm_info = localtime(&tod); \
strftime(buf, 25, "%H:%M:%S", tm_info); \
fprintf(stderr, "%20.20s [%s] ", __FUNCTION__, buf); \
fprintf(stderr, fmt, ## __VA_ARGS__); \
fprintf(stderr, "\n"); \
} while( 0 )
// fflush(stderr);
#endif