diff options
author | Jeremy Allison <jra@samba.org> | 2010-11-13 20:32:36 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-11-14 05:22:45 +0000 |
commit | 52f252064817b4be4d45d9fdbb0ad07748a0f317 (patch) | |
tree | cebc18dd44724ff5ff1e03da4a3736f89ec32f06 /source3/libsmb/clidgram.c | |
parent | 781c4aabb87e63df77c76a360b6ed5f6a20e6d58 (diff) | |
download | samba-52f252064817b4be4d45d9fdbb0ad07748a0f317.tar.gz samba-52f252064817b4be4d45d9fdbb0ad07748a0f317.tar.xz samba-52f252064817b4be4d45d9fdbb0ad07748a0f317.zip |
Fix the unexpected.tdb database problem. Change nmbd to store the
transaction id of packets it was requested to send via a client, and
only store replies that match these ids. On the client side change
clients to always attempt to ask nmbd first for name_query and
node_status calls, and then fall back to doing socket calls if
we can't talk to nmbd (either nmbd is not running, or we're not
root and cannot open the messaging tdb's). Fix readers of unexpected.tdb
to delete packets they've successfully read.
This should fix a long standing problem of unexpected.tdb
growing out of control in noisy NetBIOS envioronments with
lots of bradcasts, yet still allow unprivileged client apps
to work mostly as well as they already did (nmblookup for
example) in an environment when nmbd isn't running.
Jeremy.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sun Nov 14 05:22:45 UTC 2010 on sn-devel-104
Diffstat (limited to 'source3/libsmb/clidgram.c')
-rw-r--r-- | source3/libsmb/clidgram.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index 919ea93c919..6a7c1b9fd08 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -33,7 +33,8 @@ static bool cli_send_mailslot(struct messaging_context *msg_ctx, char *buf, int len, const char *srcname, int src_type, const char *dstname, int dest_type, - const struct sockaddr_storage *dest_ss) + const struct sockaddr_storage *dest_ss, + int dgm_id) { struct packet_struct p; struct dgram_packet *dgram = &p.packet.dgram; @@ -63,8 +64,7 @@ static bool cli_send_mailslot(struct messaging_context *msg_ctx, dgram->header.flags.node_type = M_NODE; dgram->header.flags.first = True; dgram->header.flags.more = False; - dgram->header.dgm_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + - ((unsigned)sys_getpid()%(unsigned)100); + dgram->header.dgm_id = dgm_id; /* source ip is filled by nmbd */ dgram->header.dgm_length = 0; /* Let build_dgram() handle this. */ dgram->header.packet_offset = 0; @@ -133,7 +133,8 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, struct sockaddr_storage *dc_ss, const char *domain_name, const struct dom_sid *sid, - uint32_t nt_version) + uint32_t nt_version, + int dgm_id) { struct in_addr dc_ip; const char *my_acct_name = NULL; @@ -193,12 +194,13 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx, false, NBT_MAILSLOT_NTLOGON, 0, (char *)blob.data, blob.length, global_myname(), 0, domain_name, 0x1c, - dc_ss); + dc_ss, dgm_id); } bool receive_getdc_response(TALLOC_CTX *mem_ctx, struct sockaddr_storage *dc_ss, const char *domain_name, + int dgm_id, uint32_t *nt_version, const char **dc_name, struct netlogon_samlogon_response **samlogon_response) @@ -226,7 +228,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, return false; } - packet = receive_unexpected(DGRAM_PACKET, 0, my_mailslot); + packet = receive_unexpected(DGRAM_PACKET, dgm_id, my_mailslot); if (packet == NULL) { DEBUG(5, ("Did not receive packet for %s\n", my_mailslot)); |