diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-04-14 02:36:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:11:32 -0500 |
commit | 8d0a36366c741d0ae9302f1ac8cc6894033be687 (patch) | |
tree | 34a19b847efc4865c7534a78ca7e862de4401deb /source4/torture | |
parent | 6f036daaa4a3f8c73512a7549a399e9b0f1f2758 (diff) | |
download | samba-8d0a36366c741d0ae9302f1ac8cc6894033be687.tar.gz samba-8d0a36366c741d0ae9302f1ac8cc6894033be687.tar.bz2 samba-8d0a36366c741d0ae9302f1ac8cc6894033be687.zip |
r6331: added IDL and test suite for the ADS style response to a datagram netlogon query.
Note that this response is almost identical to the CLDAP netlogon
response, so adding that will now be quite easy.
(This used to be commit 1ea4ed4ad1d9336f8288283688fa2d7bebfa533c)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/nbt/dgram.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index 14d98fc0c0..b1dd92621c 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -117,6 +117,68 @@ failed: } +/* test UDP/138 netlogon requests */ +static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx, + struct nbt_name name, const char *address) +{ + struct dgram_mailslot_handler *dgmslot; + struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(mem_ctx, NULL); + const char *myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + struct nbt_netlogon_packet logon; + struct nbt_name myname; + NTSTATUS status; + struct timeval tv = timeval_current(); + int replies = 0; + + /* try receiving replies on port 138 first, which will only + work if we are root and smbd/nmbd are not running - fall + back to listening on any port, which means replies from + some windows versions won't be seen */ + status = socket_listen(dgmsock->sock, myaddress, lp_dgram_port(), 0, 0); + if (!NT_STATUS_IS_OK(status)) { + socket_listen(dgmsock->sock, myaddress, 0, 0, 0); + } + + /* setup a temporary mailslot listener for replies */ + dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC, + netlogon_handler, &replies); + + + ZERO_STRUCT(logon); + logon.command = NETLOGON_QUERY_FOR_PDC2; + logon.req.pdc2.request_count = 0; + logon.req.pdc2.computer_name = TEST_NAME; + logon.req.pdc2.user_name = ""; + logon.req.pdc2.mailslot_name = dgmslot->mailslot_name; + logon.req.pdc2.nt_version = 11; + logon.req.pdc2.lmnt_token = 0xFFFF; + logon.req.pdc2.lm20_token = 0xFFFF; + + myname.name = TEST_NAME; + myname.type = NBT_NAME_CLIENT; + myname.scope = NULL; + + status = dgram_mailslot_netlogon_send(dgmsock, &name, address, + 0, &myname, &logon); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to send netlogon request - %s\n", nt_errstr(status)); + goto failed; + } + + + while (timeval_elapsed(&tv) < 5 && replies == 0) { + event_loop_once(dgmsock->event_ctx); + } + + talloc_free(dgmsock); + return True; + +failed: + talloc_free(dgmsock); + return False; +} + + /* reply handler for ntlogon request */ @@ -248,6 +310,7 @@ BOOL torture_nbt_dgram(void) } ret &= nbt_test_netlogon(mem_ctx, name, address); + ret &= nbt_test_netlogon2(mem_ctx, name, address); ret &= nbt_test_ntlogon(mem_ctx, name, address); talloc_free(mem_ctx); |