The branch, master has been updated
       via  9e6eb22... s4-drs: fixed the NC in the getncchanges RID alloc reply
       via  273a4d9... s4-debug: removed debug_ctx(). It didn't catch on :-)
       via  651ddb7... s4-messaging: remove only usage of debug_ctx()
       via  6a36799... s4-messaging: fixed a memory leak in messaging_path()
       via  196cb6b... s4-drs: fixed usage of ldb_dn_new()
       via  39a4e2a... s4-ldb: validate the type of the ldb argument to 
ldb_dn_new()
      from  7eee8e0... Fix comment

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


- Log -----------------------------------------------------------------
commit 9e6eb22f7fda88e1d2336ac4b2ec42a8d84c2138
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 10:12:54 2010 +1100

    s4-drs: fixed the NC in the getncchanges RID alloc reply
    
    the search happens on a different DN to the NC of the request, but the
    reply is with the original NC

commit 273a4d9803f1a92f0e248b707937703d84b0edc6
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 09:05:56 2010 +1100

    s4-debug: removed debug_ctx(). It didn't catch on :-)
    
    There was only one user, which isn't worth it for the overhead.

commit 651ddb720a2dd80c9abd65563af54a512525b622
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 09:05:29 2010 +1100

    s4-messaging: remove only usage of debug_ctx()

commit 6a36799d30c1bfb685ccfe77257433710f23215c
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 09:04:18 2010 +1100

    s4-messaging: fixed a memory leak in messaging_path()
    
    It is a bit convoluted to fix, as cluster_id_string() may return a
    const string.

commit 196cb6b359f3a8cdca5e1d4bb17a7ab7897095ab
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 09:03:45 2010 +1100

    s4-drs: fixed usage of ldb_dn_new()

commit 39a4e2a38d0a6767ebca13efaee0ac61297ad45b
Author: Andrew Tridgell <tri...@samba.org>
Date:   Sat Jan 9 09:03:08 2010 +1100

    s4-ldb: validate the type of the ldb argument to ldb_dn_new()
    
    It has been a common bug to get the first two arguments the wrong way
    around

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

Summary of changes:
 lib/util/debug.h                          |    4 ----
 source4/lib/ldb/common/ldb_dn.c           |    8 +++++++-
 source4/lib/messaging/messaging.c         |   17 +++++++++++++----
 source4/rpc_server/drsuapi/getncchanges.c |   26 ++++++++++++++------------
 4 files changed, 34 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/debug.h b/lib/util/debug.h
index f0d1695..eb2151f 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -45,17 +45,13 @@ struct debug_ops {
 #define DEBUGLEVEL *debug_level
 extern int DEBUGLEVEL;
 
-#define debug_ctx() (_debug_ctx?_debug_ctx:(_debug_ctx=talloc_new(NULL)))
-
 #define DEBUGLVL(level) ((level) <= DEBUGLEVEL)
 #define _DEBUG(level, body, header) do { \
        if (DEBUGLVL(level)) { \
-               void* _debug_ctx=NULL; \
                if (header) { \
                        dbghdr(level, __location__, __FUNCTION__); \
                } \
                dbgtext body; \
-               talloc_free(_debug_ctx); \
        } \
 } while (0)
 /** 
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 79953c6..252a0c6 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -103,7 +103,13 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx,
        dn = talloc_zero(mem_ctx, struct ldb_dn);
        LDB_DN_NULL_FAILED(dn);
 
-       dn->ldb = ldb;
+       dn->ldb = talloc_get_type(ldb, struct ldb_context);
+       if (dn->ldb == NULL) {
+               /* the caller probably got the arguments to
+                  ldb_dn_new() mixed up */
+               talloc_free(dn);
+               return NULL;
+       }
 
        if (strdn->data && strdn->length) {
                const char *data = (const char *)strdn->data;
diff --git a/source4/lib/messaging/messaging.c 
b/source4/lib/messaging/messaging.c
index 277688e..c12945b 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -119,8 +119,15 @@ static NTSTATUS irpc_uptime(struct irpc_message *msg,
 */
 static char *messaging_path(struct messaging_context *msg, struct server_id 
server_id)
 {
-       return talloc_asprintf(msg, "%s/msg.%s", msg->base_path, 
-                              cluster_id_string(msg, server_id));
+       TALLOC_CTX *tmp_ctx = talloc_new(msg);
+       const char *id = cluster_id_string(tmp_ctx, server_id);
+       char *s;
+       if (id == NULL) {
+               return NULL;
+       }
+       s = talloc_asprintf(msg, "%s/msg.%s", msg->base_path, id);
+       talloc_steal(s, tmp_ctx);
+       return s;
 }
 
 /*
@@ -261,11 +268,13 @@ static void messaging_send_handler(struct 
messaging_context *msg)
                }
                rec->retries = 0;
                if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_CTX *tmp_ctx = talloc_new(msg);
                        DEBUG(1,("messaging: Lost message from %s to %s of type 
%u - %s\n", 
-                                cluster_id_string(debug_ctx(), 
rec->header->from), 
-                                cluster_id_string(debug_ctx(), 
rec->header->to), 
+                                cluster_id_string(tmp_ctx, rec->header->from),
+                                cluster_id_string(tmp_ctx, rec->header->to),
                                 rec->header->msg_type, 
                                 nt_errstr(status)));
+                       talloc_free(tmp_ctx);
                }
                DLIST_REMOVE(msg->pending, rec);
                talloc_free(rec);
diff --git a/source4/rpc_server/drsuapi/getncchanges.c 
b/source4/rpc_server/drsuapi/getncchanges.c
index b9ba647..d0ce819 100644
--- a/source4/rpc_server/drsuapi/getncchanges.c
+++ b/source4/rpc_server/drsuapi/getncchanges.c
@@ -592,7 +592,7 @@ static WERROR getncchanges_rid_alloc(struct 
drsuapi_bind_state *b_state,
                return WERR_DS_DRA_INTERNAL_ERROR;
        }
 
-       req_dn = ldb_dn_new(ldb, mem_ctx, req8->naming_context->dn);
+       req_dn = ldb_dn_new(mem_ctx, ldb, req8->naming_context->dn);
        if (!req_dn ||
            !ldb_dn_validate(req_dn) ||
            ldb_dn_compare(req_dn, rid_manager_dn) != 0) {
@@ -653,16 +653,6 @@ static WERROR getncchanges_rid_alloc(struct 
drsuapi_bind_state *b_state,
        DEBUG(2,("Allocated RID pool for server %s\n",
                 GUID_string(mem_ctx, &req8->destination_dsa_guid)));
 
-       /* to complete the rest of the operation we need to point
-          getncchanges at the base DN for the domain */
-       req8->naming_context->dn = ldb_dn_get_linearized(base_dn);
-       ret = dsdb_find_guid_by_dn(ldb, base_dn, &req8->naming_context->guid);
-       if (ret != LDB_SUCCESS) {
-               DEBUG(0,(__location__ ": Failed to find base DN GUID - %s\n",
-                        ldb_errstring(ldb)));
-               return WERR_DS_DRA_INTERNAL_ERROR;
-       }
-
        return WERR_OK;
 }
 
@@ -713,6 +703,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct 
dcesrv_call_state *dce_call, TALLOC_
        struct drsuapi_DsGetNCChangesRequest8 *req8;
        uint32_t options;
        uint32_t max_objects;
+       struct ldb_dn *search_dn = NULL;
 
        DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
        b_state = h->data;
@@ -781,6 +772,7 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct 
dcesrv_call_state *dce_call, TALLOC_
        case DRSUAPI_EXOP_FSMO_RID_ALLOC:
                werr = getncchanges_rid_alloc(b_state, mem_ctx, req8, 
&r->out.ctr->ctr6);
                W_ERROR_NOT_OK_RETURN(werr);
+               search_dn = samdb_base_dn(b_state->sam_ctx);
                break;
 
        case DRSUAPI_EXOP_FSMO_REQ_ROLE:
@@ -863,10 +855,14 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct 
dcesrv_call_state *dce_call, TALLOC_
                        scope = LDB_SCOPE_BASE;
                }
                
+               if (!search_dn) {
+                       search_dn = getnc_state->ncRoot_dn;
+               }
+
                DEBUG(1,(__location__ ": getncchanges on %s using filter %s\n",
                         ldb_dn_get_linearized(getnc_state->ncRoot_dn), 
search_filter));
                ret = drsuapi_search_with_extended_dn(b_state->sam_ctx, 
getnc_state, &getnc_state->site_res,
-                                                     getnc_state->ncRoot_dn, 
scope, attrs,
+                                                     search_dn, scope, attrs,
                                                      search_filter);
                if (ret != LDB_SUCCESS) {
                        return WERR_DS_DRA_INTERNAL_ERROR;
@@ -1037,6 +1033,12 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct 
dcesrv_call_state *dce_call, TALLOC_
                b_state->getncchanges_state = NULL;
        }
 
+       if (req8->extended_op != DRSUAPI_EXOP_NONE) {
+               r->out.ctr->ctr6.uptodateness_vector = NULL;
+               r->out.ctr->ctr6.nc_object_count = 0;
+               ZERO_STRUCT(r->out.ctr->ctr6.new_highwatermark);
+       }
+
        DEBUG(r->out.ctr->ctr6.more_data?2:1,
              ("DsGetNCChanges with uSNChanged >= %llu flags 0x%08x on %s gave 
%u objects (done %d/%d la=%d)\n",
               (unsigned long long)(req8->highwatermark.highest_usn+1),


-- 
Samba Shared Repository

Reply via email to