ldb_tdb: Remove LTDB_FLAG_HIDDEN and ignore "HIDDEN" in @ATTRIBUTES
authorAndrew Bartlett <abartlet@samba.org>
Sun, 10 Sep 2017 22:02:16 +0000 (10:02 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:24 +0000 (21:20 +0200)
This was (unintentionally) disabled by
6ef61825541131e16a03975cdbd344e2bbebf810 in 2006.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_cache.c

index 7bf5f156b459845b344a80154b98ff2cd2d9224e..5347a3be13baa79742b2314d61ba208d9d080847 100644 (file)
@@ -36,7 +36,6 @@
 
 #define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
 #define LTDB_FLAG_INTEGER          (1<<1)
-#define LTDB_FLAG_HIDDEN           (1<<2)
 
 /* valid attribute flags */
 static const struct {
@@ -45,7 +44,7 @@ static const struct {
 } ltdb_valid_attr_flags[] = {
        { "CASE_INSENSITIVE", LTDB_FLAG_CASE_INSENSITIVE },
        { "INTEGER", LTDB_FLAG_INTEGER },
-       { "HIDDEN", LTDB_FLAG_HIDDEN },
+       { "HIDDEN", 0 },
        { "NONE", 0 },
        { NULL, 0 }
 };
@@ -150,7 +149,7 @@ static int ltdb_attributes_load(struct ldb_module *module)
        /* mapping these flags onto ldap 'syntaxes' isn't strictly correct,
           but its close enough for now */
        for (i=0;i<attrs_msg->num_elements;i++) {
-               unsigned flags;
+               unsigned flags, attr_flags;
                const char *syntax;
                const struct ldb_schema_syntax *s;
                const struct ldb_schema_attribute *a =
@@ -167,17 +166,15 @@ static int ltdb_attributes_load(struct ldb_module *module)
                                  attrs_msg->elements[i].name);
                        goto failed;
                }
-               switch (flags & ~LTDB_FLAG_HIDDEN) {
-               case 0:
-                       syntax = LDB_SYNTAX_OCTET_STRING;
-                       break;
-               case LTDB_FLAG_CASE_INSENSITIVE:
+
+               /* These are not currently flags, each is exclusive */
+               if (flags == LTDB_FLAG_CASE_INSENSITIVE) {
                        syntax = LDB_SYNTAX_DIRECTORY_STRING;
-                       break;
-               case LTDB_FLAG_INTEGER:
+               } else if (flags == LTDB_FLAG_INTEGER) {
                        syntax = LDB_SYNTAX_INTEGER;
-                       break;
-               default:
+               } else if (flags == 0) {
+                       syntax = LDB_SYNTAX_OCTET_STRING;
+               } else {
                        ldb_debug(ldb, LDB_DEBUG_ERROR, 
                                  "Invalid flag combination 0x%x for '%s' "
                                  "in @ATTRIBUTES",
@@ -194,12 +191,12 @@ static int ltdb_attributes_load(struct ldb_module *module)
                        goto failed;
                }
 
-               flags |= LDB_ATTR_FLAG_ALLOCATED | LDB_ATTR_FLAG_FROM_DB;
+               attr_flags = LDB_ATTR_FLAG_ALLOCATED | LDB_ATTR_FLAG_FROM_DB;
 
                r = ldb_schema_attribute_fill_with_syntax(ldb,
                                                          attrs,
                                                          attrs_msg->elements[i].name,
-                                                         flags, s,
+                                                         attr_flags, s,
                                                          &attrs[num_loaded_attrs + ldb->schema.num_attributes]);
                if (r != 0) {
                        goto failed;