[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-171-g465b879

Andrew Tridgell tridge at samba.org
Thu Jul 2 04:56:33 GMT 2009


The branch, master has been updated
       via  465b879902dcf06940730ec41542fbdf7bd8dc08 (commit)
       via  ae8515d31b55bbe47b45aa2892d5d98000f645c4 (commit)
       via  865ca9be64acc3bfd8bfaabb0621592234e07be7 (commit)
       via  0bdaa8b4aca56989acf087b609926ed22b6a77cb (commit)
      from  d7af80fc2e83810d6ee049eb31a46a98dd159cb6 (commit)

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


- Log -----------------------------------------------------------------
commit 465b879902dcf06940730ec41542fbdf7bd8dc08
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Jul 2 14:52:25 2009 +1000

    Changed ldb.ERR_NO_SUCH_OBJECT to LDB_ERR_NO_SUCH_OBJECT.
    
    The LDB_ERR_NO_SUCH_OBJECT varient is not a defined variable. This
    should improve error handling in our python code on some
    systems. Unfortunately it still doesn't work on mine. I need to trap
    Jelmer somewhere where he can't escape some day and force him to
    divulge the deep druid secrets of python exception handling ....

commit ae8515d31b55bbe47b45aa2892d5d98000f645c4
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Jul 2 14:49:40 2009 +1000

    fixed the pull of drs schema elements
    
    The previous code incorrectly assumed that attributes such as
    subClassOf come over the wire as strings. In fact they come over as 32
    bit integers which refer to goversIDs. We have to post-process these
    as it sometimes happens that a governsID comes over the wire before
    the record that defines what it means.

commit 865ca9be64acc3bfd8bfaabb0621592234e07be7
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Jul 2 14:47:06 2009 +1000

    the settings structure needs to be initialised

commit 0bdaa8b4aca56989acf087b609926ed22b6a77cb
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Jul 2 14:44:48 2009 +1000

    LDB_ERR_INVALID_DN_SYNTAX doesn't exist ...
    
    The correct name is ldb.ERR_INVALID_DN_SYNTAX

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

Summary of changes:
 source3/lib/ldb/swig/Ldb.py                |    2 +-
 source4/dsdb/schema/schema.h               |    9 +++
 source4/dsdb/schema/schema_inferiors.c     |   79 ++++++++++++++++++++++++++++
 source4/dsdb/schema/schema_init.c          |   53 +++++++------------
 source4/libnet/libnet_vampire.c            |    1 +
 source4/scripting/python/samba/__init__.py |   10 ++--
 6 files changed, 115 insertions(+), 39 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/ldb/swig/Ldb.py b/source3/lib/ldb/swig/Ldb.py
index 4be3eec..0ecb39b 100644
--- a/source3/lib/ldb/swig/Ldb.py
+++ b/source3/lib/ldb/swig/Ldb.py
@@ -71,7 +71,7 @@ class LdbMessage:
         if attr == 'dn':
             self.msg.dn = ldb_dn_explode(self.msg, value)
             if self.msg.dn == None:
-                err = LDB_ERR_INVALID_DN_SYNTAX
+                err = ldb.ERR_INVALID_DN_SYNTAX
                 raise LdbError(err, ldb_strerror(err))
             return
         self.__dict__[attr] = value
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index e15f65a..a605e2f 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -137,6 +137,15 @@ struct dsdb_class {
 	char **subclasses;
 	char **subclasses_direct;
 	char **posssuperiors;
+	uint32_t subClassOf_id;
+	uint32_t *systemAuxiliaryClass_ids;
+	uint32_t *auxiliaryClass_ids;
+	uint32_t *systemMayContain_ids;
+	uint32_t *systemMustContain_ids;
+	uint32_t *possSuperiors_ids;
+	uint32_t *mustContain_ids;
+	uint32_t *mayContain_ids;
+	uint32_t *systemPossSuperiors_ids;
 };
 
 struct dsdb_schema_oid_prefix {
diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c
index fc1845b..63ddb4a 100644
--- a/source4/dsdb/schema/schema_inferiors.c
+++ b/source4/dsdb/schema/schema_inferiors.c
@@ -166,10 +166,89 @@ static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct ds
 	schema_class->possibleInferiors = str_list_unique(schema_class->possibleInferiors);
 }
 
+/*
+  fill in a string class name from a governs_ID
+ */
+static void schema_fill_from_class_one(struct dsdb_schema *schema, struct dsdb_class *c, 
+				    const char **s, uint32_t id)
+{
+	if (*s == NULL && id != 0) {
+		struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, id);
+		if (c2) {
+			*s = c2->lDAPDisplayName;
+		}
+	}
+}
+
+/*
+  fill in a list of string class names from a governs_ID list
+ */
+static void schema_fill_from_class_list(struct dsdb_schema *schema, struct dsdb_class *c, 
+				     const char ***s, uint32_t *ids)
+{
+	if (*s == NULL && ids != NULL) {
+		int i;
+		for (i=0;ids[i];i++) ;
+		*s = talloc_array(c, const char *, i+1);
+		for (i=0;ids[i];i++) {
+			struct dsdb_class *c2 = dsdb_class_by_governsID_id(schema, ids[i]);
+			if (c2) {
+				(*s)[i] = c2->lDAPDisplayName;
+			} else {
+				(*s)[i] = NULL;				
+			}
+		}
+		(*s)[i] = NULL;				
+	}
+}
+
+/*
+  fill in a list of string attribute names from a attributeID list
+ */
+static void schema_fill_from_attribute_list(struct dsdb_schema *schema, struct dsdb_class *c, 
+					    const char ***s, uint32_t *ids)
+{
+	if (*s == NULL && ids != NULL) {
+		int i;
+		for (i=0;ids[i];i++) ;
+		*s = talloc_array(c, const char *, i+1);
+		for (i=0;ids[i];i++) {
+			struct dsdb_attribute *a = dsdb_attribute_by_attributeID_id(schema, ids[i]);
+			if (a) {
+				(*s)[i] = a->lDAPDisplayName;
+			} else {
+				(*s)[i] = NULL;				
+			}
+		}
+		(*s)[i] = NULL;				
+	}
+}
+
+/*
+  if the schema came from DRS then some attributes will be setup as IDs
+ */
+static void schema_fill_from_ids(struct dsdb_schema *schema)
+{
+	struct dsdb_class *c;
+	for (c=schema->classes; c; c=c->next) {
+		schema_fill_from_class_one(schema, c, &c->subClassOf, c->subClassOf_id);
+		schema_fill_from_attribute_list(schema, c, &c->systemMayContain, c->systemMayContain_ids);
+		schema_fill_from_attribute_list(schema, c, &c->systemMustContain, c->systemMustContain_ids);
+		schema_fill_from_attribute_list(schema, c, &c->mustContain, c->mustContain_ids);
+		schema_fill_from_attribute_list(schema, c, &c->mayContain, c->mayContain_ids);
+		schema_fill_from_class_list(schema, c, &c->possSuperiors, c->possSuperiors_ids);
+		schema_fill_from_class_list(schema, c, &c->systemPossSuperiors, c->systemPossSuperiors_ids);
+		schema_fill_from_class_list(schema, c, &c->systemAuxiliaryClass, c->systemAuxiliaryClass_ids);
+		schema_fill_from_class_list(schema, c, &c->auxiliaryClass, c->auxiliaryClass_ids);
+	}
+}
+
 void schema_fill_constructed(struct dsdb_schema *schema) 
 {
 	struct dsdb_class *schema_class;
 
+	schema_fill_from_ids(schema);
+
 	schema_create_subclasses(schema);
 
 	for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 76e7891..2f63931 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -1191,32 +1191,20 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
 	} \
 } while (0)
 
-#define GET_STRING_LIST_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
-	int get_string_list_counter;					\
+#define GET_UINT32_LIST_DS(s, r, attr, mem_ctx, p, elem) do { \
+	int list_counter;					\
 	struct drsuapi_DsReplicaAttribute *_a; \
 	_a = dsdb_find_object_attr_name(s, r, attr, NULL); \
-	if (strict && !_a) { \
-		d_printf("%s: %s == NULL\n", __location__, attr); \
-		return WERR_INVALID_PARAM; \
-	} \
-	(p)->elem = _a ? talloc_array(mem_ctx, const char *, _a->value_ctr.num_values + 1) : NULL; \
-        for (get_string_list_counter=0;					\
-	     _a && get_string_list_counter < _a->value_ctr.num_values;	\
-	     get_string_list_counter++) {				\
-		size_t _ret;						\
-		if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
-					     _a->value_ctr.values[get_string_list_counter].blob->data, \
-					     _a->value_ctr.values[get_string_list_counter].blob->length, \
-						       (void **)discard_const(&(p)->elem[get_string_list_counter]), &_ret, false)) { \
-			DEBUG(0,("%s: invalid data!\n", attr)); \
-			dump_data(0, \
-				     _a->value_ctr.values[get_string_list_counter].blob->data, \
-				     _a->value_ctr.values[get_string_list_counter].blob->length); \
-			return WERR_FOOBAR; \
-		} \
-		(p)->elem[get_string_list_counter+1] = NULL;		\
+	(p)->elem = _a ? talloc_array(mem_ctx, uint32_t, _a->value_ctr.num_values + 1) : NULL; \
+        for (list_counter=0;					\
+	     _a && list_counter < _a->value_ctr.num_values;	\
+	     list_counter++) {				\
+		if (_a->value_ctr.values[list_counter].blob->length != 4) { \
+			return WERR_INVALID_PARAM;			\
+		}							\
+		(p)->elem[list_counter] = IVAL(_a->value_ctr.values[list_counter].blob->data, 0); \
 	}								\
-	talloc_steal(mem_ctx, (p)->elem);				\
+	if (_a) (p)->elem[list_counter] = 0;				\
 } while (0)
 
 #define GET_DN_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
@@ -1432,19 +1420,18 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
 	GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, false);
 	GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
 
-	GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
-
+	GET_UINT32_DS(schema, r, "subClassOf", obj, subClassOf_id);
 
-	GET_STRING_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, false);
-	GET_STRING_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, false);
+	GET_UINT32_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass_ids);
+	GET_UINT32_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass_ids);
 
-	GET_STRING_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain, false);
-	GET_STRING_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain, false);
-	GET_STRING_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain, false);
-	GET_STRING_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain, false);
+	GET_UINT32_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain_ids);
+	GET_UINT32_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain_ids);
+	GET_UINT32_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain_ids);
+	GET_UINT32_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain_ids);
 
-	GET_STRING_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
-	GET_STRING_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors, false);
+	GET_UINT32_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors_ids);
+	GET_UINT32_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors_ids);
 
 	GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
 
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c
index bd88b8e..3265a04 100644
--- a/source4/libnet/libnet_vampire.c
+++ b/source4/libnet/libnet_vampire.c
@@ -81,6 +81,7 @@ static NTSTATUS vampire_prepare_db(void *private_data,
 	struct provision_result result;
 	NTSTATUS status;
 
+	ZERO_STRUCT(settings);
 	settings.site_name = p->dest_dsa->site_name;
 	settings.root_dn_str = p->forest->root_dn_str;
 	settings.domain_dn_str = p->domain->dn_str;
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index f93b0ed..60a7919 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -125,7 +125,7 @@ class Ldb(ldb.Ldb):
                      "@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
             try:
                 self.delete(attr)
-            except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                 # Ignore missing dn errors
                 pass
 
@@ -136,7 +136,7 @@ class Ldb(ldb.Ldb):
                 ["distinguishedName"]):
             try:
                 self.delete(msg.dn)
-            except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+            except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                 # Ignore no such object errors
                 pass
 
@@ -159,7 +159,7 @@ class Ldb(ldb.Ldb):
                 # and the rest
                 try:
                     res2 = self.search(basedn, ldb.SCOPE_SUBTREE, "(|(objectclass=*)(distinguishedName=*))", ["distinguishedName"])
-                except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+                except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                     # Ignore missing dn errors
                     return
 
@@ -169,10 +169,10 @@ class Ldb(ldb.Ldb):
                     try:
                         self.delete(msg.dn)
                     # Ignore no such object errors
-                    except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+                    except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
                         pass
                     # Ignore not allowed on non leaf errors
-                    except ldb.LdbError, (LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, _):
+                    except ldb.LdbError, (ldb.ERR_NOT_ALLOWED_ON_NON_LEAF, _):
                         pass
 
     def load_ldif_file_add(self, ldif_path):


-- 
Samba Shared Repository


More information about the samba-cvs mailing list