[SCM] Samba Shared Repository - branch master updated - afd405dd90561b6aa99b4c9e5b62644659b96768

Stefan Metzmacher metze at samba.org
Mon Jan 19 06:09:29 GMT 2009


The branch, master has been updated
       via  afd405dd90561b6aa99b4c9e5b62644659b96768 (commit)
       via  2973af51110ebefda71b01a7292aa27cdf58aaf9 (commit)
       via  2dcac3c5e6ab19d0d274c09eb47c4fddf82b7a2c (commit)
       via  6bcd2cbd27cc62e5cfc5a4707b7a991ab691f3c8 (commit)
       via  d5b7240ac510fc3d1a7033b22a3a59b1450103aa (commit)
       via  7c7bdf3669f55b7bd3e2ff138af8f57bcc6596ee (commit)
       via  e1c968afd85c229490f1e6c13da94a6ef824b122 (commit)
       via  fb64b12be5c347645976f8000a79f2d31c9a5c79 (commit)
       via  81a2a43a5a3c13d08ed458d861d47f63a15ceac9 (commit)
       via  bbe4785f342d6513fd001fdde94a945b2f2b654a (commit)
       via  c4402e3fde823a1984cc10f390d09c0ef9c8af0d (commit)
       via  780bc13736f264435ba9af6dda84235ea217d526 (commit)
       via  cd5e43b32761daea36187f28a72795f7696ea546 (commit)
       via  a5b3975cf71f0bf114832c958ba855646c69832c (commit)
       via  ebab6d6ce40ec4d64126964c0223aa2bdef99094 (commit)
       via  26c48098e6c387cc76b123a78d50f23518d734cf (commit)
       via  c97df0d892d71462dfd631cf5e93f04641afaab3 (commit)
       via  65f096c8cda9efd6cffb29b52cac610664bbfbc2 (commit)
       via  9598d775a5c1c26b502171737d00084f074e16f8 (commit)
       via  6d107fff13ad42828085ce368dc6e02e24f87713 (commit)
       via  bbd74f2f760184b88341f35f2769b91480e8eb9d (commit)
       via  4a878115a70851ba77bc984c4313e95a608c5764 (commit)
       via  1ffcebbf0f912f4ccbff76f05280f7ed98d5e5ea (commit)
       via  462e4d0cef822d90d982cfb0b38dd60015929bcc (commit)
       via  384b9f709a16085e48469484a564ce0a7128af13 (commit)
       via  ee8f481d9422dff239a871d363da879a5776f7d9 (commit)
       via  bae593bb118459c1b0d12d02e58ba6c89400aa97 (commit)
       via  996790719066d92f563bf53fe4222d2b5e3863a5 (commit)
       via  9d4f766ae35176b0597dd359d692e4166c2314fc (commit)
       via  3b91640fbb16b5ab248d2fa4d2832f61dac29944 (commit)
      from  d6e801b7d9a666d40f109df20dff0faaa2b46e70 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit afd405dd90561b6aa99b4c9e5b62644659b96768
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jun 18 16:24:51 2008 +0200

    nbt_server/wins: winsdb_handle() can be static
    
    metze
    (from samba4wins tree ba45b14b48f62eb1668509738f83fa17a4ce95fd)

commit 2973af51110ebefda71b01a7292aa27cdf58aaf9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 17 11:50:52 2009 +0100

    nbt_server/wins: add some const
    
    metze
    (from samba4wins tree e54b2d3ddbf338fe5d9802724e76f320fd4423e5)

commit 2dcac3c5e6ab19d0d274c09eb47c4fddf82b7a2c
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jun 18 16:22:39 2008 +0200

    nbt_server/wins: use talloc_zero() to create struct winsdb_handle
    
    metze
    (from samba4wins tree 0f2995f77ab092d71e539c2473c94956f9c253fb)

commit 6bcd2cbd27cc62e5cfc5a4707b7a991ab691f3c8
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Mar 26 20:07:10 2008 +0100

    wrepl_server: make 'use inform' the default and autofallback against old servers
    
    metze
    (from samba4wins tree f44c8c8e1986e2105e899bb1f8a3896575eef582)

commit d5b7240ac510fc3d1a7033b22a3a59b1450103aa
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Mar 26 20:06:12 2008 +0100

    libcli/wrepl: return the major version of the server in wrepl_associate()
    
    metze
    (from samba4wins tree 1ea02d50d1607b94e15ff07568fa5056cb6e4f09)

commit 7c7bdf3669f55b7bd3e2ff138af8f57bcc6596ee
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Mar 26 19:33:15 2008 +0100

    wreplserver: add "wreplsrv:propagate name releases = yes" for replicated sgroup merges
    
    metze
    (from samba4wins tree 80cbe665e561182d28acc6ad474243b83f3e4d28)

commit e1c968afd85c229490f1e6c13da94a6ef824b122
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Tue Mar 25 17:35:33 2008 +0100

    winsserver: add "wreplsrv:propagate name releases" option
    
    Add an option to propagate name releases directly.
    This make the results for #1C name queries more consistent
    among all servers.
    
    It's off by default to match windows.
    
    metze
    (from samba4wins tree 166e9fdffb9f4e26513c3b4ec1f6f168ecbe18f8)

commit fb64b12be5c347645976f8000a79f2d31c9a5c79
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Tue Mar 25 17:30:52 2008 +0100

    winsserver_release: update the expire time if only one address is released
    
    We also take the ownership if the record isn't owned.
    This matches windows...
    
    metze
    (from samba4wins tree d7b19339c0444cbe0989fcfa91a22323215d2f6b)

commit 81a2a43a5a3c13d08ed458d861d47f63a15ceac9
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Tue Mar 25 16:44:46 2008 +0100

    wrepl_scavenging: add a comment to make the is_static case more clear
    
    metze
    (from samba4wins tree 67fa7dc4fe36b143d36df1309840328a14683e31)

commit bbe4785f342d6513fd001fdde94a945b2f2b654a
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Thu Mar 20 13:27:13 2008 +0100

    wrepl_server: fix the record expire time of sgroup merges
    
    if we're the owner, the expire time becomes the highest
    expire time of owned addresses
    
    metze
    (from samba4wins tree 024f439db45046c7c0bb4759c75877462405baec)

commit c4402e3fde823a1984cc10f390d09c0ef9c8af0d
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Thu Mar 20 13:26:14 2008 +0100

    wrepl_server: use a local 'local_owner' variable to make the code more readable
    
    metze
    (from samba4wins tree eba9a8ce0641a2984112f4e1473801fa449ed96d)

commit 780bc13736f264435ba9af6dda84235ea217d526
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Tue Mar 18 16:08:02 2008 +0100

    winsdb: the we_are_owner in winsdb_lookup() needs to be per address
    
    This fixes a bug where #1C addresses are registered with different
    WINS-Servers and a merged #1C record.
    
    metze
    (from samba4wins tree 72e055394a0fd1f543be9c196b4179356a1033f6)

commit cd5e43b32761daea36187f28a72795f7696ea546
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Fri Feb 8 11:50:34 2008 +0100

    nbt_server: fix crash bug, the wins client interface may not have a nbtsock
    
    metze
    (from samba4wins tree 8035601da7c7e8b65fe1d82c2654c412fa169338)

commit a5b3975cf71f0bf114832c958ba855646c69832c
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jan 16 13:57:50 2008 +0100

    nbt_server: redirect incoming response packets to the correct interface
    
    We may send requests packets (WACK challenges or similar things)
    via a different udp socket than the socket we receive the
    matching response. We need to setup an unexpected handler
    on the nbt sockets and redirect responses to the correct
    nbt_socket. (By redirect I mean we use the correct
    nbt_socket structure, we're *not* resending the packet
    with sendto() via the kernel...)
    
    metze
    (from samba4wins tree 7ce8e705e5a9aabb787d17fbec7a078d9d6780dc)

commit ebab6d6ce40ec4d64126964c0223aa2bdef99094
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jan 16 14:51:56 2008 +0100

    libcli/nbt: add nbt_name_socket_handle_response_packet()
    
    Move the last part of nbt_name_socket_recv() into
    a new function nbt_name_socket_handle_response_packet()
    so that it can be reused by an unexpected handler.
    
    metze
    (from samba4wins tree cb0377f3b95e50c84fac999a49dde80acc933124)

commit 26c48098e6c387cc76b123a78d50f23518d734cf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 17 18:15:24 2009 +0100

    libcli/nbt: add nbt_set_unexpected_handler()
    
    metze
    (from samba4wins tree 74232901d1e7ea9ebcb3bd8d584dda36fac37223)

commit c97df0d892d71462dfd631cf5e93f04641afaab3
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jan 16 13:43:07 2008 +0100

    nbt_server: add some debug messages which show the used interfaces addresses
    
    metze
    (from samba4wins tree 8eb30add7c95672a85b4084b4a3dbfa78db820c4)

commit 65f096c8cda9efd6cffb29b52cac610664bbfbc2
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Mon Jan 14 13:57:12 2008 +0100

    wreplsrv: don't log scavenging events at level 0
    
    metze
    (from samba4wins tree 7a1d4fac9d77440c2c463bfdb2a5671e4817cfdf)

commit 9598d775a5c1c26b502171737d00084f074e16f8
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Mon Jan 14 13:56:25 2008 +0100

    wreplsrv: log a successful replication cycle at level 1
    
    metze
    (from samba4wins tree b411e60e1536668e11bc5d8eaa389071b25077bf)

commit 6d107fff13ad42828085ce368dc6e02e24f87713
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Mon Jan 14 13:52:14 2008 +0100

    wreplsrv: log replication failures at log level 0
    
    metze
    (from samba4wins tree 405cbb74b7191e744178894a5e0ac4abcac2a4fe)

commit bbd74f2f760184b88341f35f2769b91480e8eb9d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 17 18:14:29 2009 +0100

    libcli/nbt: fix wack timeout handling
    
    If the client gets a WACK response, the server
    sends a timeout to the client. Possible
    values are between 9 and 105 seconds.
    
    Because w2k3 servers have a bug and always return
    a value of 5 seconds, we need a workarround.
    
    Always using a fixed value of 30 seconds is bad
    as we could timeout to early.
    
    Now we use the value from the server if it's in the
    valid range and otherwise we use the upper limit
    of the valid range (105s).
    
    metze
    (from samba4wins tree 40ef7739f4141598a6392c203e4a2d52d972fe06)

commit 4a878115a70851ba77bc984c4313e95a608c5764
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Mon Jan 14 09:10:37 2008 +0100

    NBT-WINS: test if the server ignores resent packets
    
    metze
    (from samba4wins tree 24eb7577414c8584b97f43c850d738d3dbb30777)

commit 1ffcebbf0f912f4ccbff76f05280f7ed98d5e5ea
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Fri Jan 11 19:10:30 2008 +0100

    NBT-WINS: we don't need the slow low port tests for every name
    
    metze
    (from samba4wins tree 7862deca8555f960a5ef65e6315ce94af5023a2a)

commit 462e4d0cef822d90d982cfb0b38dd60015929bcc
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Fri Jan 11 19:05:33 2008 +0100

    NBT-WINS: if we're bound to port 137 trigger WACK reponses with timeouts
    
    metze
    (from samba4wins tree de7225658493006c19d139ac77ac1b1ffab01d25)

commit 384b9f709a16085e48469484a564ce0a7128af13
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Fri Jan 11 19:01:50 2008 +0100

    NBT-WINS: try to bind to port 137 in the NBT-WINS test
    
    metze
    (from samba4wins tree 5e101475d5ed62060c991ea71c943e76b862aeef)

commit ee8f481d9422dff239a871d363da879a5776f7d9
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Fri Jan 11 16:11:59 2008 +0100

    winsserver: we need to ignore duplicated name register requests.
    
    This fixes the following bug:
    
    While we reply with a WACK response to a client.
    Instead of waiting for the final reply some
    windows client just resends the request using
    the same name_trn_id in the nbt_name_packet.
    We handled this as a new request and send a
    WACK response (and the challenges) again.
    Then the first request gets its final success
    response, but the when we try to send the success
    for the "second" request we notice that
    the record was changed in between and we return
    an error.
    
    Windows 2003 (and I assume all other versions as well)
    detect the packet is just a resent of a currently pending
    request and ignores it.
    
    So we now keep a list of all pending WINS name register
    requests which result in a WACK response. On each incoming
    name register request we search through the list to find
    duplicate requests and ignore them. In theory we should
    do that for all requests, but name register requests
    are the only requests we response async and only
    if we have to go via the WACK code path.
    
    metze
    (from samba4wins tree 382e7d384b70d03e9f81c7bb353afaed288d80f0)

commit bae593bb118459c1b0d12d02e58ba6c89400aa97
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 17 18:13:31 2009 +0100

    ndr_print: fix the output ndr debug messages only add header line once
    
    metze
    (from samba4wins tree e99531aae325e4443fcb917a75dfe4a86b892583)

commit 996790719066d92f563bf53fe4222d2b5e3863a5
Author: Stefan Metzmacher <metze at sernet.de>
Date:   Wed Jan 30 10:34:57 2008 +0100

    util_str: setup the correct talloc name for strings
    
    metze
    (partly from samba4wins tree 447e7f9532131117e896712db9def321c96718eb)

commit 9d4f766ae35176b0597dd359d692e4166c2314fc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sun Jan 18 23:20:01 2009 +0100

    Revert "Remove another use of global_loadparm."
    
    This reverts commit ee7c2170a79f1ca9e2ad1a209d342d8fd287ec8d.
    
    A much more correct fix will come soon.
    (40ef7739f4141598a6392c203e4a2d52d972fe06 from the samba4wins tree)
    
    metze

commit 3b91640fbb16b5ab248d2fa4d2832f61dac29944
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 17 10:06:08 2009 +0100

    NBT-WINS: initialize .dest_port explicit (we should fill the whole struct each time)
    
    This makes the code more clear.
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 lib/util/substitute.c                      |    2 +
 lib/util/util_str.c                        |    2 +
 libcli/nbt/libnbt.h                        |    9 +-
 libcli/nbt/nbtsocket.c                     |   48 ++++++-
 libcli/nbt/pynbt.c                         |    3 +-
 librpc/ndr/ndr.c                           |    6 +
 source4/libcli/raw/rawfile.c               |    2 +
 source4/libcli/wrepl/winsrepl.c            |    1 +
 source4/libcli/wrepl/winsrepl.h            |    1 +
 source4/nbt_server/interfaces.c            |   68 +++++++++-
 source4/nbt_server/nbt_server.h            |    2 +
 source4/nbt_server/wins/wins_ldb.c         |    2 +-
 source4/nbt_server/wins/winsdb.c           |   51 +++----
 source4/nbt_server/wins/winsserver.c       |   83 ++++++++++-
 source4/torture/nbt/wins.c                 |  217 +++++++++++++++++++++++++---
 source4/wrepl_server/wrepl_apply_records.c |   50 +++++++-
 source4/wrepl_server/wrepl_in_call.c       |   12 +-
 source4/wrepl_server/wrepl_out_helpers.c   |   25 +++-
 source4/wrepl_server/wrepl_out_pull.c      |    6 +-
 source4/wrepl_server/wrepl_scavenging.c    |   66 +++++++--
 source4/wrepl_server/wrepl_server.c        |    2 +-
 source4/wrepl_server/wrepl_server.h        |    1 +
 22 files changed, 562 insertions(+), 97 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/substitute.c b/lib/util/substitute.c
index 84514ac..32945a7 100644
--- a/lib/util/substitute.c
+++ b/lib/util/substitute.c
@@ -120,6 +120,8 @@ _PUBLIC_ char *string_sub_talloc(TALLOC_CTX *mem_ctx, const char *s,
 
 	SMB_ASSERT(ret[len] == '\0');
 
+	talloc_set_name_const(ret, ret);
+
 	return ret;
 }
 
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index 7dcefc9..a2c50fd 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -153,6 +153,8 @@ _PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s)
 		}
 	}
 
+	talloc_set_name_const(ret, ret);
+
 	return ret;
 }
 
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 0c4420c..491abd7 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -122,8 +122,6 @@ struct nbt_name_socket {
 				struct socket_address *);
 		void *private_data;
 	} unexpected;
-
-	uint32_t wack_timeout;
 };
 
 
@@ -279,6 +277,9 @@ struct nbt_name_release {
 struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
 					     struct tevent_context *event_ctx,
 					     struct smb_iconv_convenience *iconv_convenience);
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+					    struct nbt_name_packet *packet,
+					    struct socket_address *src);
 struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
 					     struct nbt_name_query *io);
 NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
@@ -326,6 +327,10 @@ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
 				  void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
 						  struct socket_address *),
 				  void *private_data);
+NTSTATUS nbt_set_unexpected_handler(struct nbt_name_socket *nbtsock,
+				    void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+						    struct socket_address *),
+				    void *private);
 NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
 			     struct socket_address *dest,
 			     struct nbt_name_packet *request);
diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c
index 780e2bb..0d269fa 100644
--- a/libcli/nbt/nbtsocket.c
+++ b/libcli/nbt/nbtsocket.c
@@ -231,9 +231,20 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
 		return;
 	}
 
+	talloc_steal(req, packet);
+	talloc_steal(req, src);
+	talloc_free(tmp_ctx);
+	nbt_name_socket_handle_response_packet(req, packet, src);
+}
+
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+					    struct nbt_name_packet *packet,
+					    struct socket_address *src)
+{
 	/* if this is a WACK response, this we need to go back to waiting,
 	   but perhaps increase the timeout */
 	if ((packet->operation & NBT_OPCODE) == NBT_OPCODE_WACK) {
+		uint32_t ttl;
 		if (req->received_wack || packet->ancount < 1) {
 			nbt_name_request_destructor(req);
 			req->status = NT_STATUS_INVALID_NETWORK_RESPONSE;
@@ -245,13 +256,26 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
 		   has received our request */
 		req->num_retries   = 0;
 		req->received_wack = true;
-		/* although there can be a timeout in the packet, w2k3 screws it up,
-		   so better to set it ourselves */
-		req->timeout = nbtsock->wack_timeout;
+		/*
+		 * there is a timeout in the packet,
+		 * it is 5 + 4 * num_old_addresses
+		 *
+		 * although w2k3 screws it up
+		 * and uses num_old_addresses = 0
+		 *
+		 * so we better fallback to the maximum
+		 * of num_old_addresses = 25 if we got
+		 * a timeout of less than 9s (5 + 4*1)
+		 * or more than 105s (5 + 4*25).
+		 */
+		ttl = packet->answers[0].ttl;
+		if ((ttl < (5 + 4*1)) || (ttl > (5 + 4*25))) {
+			ttl = 5 + 4*25;
+		}
+		req->timeout = ttl;
 		req->te = event_add_timed(req->nbtsock->event_ctx, req,
 					  timeval_current_ofs(req->timeout, 0),
 					  nbt_name_socket_timeout, req);
-		talloc_free(tmp_ctx);
 		return;
 	}
 
@@ -273,7 +297,6 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
 	/* if we don't want multiple replies then we are done */
 	if (req->allow_multiple_replies &&
 	    req->num_replies < NBT_MAX_REPLIES) {
-		talloc_free(tmp_ctx);
 		return;
 	}
 
@@ -282,7 +305,6 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
 	req->status = NT_STATUS_OK;
 
 done:
-	talloc_free(tmp_ctx);
 	if (req->async.fn) {
 		req->async.fn(req);
 	}
@@ -334,7 +356,6 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
 
 	nbtsock->send_queue = NULL;
 	nbtsock->num_pending = 0;
-	nbtsock->wack_timeout = 30;
 	nbtsock->incoming.handler = NULL;
 	nbtsock->unexpected.handler = NULL;
 	nbtsock->iconv_convenience = iconv_convenience;
@@ -495,6 +516,19 @@ _PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
 	return NT_STATUS_OK;
 }
 
+/*
+  setup a handler for unexpected requests
+*/
+NTSTATUS nbt_set_unexpected_handler(struct nbt_name_socket *nbtsock,
+				    void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+						    struct socket_address *),
+				    void *private)
+{
+	nbtsock->unexpected.handler = handler;
+	nbtsock->unexpected.private_data = private;
+	EVENT_FD_READABLE(nbtsock->fde);
+	return NT_STATUS_OK;
+}
 
 /*
   turn a NBT rcode into a NTSTATUS
diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c
index 63ee9bb..9be6c79 100644
--- a/libcli/nbt/pynbt.c
+++ b/libcli/nbt/pynbt.c
@@ -52,8 +52,7 @@ static PyObject *py_nbt_node_init(PyTypeObject *self, PyObject *args, PyObject *
 		return NULL;
 
 	ev = s4_event_context_init(ret->mem_ctx);
-	ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, 
-									   py_iconv_convenience(ret->mem_ctx));
+	ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, py_iconv_convenience(ret->mem_ctx));
 	return (PyObject *)ret;
 }
 
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index c382abb..9f7aab3 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -211,6 +211,8 @@ _PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
 {
 	struct ndr_print *ndr;
 
+	DEBUG(0,(""));
+
 	ndr = talloc_zero(NULL, struct ndr_print);
 	if (!ndr) return;
 	ndr->print = ndr_print_debug_helper;
@@ -227,6 +229,8 @@ _PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_
 {
 	struct ndr_print *ndr;
 
+	DEBUG(0,(""));
+
 	ndr = talloc_zero(NULL, struct ndr_print);
 	if (!ndr) return;
 	ndr->print = ndr_print_debug_helper;
@@ -244,6 +248,8 @@ _PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name
 {
 	struct ndr_print *ndr;
 
+	DEBUG(0,(""));
+
 	ndr = talloc_zero(NULL, struct ndr_print);
 	if (!ndr) return;
 	ndr->print = ndr_print_debug_helper;
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 8cabac6..63de051 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -71,6 +71,8 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib)
 
 	ret[len] = 0;
 
+	talloc_set_name_const(ret, ret);
+
 	return ret;
 }
 
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index c063a4b..61bb10b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -611,6 +611,7 @@ NTSTATUS wrepl_associate_recv(struct wrepl_request *req,
 	}
 	if (NT_STATUS_IS_OK(status)) {
 		io->out.assoc_ctx = packet->message.start_reply.assoc_ctx;
+		io->out.major_version = packet->message.start_reply.major_version;
 	}
 	talloc_free(packet);
 	return status;
diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h
index 532496d..738ba39 100644
--- a/source4/libcli/wrepl/winsrepl.h
+++ b/source4/libcli/wrepl/winsrepl.h
@@ -93,6 +93,7 @@ struct wrepl_request {
 struct wrepl_associate {
 	struct {
 		uint32_t assoc_ctx;
+		uint16_t major_version;
 	} out;
 };
 
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index 4940644..0a9196a 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -75,6 +75,58 @@ static void nbtd_request_handler(struct nbt_name_socket *nbtsock,
 	}
 }
 
+static void nbtd_unexpected_handler(struct nbt_name_socket *nbtsock,
+				    struct nbt_name_packet *packet,
+				    struct socket_address *src)
+{
+	struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private_data,
+						       struct nbtd_interface);
+	struct nbtd_server *nbtsrv = iface->nbtsrv;
+	struct nbtd_interface *i;
+	struct nbt_name_request *req = NULL;
+
+	nbtsrv->stats.total_received++;
+
+	DEBUG(10,("unexpected from src[%s] on interface[%p] %s/%s\n",
+		src->addr, iface, iface->ip_address, iface->netmask));
+
+	/* try the broadcast interface */
+	if (nbtsrv->bcast_interface) {
+		i = nbtsrv->bcast_interface;
+		req = idr_find(i->nbtsock->idr, packet->name_trn_id);
+	}
+
+	/* try the wins server client interface */
+	if (!req && nbtsrv->wins_interface && nbtsrv->wins_interface->nbtsock) {
+		i = nbtsrv->wins_interface;
+		req = idr_find(i->nbtsock->idr, packet->name_trn_id);
+	}
+
+	/* try all other interfaces... */
+	if (!req) {
+		for (i = nbtsrv->interfaces; i; i = i->next) {
+			if (i == iface) {
+				continue;
+			}
+			req = idr_find(i->nbtsock->idr, packet->name_trn_id);
+			if (req) break;
+		}
+	}
+
+	if (!req) {
+		DEBUG(10,("unexpected from src[%s] unable to redirected\n", src->addr));
+		return;
+	}
+
+	DEBUG(10,("unexpected from src[%s] redirected to interface[%p] %s/%s\n",
+		src->addr, i, i->ip_address, i->netmask));
+
+	/*
+	 * redirect the incoming response to the socket
+	 * we sent the matching request
+	 */
+	nbt_name_socket_handle_response_packet(req, packet, src);
+}
 
 /*
   find a registered name on an interface
@@ -109,6 +161,8 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
 	struct socket_address *bcast_address;
 	struct socket_address *unicast_address;
 
+	DEBUG(6,("nbtd_add_socket(%s, %s, %s, %s)\n", bind_address, address, bcast, netmask));
+
 	/*
 	  we actually create two sockets. One listens on the broadcast address
 	  for the interface, and the other listens on our specific address. This
@@ -125,6 +179,7 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
 	iface->ip_address    = talloc_steal(iface, address);
 	iface->netmask       = talloc_steal(iface, netmask);
 	iface->names         = NULL;
+	iface->wack_queue    = NULL;
 
 	if (strcmp(netmask, "0.0.0.0") != 0) {
 		struct nbt_name_socket *bcast_nbtsock;
@@ -177,6 +232,7 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
 	talloc_free(unicast_address);
 
 	nbt_set_incoming_handler(iface->nbtsock, nbtd_request_handler, iface);
+	nbt_set_unexpected_handler(iface->nbtsock, nbtd_unexpected_handler, iface);
 
 	/* also setup the datagram listeners */
 	status = nbtd_dgram_setup(iface, bind_address);
@@ -325,17 +381,25 @@ struct nbtd_interface *nbtd_find_request_iface(struct nbtd_server *nbtd_server,
 	/* try to find a exact match */
 	for (cur=nbtd_server->interfaces;cur;cur=cur->next) {
 		if (iface_same_net(address, cur->ip_address, cur->netmask)) {
+			DEBUG(10,("find interface for dst[%s] ip: %s/%s (iface[%p])\n",
+				  address, cur->ip_address, cur->netmask, cur));
 			return cur;
 		}
 	}
 
 	/* no exact match, if we have the broadcast interface, use that */
 	if (allow_bcast_iface && nbtd_server->bcast_interface) {
-		return nbtd_server->bcast_interface;
+		cur = nbtd_server->bcast_interface;
+		DEBUG(10,("find interface for dst[%s] ip: %s/%s (bcast iface[%p])\n",
+			address, cur->ip_address, cur->netmask, cur));
+		return cur;
 	}
 
 	/* fallback to first interface */
-	return nbtd_server->interfaces;
+	cur = nbtd_server->interfaces;
+	DEBUG(10,("find interface for dst[%s] ip: %s/%s (default iface[%p])\n",
+		address, cur->ip_address, cur->netmask, cur));
+	return cur;
 }
 
 /*
diff --git a/source4/nbt_server/nbt_server.h b/source4/nbt_server/nbt_server.h
index 00d8f31..c80e5bf 100644
--- a/source4/nbt_server/nbt_server.h
+++ b/source4/nbt_server/nbt_server.h
@@ -41,6 +41,7 @@ struct nbtd_iface_name {
 	const char *wins_server;
 };
 
+struct nbtd_wins_wack_state;
 
 /* a list of network interfaces we are listening on */
 struct nbtd_interface {
@@ -52,6 +53,7 @@ struct nbtd_interface {
 	struct nbt_name_socket *nbtsock;
 	struct nbt_dgram_socket *dgmsock;
 	struct nbtd_iface_name *names;
+	struct nbtd_wins_wack_state *wack_queue;
 };
 
 
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index 02ea306..557c0f1 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -98,7 +98,7 @@ static int wins_ldb_init(struct ldb_module *ctx)
 		}
 	}
 
-	h = talloc(ctx, struct winsdb_handle);
+	h = talloc_zero(ctx, struct winsdb_handle);
 	if (!h) goto failed;
 	h->ldb		= ctx->ldb;
 	h->caller	= WINSDB_HANDLE_CALLER_ADMIN;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 945914c..bf9b8c4 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -153,7 +153,8 @@ failed:
 /*
   return a DN for a nbt_name
 */
-static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, struct nbt_name *name)
+static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
+				const struct nbt_name *name)
 {
 	struct ldb_dn *dn;
 
@@ -167,7 +168,7 @@ static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, st
 	return dn;
 }
 
-static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct nbt_name **_name)
+static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, const struct ldb_dn *dn, struct nbt_name **_name)
 {
 	NTSTATUS status;
 	struct nbt_name *name;
@@ -568,7 +569,7 @@ const char **winsdb_addr_string_list(TALLOC_CTX *mem_ctx, struct winsdb_addr **a
   load a WINS entry from the database
 */
 NTSTATUS winsdb_lookup(struct winsdb_handle *h, 
-		       struct nbt_name *name,
+		       const struct nbt_name *name,
 		       TALLOC_CTX *mem_ctx,
 		       struct winsdb_record **_rec)
 {
@@ -613,7 +614,6 @@ NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_
 	struct ldb_message_element *el;
 	struct nbt_name *name;
 	uint32_t i, j, num_values;
-	bool we_are_owner = false;
 
 	rec = talloc(mem_ctx, struct winsdb_record);
 	if (rec == NULL) {
@@ -674,26 +674,6 @@ NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_
 		goto failed;
 	}
 
-	if (strcmp(rec->wins_owner, h->local_owner) == 0) {
-		we_are_owner = true;
-	}
-
-	/* 
-	 * see if it has already expired
-	 * 
-	 * NOTE: only expire owned records this way!
-	 *       w2k3 resolves expired replicas
-	 *       which are in active state
-	 */
-	if (!rec->is_static &&
-	    rec->expire_time <= now &&
-	    rec->state == WREPL_STATE_ACTIVE &&
-	    we_are_owner) {
-		DEBUG(5,("WINS: expiring name %s (expired at %s)\n", 
-			 nbt_name_string(mem_ctx, rec->name), timestring(mem_ctx, rec->expire_time)));
-		rec->state = WREPL_STATE_RELEASED;
-	}
-
 	rec->addresses     = talloc_array(rec, struct winsdb_addr *, num_values+1);
 	if (rec->addresses == NULL) {
 		status = NT_STATUS_NO_MEMORY;
@@ -701,12 +681,26 @@ NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_
 	}
 
 	for (i=0,j=0;i<num_values;i++) {
+		bool we_are_owner = false;
+
 		status = winsdb_addr_decode(h, rec, &el->values[i], rec->addresses, &rec->addresses[j]);
 		if (!NT_STATUS_IS_OK(status)) goto failed;
 
+		if (strcmp(rec->addresses[j]->wins_owner, h->local_owner) == 0) {
+			we_are_owner = true;
+		}
+
 		/*
 		 * the record isn't static and is active
-		 * then don't add the address if it's expired
+		 * then don't add the address if it's expired,
+		 * but only if we're the owner of the address
+		 *
+		 * This is important for SGROUP records,
+		 * because each server thinks he's the owner of the
+		 * record and the record isn't replicated on a
+		 * name_refresh. So addresses owned by another owner
+		 * could expire, but we still need to return them
+		 * (as windows does).
 		 */
 		if (!rec->is_static &&
 		    rec->addresses[j]->expire_time <= now &&
@@ -752,8 +746,9 @@ failed:
 /*
   form a ldb_message from a winsdb_record
 */
-struct ldb_message *winsdb_message(struct ldb_context *ldb, 
-				   struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
+static struct ldb_message *winsdb_message(struct ldb_context *ldb,
+					  struct winsdb_record *rec,
+					  TALLOC_CTX *mem_ctx)
 {
 	int i, ret=0;
 	size_t addr_count;
@@ -1013,7 +1008,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx,
 	bool ret;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list