summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-01-23 14:54:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:23 -0500
commitdd5afc5a775e64bd9b8f8bb57d015e4fb0532f3e (patch)
tree5bb2f66b25ef9c183220eae139155f214d7cdaf4 /source4/nbt_server
parent627983ced0d38b1a0734918af4d3759a28a25ef4 (diff)
downloadsamba-dd5afc5a775e64bd9b8f8bb57d015e4fb0532f3e.tar.gz
samba-dd5afc5a775e64bd9b8f8bb57d015e4fb0532f3e.tar.bz2
samba-dd5afc5a775e64bd9b8f8bb57d015e4fb0532f3e.zip
r13087: don't store timestamps for static records
(only a per record timestamp when it's not active) metze (This used to be commit aba54b870852a9e1ccc442703591fda0f5bde51b)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/wins/winsdb.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index e3c02e05f0..625d4e68dc 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -310,22 +310,30 @@ failed:
/*
encode the winsdb_addr("address") attribute like this:
+ non-static record:
"172.31.1.1;winsOwner:172.31.9.202;expireTime:20050923032330.0Z;"
+ static record:
+ "172.31.1.1"
*/
-static int ldb_msg_add_winsdb_addr(struct ldb_message *msg,
+static int ldb_msg_add_winsdb_addr(struct ldb_message *msg, struct winsdb_record *rec,
const char *attr_name, struct winsdb_addr *addr)
{
struct ldb_val val;
const char *str;
- char *expire_time;
- expire_time = ldb_timestring(msg, addr->expire_time);
- if (!expire_time) return -1;
- str = talloc_asprintf(msg, "%s;winsOwner:%s;expireTime:%s;",
- addr->address, addr->wins_owner,
- expire_time);
- talloc_free(expire_time);
- if (!str) return -1;
+ if (rec->is_static) {
+ str = talloc_strdup(msg, addr->address);
+ if (!str) return -1;
+ } else {
+ char *expire_time;
+ expire_time = ldb_timestring(msg, addr->expire_time);
+ if (!expire_time) return -1;
+ str = talloc_asprintf(msg, "%s;winsOwner:%s;expireTime:%s;",
+ addr->address, addr->wins_owner,
+ expire_time);
+ talloc_free(expire_time);
+ if (!str) return -1;
+ }
val.data = discard_const_p(uint8_t, str);
val.length = strlen(str);
@@ -617,13 +625,6 @@ struct ldb_message *winsdb_message(struct ldb_context *ldb,
struct ldb_message *msg = ldb_msg_new(mem_ctx);
if (msg == NULL) goto failed;
- if (rec->is_static && rec->state == WREPL_STATE_ACTIVE) {
- rec->expire_time = get_time_t_max();
- for (i=0;rec->addresses[i];i++) {
- rec->addresses[i]->expire_time = rec->expire_time;
- }
- }
-
/* make sure we don't put in corrupted records */
addr_count = winsdb_addr_list_length(rec->addresses);
if (rec->state == WREPL_STATE_ACTIVE && addr_count == 0) {
@@ -652,12 +653,15 @@ struct ldb_message *winsdb_message(struct ldb_context *ldb,
ret |= ldb_msg_add_fmt(msg, "recordState", "%u", rec->state);
ret |= ldb_msg_add_fmt(msg, "nodeType", "%u", rec->node);
ret |= ldb_msg_add_fmt(msg, "isStatic", "%u", rec->is_static);
- ret |= ldb_msg_add_string(msg, "expireTime", expire_time);
+ ret |= ldb_msg_add_empty(msg, "expireTime", 0);
+ if (!(rec->is_static && rec->state == WREPL_STATE_ACTIVE)) {
+ ret |= ldb_msg_add_string(msg, "expireTime", expire_time);
+ }
ret |= ldb_msg_add_fmt(msg, "versionID", "%llu", (long long)rec->version);
ret |= ldb_msg_add_string(msg, "winsOwner", rec->wins_owner);
ret |= ldb_msg_add_empty(msg, "address", 0);
for (i=0;rec->addresses[i];i++) {
- ret |= ldb_msg_add_winsdb_addr(msg, "address", rec->addresses[i]);
+ ret |= ldb_msg_add_winsdb_addr(msg, rec, "address", rec->addresses[i]);
}
ret |= ldb_msg_add_empty(msg, "registeredBy", 0);
if (rec->registered_by) {