The branch, master has been updated via 2a92cc1 gitignore: ignore .gpg-* generated files (for ubuntu 16.04) via ece7a75 repl_meta_data: single valued error codes depend on change type via e150697 replmd: special-case member return value in replmd_add_fix_la() via 5678484 replmd: check duplicate linked attributes via 990b23d replmd: check single values in replmd_add_fix_la via 6f956cc ldb: 1.1.31 via 7d6f36a ldb: relatively efficient functions for finding duplicate values via f3703c1 dsdb/tests/ldap: test single valued linked attributes via ccf61f9 s4/linked_attribute tests: test duplicate values via 69d0b39 dsdb/tests/ldap: multivalued attributes via 142d861 python/test: delete_force() passes on command line args via aa61a22 ldb.h whitespace via 16d208a ldb tests/ldb_mod_op_test: don't double include cmocka.h via 433d600 ldb: fix a typo via 44764ee ldb: fix whitespace in ldb_msg.c from a4d9438 libcli:smb2: Gracefully handle not supported for FSCTL_VALIDATE_NEGOTIATE_INFO
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 2a92cc196285fa20878cce9dda6ebf9761582f1c Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Jun 15 10:53:03 2017 +1200 gitignore: ignore .gpg-* generated files (for ubuntu 16.04) Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Thu Jun 15 21:40:08 CEST 2017 on sn-devel-144 commit ece7a75a4261cb9575dee4e7c7fda96e68e6c0c2 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed Jun 7 17:45:15 2017 +1200 repl_meta_data: single valued error codes depend on change type A replace leads to CONSTRAINT_VIOLATION while an add causes ATTRIBUTE_OR_VALUE_EXISTS. For this we need to check the mod type before the replmd_modify_la_* calls because they change everything into a replace. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit e150697a1edae8e65c2282b7c0a50ee06b55fbb8 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed May 31 17:40:05 2017 +1200 replmd: special-case member return value in replmd_add_fix_la() Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Pair-programmed-with: Garming Sam <garm...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 567848498f7cbb9977dc3ad723be809a4cc3c03e Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed May 31 15:22:45 2017 +1200 replmd: check duplicate linked attributes This is simple enough because we already have the sorted list. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Pair-programmed-with: Garming Sam <garm...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 990b23d7b6f3099bb471234590b92ed82cd2b5a9 Author: Garming Sam <garm...@catalyst.net.nz> Date: Fri May 26 15:17:21 2017 +1200 replmd: check single values in replmd_add_fix_la repl_meta_data knows whether linked attributes are appropriately [un-]duplicated, and this is how it tells ldb_tdb that. Signed-off-by: Garming Sam <garm...@catalyst.net.nz> Pair-programmed-with: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 6f956cce62c334bb52f593a5d5e0b0a4e3672420 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Jun 15 11:34:20 2017 +1200 ldb: 1.1.31 * Add efficient function to find duplicate values in ldb messages (this makes large multi-valued attributes in ldb_tdb more efficient) Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 7d6f36aae387a394b912501e9a4e329c2f11a8a1 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Jun 15 11:30:33 2017 +1200 ldb: relatively efficient functions for finding duplicate values ldb backends need to make sure they are not adding duplicate values to multi-valued attributes in ADD and MODIFY operations. Until now they have done this inefficiently using nested loops. Here we add common functions that deal with large numbers of values in O(n log n) time, but continue to use the simple methods for small numbers of values. These functions take a struct ldb_context pointer and an options flag arguments, although the ldb is not used, and only one bit of the options has meaning. This is to allow further patches to switch on schema-aware comparisons. This entails an ABI jump to add the two new functions. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit f3703c1727864c7aa487e96af772359d64bea513 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Thu Jun 1 12:20:15 2017 +1200 dsdb/tests/ldap: test single valued linked attributes This fails, so we add it to selftest/knownfail.d/ Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit ccf61f9878c1093b7b90e452889a31619832b499 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed May 31 17:42:01 2017 +1200 s4/linked_attribute tests: test duplicate values Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 69d0b39a5657289016ebee52045d9989387aaf7d Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Fri May 26 15:41:34 2017 +1200 dsdb/tests/ldap: multivalued attributes Various return codes tested against Windows 2012r2. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 142d8617fe6b0dc4587384c373119d1d6289637c Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed Jun 7 17:44:25 2017 +1200 python/test: delete_force() passes on command line args This allows you to use e.g.: delete_force(self.ldb, ou, controls=['tree_delete:1']) Only in tests of course. Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit aa61a2212b13d1bb1eb0a7efd87f892038bcc312 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed Jun 7 11:29:23 2017 +1200 ldb.h whitespace Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 16d208acc4b0acf5c3accfa5567199a940120da0 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Fri May 19 12:03:37 2017 +1200 ldb tests/ldb_mod_op_test: don't double include cmocka.h Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 433d600c56582a133f602519dd984bd3a32f7800 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Fri May 19 16:09:20 2017 +1200 ldb: fix a typo Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 44764ee33d24099b1831628fc0700b0f0caef443 Author: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Date: Wed May 17 12:00:55 2017 +1200 ldb: fix whitespace in ldb_msg.c Signed-off-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: .gitignore | 1 + lib/ldb/ABI/{ldb-1.1.30.sigs => ldb-1.1.31.sigs} | 2 + ...ldb-util-1.1.10.sigs => pyldb-util-1.1.31.sigs} | 0 ...util-1.1.10.sigs => pyldb-util.py3-1.1.31.sigs} | 0 lib/ldb/common/ldb.c | 2 +- lib/ldb/common/ldb_msg.c | 288 +++++++++++++++-- lib/ldb/include/ldb.h | 182 +++++------ lib/ldb/include/ldb_private.h | 51 +++ lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 22 +- lib/ldb/ldb_tdb/ldb_tdb.c | 136 +++++--- lib/ldb/tests/ldb_mod_op_test.c | 2 - lib/ldb/tests/ldb_msg.c | 352 +++++++++++++++++++++ lib/ldb/wscript | 14 +- python/samba/tests/__init__.py | 4 +- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 41 ++- source4/dsdb/tests/python/ldap.py | 139 ++++++++ source4/dsdb/tests/python/linked_attributes.py | 20 +- 17 files changed, 1059 insertions(+), 197 deletions(-) copy lib/ldb/ABI/{ldb-1.1.30.sigs => ldb-1.1.31.sigs} (98%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-1.1.31.sigs} (100%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util.py3-1.1.31.sigs} (100%) create mode 100644 lib/ldb/tests/ldb_msg.c Changeset truncated at 500 lines: diff --git a/.gitignore b/.gitignore index f8d4eab..1f06493 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ autom4te.cache *.pyc semantic.cache /selftest/gnupg/random_seed +/selftest/gnupg/.gpg-* /pidl/blib /pidl/cover_db /pidl/Makefile diff --git a/lib/ldb/ABI/ldb-1.1.30.sigs b/lib/ldb/ABI/ldb-1.1.31.sigs similarity index 98% copy from lib/ldb/ABI/ldb-1.1.30.sigs copy to lib/ldb/ABI/ldb-1.1.31.sigs index ef9c53e..d183708 100644 --- a/lib/ldb/ABI/ldb-1.1.30.sigs +++ b/lib/ldb/ABI/ldb-1.1.31.sigs @@ -170,6 +170,8 @@ ldb_msg_find_attr_as_int64: int64_t (const struct ldb_message *, const char *, i ldb_msg_find_attr_as_string: const char *(const struct ldb_message *, const char *, const char *) ldb_msg_find_attr_as_uint: unsigned int (const struct ldb_message *, const char *, unsigned int) ldb_msg_find_attr_as_uint64: uint64_t (const struct ldb_message *, const char *, uint64_t) +ldb_msg_find_common_values: int (struct ldb_context *, TALLOC_CTX *, struct ldb_message_element *, struct ldb_message_element *, uint32_t) +ldb_msg_find_duplicate_val: int (struct ldb_context *, TALLOC_CTX *, const struct ldb_message_element *, struct ldb_val **, uint32_t) ldb_msg_find_element: struct ldb_message_element *(const struct ldb_message *, const char *) ldb_msg_find_ldb_val: const struct ldb_val *(const struct ldb_message *, const char *) ldb_msg_find_val: struct ldb_val *(const struct ldb_message_element *, struct ldb_val *) diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-1.1.31.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util-1.1.31.sigs diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util.py3-1.1.31.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util.py3-1.1.31.sigs diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c index c950330..700d89c 100644 --- a/lib/ldb/common/ldb.c +++ b/lib/ldb/common/ldb.c @@ -108,7 +108,7 @@ struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx) } /* A new event context so that callers who don't want ldb - * operating on thier global event context can work without + * operating on their global event context can work without * having to provide their own private one explicitly */ if (ev_ctx == NULL) { ev_ctx = tevent_context_init(ldb); diff --git a/lib/ldb/common/ldb_msg.c b/lib/ldb/common/ldb_msg.c index 3f65351..abad5a8 100644 --- a/lib/ldb/common/ldb_msg.c +++ b/lib/ldb/common/ldb_msg.c @@ -1,4 +1,4 @@ -/* +/* ldb database library Copyright (C) Andrew Tridgell 2004 @@ -6,7 +6,7 @@ ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -44,7 +44,7 @@ struct ldb_message *ldb_msg_new(TALLOC_CTX *mem_ctx) /* find an element in a message by attribute name */ -struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, +struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name) { unsigned int i; @@ -77,7 +77,7 @@ int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2) find a value in an element assumes case sensitive comparison */ -struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, +struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val) { unsigned int i; @@ -89,6 +89,224 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, return NULL; } + +static int ldb_val_cmp(const struct ldb_val *v1, const struct ldb_val *v2) +{ + if (v1->length != v2->length) { + return v1->length - v2->length; + } + return memcmp(v1->data, v2->data, v1->length); +} + + +/* + ldb_msg_find_duplicate_val() will set the **duplicate pointer to the first + duplicate value it finds. It does a case sensitive comparison (memcmp). + + LDB_ERR_OPERATIONS_ERROR indicates an allocation failure or an unknown + options flag, otherwise LDB_SUCCESS. +*/ +#define LDB_DUP_QUADRATIC_THRESHOLD 10 + +int ldb_msg_find_duplicate_val(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + const struct ldb_message_element *el, + struct ldb_val **duplicate, + uint32_t options) +{ + unsigned int i, j; + struct ldb_val *val; + + if (options != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + *duplicate = NULL; + + /* + If there are not many values, it is best to avoid the talloc + overhead and just do a brute force search. + */ + if (el->num_values < LDB_DUP_QUADRATIC_THRESHOLD) { + for (j = 0; j < el->num_values; j++) { + val = &el->values[j]; + for ( i = j + 1; i < el->num_values; i++) { + if (ldb_val_equal_exact(val, &el->values[i])) { + *duplicate = val; + return LDB_SUCCESS; + } + } + } + } else { + struct ldb_val *values; + values = talloc_array(mem_ctx, struct ldb_val, el->num_values); + if (values == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + memcpy(values, el->values, + el->num_values * sizeof(struct ldb_val)); + TYPESAFE_QSORT(values, el->num_values, ldb_val_cmp); + for (i = 1; i < el->num_values; i++) { + if (ldb_val_equal_exact(&values[i], + &values[i - 1])) { + /* find the original location */ + for (j = 0; j < el->num_values; j++) { + if (ldb_val_equal_exact(&values[i], + &el->values[j]) + ) { + *duplicate = &el->values[j]; + break; + } + } + talloc_free(values); + if (*duplicate == NULL) { + /* how we got here, I don't know */ + return LDB_ERR_OPERATIONS_ERROR; + } + return LDB_SUCCESS; + } + } + talloc_free(values); + } + return LDB_SUCCESS; +} + + +/* + Determine whether the values in an element are also in another element. + + Without any flags, return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS if the elements + share values, or LDB_SUCCESS if they don't. In this case, the function + simply determines the set intersection and it doesn't matter in which order + the elements are provided. + + With the LDB_MSG_FIND_COMMON_REMOVE_DUPLICATES flag, any values in common are + removed from the first element and LDB_SUCCESS is returned. + + LDB_ERR_OPERATIONS_ERROR indicates an allocation failure or an unknown option. + LDB_ERR_INAPPROPRIATE_MATCHING is returned if the elements differ in name. +*/ + +int ldb_msg_find_common_values(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + struct ldb_message_element *el, + struct ldb_message_element *el2, + uint32_t options) +{ + struct ldb_val *values; + struct ldb_val *values2; + unsigned int i, j, k, n_values; + + bool remove_duplicates = options & LDB_MSG_FIND_COMMON_REMOVE_DUPLICATES; + + if ((options & ~LDB_MSG_FIND_COMMON_REMOVE_DUPLICATES) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (strcmp(el->name, el2->name) != 0) { + return LDB_ERR_INAPPROPRIATE_MATCHING; + } + /* + With few values, it is better to do the brute-force search than the + clever search involving tallocs, memcpys, sorts, etc. + */ + if (MIN(el->num_values, el2->num_values) == 1 || + MAX(el->num_values, el2->num_values) < LDB_DUP_QUADRATIC_THRESHOLD) { + for (i = 0; i < el2->num_values; i++) { + for (j = 0; j < el->num_values; j++) { + if (ldb_val_equal_exact(&el->values[j], + &el2->values[i])) { + if (! remove_duplicates) { + return \ + LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; + } + /* + With the remove_duplicates flag, we + resolve the intersection by removing + the offending one from el. + */ + el->num_values--; + for (k = j; k < el->num_values; k++) { + el->values[k] = \ + el->values[k + 1]; + } + j--; /* rewind */ + } + } + } + return LDB_SUCCESS; + } + + values = talloc_array(mem_ctx, struct ldb_val, el->num_values); + if (values == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + values2 = talloc_array(mem_ctx, struct ldb_val, + el2->num_values); + if (values2 == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + memcpy(values, el->values, + el->num_values * sizeof(struct ldb_val)); + memcpy(values2, el2->values, + el2->num_values * sizeof(struct ldb_val)); + TYPESAFE_QSORT(values, el->num_values, ldb_val_cmp); + TYPESAFE_QSORT(values2, el2->num_values, ldb_val_cmp); + + /* + el->n_values may diverge from the number of values in the sorted + list when the remove_duplicates flag is used. + */ + n_values = el->num_values; + i = 0; + j = 0; + while (i != n_values) { + int ret = ldb_val_cmp(&values[i], &values2[j]); + if (ret < 0) { + i++; + } else if (ret > 0) { + j++; + if (j == el2->num_values) { + /* + We have walked past the end of the second + list, meaning the remainder of the first + list cannot collide and we're done. + */ + break; + } + } else { + /* we have a collision */ + if (! remove_duplicates) { + TALLOC_FREE(values); + TALLOC_FREE(values2); + return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; + } + /* + With the remove_duplicates flag we need to find + this in the original list and remove it, which is + inefficient but hopefully rare. + */ + for (k = 0; k < el->num_values; k++) { + if (ldb_val_equal_exact(&el->values[k], + &values[i])) { + break; + } + } + el->num_values--; + for (; k < el->num_values; k++) { + el->values[k] = el->values[k + 1]; + } + i++; + } + } + TALLOC_FREE(values); + TALLOC_FREE(values2); + + return LDB_SUCCESS; +} + /* duplicate a ldb_val structure */ @@ -181,8 +399,8 @@ int ldb_msg_add_empty(struct ldb_message *msg, * is invalidated for some reason, this will * corrupt *msg contents also */ -int ldb_msg_add(struct ldb_message *msg, - const struct ldb_message_element *el, +int ldb_msg_add(struct ldb_message *msg, + const struct ldb_message_element *el, int flags) { int ret; @@ -207,7 +425,7 @@ int ldb_msg_add(struct ldb_message *msg, /* add a value to a message */ -int ldb_msg_add_value(struct ldb_message *msg, +int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val, struct ldb_message_element **return_el) @@ -244,7 +462,7 @@ int ldb_msg_add_value(struct ldb_message *msg, /* add a value to a message, stealing it into the 'right' place */ -int ldb_msg_add_steal_value(struct ldb_message *msg, +int ldb_msg_add_steal_value(struct ldb_message *msg, const char *attr_name, struct ldb_val *val) { @@ -262,7 +480,7 @@ int ldb_msg_add_steal_value(struct ldb_message *msg, /* add a string element to a message */ -int ldb_msg_add_string(struct ldb_message *msg, +int ldb_msg_add_string(struct ldb_message *msg, const char *attr_name, const char *str) { struct ldb_val val; @@ -281,7 +499,7 @@ int ldb_msg_add_string(struct ldb_message *msg, /* add a string element to a message, stealing it into the 'right' place */ -int ldb_msg_add_steal_string(struct ldb_message *msg, +int ldb_msg_add_steal_string(struct ldb_message *msg, const char *attr_name, char *str) { struct ldb_val val; @@ -318,7 +536,7 @@ int ldb_msg_add_linearized_dn(struct ldb_message *msg, const char *attr_name, /* add a printf formatted element to a message */ -int ldb_msg_add_fmt(struct ldb_message *msg, +int ldb_msg_add_fmt(struct ldb_message *msg, const char *attr_name, const char *fmt, ...) { struct ldb_val val; @@ -341,7 +559,7 @@ int ldb_msg_add_fmt(struct ldb_message *msg, compare two ldb_message_element structures assumes case sensitive comparison */ -int ldb_msg_element_compare(struct ldb_message_element *el1, +int ldb_msg_element_compare(struct ldb_message_element *el1, struct ldb_message_element *el2) { unsigned int i; @@ -383,7 +601,7 @@ bool ldb_msg_element_equal_ordered(const struct ldb_message_element *el1, compare two ldb_message_element structures comparing by element name */ -int ldb_msg_element_compare_name(struct ldb_message_element *el1, +int ldb_msg_element_compare_name(struct ldb_message_element *el1, struct ldb_message_element *el2) { return ldb_attr_cmp(el1->name, el2->name); @@ -393,7 +611,7 @@ int ldb_msg_element_compare_name(struct ldb_message_element *el1, convenience functions to return common types from a message these return the first value if the attribute is multi-valued */ -const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, +const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name) { struct ldb_message_element *el = ldb_msg_find_element(msg, attr_name); @@ -403,7 +621,7 @@ const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, return &el->values[0]; } -int ldb_msg_find_attr_as_int(const struct ldb_message *msg, +int ldb_msg_find_attr_as_int(const struct ldb_message *msg, const char *attr_name, int default_value) { @@ -467,7 +685,7 @@ unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg, return ret; } -int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg, +int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg, const char *attr_name, int64_t default_value) { @@ -531,7 +749,7 @@ uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, return ret; } -double ldb_msg_find_attr_as_double(const struct ldb_message *msg, +double ldb_msg_find_attr_as_double(const struct ldb_message *msg, const char *attr_name, double default_value) { @@ -560,7 +778,7 @@ double ldb_msg_find_attr_as_double(const struct ldb_message *msg, return ret; } -int ldb_msg_find_attr_as_bool(const struct ldb_message *msg, +int ldb_msg_find_attr_as_bool(const struct ldb_message *msg, const char *attr_name, int default_value) { @@ -577,7 +795,7 @@ int ldb_msg_find_attr_as_bool(const struct ldb_message *msg, return default_value; } -const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, +const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *attr_name, const char *default_value) { @@ -624,7 +842,7 @@ void ldb_msg_sort_elements(struct ldb_message *msg) shallow copy a message - copying only the elements array so that the caller can safely add new elements without changing the message */ -struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, +struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, const struct ldb_message *msg) { struct ldb_message *msg2; @@ -635,7 +853,7 @@ struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, *msg2 = *msg; - msg2->elements = talloc_array(msg2, struct ldb_message_element, + msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements); if (msg2->elements == NULL) goto failed; @@ -654,7 +872,7 @@ failed: /* copy a message, allocating new memory for all parts */ -struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx, +struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx, const struct ldb_message *msg) { struct ldb_message *msg2; @@ -692,7 +910,7 @@ failed: /** * Canonicalize a message, merging elements of the same name */ -struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, +struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, const struct ldb_message *msg) { int ret; @@ -764,7 +982,7 @@ int ldb_msg_normalize(struct ldb_context *ldb, * If you then use this in a ldb_modify() call, * it can be used to save edits to a message */ -struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, +struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2) { @@ -870,7 +1088,7 @@ failed: } -int ldb_msg_sanity_check(struct ldb_context *ldb, +int ldb_msg_sanity_check(struct ldb_context *ldb, const struct ldb_message *msg) { unsigned int i, j; @@ -887,7 +1105,7 @@ int ldb_msg_sanity_check(struct ldb_context *ldb, if (msg->elements[i].values[j].length == 0) { /* an attribute cannot be empty */ ldb_asprintf_errstring(ldb, "Element %s has empty attribute in ldb message (%s)!", - msg->elements[i].name, + msg->elements[i].name, ldb_dn_get_linearized(msg->dn)); -- Samba Shared Repository