diff options
author | Günther Deschner <gd@samba.org> | 2008-05-07 18:57:43 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-05-09 14:59:19 +0200 |
commit | 9be17e2187a93633b23761fc2f6f0b40c94db809 (patch) | |
tree | b28b84c22ca70f8e00ff657fbb3ef09d4b02b692 /source3 | |
parent | 926cc828973c1f0dc6b72b23552dc1b7028a3c97 (diff) | |
download | samba-9be17e2187a93633b23761fc2f6f0b40c94db809.tar.gz samba-9be17e2187a93633b23761fc2f6f0b40c94db809.tar.bz2 samba-9be17e2187a93633b23761fc2f6f0b40c94db809.zip |
dsgetdcname: mailslot replies are identical to the cldap ones, use cldap everywhere.
Guenther
(This used to be commit fe904ee77a7fec1674e9db660978c40c17897f77)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/clidgram.c | 62 | ||||
-rw-r--r-- | source3/libsmb/dsgetdcname.c | 79 | ||||
-rw-r--r-- | source3/winbindd/winbindd_cm.c | 1 |
3 files changed, 61 insertions, 81 deletions
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index 1d3293c60f..367b028396 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -197,14 +197,15 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, bool receive_getdc_response(TALLOC_CTX *mem_ctx, struct sockaddr_storage *dc_ss, const char *domain_name, + uint32_t *nt_version, const char **dc_name, - struct nbt_ntlogon_packet **reply) + union nbt_cldap_netlogon **reply) { struct packet_struct *packet; const char *my_mailslot = NULL; struct in_addr dc_ip; DATA_BLOB blob; - struct nbt_ntlogon_packet r; + union nbt_cldap_netlogon r; union dgram_message_body p; enum ndr_err_code ndr_err; @@ -259,31 +260,50 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, return false; } + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(dgram_smb_packet, &p); + } + blob = p.smb.body.trans.data; - ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &r, - (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet); - if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(0,("failed to parse packet\n")); + if (!pull_mailslot_cldap_reply(mem_ctx, &blob, + &r, nt_version)) + { return false; } - if (DEBUGLEVEL >= 10) { - NDR_PRINT_DEBUG(nbt_ntlogon_packet, &r); - } - - switch (r.command) { - case NTLOGON_SAM_LOGON_REPLY: - case NTLOGON_SAM_LOGON_REPLY15: - returned_domain = r.req.reply.domain; - returned_dc = r.req.reply.server; + switch (*nt_version) { + case 1: + returned_domain = r.logon1.domain_name; + returned_dc = r.logon1.pdc_name; + break; + case 2: + case 3: + returned_domain = r.logon3.domain_name; + returned_dc = r.logon3.pdc_name; break; - case NTLOGON_RESPONSE_FROM_PDC2: - returned_domain = r.req.reply2.domain; - returned_dc = r.req.reply2.pdc_name; + case 4: + case 5: + case 6: + case 7: + returned_domain = r.logon5.domain; + returned_dc = r.logon5.pdc_name; + break; + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + returned_domain = r.logon13.domain; + returned_dc = r.logon13.pdc_name; break; default: - return false; + returned_domain = r.logon29.domain; + returned_dc = r.logon29.pdc_name; + break; } if (!strequal(returned_domain, domain_name)) { @@ -301,8 +321,8 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, if (**dc_name == '\\') *dc_name += 1; if (reply) { - *reply = (struct nbt_ntlogon_packet *)talloc_memdup( - mem_ctx, &r, sizeof(struct nbt_ntlogon_packet)); + *reply = (union nbt_cldap_netlogon *)talloc_memdup( + mem_ctx, &r, sizeof(union nbt_cldap_netlogon)); if (!*reply) { return false; } diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index b64f340456..a21fc9a217 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -925,18 +925,10 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, enum nbt_name_type name_type = NBT_NAME_LOGON; int i; - const char *dc_hostname, *dc_domain_name; - const char *dc_address; - uint32_t dc_address_type; - uint32_t dc_flags = 0; const char *dc_name = NULL; - const char *dc_forest = NULL; - const char *dc_server_site = NULL; - const char *dc_client_site = NULL; - struct GUID *dc_domain_guid = NULL; fstring tmp_dc_name; struct messaging_context *msg_ctx = msg_context(mem_ctx); - struct nbt_ntlogon_packet *reply = NULL; + union nbt_cldap_netlogon *reply = NULL; uint32_t nt_version = NETLOGON_VERSION_1 | NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX_WITH_IP; @@ -968,12 +960,10 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, if (receive_getdc_response(mem_ctx, &dclist[i].ss, domain_name, + &nt_version, &dc_name, &reply)) { namecache_store(dc_name, NBT_NAME_SERVER, 1, &ip_list); - dc_hostname = dc_name; - dc_domain_name = talloc_strdup_upper(mem_ctx, domain_name); - NT_STATUS_HAVE_NO_MEMORY(dc_domain_name); goto make_reply; } smb_msleep(1500); @@ -986,65 +976,34 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, &dclist[i].ss, tmp_dc_name)) { - dc_hostname = tmp_dc_name; - dc_domain_name = talloc_strdup_upper(mem_ctx, domain_name); - namecache_store(tmp_dc_name, NBT_NAME_SERVER, 1, &ip_list); - goto make_reply; - } - } + struct nbt_cldap_netlogon_1 logon1; - return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; + reply = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon); + NT_STATUS_HAVE_NO_MEMORY(reply); - make_reply: + ZERO_STRUCT(logon1); - if (reply && reply->command == NTLOGON_RESPONSE_FROM_PDC2) { + nt_version = NETLOGON_VERSION_1; - dc_flags |= reply->req.reply2.server_type; - dc_forest = reply->req.reply2.forest; - dc_server_site = reply->req.reply2.server_site; - dc_client_site = reply->req.reply2.client_site; + logon1.nt_version = nt_version; + logon1.pdc_name = tmp_dc_name; + logon1.domain_name = talloc_strdup_upper(mem_ctx, domain_name); + NT_STATUS_HAVE_NO_MEMORY(logon1.domain_name); - dc_domain_guid = &reply->req.reply2.domain_uuid; + reply->logon1 = logon1; - if (flags & DS_RETURN_DNS_NAME) { - dc_domain_name = reply->req.reply2.dns_domain; - dc_hostname = reply->req.reply2.pdc_dns_name; - dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER; - } else if (flags & DS_RETURN_FLAT_NAME) { - dc_domain_name = reply->req.reply2.domain; - dc_hostname = reply->req.reply2.pdc_name; - } - } + namecache_store(tmp_dc_name, NBT_NAME_SERVER, 1, &ip_list); - if (flags & DS_IP_REQUIRED) { - char addr[INET6_ADDRSTRLEN]; - print_sockaddr(addr, sizeof(addr), &dclist[i].ss); - dc_address = talloc_asprintf(mem_ctx, "\\\\%s", addr); - dc_address_type = DS_ADDRESS_TYPE_INET; - } else { - dc_address = talloc_asprintf(mem_ctx, "\\\\%s", dc_hostname); - dc_address_type = DS_ADDRESS_TYPE_NETBIOS; + goto make_reply; + } } - if (flags & DS_PDC_REQUIRED) { - dc_flags |= NBT_SERVER_PDC | NBT_SERVER_WRITABLE; - } + return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; - if (dc_forest) { - dc_flags |= DS_DNS_FOREST; - } + make_reply: - return make_domain_controller_info(mem_ctx, - dc_hostname, - dc_address, - dc_address_type, - dc_domain_guid, - dc_domain_name, - dc_forest, - dc_flags, - dc_server_site, - dc_client_site, - info); + return make_dc_info_from_cldap_reply(mem_ctx, flags, &dclist[i].ss, + nt_version, reply, info); } /**************************************************************** diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 80f6bfaab3..0b0de5ad4f 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1101,6 +1101,7 @@ static bool dcip_to_name(TALLOC_CTX *mem_ctx, smb_msleep(100); for (i=0; i<5; i++) { if (receive_getdc_response(mem_ctx, pss, domain->name, + &nt_version, &dc_name, NULL)) { fstrcpy(name, dc_name); namecache_store(name, 0x20, 1, &ip_list); |