r9689: valgrind-clean now. Editing works now mostly, you just lose half of your
[ira/wip.git] / source4 / lib / ldb / samba / samba3sam.c
index 7c1e61ca4d34f37deb224fac273aac53cfcde934..23f794d90bab39bfe280bb509ca13964212d5bd3 100644 (file)
 
 static struct ldb_message_element *convert_sid_rid(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
 {
+       struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
+       int i;
+
        printf("Converting SID TO RID *\n");
 
-       return talloc_memdup(ctx, el, sizeof(*el));
+       ret->flags = el->flags;
+       ret->name = talloc_strdup(ret, remote_attr);
+       ret->num_values = el->num_values;
+       ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
+
+       for (i = 0; i < ret->num_values; i++) {
+               ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
+       }
+
+       return ret;
 }
 
 static struct ldb_message_element *convert_rid_sid(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
 {
+       struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
+       int i;
+
        printf("Converting RID TO SID *\n");
 
-       return talloc_memdup(ctx, el, sizeof(*el));
+       ret->flags = el->flags;
+       ret->name = talloc_strdup(ret, remote_attr);
+       ret->num_values = el->num_values;
+       ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
+
+       for (i = 0; i < ret->num_values; i++) {
+               ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
+       }
+
+       return ret;
 }
 
 static struct ldb_message_element *convert_unix_id2name(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
 {
+       int i;
+       struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
+
        printf("Converting UNIX ID to name\n");
 
-       return talloc_memdup(ctx, el, sizeof(*el));
+       ret->flags = el->flags;
+       ret->name = talloc_strdup(ret, remote_attr);
+       ret->num_values = el->num_values;
+       ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
+
+       for (i = 0; i < ret->num_values; i++) {
+               ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
+       }
+
+       return ret;
 }
 
 static struct ldb_message_element *convert_unix_name2id(TALLOC_CTX *ctx, const char *remote_attr, const struct ldb_message_element *el)
 {
+       struct ldb_message_element *ret = talloc(ctx, struct ldb_message_element);
+       int i;
+
        printf("Converting UNIX name to ID\n");
 
-       return talloc_memdup(ctx, el, sizeof(*el));
+       ret->flags = el->flags;
+       ret->name = talloc_strdup(ret, remote_attr);
+       ret->num_values = el->num_values;
+       ret->values = talloc_array(ret, struct ldb_val, ret->num_values);
+
+       for (i = 0; i < ret->num_values; i++) {
+               ret->values[i] = ldb_val_dup(ret->values, &el->values[i]);
+       }
+
+       return ret;
 }
 
 const struct ldb_map_objectclass samba3_objectclasses[] = {