r9672: Fix build for compilers that don't like undefined-length arrays at the end...
authorJelmer Vernooij <jelmer@samba.org>
Sat, 27 Aug 2005 02:10:28 +0000 (02:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:39 +0000 (13:34 -0500)
source/include/structs.h
source/lib/ldb/ldb_map/ldb_map.c
source/lib/ldb/ldb_map/ldb_map.h
source/lib/samba3/ldb_samba3.c

index 4f79ccb65778f37a112b4b1b1595b2420edb4708..59ab6a77da6881c2c5f5006b9871696a14c64fdb 100644 (file)
@@ -282,4 +282,5 @@ struct samba3_secrets;
 struct samba3_share_info;
 struct samba3;
 
-struct ldb_map_mappings;
+struct ldb_map_attribute;
+struct ldb_map_objectclass;
index 4006ccbbd7d690ea626af5dfd67b1ba8987c5363..dea3c24e37e370c5da7fb75fb40ff1ff0142b98c 100644 (file)
@@ -34,7 +34,8 @@
  */
 
 struct map_private {
-       const struct ldb_map_mappings *mappings;
+       const struct ldb_map_attribute *attribute_maps;
+       const struct ldb_map_objectclass *objectclass_maps;
        const char *last_err_string;
 };
 
@@ -43,9 +44,9 @@ static const struct ldb_map_attribute *map_find_attr_local(struct ldb_module *mo
 {
        struct map_private *privdat = module->private_data;
        int i;
-       for (i = 0; privdat->mappings->attribute_maps[i]; i++) {
-               if (!strcmp(privdat->mappings->attribute_maps[i]->local_name, attr)) 
-                       return privdat->mappings->attribute_maps[i];
+       for (i = 0; privdat->attribute_maps[i].local_name; i++) {
+               if (!strcmp(privdat->attribute_maps[i].local_name, attr)) 
+                       return &privdat->attribute_maps[i];
        }
 
        return NULL;
@@ -56,13 +57,13 @@ static const struct ldb_map_attribute *map_find_attr_remote(struct ldb_module *m
 {
        struct map_private *privdat = module->private_data;
        int i;
-       for (i = 0; privdat->mappings->attribute_maps[i]; i++) {
-               if (privdat->mappings->attribute_maps[i]->type != MAP_RENAME &&
-                       privdat->mappings->attribute_maps[i]->type != MAP_CONVERT) 
+       for (i = 0; privdat->attribute_maps[i].local_name; i++) {
+               if (privdat->attribute_maps[i].type != MAP_RENAME &&
+                       privdat->attribute_maps[i].type != MAP_CONVERT) 
                        continue;
 
-               if (!strcmp(privdat->mappings->attribute_maps[i]->u.rename.remote_name, attr)) 
-                       return privdat->mappings->attribute_maps[i];
+               if (!strcmp(privdat->attribute_maps[i].u.rename.remote_name, attr)) 
+                       return &privdat->attribute_maps[i];
        }
 
        return NULL;
@@ -573,7 +574,7 @@ static const struct ldb_module_ops map_ops = {
 };
 
 /* the init function */
-struct ldb_module *ldb_map_init(struct ldb_context *ldb, const struct ldb_map_mappings *mappings, const char *options[])
+struct ldb_module *ldb_map_init(struct ldb_context *ldb, const struct ldb_map_attribute *attrs, const struct ldb_map_objectclass *ocls, const char *options[])
 {
        struct ldb_module *ctx;
        struct map_private *data;
@@ -588,7 +589,8 @@ struct ldb_module *ldb_map_init(struct ldb_context *ldb, const struct ldb_map_ma
                return NULL;
        }
 
-       data->mappings = mappings;
+       data->attribute_maps = attrs;
+       data->objectclass_maps = ocls;
        ctx->private_data = data;
        ctx->ldb = ldb;
        ctx->prev = ctx->next = NULL;
index da3198429df488650cf4c8e4336fab5aefafea61..bdeafc827a829e3df5d3a9a888b8074cffed28c6 100644 (file)
@@ -90,7 +90,8 @@ struct ldb_map_attribute
                        /* Name(s) for this attribute on the remote server. This is an array since 
                         * one local attribute's data can be split up into several attributes 
                         * remotely */
-                       const char *remote_names[];
+#define LDB_MAP_MAX_REMOTE_NAMES 10
+                       const char *remote_names[LDB_MAP_MAX_REMOTE_NAMES];
                } generate;
        } u;
 };
@@ -101,12 +102,4 @@ struct ldb_map_objectclass
        const char *remote_name;
 };
 
-/* Base ldb_map struct. Fill this in to create a mapping backend */
-struct ldb_map_mappings 
-{
-       const char *name;
-       const struct ldb_map_attribute *attribute_maps[];
-};
-
-
 #endif /* __LDB_MAP_H__ */
index 4cfdd3db751f817e1288ae38a09e6118c911aca3..68f5412c90c9d409d207a18b47653da8e0314f70 100644 (file)
  * sambaMungedDial
  * sambaLogonHours */
 
-/* sambaNextRid -> nextRid */
-const struct ldb_map_attribute attr_nextRid = {
-       .local_name = "nextRid",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaNextRid",
-};
-
-/* sambaBadPasswordTime -> badPasswordtime*/
-const struct ldb_map_attribute attr_badPasswordTime = {
-       .local_name = "badPasswordTime",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaBadPasswordTime",
-};
 
-/* sambaLMPassword -> lmPwdHash*/
-const struct ldb_map_attribute attr_lmPwdHash = {
-       .local_name = "lmPwdHash",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaLMPassword",
-};
 
-/* sambaGroupType -> groupType */
-const struct ldb_map_attribute attr_groupType = {
-       .local_name = "groupType",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaGroupType",
+const struct ldb_map_objectclass samba3_objectclasses[] = {
+       { "group", "sambaGroupMapping" },
+       { "user", "sambaSAMAccount" },
+       { "domain", "sambaDomain" },
 };
 
-/* sambaNTPassword -> ntPwdHash*/
-const struct ldb_map_attribute attr_ntPwdHash = {
-       .local_name = "badPwdCount",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaNTPassword",
-};
+const struct ldb_map_attribute samba3_attributes[] = 
+{
+       /* sambaNextRid -> nextRid */
+       {
+               .local_name = "nextRid",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaNextRid",
+       },
 
-/* sambaPrimaryGroupSID -> primaryGroupID */
-const struct ldb_map_attribute attr_primaryGroupID = {
-       .local_name = "primaryGroupID",
-       .type = MAP_CONVERT,
-       .u.convert.remote_name = "sambaPrimaryGroupSID",
-       .u.convert.convert_local = NULL, /* FIXME: Add domain SID */
-       .u.convert.convert_remote = NULL, /* FIXME: Extract RID */
-};
+       /* sambaBadPasswordTime -> badPasswordtime*/
+       {
+               .local_name = "badPasswordTime",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaBadPasswordTime",
+       },
 
-/* sambaBadPasswordCount -> badPwdCount */
-const struct ldb_map_attribute attr_badPwdCount = {
-       .local_name = "badPwdCount",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaBadPasswordCount",
-};
+       /* sambaLMPassword -> lmPwdHash*/
+       {
+               .local_name = "lmPwdHash",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaLMPassword",
+       },
 
-/* sambaLogonTime -> lastLogon*/
-const struct ldb_map_attribute attr_lastLogon = {
-       .local_name = "lastLogon",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaLogonTime",
-};
+       /* sambaGroupType -> groupType */
+       {
+               .local_name = "groupType",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaGroupType",
+       },
 
-/* sambaLogoffTime -> lastLogoff*/
-const struct ldb_map_attribute attr_lastLogoff = {
-       .local_name = "lastLogoff",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaLogoffTime",
-};
+       /* sambaNTPassword -> ntPwdHash*/
+       {
+               .local_name = "badPwdCount",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaNTPassword",
+       },
 
-/* gidNumber -> unixName */
-const struct ldb_map_attribute attr_unixName_gid = {
-       .local_name = "unixName",
-       .type = MAP_CONVERT,
-       .u.convert.remote_name = "gidNumber",
-       .u.convert.convert_local = NULL, /* FIXME: Lookup gid */
-       .u.convert.convert_remote = NULL, /* FIXME: Lookup groupname */
-};
+       /* sambaPrimaryGroupSID -> primaryGroupID */
+       {
+               .local_name = "primaryGroupID",
+               .type = MAP_CONVERT,
+               .u.convert.remote_name = "sambaPrimaryGroupSID",
+               .u.convert.convert_local = NULL, /* FIXME: Add domain SID */
+               .u.convert.convert_remote = NULL, /* FIXME: Extract RID */
+       },
+
+       /* sambaBadPasswordCount -> badPwdCount */
+       {
+               .local_name = "badPwdCount",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaBadPasswordCount",
+       },
 
-/* uid -> unixName */
-const struct ldb_map_attribute attr_unixName_uid = {
-       .local_name = "unixName",
-       .type = MAP_CONVERT,
-       .u.convert.remote_name = "uid",
-       .u.convert.convert_local = NULL, /* FIXME: Lookup uid */
-       .u.convert.convert_remote = NULL, /* FIXME: Lookup username */
-};
+       /* sambaLogonTime -> lastLogon*/
+       {
+               .local_name = "lastLogon",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaLogonTime",
+       },
 
-/* displayName -> name */
-const struct ldb_map_attribute attr_name = {
-       .local_name = "name",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "displayName",
-};
+       /* sambaLogoffTime -> lastLogoff*/
+       {
+               .local_name = "lastLogoff",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaLogoffTime",
+       },
 
-/* cn */
-const struct ldb_map_attribute attr_cn = {
-       .local_name = "cn",
-       .type = MAP_KEEP,
-};
+       /* gidNumber -> unixName */
+       {
+               .local_name = "unixName",
+               .type = MAP_CONVERT,
+               .u.convert.remote_name = "gidNumber",
+               .u.convert.convert_local = NULL, /* FIXME: Lookup gid */
+               .u.convert.convert_remote = NULL, /* FIXME: Lookup groupname */
+       },
+
+       /* uid -> unixName */
+       {
+               .local_name = "unixName",
+               .type = MAP_CONVERT,
+               .u.convert.remote_name = "uid",
+               .u.convert.convert_local = NULL, /* FIXME: Lookup uid */
+               .u.convert.convert_remote = NULL, /* FIXME: Lookup username */
+       },
+
+       /* displayName -> name */
+       {
+               .local_name = "name",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "displayName",
+       },
 
-/* description */
-const struct ldb_map_attribute attr_description = {
-       .local_name = "description",
-       .type = MAP_KEEP,
-};
+       /* cn */
+       {
+               .local_name = "cn",
+               .type = MAP_KEEP,
+       },
 
-/* sambaSID -> objectSid*/
-const struct ldb_map_attribute attr_objectSid = {
-       .local_name = "objectSid",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaSID", 
-};
+       /* description */
+       {
+               .local_name = "description",
+               .type = MAP_KEEP,
+       },
 
-/* sambaPwdLastSet -> pwdLastSet*/
-const struct ldb_map_attribute attr_pwdLastSet = {
-       .local_name = "pwdLastSet",
-       .type = MAP_RENAME,
-       .u.rename.remote_name = "sambaPwdLastSet",
-};
+       /* sambaSID -> objectSid*/
+       {
+               .local_name = "objectSid",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaSID", 
+       },
 
-const struct ldb_map_objectclass samba3_objectclasses[] = {
-       { "group", "sambaGroupMapping" },
-       { "user", "sambaSAMAccount" },
-       { "domain", "sambaDomain" },
+       /* sambaPwdLastSet -> pwdLastSet*/
+       {
+               .local_name = "pwdLastSet",
+               .type = MAP_RENAME,
+               .u.rename.remote_name = "sambaPwdLastSet",
+       },      
 };
 
-const struct ldb_map_mappings samba3_mappings = 
-{
-       .name = "samba3",
-       {
-               &attr_objectSid,
-               &attr_pwdLastSet,
-               &attr_description,
-               &attr_cn,
-               &attr_unixName_uid,
-               &attr_unixName_gid,
-               &attr_name,
-               &attr_lastLogoff,
-               &attr_lastLogon,
-               &attr_primaryGroupID,
-               &attr_badPwdCount,
-               &attr_ntPwdHash,
-               &attr_lmPwdHash,
-               &attr_groupType,
-               &attr_badPasswordTime,
-               &attr_nextRid,
-       }
-};     
-
-/* the init function */
+       /* the init function */
 #ifdef HAVE_DLOPEN_DISABLED
- struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
      struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
 #else
-struct ldb_module *ldb_samba3_module_init(struct ldb_context *ldb, const char *options[])
+       struct ldb_module *ldb_samba3_module_init(struct ldb_context *ldb, const char *options[])
 #endif
 {
-       return ldb_map_init(ldb, &samba3_mappings, options);
+       return ldb_map_init(ldb, &samba3_attributes, &samba3_objectclasses, options);
 }