s4-winsrepl: don't put in attributes with no elements
authorAndrew Tridgell <tridge@samba.org>
Fri, 16 Oct 2009 00:41:52 +0000 (11:41 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 16 Oct 2009 00:56:40 +0000 (11:56 +1100)
Empty attributes are no longer allowed by ldb. This also fixes the
error checking in winsdb_message()

This fixes the samba4.nbt.winsreplication test

source4/nbt_server/wins/winsdb.c

index 5c3efe2b83c9803b0de0e6365962381680fd3d24..389995e1bc67c22bc9bd7ef3f4e4e70fafff6955 100644 (file)
@@ -794,11 +794,11 @@ static struct ldb_message *winsdb_message(struct ldb_context *ldb,
        for (i=0;rec->addresses[i];i++) {
                ret |= ldb_msg_add_winsdb_addr(msg, rec, "address", rec->addresses[i]);
        }
        for (i=0;rec->addresses[i];i++) {
                ret |= ldb_msg_add_winsdb_addr(msg, rec, "address", rec->addresses[i]);
        }
-       ret |= ldb_msg_add_empty(msg, "registeredBy", 0, NULL);
        if (rec->registered_by) {
        if (rec->registered_by) {
+               ret |= ldb_msg_add_empty(msg, "registeredBy", 0, NULL);
                ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by);
                ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by);
-               if (ret != 0) goto failed;
        }
        }
+       if (ret != 0) goto failed;
        return msg;
 
 failed:
        return msg;
 
 failed: