summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@sernet.de>2008-03-18 16:08:02 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-19 07:05:50 +0100
commit780bc13736f264435ba9af6dda84235ea217d526 (patch)
treef8bff00f7d695f89c26e3c7591815c88f682bd55 /source4/nbt_server
parentcd5e43b32761daea36187f28a72795f7696ea546 (diff)
downloadsamba-780bc13736f264435ba9af6dda84235ea217d526.tar.gz
samba-780bc13736f264435ba9af6dda84235ea217d526.tar.bz2
samba-780bc13736f264435ba9af6dda84235ea217d526.zip
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)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/wins/winsdb.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 945914ccdf..5fb688b7b7 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -613,7 +613,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 +673,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 +680,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 &&