summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-05-07 21:04:10 +0200
committerGünther Deschner <gd@samba.org>2008-05-09 14:59:19 +0200
commit8441681819dcbc54143ac0f590c2795750daa96c (patch)
treedbb794a6ab808fe63179d5c449a3feb23c0ff158 /source3/libsmb
parenteaef936523b9fbd62e53b7b8f8ee6576da525eb4 (diff)
downloadsamba-8441681819dcbc54143ac0f590c2795750daa96c.tar.gz
samba-8441681819dcbc54143ac0f590c2795750daa96c.tar.bz2
samba-8441681819dcbc54143ac0f590c2795750daa96c.zip
dsgetdcname: be more paranoid about the existance of an ip_address.
Guenther (This used to be commit d13fe66f3d9ba152e3e8197ee6682e175163a6cd)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/dsgetdcname.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 981994ca43..388c7be395 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -621,7 +621,12 @@ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx,
}
if (dc_address) {
- info->dc_address = talloc_strdup(mem_ctx, dc_address);
+ if (!(dc_address[0] == '\\' && dc_address[1] == '\\')) {
+ info->dc_address = talloc_asprintf(mem_ctx, "\\\\%s",
+ dc_address);
+ } else {
+ info->dc_address = talloc_strdup(mem_ctx, dc_address);
+ }
NT_STATUS_HAVE_NO_MEMORY(info->dc_address);
}
@@ -681,16 +686,21 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), ss);
-
- dc_address = talloc_asprintf(mem_ctx, "\\\\%s", addr);
- NT_STATUS_HAVE_NO_MEMORY(dc_address);
- dc_address_type = DS_ADDRESS_TYPE_INET;
+ if (ss) {
+ print_sockaddr(addr, sizeof(addr), ss);
+ dc_address = addr;
+ dc_address_type = DS_ADDRESS_TYPE_INET;
+ }
switch (nt_version & 0x000000ff) {
case 0:
return NT_STATUS_INVALID_PARAMETER;
case 1:
+ if (!ss) {
+ dc_address = r->logon1.pdc_name;
+ dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
+ }
+
dc_hostname = r->logon1.pdc_name;
dc_domain_name = r->logon1.domain_name;
if (flags & DS_PDC_REQUIRED) {
@@ -699,6 +709,11 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
break;
case 2:
case 3:
+ if (!ss) {
+ dc_address = r->logon3.pdc_ip;
+ dc_address_type = DS_ADDRESS_TYPE_INET;
+ }
+
switch (flags & 0xf0000000) {
case DS_RETURN_FLAT_NAME:
dc_hostname = r->logon3.pdc_name;
@@ -721,6 +736,11 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
case 5:
case 6:
case 7:
+ if (!ss) {
+ dc_address = r->logon5.pdc_name;
+ dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
+ }
+
switch (flags & 0xf0000000) {
case DS_RETURN_FLAT_NAME:
dc_hostname = r->logon5.pdc_name;
@@ -749,6 +769,11 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
case 13:
case 14:
case 15:
+ if (!ss) {
+ dc_address = r->logon13.dc_sock_addr.pdc_ip;
+ dc_address_type = DS_ADDRESS_TYPE_INET;
+ }
+
switch (flags & 0xf0000000) {
case DS_RETURN_FLAT_NAME:
dc_hostname = r->logon13.pdc_name;
@@ -770,6 +795,11 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
break;
default:
+ if (!ss) {
+ dc_address = r->logon29.dc_sock_addr.pdc_ip;
+ dc_address_type = DS_ADDRESS_TYPE_INET;
+ }
+
switch (flags & 0xf0000000) {
case DS_RETURN_FLAT_NAME:
dc_hostname = r->logon29.pdc_name;