mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Clean up NLA authentication failure handling code
1. Make use of freerdp_set_last_error to set authentication failure without the helper functions 2. Rename ssl callback function 3. Break out AuthenticationOnly exit handling from bad connect handling
This commit is contained in:
@@ -1526,12 +1526,28 @@ void* xf_client_thread(void* param)
|
||||
|
||||
xfc = (xfContext*) instance->context;
|
||||
|
||||
/* Connection succeeded. --authonly ? */
|
||||
if (instance->settings->AuthenticationOnly || !status)
|
||||
/* --authonly ? */
|
||||
if (instance->settings->AuthenticationOnly)
|
||||
{
|
||||
WLog_ERR(TAG, "Authentication only, exit status %d", !status);
|
||||
if (freerdp_get_nla_failure(instance))
|
||||
exit_code = XF_EXIT_NLA_AUTH_FAILURE;
|
||||
if (!status)
|
||||
{
|
||||
if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_AUTHENTICATION_FAILED)
|
||||
exit_code = XF_EXIT_AUTH_FAILURE;
|
||||
else
|
||||
exit_code = XF_EXIT_CONN_FAILED;
|
||||
}
|
||||
else
|
||||
exit_code = XF_EXIT_SUCCESS;
|
||||
goto disconnect;
|
||||
}
|
||||
|
||||
if (!status)
|
||||
{
|
||||
WLog_ERR(TAG, "Freerdp connect error exit status %d", !status);
|
||||
exit_code = freerdp_error_info(instance);
|
||||
if (freerdp_get_last_error(instance->context) == FREERDP_ERROR_AUTHENTICATION_FAILED)
|
||||
exit_code = XF_EXIT_AUTH_FAILURE;
|
||||
else
|
||||
exit_code = XF_EXIT_CONN_FAILED;
|
||||
goto disconnect;
|
||||
@@ -1644,7 +1660,7 @@ disconnect:
|
||||
|
||||
DWORD xf_exit_code_from_disconnect_reason(DWORD reason)
|
||||
{
|
||||
if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS && reason <= XF_EXIT_NLA_AUTH_FAILURE))
|
||||
if (reason == 0 || (reason >= XF_EXIT_PARSE_ARGUMENTS && reason <= XF_EXIT_AUTH_FAILURE))
|
||||
return reason;
|
||||
/* License error set */
|
||||
else if (reason >= 0x100 && reason <= 0x10A)
|
||||
|
||||
@@ -268,7 +268,7 @@ enum XF_EXIT_CODE
|
||||
XF_EXIT_MEMORY = 129,
|
||||
XF_EXIT_PROTOCOL = 130,
|
||||
XF_EXIT_CONN_FAILED = 131,
|
||||
XF_EXIT_NLA_AUTH_FAILURE = 132,
|
||||
XF_EXIT_AUTH_FAILURE = 132,
|
||||
|
||||
XF_EXIT_UNKNOWN = 255,
|
||||
};
|
||||
|
||||
@@ -815,15 +815,3 @@ FREERDP_API void setChannelError(rdpContext* context, UINT errorNum, char* descr
|
||||
strncpy(context->errorDescription, description, 499);
|
||||
SetEvent(context->channelErrorEvent);
|
||||
}
|
||||
|
||||
BOOL freerdp_get_nla_failure(freerdp* instance)
|
||||
{
|
||||
rdpRdp* rdp;
|
||||
|
||||
rdp = instance->context->rdp;
|
||||
|
||||
if (transport_get_nla_failure(rdp->transport))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
static void* transport_client_thread(void* arg);
|
||||
|
||||
|
||||
static void test_function(SSL* ssl, int where, int ret)
|
||||
static void transport_ssl_cb(SSL* ssl, int where, int ret)
|
||||
{
|
||||
rdpTransport *transport;
|
||||
if ((where | SSL_CB_ALERT) && (ret == 561))
|
||||
@@ -157,7 +157,7 @@ BOOL transport_connect_tls(rdpTransport* transport)
|
||||
|
||||
transport->frontBio = tls->bio;
|
||||
|
||||
BIO_callback_ctrl(tls->bio, BIO_CTRL_SET_CALLBACK, (bio_info_cb*) test_function);
|
||||
BIO_callback_ctrl(tls->bio, BIO_CTRL_SET_CALLBACK, (bio_info_cb*) transport_ssl_cb);
|
||||
SSL_set_app_data(tls->ssl, transport);
|
||||
|
||||
if (!transport->frontBio)
|
||||
@@ -200,7 +200,6 @@ BOOL transport_connect_nla(rdpTransport* transport)
|
||||
|
||||
if (nla_client_begin(rdp->nla) < 0)
|
||||
{
|
||||
transport->nlaFailure = TRUE;
|
||||
if (!freerdp_get_last_error(context))
|
||||
freerdp_set_last_error(context, FREERDP_ERROR_AUTHENTICATION_FAILED);
|
||||
|
||||
@@ -358,7 +357,6 @@ BOOL transport_accept_nla(rdpTransport* transport)
|
||||
|
||||
if (nla_authenticate(transport->nla) < 0)
|
||||
{
|
||||
transport->nlaFailure = TRUE;
|
||||
WLog_ERR(TAG, "client authentication failure");
|
||||
transport_set_nla_mode(transport, FALSE);
|
||||
nla_free(transport->nla);
|
||||
@@ -1044,15 +1042,3 @@ void transport_free(rdpTransport* transport)
|
||||
|
||||
free(transport);
|
||||
}
|
||||
|
||||
BOOL transport_get_nla_failure(rdpTransport* transport)
|
||||
{
|
||||
if (transport != NULL)
|
||||
{
|
||||
if (transport->nlaFailure == TRUE)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user