diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-12-30 21:12:15 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:05 -0500 |
commit | 905c3ff8e1e63f2151f63552e556086968424118 (patch) | |
tree | e779dacb6c33f939ccb67effc8cabbfca2ebbbc8 /source4 | |
parent | 0391b1cb3a1527aed5beefbdda67a6ce5062bbab (diff) | |
download | samba-905c3ff8e1e63f2151f63552e556086968424118.tar.gz samba-905c3ff8e1e63f2151f63552e556086968424118.tar.bz2 samba-905c3ff8e1e63f2151f63552e556086968424118.zip |
r12618: use our primary interface address or the "winsdb:local_owner" -address
as winsOwner: attrbute for owned records
metze
(This used to be commit 37dece8304c0b9887740f4d4e8096732045a1785)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/nbt_server/wins/winsdb.c | 38 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsdb.h | 6 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsserver.c | 14 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_apply_records.c | 4 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_in_call.c | 15 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_scavenging.c | 12 | ||||
-rw-r--r-- | source4/wrepl_server/wrepl_server.c | 3 |
7 files changed, 48 insertions, 44 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index 42a6f19d84..47abcd4a63 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -165,14 +165,14 @@ failed: "172.31.1.1;winsOwner:172.31.9.202;expireTime:20050923032330.0Z;" are valid records */ -static NTSTATUS winsdb_addr_decode(struct winsdb_record *rec, struct ldb_val *val, +static NTSTATUS winsdb_addr_decode(struct winsdb_handle *h, struct winsdb_record *rec, struct ldb_val *val, TALLOC_CTX *mem_ctx, struct winsdb_addr **_addr) { NTSTATUS status; struct winsdb_addr *addr; - char *address; - char *wins_owner; - char *expire_time; + const char *address; + const char *wins_owner; + const char *expire_time; char *p; addr = talloc(mem_ctx, struct winsdb_addr); @@ -216,6 +216,9 @@ static NTSTATUS winsdb_addr_decode(struct winsdb_record *rec, struct ldb_val *va } *p = '\0';p++; + if (strcmp(wins_owner, "0.0.0.0") == 0) { + wins_owner = h->local_owner; + } addr->wins_owner = talloc_strdup(addr, wins_owner); if (!addr->wins_owner) { status = NT_STATUS_NO_MEMORY; @@ -393,7 +396,7 @@ NTSTATUS winsdb_lookup(struct winsdb_handle *h, talloc_steal(tmp_ctx, res); - status = winsdb_record(res->msgs[0], tmp_ctx, &rec); + status = winsdb_record(h, res->msgs[0], tmp_ctx, &rec); if (!NT_STATUS_IS_OK(status)) goto failed; /* see if it has already expired */ @@ -414,7 +417,7 @@ failed: return status; } -NTSTATUS winsdb_record(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct winsdb_record **_rec) +NTSTATUS winsdb_record(struct winsdb_handle *h, struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct winsdb_record **_rec) { NTSTATUS status; struct winsdb_record *rec; @@ -453,12 +456,8 @@ NTSTATUS winsdb_record(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct wins talloc_steal(rec, rec->wins_owner); talloc_steal(rec, rec->registered_by); - if (!rec->wins_owner) { - rec->wins_owner = talloc_strdup(rec, WINSDB_OWNER_LOCAL); - if (rec->wins_owner == NULL) { - status = NT_STATUS_NO_MEMORY; - goto failed; - } + if (!rec->wins_owner || strcmp(rec->wins_owner, "0.0.0.0") == 0) { + rec->wins_owner = h->local_owner; } el = ldb_msg_find_element(msg, "address"); @@ -488,7 +487,7 @@ NTSTATUS winsdb_record(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct wins } for (i=0;i<num_values;i++) { - status = winsdb_addr_decode(rec, &el->values[i], rec->addresses, &rec->addresses[i]); + status = winsdb_addr_decode(h, rec, &el->values[i], rec->addresses, &rec->addresses[i]); if (!NT_STATUS_IS_OK(status)) goto failed; } rec->addresses[i] = NULL; @@ -596,7 +595,7 @@ uint8_t winsdb_add(struct winsdb_handle *h, struct winsdb_record *rec, uint32_t if (rec->version == 0) goto failed; } if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) { - rec->wins_owner = WINSDB_OWNER_LOCAL; + rec->wins_owner = h->local_owner; } msg = winsdb_message(wins_db, rec, tmp_ctx); @@ -637,7 +636,7 @@ uint8_t winsdb_modify(struct winsdb_handle *h, struct winsdb_record *rec, uint32 if (rec->version == 0) goto failed; } if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) { - rec->wins_owner = WINSDB_OWNER_LOCAL; + rec->wins_owner = h->local_owner; } msg = winsdb_message(wins_db, rec, tmp_ctx); @@ -698,6 +697,7 @@ failed: struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx) { struct winsdb_handle *h = NULL; + const char *owner; h = talloc(mem_ctx, struct winsdb_handle); if (!h) return NULL; @@ -706,6 +706,14 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx) system_session(h), NULL, 0, NULL); if (!h->ldb) goto failed; + owner = lp_parm_string(-1, "winsdb", "local_owner"); + if (!owner) { + owner = iface_n_ip(0); + } + + h->local_owner = talloc_strdup(h, owner); + if (!h->local_owner) goto failed; + return h; failed: talloc_free(h); diff --git a/source4/nbt_server/wins/winsdb.h b/source4/nbt_server/wins/winsdb.h index f890a10148..6bc1442f3c 100644 --- a/source4/nbt_server/wins/winsdb.h +++ b/source4/nbt_server/wins/winsdb.h @@ -20,9 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define WINSDB_OWNER_LOCAL "0.0.0.0" -#define WINSDB_GROUP_ADDRESS "255.255.255.255" - #define WINSDB_FLAG_ALLOC_VERSION (1<<0) #define WINSDB_FLAG_TAKE_OWNERSHIP (1<<1) @@ -53,6 +50,9 @@ struct winsdb_record { struct winsdb_handle { /* wins server database handle */ struct ldb_context *ldb; + + /* local owner address */ + const char *local_owner; }; struct wins_server { diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index c01ab9a19b..3eddfb7639 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -91,7 +91,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock, rec.addresses = winsdb_addr_list_add(rec.addresses, address, - WINSDB_OWNER_LOCAL, + winssrv->wins_db->local_owner, rec.expire_time); if (rec.addresses == NULL) return NBT_RCODE_SVR; @@ -122,11 +122,11 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock, rec->registered_by = src->addr; if (winsdb_addr) { - winsdb_addr->wins_owner = WINSDB_OWNER_LOCAL; + winsdb_addr->wins_owner = winssrv->wins_db->local_owner; winsdb_addr->expire_time = rec->expire_time; } - if (strcmp(WINSDB_OWNER_LOCAL, rec->wins_owner) != 0) { + if (strcmp(winssrv->wins_db->local_owner, rec->wins_owner) != 0) { modify_flags = WINSDB_FLAG_ALLOC_VERSION | WINSDB_FLAG_TAKE_OWNERSHIP; } @@ -155,7 +155,7 @@ static uint8_t wins_sgroup_merge(struct nbt_name_socket *nbtsock, rec->addresses = winsdb_addr_list_add(rec->addresses, address, - WINSDB_OWNER_LOCAL, + winssrv->wins_db->local_owner, rec->expire_time); if (rec->addresses == NULL) return NBT_RCODE_SVR; @@ -243,7 +243,7 @@ static void wins_wack_allow(struct wack_state *s) break; } if (found) { - rec->addresses[i]->wins_owner = WINSDB_OWNER_LOCAL; + rec->addresses[i]->wins_owner = s->winssrv->wins_db->local_owner; rec->addresses[i]->expire_time = rec->expire_time; continue; } @@ -253,7 +253,7 @@ static void wins_wack_allow(struct wack_state *s) rec->addresses = winsdb_addr_list_add(rec->addresses, s->reg_address, - WINSDB_OWNER_LOCAL, + s->winssrv->wins_db->local_owner, rec->expire_time); if (rec->addresses == NULL) goto failed; @@ -597,7 +597,7 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock, nbtd_negative_name_query_reply(nbtsock, packet, src); return; } - addresses[0] = WINSDB_GROUP_ADDRESS; + addresses[0] = "255.255.255.255"; addresses[1] = NULL; goto found; } diff --git a/source4/wrepl_server/wrepl_apply_records.c b/source4/wrepl_server/wrepl_apply_records.c index 7fb73728e5..6035041f11 100644 --- a/source4/wrepl_server/wrepl_apply_records.c +++ b/source4/wrepl_server/wrepl_apply_records.c @@ -1187,7 +1187,7 @@ static NTSTATUS r_do_sgroup_merge(struct wreplsrv_partner *partner, } /* if we're the owner of the old record, we'll be the owner of the new one too */ - if (strcmp(rec->wins_owner, WINSDB_OWNER_LOCAL)==0) { + if (strcmp(rec->wins_owner, partner->service->wins_db->local_owner)==0) { become_owner = True; } @@ -1239,7 +1239,7 @@ static NTSTATUS wreplsrv_apply_one_record(struct wreplsrv_partner *partner, } NT_STATUS_NOT_OK_RETURN(status); - if (strcmp(rec->wins_owner, WINSDB_OWNER_LOCAL)==0) { + if (strcmp(rec->wins_owner, partner->service->wins_db->local_owner)==0) { local_vs_replica = True; } else if (strcmp(rec->wins_owner, owner->address)==0) { same_owner = True; diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c index a2637d1b39..9bd01c14bb 100644 --- a/source4/wrepl_server/wrepl_in_call.c +++ b/source4/wrepl_server/wrepl_in_call.c @@ -138,7 +138,7 @@ static NTSTATUS wreplsrv_record2wins_name(TALLOC_CTX *mem_ctx, talloc_steal(mem_ctx, rec->name); name->id = rec->version; - name->unknown = WINSDB_GROUP_ADDRESS; + name->unknown = "255.255.255.255"; name->flags = WREPL_NAME_FLAGS(rec->type, rec->state, rec->node, rec->is_static); @@ -153,13 +153,8 @@ static NTSTATUS wreplsrv_record2wins_name(TALLOC_CTX *mem_ctx, NT_STATUS_HAVE_NO_MEMORY(ips); for (i = 0; i < num_ips; i++) { - if (strcasecmp(WINSDB_OWNER_LOCAL, rec->addresses[i]->wins_owner) == 0) { - ips[i].owner = talloc_strdup(ips, our_address); - NT_STATUS_HAVE_NO_MEMORY(ips[i].owner); - } else { - ips[i].owner = rec->addresses[i]->wins_owner; - talloc_steal(ips, rec->addresses[i]->wins_owner); - } + ips[i].owner = rec->addresses[i]->wins_owner; + talloc_steal(ips, rec->addresses[i]->wins_owner); ips[i].ip = rec->addresses[i]->address; talloc_steal(ips, rec->addresses[i]->address); } @@ -190,7 +185,7 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) if (strcmp(call->wreplconn->our_ip, owner_in->address) == 0) { ZERO_STRUCT(local_owner); - local_owner.owner.address = WINSDB_OWNER_LOCAL; + local_owner.owner.address = service->wins_db->local_owner; local_owner.owner.min_version = 0; local_owner.owner.max_version = wreplsrv_local_max_version(service); local_owner.owner.type = 1; @@ -260,7 +255,7 @@ static NTSTATUS wreplsrv_in_send_request(struct wreplsrv_in_call *call) NT_STATUS_HAVE_NO_MEMORY(names); for (i = 0; i < res->count; i++) { - status = winsdb_record(res->msgs[i], call, &rec); + status = winsdb_record(service->wins_db, res->msgs[i], call, &rec); NT_STATUS_NOT_OK_RETURN(status); status = wreplsrv_record2wins_name(names, call->wreplconn->our_ip, &names[i], rec); diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index bc25354e3c..24ef974f2d 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -51,7 +51,7 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi filter = talloc_asprintf(tmp_mem, "(&(winsOwner=%s)(objectClass=winsRecord)" "(expireTime<=%s)(!(isStatic=1)))", - WINSDB_OWNER_LOCAL, now_timestr); + service->wins_db->local_owner, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -63,7 +63,7 @@ static NTSTATUS wreplsrv_scavenging_owned_records(struct wreplsrv_service *servi delete_tombstones = timeval_expired(&tombstone_extra_time); for (i=0; i < res->count; i++) { - status = winsdb_record(res->msgs[i], tmp_mem, &rec); + status = winsdb_record(service->wins_db, res->msgs[i], tmp_mem, &rec); NT_STATUS_NOT_OK_RETURN(status); if (rec->is_static) { @@ -159,7 +159,7 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s filter = talloc_asprintf(tmp_mem, "(&(!(winsOwner=%s))(objectClass=winsRecord)" "(!(recordState=%u))(expireTime<=%s)(!(isStatic=1)))", - WINSDB_OWNER_LOCAL, WREPL_STATE_ACTIVE, now_timestr); + service->wins_db->local_owner, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -171,7 +171,7 @@ static NTSTATUS wreplsrv_scavenging_replica_non_active_records(struct wreplsrv_s delete_tombstones = timeval_expired(&tombstone_extra_time); for (i=0; i < res->count; i++) { - status = winsdb_record(res->msgs[i], tmp_mem, &rec); + status = winsdb_record(service->wins_db, res->msgs[i], tmp_mem, &rec); NT_STATUS_NOT_OK_RETURN(status); if (rec->is_static) { @@ -262,14 +262,14 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi filter = talloc_asprintf(tmp_mem, "(&(!(winsOwner=%s))(objectClass=winsRecord)" "(recordState=%u)(expireTime<=%s)(!(isStatic=1)))", - WINSDB_OWNER_LOCAL, WREPL_STATE_ACTIVE, now_timestr); + service->wins_db->local_owner, WREPL_STATE_ACTIVE, now_timestr); NT_STATUS_HAVE_NO_MEMORY(filter); ret = ldb_search(service->wins_db->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res); if (ret != LDB_SUCCESS) return NT_STATUS_INTERNAL_DB_CORRUPTION; talloc_steal(tmp_mem, res); for (i=0; i < res->count; i++) { - status = winsdb_record(res->msgs[i], tmp_mem, &rec); + status = winsdb_record(service->wins_db, res->msgs[i], tmp_mem, &rec); NT_STATUS_NOT_OK_RETURN(status); if (rec->is_static) { diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index 2682ca6721..9f1664bc22 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -264,7 +264,8 @@ NTSTATUS wreplsrv_add_table(struct wreplsrv_service *service, struct wreplsrv_owner *table = *_table; struct wreplsrv_owner *cur; - if (strcmp(WINSDB_OWNER_LOCAL, wins_owner) == 0) { + if (strcmp(service->wins_db->local_owner, wins_owner) == 0 || + strcmp("0.0.0.0", wins_owner) == 0) { return NT_STATUS_OK; } |