libfreerdp-core: added authenticate callback

This commit is contained in:
Marc-André Moreau 2011-09-29 01:03:07 -04:00
parent af063100d2
commit 10331c5c44
7 changed files with 40 additions and 29 deletions

View File

@ -66,6 +66,7 @@ freerdp_sem g_sem;
static int g_thread_count = 0;
static long xv_port = 0;
const size_t password_size = 512;
struct thread_data
{
@ -647,6 +648,16 @@ boolean xf_post_connect(freerdp* instance)
return True;
}
boolean xf_authenticate(freerdp* instance, char** username, char** password, char** domain)
{
*password = xmalloc(password_size * sizeof(char));
if (freerdp_passphrase_read("Password: ", *password, password_size) == NULL)
return False;
return True;
}
int xf_process_ui_args(rdpSettings* settings, const char* opt, const char* val, void* user_data)
{
int argc = 0;
@ -902,8 +913,8 @@ int main(int argc, char* argv[])
{
pthread_t thread;
freerdp* instance;
struct thread_data* data;
rdpChanMan* chanman;
struct thread_data* data;
freerdp_handle_signals();
@ -916,6 +927,7 @@ int main(int argc, char* argv[])
instance = freerdp_new();
instance->PreConnect = xf_pre_connect;
instance->PostConnect = xf_post_connect;
instance->Authenticate = xf_authenticate;
instance->ReceiveChannelData = xf_receive_channel_data;
chanman = freerdp_chanman_new();
@ -927,19 +939,6 @@ int main(int argc, char* argv[])
xf_process_plugin_args, chanman, xf_process_ui_args, NULL) < 0)
return 1;
if (instance->settings->password == NULL)
{
const size_t password_size = 512;
instance->settings->password = xmalloc(password_size * sizeof(char));
if(freerdp_passphrase_read("Password: ", instance->settings->password, password_size) == NULL)
{
perror("xfreerdp");
exit(errno);
}
}
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));
data->instance = instance;

View File

@ -127,7 +127,7 @@ void test_gcc_write_client_core_data(void)
rdpSettings* settings;
s = stream_new(512);
settings = settings_new();
settings = settings_new(NULL);
settings->width = 1280;
settings->height = 1024;
@ -154,7 +154,7 @@ void test_gcc_write_client_security_data(void)
rdpSettings* settings;
s = stream_new(12);
settings = settings_new();
settings = settings_new(NULL);
settings->encryption = 1; /* turn on encryption */
settings->encryption_method =
@ -177,7 +177,7 @@ void test_gcc_write_client_cluster_data(void)
rdpSettings* settings;
s = stream_new(12);
settings = settings_new();
settings = settings_new(NULL);
gcc_write_client_cluster_data(s, settings);

View File

@ -40,6 +40,7 @@ FREERDP_API void freerdp_global_finish();
typedef boolean (*pcConnect)(freerdp* instance);
typedef boolean (*pcPreConnect)(freerdp* instance);
typedef boolean (*pcPostConnect)(freerdp* instance);
typedef boolean (*pcAuthenticate)(freerdp* instance, char** username, char** password, char** domain);
typedef boolean (*pcGetFileDescriptor)(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);
typedef boolean (*pcCheckFileDescriptor)(freerdp* instance);
typedef int (*pcSendChannelData)(freerdp* instance, int channelId, uint8* data, int size);
@ -61,6 +62,7 @@ struct rdp_freerdp
pcConnect Connect;
pcPreConnect PreConnect;
pcPostConnect PostConnect;
pcAuthenticate Authenticate;
pcGetFileDescriptor GetFileDescriptor;
pcCheckFileDescriptor CheckFileDescriptor;
pcSendChannelData SendChannelData;

View File

@ -182,6 +182,8 @@ struct rdp_monitor
struct rdp_settings
{
void* instance;
uint16 width;
uint16 height;
boolean sw_gdi;
@ -322,7 +324,7 @@ struct rdp_settings
};
typedef struct rdp_settings rdpSettings;
rdpSettings* settings_new();
rdpSettings* settings_new(void* instance);
void settings_free(rdpSettings* settings);
#endif /* __RDP_SETTINGS_H */

View File

@ -74,8 +74,16 @@
void credssp_ntlmssp_init(rdpCredssp* credssp)
{
NTLMSSP *ntlmssp = credssp->ntlmssp;
rdpSettings *settings = credssp->transport->settings;
freerdp* instance;
NTLMSSP* ntlmssp = credssp->ntlmssp;
rdpSettings* settings = credssp->transport->settings;
instance = (freerdp*) settings->instance;
if (settings->password == NULL)
{
IFCALL(instance->Authenticate, instance,
&settings->username, &settings->password, &settings->domain);
}
ntlmssp_set_password(ntlmssp, settings->password);
ntlmssp_set_username(ntlmssp, settings->username);
@ -83,9 +91,7 @@ void credssp_ntlmssp_init(rdpCredssp* credssp)
if (settings->domain != NULL)
{
if (strlen(settings->domain) > 0)
{
ntlmssp_set_domain(ntlmssp, settings->domain);
}
}
else
{
@ -134,7 +140,7 @@ int credssp_get_public_key(rdpCredssp* credssp)
int credssp_authenticate(rdpCredssp* credssp)
{
NTLMSSP *ntlmssp = credssp->ntlmssp;
NTLMSSP* ntlmssp = credssp->ntlmssp;
STREAM* s = stream_new(0);
uint8* negoTokenBuffer = (uint8*) xmalloc(2048);
@ -200,7 +206,7 @@ int credssp_authenticate(rdpCredssp* credssp)
void credssp_encrypt_public_key(rdpCredssp* credssp, rdpBlob* d)
{
uint8 *p;
uint8* p;
uint8 signature[16];
rdpBlob encrypted_public_key;
NTLMSSP *ntlmssp = credssp->ntlmssp;
@ -239,7 +245,7 @@ void credssp_encrypt_public_key(rdpCredssp* credssp, rdpBlob* d)
int credssp_verify_public_key(rdpCredssp* credssp, rdpBlob* d)
{
uint8 *p1, *p2;
uint8 *signature;
uint8* signature;
rdpBlob public_key;
rdpBlob encrypted_public_key;
@ -273,10 +279,10 @@ int credssp_verify_public_key(rdpCredssp* credssp, rdpBlob* d)
void credssp_encrypt_ts_credentials(rdpCredssp* credssp, rdpBlob* d)
{
uint8 *p;
uint8* p;
uint8 signature[16];
rdpBlob encrypted_ts_credentials;
NTLMSSP *ntlmssp = credssp->ntlmssp;
NTLMSSP* ntlmssp = credssp->ntlmssp;
freerdp_blob_alloc(d, credssp->ts_credentials.length + 16);
ntlmssp_encrypt_message(ntlmssp, &credssp->ts_credentials, &encrypted_ts_credentials, signature);

View File

@ -807,7 +807,7 @@ rdpRdp* rdp_new(freerdp* instance)
if (rdp != NULL)
{
rdp->settings = settings_new();
rdp->settings = settings_new((void*) instance);
rdp->transport = transport_new(rdp->settings);
rdp->license = license_new(rdp);
rdp->input = input_new(rdp);

View File

@ -29,7 +29,7 @@
static char client_dll[] = "C:\\Windows\\System32\\mstscax.dll";
rdpSettings* settings_new()
rdpSettings* settings_new(void* instance)
{
rdpSettings* settings;
@ -37,6 +37,8 @@ rdpSettings* settings_new()
if (settings != NULL)
{
settings->instance = instance;
settings->width = 1024;
settings->height = 768;
settings->workarea = False;