s4:linked_attributes: fix a crash bug when the definition of a target attribute is...
authorStefan Metzmacher <metze@samba.org>
Thu, 2 Oct 2008 09:05:02 +0000 (11:05 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 2 Oct 2008 10:20:57 +0000 (12:20 +0200)
Windows 2003 has a broken schema where the definition of msDS-IsDomainFor
is missing (which is supposed to be the backlink of the msDS-HasDomainNCs
attribute.

Our schema is extracted from windows 2003, so we have the problem.

As the NET-API-BECOME-DC test triggers this bug, windows 2003
seems to just skip creating a backlink.

metze

source4/dsdb/samdb/ldb_modules/linked_attributes.c

index 3b389afffbb853a33f4c71a0f8389069eb0f72e0..14fd107d81d504f347f39bfde334121fb317ffee 100644 (file)
@@ -217,6 +217,17 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *
                
                /* Even link IDs are for the originating attribute */
                target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1);
+               if (!target_attr) {
+                       /*
+                        * windows 2003 has a broken schema where
+                        * the definition of msDS-IsDomainFor
+                        * is missing (which is supposed to be
+                        * the backlink of the msDS-HasDomainNCs
+                        * attribute
+                        */
+                       continue;
+               }
+
                attr_name = target_attr->lDAPDisplayName;
                attr_val = ldb_dn_get_linearized(ac->req->op.add.message->dn);
 
@@ -301,6 +312,16 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are
                        }
 
                        target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1);
+                       if (!target_attr) {
+                               /*
+                                * windows 2003 has a broken schema where
+                                * the definition of msDS-IsDomainFor
+                                * is missing (which is supposed to be
+                                * the backlink of the msDS-HasDomainNCs
+                                * attribute
+                                */
+                               continue;
+                       }
                        attr_name = target_attr->lDAPDisplayName;
 
                        /* make sure we manage each value */
@@ -399,9 +420,14 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques
                /* Now find the target attribute */
                target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1);
                if (!target_attr) {
-                       ldb_asprintf_errstring(module->ldb, 
-                                              "attribute %s does not have valid link target", el->name);
-                       return LDB_ERR_OBJECT_CLASS_VIOLATION;                  
+                       /*
+                        * windows 2003 has a broken schema where
+                        * the definition of msDS-IsDomainFor
+                        * is missing (which is supposed to be
+                        * the backlink of the msDS-HasDomainNCs
+                        * attribute
+                        */
+                       continue;
                }
 
                attr_name = target_attr->lDAPDisplayName;
@@ -654,9 +680,15 @@ static int la_op_search_callback(struct ldb_request *req,
                        if ((schema_attr->linkID & 1) == 0) {
                                /* Odd is for the target. */
                                target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID + 1);
+                               if (!target_attr) {
+                                       continue;
+                               }
                                attr_name = target_attr->lDAPDisplayName;
                        } else {
                                target_attr = dsdb_attribute_by_linkID(ac->schema, schema_attr->linkID - 1);
+                               if (!target_attr) {
+                                       continue;
+                               }
                                attr_name = target_attr->lDAPDisplayName;
                        }
                        for (j = 0; j < el->num_values; j++) {