2021-07-29 13:33:22 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Terminal Server Gateway (utils)
|
|
|
|
*
|
|
|
|
* Copyright 2021 Armin Novak <armin.novak@thincast.com>
|
|
|
|
* Copyright 2021 Thincast Technologies GmbH
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2021-07-29 13:33:22 +03:00
|
|
|
|
2023-10-16 13:59:19 +03:00
|
|
|
#include "settings.h"
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
#include <winpr/assert.h>
|
|
|
|
|
|
|
|
#include <freerdp/freerdp.h>
|
2024-03-06 17:08:25 +03:00
|
|
|
#include <freerdp/channels/cliprdr.h>
|
|
|
|
#include <freerdp/channels/rdpdr.h>
|
2021-07-29 13:33:22 +03:00
|
|
|
|
|
|
|
#include <freerdp/log.h>
|
|
|
|
#define TAG FREERDP_TAG("core.gateway.utils")
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
#include "../core/rdp.h"
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
BOOL utils_str_copy(const char* value, char** dst)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(dst);
|
|
|
|
|
|
|
|
free(*dst);
|
|
|
|
*dst = NULL;
|
|
|
|
if (!value)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
(*dst) = _strdup(value);
|
|
|
|
return (*dst) != NULL;
|
|
|
|
}
|
|
|
|
|
2023-02-16 13:18:30 +03:00
|
|
|
static BOOL utils_copy_smartcard_settings(const rdpSettings* settings, rdpSettings* origSettings)
|
|
|
|
{
|
|
|
|
/* update original settings with provided smart card settings */
|
|
|
|
origSettings->SmartcardLogon = settings->SmartcardLogon;
|
|
|
|
origSettings->PasswordIsSmartcardPin = settings->PasswordIsSmartcardPin;
|
|
|
|
if (!utils_str_copy(settings->ReaderName, &origSettings->ReaderName))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->CspName, &origSettings->CspName))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->ContainerName, &origSettings->ContainerName))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
auth_status utils_authenticate_gateway(freerdp* instance, rdp_auth_reason reason)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpSettings* settings = NULL;
|
|
|
|
rdpSettings* origSettings = NULL;
|
2021-07-29 13:33:22 +03:00
|
|
|
BOOL prompt = FALSE;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL proceed = 0;
|
2021-07-29 13:33:22 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance->context->settings);
|
2022-11-18 13:38:55 +03:00
|
|
|
WINPR_ASSERT(instance->context->rdp);
|
|
|
|
WINPR_ASSERT(instance->context->rdp->originalSettings);
|
2021-07-29 13:33:22 +03:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
settings = instance->context->settings;
|
2022-11-18 13:38:55 +03:00
|
|
|
origSettings = instance->context->rdp->originalSettings;
|
2021-07-29 13:33:22 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (freerdp_shall_disconnect_context(instance->context))
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2022-06-03 11:25:30 +03:00
|
|
|
if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_GatewayPassword)))
|
|
|
|
prompt = TRUE;
|
|
|
|
if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_GatewayUsername)))
|
2021-07-29 13:33:22 +03:00
|
|
|
prompt = TRUE;
|
|
|
|
|
|
|
|
if (!prompt)
|
|
|
|
return AUTH_SKIP;
|
|
|
|
|
|
|
|
if (!instance->GatewayAuthenticate && !instance->AuthenticateEx)
|
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
|
2023-03-11 10:52:34 +03:00
|
|
|
if (!instance->GatewayAuthenticate)
|
2023-03-11 13:37:30 +03:00
|
|
|
{
|
2021-07-29 13:33:22 +03:00
|
|
|
proceed =
|
|
|
|
instance->AuthenticateEx(instance, &settings->GatewayUsername,
|
|
|
|
&settings->GatewayPassword, &settings->GatewayDomain, reason);
|
2023-03-11 13:37:30 +03:00
|
|
|
if (!proceed)
|
|
|
|
return AUTH_CANCELLED;
|
|
|
|
}
|
2021-07-29 13:33:22 +03:00
|
|
|
else
|
2023-03-11 13:37:30 +03:00
|
|
|
{
|
2021-07-29 13:33:22 +03:00
|
|
|
proceed =
|
|
|
|
instance->GatewayAuthenticate(instance, &settings->GatewayUsername,
|
|
|
|
&settings->GatewayPassword, &settings->GatewayDomain);
|
2023-03-11 13:37:30 +03:00
|
|
|
if (!proceed)
|
2023-07-26 16:43:12 +03:00
|
|
|
return AUTH_CANCELLED;
|
2023-03-11 13:37:30 +03:00
|
|
|
}
|
2023-02-13 14:37:17 +03:00
|
|
|
|
|
|
|
if (utils_str_is_empty(settings->GatewayUsername) ||
|
|
|
|
utils_str_is_empty(settings->GatewayPassword))
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
|
|
|
|
if (!utils_sync_credentials(settings, FALSE))
|
|
|
|
return AUTH_FAILED;
|
2022-11-18 13:38:55 +03:00
|
|
|
|
|
|
|
/* update original settings with provided user credentials */
|
|
|
|
if (!utils_str_copy(settings->GatewayUsername, &origSettings->GatewayUsername))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_str_copy(settings->GatewayDomain, &origSettings->GatewayDomain))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_str_copy(settings->GatewayPassword, &origSettings->GatewayPassword))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_sync_credentials(origSettings, FALSE))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2023-02-16 13:18:30 +03:00
|
|
|
if (!utils_copy_smartcard_settings(settings, origSettings))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
auth_status utils_authenticate(freerdp* instance, rdp_auth_reason reason, BOOL override)
|
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
rdpSettings* settings = NULL;
|
|
|
|
rdpSettings* origSettings = NULL;
|
2021-07-29 13:33:22 +03:00
|
|
|
BOOL prompt = !override;
|
2024-01-23 18:49:54 +03:00
|
|
|
BOOL proceed = 0;
|
2021-07-29 13:33:22 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(instance);
|
|
|
|
WINPR_ASSERT(instance->context);
|
2022-03-23 15:18:35 +03:00
|
|
|
WINPR_ASSERT(instance->context->settings);
|
2022-11-18 13:38:55 +03:00
|
|
|
WINPR_ASSERT(instance->context->rdp);
|
|
|
|
WINPR_ASSERT(instance->context->rdp->originalSettings);
|
2021-07-29 13:33:22 +03:00
|
|
|
|
2022-03-23 15:18:35 +03:00
|
|
|
settings = instance->context->settings;
|
2022-11-18 13:38:55 +03:00
|
|
|
origSettings = instance->context->rdp->originalSettings;
|
2021-07-29 13:33:22 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
if (freerdp_shall_disconnect_context(instance->context))
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2023-09-22 23:13:54 +03:00
|
|
|
if (settings->ConnectChildSession)
|
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
/* Ask for auth data if no or an empty username was specified or no password was given */
|
2022-06-03 11:25:30 +03:00
|
|
|
if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_Username)) ||
|
2021-07-29 13:33:22 +03:00
|
|
|
(settings->Password == NULL && settings->RedirectionPassword == NULL))
|
|
|
|
prompt = TRUE;
|
|
|
|
|
|
|
|
if (!prompt)
|
|
|
|
return AUTH_SKIP;
|
|
|
|
|
2022-03-09 11:09:53 +03:00
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case AUTH_RDP:
|
|
|
|
case AUTH_TLS:
|
2022-03-23 15:18:35 +03:00
|
|
|
if (settings->SmartcardLogon)
|
2022-03-09 11:09:53 +03:00
|
|
|
{
|
|
|
|
if (!utils_str_is_empty(settings->Password))
|
|
|
|
{
|
|
|
|
WLog_INFO(TAG, "Authentication via smartcard");
|
|
|
|
return AUTH_SUCCESS;
|
|
|
|
}
|
|
|
|
reason = AUTH_SMARTCARD_PIN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AUTH_NLA:
|
2022-03-23 15:18:35 +03:00
|
|
|
if (settings->SmartcardLogon)
|
2022-03-09 11:09:53 +03:00
|
|
|
reason = AUTH_SMARTCARD_PIN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
/* If no callback is specified still continue connection */
|
|
|
|
if (!instance->Authenticate && !instance->AuthenticateEx)
|
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
|
2023-03-11 10:52:34 +03:00
|
|
|
if (!instance->Authenticate)
|
2023-03-11 13:37:30 +03:00
|
|
|
{
|
2021-09-06 16:12:12 +03:00
|
|
|
proceed = instance->AuthenticateEx(instance, &settings->Username, &settings->Password,
|
|
|
|
&settings->Domain, reason);
|
2023-03-11 13:37:30 +03:00
|
|
|
if (!proceed)
|
|
|
|
return AUTH_CANCELLED;
|
|
|
|
}
|
2021-07-29 13:33:22 +03:00
|
|
|
else
|
2023-03-11 13:37:30 +03:00
|
|
|
{
|
2021-09-06 16:12:12 +03:00
|
|
|
proceed = instance->Authenticate(instance, &settings->Username, &settings->Password,
|
|
|
|
&settings->Domain);
|
2023-03-11 13:37:30 +03:00
|
|
|
if (!proceed)
|
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
}
|
2023-02-13 14:37:17 +03:00
|
|
|
|
|
|
|
if (utils_str_is_empty(settings->Username) || utils_str_is_empty(settings->Password))
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_NO_CREDENTIALS;
|
|
|
|
|
|
|
|
if (!utils_sync_credentials(settings, TRUE))
|
|
|
|
return AUTH_FAILED;
|
2022-11-18 13:38:55 +03:00
|
|
|
|
|
|
|
/* update original settings with provided user credentials */
|
|
|
|
if (!utils_str_copy(settings->Username, &origSettings->Username))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_str_copy(settings->Domain, &origSettings->Domain))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_str_copy(settings->Password, &origSettings->Password))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
if (!utils_sync_credentials(origSettings, TRUE))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2023-02-16 13:18:30 +03:00
|
|
|
if (!utils_copy_smartcard_settings(settings, origSettings))
|
|
|
|
return AUTH_FAILED;
|
|
|
|
|
2021-07-29 13:33:22 +03:00
|
|
|
return AUTH_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL utils_sync_credentials(rdpSettings* settings, BOOL toGateway)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
if (!settings->GatewayUseSameCredentials)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (toGateway)
|
|
|
|
{
|
|
|
|
if (!utils_str_copy(settings->Username, &settings->GatewayUsername))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->Domain, &settings->GatewayDomain))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->Password, &settings->GatewayPassword))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!utils_str_copy(settings->GatewayUsername, &settings->Username))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->GatewayDomain, &settings->Domain))
|
|
|
|
return FALSE;
|
|
|
|
if (!utils_str_copy(settings->GatewayPassword, &settings->Password))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL utils_str_is_empty(const char* str)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return TRUE;
|
|
|
|
if (strlen(str) == 0)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2022-03-07 15:47:43 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
BOOL utils_abort_connect(rdpRdp* rdp)
|
|
|
|
{
|
2022-06-23 10:10:30 +03:00
|
|
|
if (!rdp)
|
|
|
|
return FALSE;
|
2022-04-19 15:29:17 +03:00
|
|
|
|
|
|
|
return SetEvent(rdp->abortEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL utils_reset_abort(rdpRdp* rdp)
|
2022-03-07 15:47:43 +03:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
|
|
|
|
return ResetEvent(rdp->abortEvent);
|
|
|
|
}
|
2022-03-07 15:47:43 +03:00
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
HANDLE utils_get_abort_event(rdpRdp* rdp)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
return rdp->abortEvent;
|
2022-03-07 15:47:43 +03:00
|
|
|
}
|
|
|
|
|
2022-04-19 15:29:17 +03:00
|
|
|
BOOL utils_abort_event_is_set(rdpRdp* rdp)
|
2022-03-07 15:47:43 +03:00
|
|
|
{
|
2024-01-23 18:49:54 +03:00
|
|
|
DWORD status = 0;
|
2022-04-19 15:29:17 +03:00
|
|
|
WINPR_ASSERT(rdp);
|
|
|
|
status = WaitForSingleObject(rdp->abortEvent, 0);
|
|
|
|
return status == WAIT_OBJECT_0;
|
2022-03-07 15:47:43 +03:00
|
|
|
}
|
2023-11-14 18:33:53 +03:00
|
|
|
|
|
|
|
const char* utils_is_vsock(const char* hostname)
|
|
|
|
{
|
|
|
|
if (!hostname)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const char vsock[8] = "vsock://";
|
|
|
|
if (strncmp(hostname, vsock, sizeof(vsock)) == 0)
|
|
|
|
return &hostname[sizeof(vsock)];
|
|
|
|
return NULL;
|
|
|
|
}
|
2024-03-06 17:08:25 +03:00
|
|
|
|
|
|
|
static BOOL remove_rdpdr_type(rdpSettings* settings, UINT32 type)
|
|
|
|
{
|
|
|
|
RDPDR_DEVICE* printer = NULL;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
printer = freerdp_device_collection_find_type(settings, type);
|
|
|
|
freerdp_device_collection_del(settings, printer);
|
|
|
|
freerdp_device_free(printer);
|
|
|
|
} while (printer);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL disable_clipboard(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
freerdp_static_channel_collection_del(settings, CLIPRDR_SVC_CHANNEL_NAME);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL disable_drive(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectDrives, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectHomeDrive, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return remove_rdpdr_type(settings, RDPDR_DTYP_FILESYSTEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL disable_printers(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectPrinters, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return remove_rdpdr_type(settings, RDPDR_DTYP_PRINT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL disable_port(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
if (!remove_rdpdr_type(settings, RDPDR_DTYP_SERIAL))
|
|
|
|
return FALSE;
|
|
|
|
return remove_rdpdr_type(settings, RDPDR_DTYP_PARALLEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL disable_pnp(rdpSettings* settings)
|
|
|
|
{
|
|
|
|
// TODO(akallabeth): [MS-RDPEPNP] related stuff is disabled.
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL apply_gw_policy(rdpContext* context)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
2024-03-07 16:26:58 +03:00
|
|
|
return utils_reload_channels(context);
|
2024-03-06 17:08:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL utils_apply_gateway_policy(wLog* log, rdpContext* context, UINT32 flags, const char* module)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(log);
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
rdpSettings* settings = context->settings;
|
|
|
|
WINPR_ASSERT(settings);
|
|
|
|
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_ENABLE_ALL)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_DEBUG, "[%s] policy allows all redirections", module);
|
|
|
|
}
|
|
|
|
else if (freerdp_settings_get_bool(settings, FreeRDP_GatewayIgnoreRedirectionPolicy))
|
|
|
|
{
|
|
|
|
char buffer[128] = { 0 };
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy ignored on user request %s", module,
|
|
|
|
utils_redir_flags_to_string(flags, buffer, sizeof(buffer)));
|
|
|
|
}
|
|
|
|
else if (flags & HTTP_TUNNEL_REDIR_DISABLE_ALL)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies all redirections", module);
|
|
|
|
if (!disable_drive(settings))
|
|
|
|
return FALSE;
|
|
|
|
if (!disable_printers(settings))
|
|
|
|
return FALSE;
|
|
|
|
if (!disable_clipboard(settings))
|
|
|
|
return FALSE;
|
|
|
|
if (!disable_port(settings))
|
|
|
|
return FALSE;
|
|
|
|
if (!disable_pnp(settings))
|
|
|
|
return FALSE;
|
|
|
|
if (!apply_gw_policy(context))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_DRIVE)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies drive redirections", module);
|
|
|
|
if (!disable_drive(settings))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PRINTER)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies printer redirections", module);
|
|
|
|
if (!disable_printers(settings))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PORT)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies port redirections", module);
|
|
|
|
if (!disable_port(settings))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies clipboard redirections", module);
|
|
|
|
if (!disable_clipboard(settings))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PNP)
|
|
|
|
{
|
|
|
|
WLog_Print(log, WLOG_INFO, "[%s] policy denies PNP redirections", module);
|
|
|
|
if (!disable_pnp(settings))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (flags != 0)
|
|
|
|
{
|
|
|
|
if (!apply_gw_policy(context))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* utils_redir_flags_to_string(UINT32 flags, char* buffer, size_t size)
|
|
|
|
{
|
|
|
|
winpr_str_append("{", buffer, size, "");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_ENABLE_ALL)
|
|
|
|
winpr_str_append("ENABLE_ALL", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_ALL)
|
|
|
|
winpr_str_append("DISABLE_ALL", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_DRIVE)
|
|
|
|
winpr_str_append("DISABLE_DRIVE", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PRINTER)
|
|
|
|
winpr_str_append("DISABLE_PRINTER", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PORT)
|
|
|
|
winpr_str_append("DISABLE_PORT", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD)
|
|
|
|
winpr_str_append("DISABLE_CLIPBOARD", buffer, size, "|");
|
|
|
|
if (flags & HTTP_TUNNEL_REDIR_DISABLE_PNP)
|
|
|
|
winpr_str_append("DISABLE_PNP", buffer, size, "|");
|
|
|
|
|
|
|
|
char fbuffer[16] = { 0 };
|
|
|
|
_snprintf(fbuffer, sizeof(fbuffer), "[0x%08" PRIx32 "]", flags);
|
|
|
|
|
|
|
|
winpr_str_append(fbuffer, buffer, size, " ");
|
|
|
|
winpr_str_append("{", buffer, size, "}");
|
|
|
|
return buffer;
|
|
|
|
}
|
2024-03-07 16:26:58 +03:00
|
|
|
|
|
|
|
BOOL utils_reload_channels(rdpContext* context)
|
|
|
|
{
|
|
|
|
WINPR_ASSERT(context);
|
|
|
|
|
|
|
|
freerdp_channels_disconnect(context->channels, context->instance);
|
|
|
|
freerdp_channels_close(context->channels, context->instance);
|
|
|
|
freerdp_channels_free(context->channels);
|
|
|
|
context->channels = freerdp_channels_new(context->instance);
|
|
|
|
WINPR_ASSERT(context->channels);
|
|
|
|
|
|
|
|
BOOL rc = TRUE;
|
|
|
|
IFCALLRET(context->instance->LoadChannels, rc, context->instance);
|
|
|
|
if (rc)
|
|
|
|
return freerdp_channels_pre_connect(context->channels, context->instance) == CHANNEL_RC_OK;
|
|
|
|
return rc;
|
|
|
|
}
|