The branch, master has been updated
       via  8516fad s4:dsdb/objectclass_attrs: not all objects have delete 
protected attributes as must contain
       via  60691c1 s4:dsdb/samdb: optimize samldb_prim_group_change()
       via  a94fbb9 s4:dsdb/common: fix memory leak in samdb_ntds_settings_dn()
       via  e3276b3 s4:dsdb/kcc: fix memory leak in kcctpl_copy_output_edges()
      from  8b71438 s3-waf: add check for httpConnect and httpConnectEncrypt.

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


- Log -----------------------------------------------------------------
commit 8516fad3b49f6ac87e9e17dc2929433116dcb04d
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Nov 4 12:37:29 2010 +0100

    s4:dsdb/objectclass_attrs: not all objects have delete protected attributes 
as must contain
    
    Before we got the following error, while starting samba after a
    'samba-tool vampire':
    
    Failed to store repsFrom - objectclass_attrs: delete protected attribute
    'objectSid' on entry 
'DC=ForestDnsZones,DC=alpha,DC=sz,DC=salzgitter-ag,DC=lab'
    missing!
    
    metze
    
    Autobuild-User: Stefan Metzmacher <[email protected]>
    Autobuild-Date: Thu Nov  4 17:01:59 UTC 2010 on sn-devel-104

commit 60691c13224656e6a889eb01246582f10c056b7b
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Nov 3 12:33:54 2010 +0100

    s4:dsdb/samdb: optimize samldb_prim_group_change()
    
    We should only do searches when we have to.
    
    metze

commit a94fbb9ed592103b55d803497f6fc483e828dc1f
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Nov 4 14:29:12 2010 +0100

    s4:dsdb/common: fix memory leak in samdb_ntds_settings_dn()
    
    fetch and set should use the same name!
    
    metze

commit e3276b3ab369207ae88fdd78fbb42d34f0b83f3d
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Nov 4 13:32:06 2010 +0100

    s4:dsdb/kcc: fix memory leak in kcctpl_copy_output_edges()
    
    metze

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

Summary of changes:
 source4/dsdb/common/util.c                         |    2 +-
 source4/dsdb/kcc/kcc_topology.c                    |    1 +
 source4/dsdb/samdb/ldb_modules/objectclass_attrs.c |   14 +++
 source4/dsdb/samdb/ldb_modules/samldb.c            |  120 ++++++++++----------
 4 files changed, 76 insertions(+), 61 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 39fcc4d..3fa6774 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -1383,7 +1383,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context 
*ldb)
        settings_dn = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, root_res->msgs[0], 
"dsServiceName");
 
        /* cache the domain_sid in the ldb */
-       if (ldb_set_opaque(ldb, "cache.settings_dn", settings_dn) != 
LDB_SUCCESS) {
+       if (ldb_set_opaque(ldb, "cache.ntds_settings_dn", settings_dn) != 
LDB_SUCCESS) {
                goto failed;
        }
 
diff --git a/source4/dsdb/kcc/kcc_topology.c b/source4/dsdb/kcc/kcc_topology.c
index 51c09fd..c13e330 100644
--- a/source4/dsdb/kcc/kcc_topology.c
+++ b/source4/dsdb/kcc/kcc_topology.c
@@ -1731,6 +1731,7 @@ static NTSTATUS kcctpl_copy_output_edges(struct 
kccsrv_service *service,
        }
 
        talloc_steal(mem_ctx, copy.data);
+       talloc_free(tmp_ctx);
        *_copy = copy;
        return NT_STATUS_OK;
 }
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c 
b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
index ed19349..26eaaea 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
@@ -43,6 +43,8 @@ struct oc_context {
        struct ldb_request *req;
        const struct dsdb_schema *schema;
 
+       struct ldb_message *msg;
+
        struct ldb_reply *search_res;
        struct ldb_reply *mod_ares;
 };
@@ -107,6 +109,7 @@ static int attr_handler(struct oc_context *ac)
        if (msg == NULL) {
                return ldb_oom(ldb);
        }
+       ac->msg = msg;
 
        /* initialize syntax checking context */
        dsdb_syntax_ctx_init(&syntax_ctx, ldb, ac->schema);
@@ -275,6 +278,17 @@ static int attr_handler2(struct oc_context *ac)
        /* Check the delete-protected attributes list */
        msg = ac->search_res->message;
        for (l = del_prot_attributes; *l != NULL; l++) {
+               struct ldb_message_element *el;
+
+               el = ldb_msg_find_element(ac->msg, *l);
+               if (el == NULL) {
+                       /*
+                        * It was not specified in the add or modify,
+                        * so it doesn't need to be in the stored record
+                        */
+                       continue;
+               }
+
                found = str_list_check_ci(must_contain, *l);
                if (!found) {
                        found = str_list_check_ci(may_contain, *l);
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c 
b/source4/dsdb/samdb/ldb_modules/samldb.c
index be8eb1a..ee43d84 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -1004,8 +1004,8 @@ static int samldb_prim_group_change(struct samldb_ctx *ac)
        struct ldb_result *res;
        struct ldb_message_element *el;
        struct ldb_message *msg;
-       uint32_t rid;
-       struct dom_sid *sid;
+       uint32_t prev_rid, new_rid;
+       struct dom_sid *prev_sid, *new_sid;
        struct ldb_dn *prev_prim_group_dn, *new_prim_group_dn;
        int ret;
 
@@ -1028,22 +1028,17 @@ static int samldb_prim_group_change(struct samldb_ctx 
*ac)
 
        /* Finds out the DN of the old primary group */
 
-       rid = ldb_msg_find_attr_as_uint(res->msgs[0], "primaryGroupID", 
(uint32_t) -1);
-       if (rid == (uint32_t) -1) {
+       prev_rid = ldb_msg_find_attr_as_uint(res->msgs[0], "primaryGroupID",
+                                            (uint32_t) -1);
+       if (prev_rid == (uint32_t) -1) {
                /* User objects do always have a mandatory "primaryGroupID"
                 * attribute. If this doesn't exist then the object is of the
                 * wrong type. This is the exact Windows error code */
                return LDB_ERR_OBJECT_CLASS_VIOLATION;
        }
 
-       sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid);
-       if (sid == NULL) {
-               return ldb_operr(ldb);
-       }
-
-       prev_prim_group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSid=%s)",
-                                            ldap_encode_ndr_dom_sid(ac, sid));
-       if (prev_prim_group_dn == NULL) {
+       prev_sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), prev_rid);
+       if (prev_sid == NULL) {
                return ldb_operr(ldb);
        }
 
@@ -1059,76 +1054,81 @@ static int samldb_prim_group_change(struct samldb_ctx 
*ac)
        if (ret != LDB_SUCCESS) {
                return ret;
        }
-       rid = ldb_msg_find_attr_as_uint(msg, "primaryGroupID", (uint32_t) -1);
+       new_rid = ldb_msg_find_attr_as_uint(msg, "primaryGroupID", (uint32_t) 
-1);
        talloc_free(msg);
-       if (rid == (uint32_t) -1) {
+       if (new_rid == (uint32_t) -1) {
                /* we aren't affected of any primary group change */
                return LDB_SUCCESS;
        }
 
-       sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), rid);
-       if (sid == NULL) {
+       if (prev_rid == new_rid) {
+               return LDB_SUCCESS;
+       }
+
+       prev_prim_group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSid=%s)",
+                                            ldap_encode_ndr_dom_sid(ac, 
prev_sid));
+       if (prev_prim_group_dn == NULL) {
+               return ldb_operr(ldb);
+       }
+
+       new_sid = dom_sid_add_rid(ac, samdb_domain_sid(ldb), new_rid);
+       if (new_sid == NULL) {
                return ldb_operr(ldb);
        }
 
        new_prim_group_dn = samdb_search_dn(ldb, ac, NULL, "(objectSid=%s)",
-                                           ldap_encode_ndr_dom_sid(ac, sid));
+                                           ldap_encode_ndr_dom_sid(ac, 
new_sid));
        if (new_prim_group_dn == NULL) {
                /* Here we know if the specified new primary group candidate is
                 * valid or not. */
                return LDB_ERR_UNWILLING_TO_PERFORM;
        }
 
-       /* Only update the "member" attributes when we really do have a change 
*/
-       if (ldb_dn_compare(new_prim_group_dn, prev_prim_group_dn) != 0) {
-               /* We need to be already a normal member of the new primary
-                * group in order to be successful. */
-               el = samdb_find_attribute(ldb, res->msgs[0], "memberOf",
-                                         
ldb_dn_get_linearized(new_prim_group_dn));
-               if (el == NULL) {
-                       return LDB_ERR_UNWILLING_TO_PERFORM;
-               }
-
-               /* Remove the "member" attribute on the new primary group */
-               msg = ldb_msg_new(ac->msg);
-               if (msg == NULL) {
-                       return ldb_module_oom(ac->module);
-               }
-               msg->dn = new_prim_group_dn;
+       /* We need to be already a normal member of the new primary
+        * group in order to be successful. */
+       el = samdb_find_attribute(ldb, res->msgs[0], "memberOf",
+                                 ldb_dn_get_linearized(new_prim_group_dn));
+       if (el == NULL) {
+               return LDB_ERR_UNWILLING_TO_PERFORM;
+       }
 
-               ret = samdb_msg_add_delval(ldb, msg, msg, "member",
-                                          ldb_dn_get_linearized(ac->msg->dn));
-               if (ret != LDB_SUCCESS) {
-                       return ret;
-               }
+       /* Remove the "member" attribute on the new primary group */
+       msg = ldb_msg_new(ac->msg);
+       if (msg == NULL) {
+               return ldb_module_oom(ac->module);
+       }
+       msg->dn = new_prim_group_dn;
 
-               ret = dsdb_module_modify(ac->module, msg, 
DSDB_FLAG_NEXT_MODULE);
-               if (ret != LDB_SUCCESS) {
-                       return ret;
-               }
-               talloc_free(msg);
+       ret = samdb_msg_add_delval(ldb, msg, msg, "member",
+                                  ldb_dn_get_linearized(ac->msg->dn));
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
 
-               /* Add a "member" attribute for the previous primary group */
-               msg = ldb_msg_new(ac->msg);
-               if (msg == NULL) {
-                       return ldb_module_oom(ac->module);
-               }
-               msg->dn = prev_prim_group_dn;
+       ret = dsdb_module_modify(ac->module, msg, DSDB_FLAG_NEXT_MODULE);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+       talloc_free(msg);
 
-               ret = samdb_msg_add_addval(ldb, msg, msg, "member",
-                                          ldb_dn_get_linearized(ac->msg->dn));
-               if (ret != LDB_SUCCESS) {
-                       return ret;
-               }
+       /* Add a "member" attribute for the previous primary group */
+       msg = ldb_msg_new(ac->msg);
+       if (msg == NULL) {
+               return ldb_module_oom(ac->module);
+       }
+       msg->dn = prev_prim_group_dn;
 
-               ret = dsdb_module_modify(ac->module, msg, 
DSDB_FLAG_NEXT_MODULE);
-               if (ret != LDB_SUCCESS) {
-                       return ret;
-               }
-               talloc_free(msg);
+       ret = samdb_msg_add_addval(ldb, msg, msg, "member",
+                                  ldb_dn_get_linearized(ac->msg->dn));
+       if (ret != LDB_SUCCESS) {
+               return ret;
        }
 
-       talloc_free(res);
+       ret = dsdb_module_modify(ac->module, msg, DSDB_FLAG_NEXT_MODULE);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+       talloc_free(msg);
 
        return LDB_SUCCESS;
 }


-- 
Samba Shared Repository

Reply via email to