Skip to content

Commit

Permalink
[core] allow to specify the hostname used for AAD
Browse files Browse the repository at this point in the history
The previous code was assuming that the host name used for doing AAD was
ServerHostname parameter. But when you connect directly to Azure hosts you most
likely connect by IP and use short name for the AAD host, so you need to be able
to give ServerHostname=<IP of host> and AadServerHostname=<shortname>.
  • Loading branch information
hardening authored and akallabeth committed Dec 15, 2023
1 parent ed4c1e1 commit 6a31820
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/freerdp/settings_types_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ struct rdp_settings
SETTINGS_DEPRECATED(ALIGN64 char* AcceptedCert); /* 27 */
SETTINGS_DEPRECATED(ALIGN64 UINT32 AcceptedCertLength); /* 28 */
SETTINGS_DEPRECATED(ALIGN64 char* UserSpecifiedServerName); /* 29 */
UINT64 padding0064[64 - 30]; /* 30 */
SETTINGS_DEPRECATED(ALIGN64 char* AadServerHostname); /* 30 */
UINT64 padding0064[64 - 31]; /* 31 */
/* resource management related options */
SETTINGS_DEPRECATED(ALIGN64 UINT32 ThreadingFlags); /* 64 */

Expand Down
12 changes: 12 additions & 0 deletions libfreerdp/common/settings_getters.c
Original file line number Diff line number Diff line change
Expand Up @@ -2613,6 +2613,9 @@ const char* freerdp_settings_get_string(const rdpSettings* settings,

switch (id)
{
case FreeRDP_AadServerHostname:
return settings->AadServerHostname;

case FreeRDP_AcceptedCert:
return settings->AcceptedCert;

Expand Down Expand Up @@ -2919,6 +2922,9 @@ char* freerdp_settings_get_string_writable(rdpSettings* settings, FreeRDP_Settin

switch (id)
{
case FreeRDP_AadServerHostname:
return settings->AadServerHostname;

case FreeRDP_AcceptedCert:
return settings->AcceptedCert;

Expand Down Expand Up @@ -3235,6 +3241,9 @@ BOOL freerdp_settings_set_string_(rdpSettings* settings, FreeRDP_Settings_Keys_S

switch (id)
{
case FreeRDP_AadServerHostname:
return update_string_(&settings->AadServerHostname, cnv.c, len);

case FreeRDP_AcceptedCert:
return update_string_(&settings->AcceptedCert, cnv.c, len);

Expand Down Expand Up @@ -3566,6 +3575,9 @@ BOOL freerdp_settings_set_string_copy_(rdpSettings* settings, FreeRDP_Settings_K

switch (id)
{
case FreeRDP_AadServerHostname:
return update_string_copy_(&settings->AadServerHostname, cnv.cc, len, cleanup);

case FreeRDP_AcceptedCert:
return update_string_copy_(&settings->AcceptedCert, cnv.cc, len, cleanup);

Expand Down
1 change: 1 addition & 0 deletions libfreerdp/common/settings_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ static const struct settings_str_entry settings_map[] = {
{ FreeRDP_XPan, FREERDP_SETTINGS_TYPE_INT32, "FreeRDP_XPan" },
{ FreeRDP_YPan, FREERDP_SETTINGS_TYPE_INT32, "FreeRDP_YPan" },
{ FreeRDP_ParentWindowId, FREERDP_SETTINGS_TYPE_UINT64, "FreeRDP_ParentWindowId" },
{ FreeRDP_AadServerHostname, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_AadServerHostname" },
{ FreeRDP_AcceptedCert, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_AcceptedCert" },
{ FreeRDP_ActionScript, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_ActionScript" },
{ FreeRDP_AllowedTlsCiphers, FREERDP_SETTINGS_TYPE_STRING, "FreeRDP_AllowedTlsCiphers" },
Expand Down
4 changes: 3 additions & 1 deletion libfreerdp/core/aad.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ int aad_client_begin(rdpAad* aad)
WINPR_ASSERT(instance);

/* Get the host part of the hostname */
const char* hostname = freerdp_settings_get_string(settings, FreeRDP_ServerHostname);
const char* hostname = freerdp_settings_get_string(settings, FreeRDP_AadServerHostname);
if (!hostname)
hostname = freerdp_settings_get_string(settings, FreeRDP_ServerHostname);
if (!hostname)
{
WLog_Print(aad->log, WLOG_ERROR, "FreeRDP_ServerHostname == NULL");
Expand Down
1 change: 1 addition & 0 deletions libfreerdp/core/test/settings_property_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ static const size_t uint64_list_indices[] = {

#define have_string_list_indices
static const size_t string_list_indices[] = {
FreeRDP_AadServerHostname,
FreeRDP_AcceptedCert,
FreeRDP_ActionScript,
FreeRDP_AllowedTlsCiphers,
Expand Down

0 comments on commit 6a31820

Please sign in to comment.