Author: gd Date: 2007-08-30 09:52:21 +0000 (Thu, 30 Aug 2007) New Revision: 24799
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24799 Log: Prefer IP address to dns name when replying in winbindd dsgetdcname. Guenther Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c Changeset: Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c =================================================================== --- branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c 2007-08-30 09:51:33 UTC (rev 24798) +++ branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c 2007-08-30 09:52:21 UTC (rev 24799) @@ -298,6 +298,7 @@ { NTSTATUS result; struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + const char *dc = NULL; state->request.domain_name [sizeof(state->request.domain_name)-1] = '\0'; @@ -312,8 +313,23 @@ return WINBINDD_ERROR; } - fstrcpy(state->response.data.dc_name, info->domain_controller_name); + if (info->domain_controller_address) { + dc = info->domain_controller_address; + if ((dc[0] == '\\') && (dc[1] == '\\')) { + dc += 2; + } + } + if ((!dc || !is_ipaddress(dc)) && info->domain_controller_name) { + dc = info->domain_controller_name; + } + + if (!dc || !*dc) { + return WINBINDD_ERROR; + } + + fstrcpy(state->response.data.dc_name, dc); + return WINBINDD_OK; } Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c =================================================================== --- branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c 2007-08-30 09:51:33 UTC (rev 24798) +++ branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c 2007-08-30 09:52:21 UTC (rev 24799) @@ -298,6 +298,7 @@ { NTSTATUS result; struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + const char *dc = NULL; state->request.domain_name [sizeof(state->request.domain_name)-1] = '\0'; @@ -312,8 +313,23 @@ return WINBINDD_ERROR; } - fstrcpy(state->response.data.dc_name, info->domain_controller_name); + if (info->domain_controller_address) { + dc = info->domain_controller_address; + if ((dc[0] == '\\') && (dc[1] == '\\')) { + dc += 2; + } + } + if ((!dc || !is_ipaddress(dc)) && info->domain_controller_name) { + dc = info->domain_controller_name; + } + + if (!dc || !*dc) { + return WINBINDD_ERROR; + } + + fstrcpy(state->response.data.dc_name, dc); + return WINBINDD_OK; }