summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/libcli/dgram/libdgram.h6
-rw-r--r--source4/libcli/dgram/mailslot.c2
-rw-r--r--source4/libcli/dgram/netlogon.c16
-rw-r--r--source4/librpc/idl/nbt.idl14
-rw-r--r--source4/torture/nbt/dgram.c22
5 files changed, 56 insertions, 4 deletions
diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h
index 482fd86980..0b8157f0c6 100644
--- a/source4/libcli/dgram/libdgram.h
+++ b/source4/libcli/dgram/libdgram.h
@@ -124,5 +124,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
const char *dest_address,
struct nbt_name *src_name,
struct nbt_netlogon_packet *request);
-
-
+NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_packet *netlogon);
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index 89aab9c874..3b7fcdcd81 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -64,6 +64,8 @@ struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dg
DLIST_ADD(dgmsock->mailslot_handlers, dgmslot);
talloc_set_destructor(dgmslot, dgram_mailslot_destructor);
+ EVENT_FD_READABLE(dgmsock->fde);
+
return dgmslot;
}
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index 1f3a3d6c62..c76264eea4 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -56,3 +56,19 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
return status;
}
+
+/*
+ parse a netlogon response. The packet must be a valid mailslot packet
+*/
+NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_packet *netlogon)
+{
+ DATA_BLOB *data = &dgram->data.msg.body.smb.body.trans.data;
+ NTSTATUS status;
+
+ status = ndr_pull_struct_blob(data, mem_ctx, netlogon,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
+ return status;
+}
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index 09738820bb..6f17a14cde 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -321,7 +321,8 @@ interface nbt
/* \MAILSLOT\NET\NETLOGON mailslot requests */
typedef [enum8bit] enum {
- NETLOGON_QUERY_FOR_PDC = 0x7
+ NETLOGON_QUERY_FOR_PDC = 0x7,
+ NETLOGON_RESPONSE_FROM_PDC = 0xc
} nbt_netlogon_command;
/* query for pdc request */
@@ -334,8 +335,19 @@ interface nbt
uint16 lm20_token;
} nbt_netlogon_query_for_pdc;
+ /* response from request */
+ typedef struct {
+ astring pdc_name;
+ nstring unicode_pdc_name;
+ nstring domain_name;
+ uint32 nt_version;
+ uint16 lmnt_token;
+ uint16 lm20_token;
+ } nbt_netlogon_response_from_pdc;
+
typedef [nodiscriminant] union {
[case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
+ [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
} nbt_netlogon_request;
typedef [flag(NDR_NOALIGN),public] struct {
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index c87940a94d..b87e7e0b0f 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -36,9 +36,22 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
const char *src_address, int src_port)
{
+ NTSTATUS status;
+ struct nbt_netlogon_packet netlogon;
+
printf("netlogon reply from %s:%d\n", src_address, src_port);
+
+ status = dgram_mailslot_netlogon_parse(dgmslot, dgmslot, packet, &netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to parse netlogon packet from %s:%d\n",
+ src_address, src_port);
+ return;
+ }
+
+ NDR_PRINT_DEBUG(nbt_netlogon_packet, &netlogon);
}
+
/* test UDP/138 netlogon requests */
static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx,
struct nbt_name name, const char *address)
@@ -52,7 +65,14 @@ static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx,
int timelimit = lp_parm_int(-1, "torture", "timelimit", 10);
struct timeval tv = timeval_current();
- socket_listen(dgmsock->sock, myaddress, 0, 0, 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, "\\MAILSLOT\\NET\\GETDC",