[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Wed Mar 9 12:53:05 UTC 2016
The branch, master has been updated
via 1c79654 configure: set HAVE___ATTRIBUTE__ for heimdal
via c1b68fa torture_ldap_sort: avoid segfault
via 5d6a67e ldb sort: allow sorting on attributes not returned in search
via b797baa Add python server sort tests
via 577f972 ldb_controls: add base64 option to VLV
via 9bbd7d1 asn1: make readContextSimple() add a NUL byte
via 16fda12 ldb controls: use uint8_t* for contextID binary blob
via fe2bcf9 ldap VLV: correct ASN1 parsing of VLV requests
via 8ca1e34 ASN1: use a talloc context in read_contextSimple
via 8b650a5 ldap: fix search control rule identifiers ASN.1 type
via 177ca76 vlv: better syntax for parsing greater than or equal strings
via d2c6f76 ldap VLV: memdup, not strdup VLV context_id
via 5421d70 ldap VLV: use correct ASN.1 encoding for requests
via 78f8a89 ldb controls: better error string for VLV control
via 2973d4c ldb controls: base64 encode VLV response context strings
via 182c87f ldb paged_results: quieten a warning.
via 4c38e74 dsdb: Introduce LDB_SYNTAX_SAMBA_OCTET_STRING
via 407c812 util/tests: add test for BINARY_ARRAY_SEARCH_V macro
via 5235f1f util/binsearch: macro for greater than or equal search
via 42fe66f tests: Allow alternative error code for backupkey test
via ca9bbc8 selftest: Avoid sorting issues on Ubuntu 10.04 vs 14.04
from 2041794 pytalloc: Correct description of pytalloc_Get{Base,}ObjectType behaviour
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 1c796547f20fa3c7c2e93fd5ce6ee8453a2bb435
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Mar 8 10:23:09 2016 +1300
configure: set HAVE___ATTRIBUTE__ for heimdal
Without this, heimdal ends up defining __attribute__ away, causing
gcc-6 compile errors with -Werror=return-type because it can't tell
when functions have __attribute__((noreturn)).
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Wed Mar 9 13:52:26 CET 2016 on sn-devel-144
commit c1b68fa0b82cba05a32350a1e0b22842203c9274
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Mar 2 17:15:50 2016 +1300
torture_ldap_sort: avoid segfault
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 5d6a67e9de0a5bee1e97db4284f15662d0e28717
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Mar 8 14:43:40 2016 +1300
ldb sort: allow sorting on attributes not returned in search
The attribute is added to the search request, then peeled off again
before the sort module passes the results on.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit b797baaa6017549e8ca294e83a64dedc09162a54
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Mar 9 11:25:36 2016 +1300
Add python server sort tests
The tests are repeated twice: once properly with complex Unicode
strings, and again in a simplified ASCII subset. We only expect Samba
to pass the simplified version. The hard tests are aspirational and
show what Active Directory does.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 577f972f4570e2ab08f0b2ff4a9737089c3d2bc6
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Fri Jan 29 17:47:45 2016 +1300
ldb_controls: add base64 option to VLV
The Samba control syntax limits the range of valid search terms for
VLV's gt_eq mode. To get around that, we allow base64 encoded strings
using the syntax 'base64>=Zm9vCg==' rather than '>=foo'.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 9bbd7d1c77b63ead59e3abac29abca1e732d343c
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Mon Jan 11 11:36:07 2016 +1300
asn1: make readContextSimple() add a NUL byte
Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 16fda12282ac6ce044f28122376cedf0257582e7
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Jan 26 13:33:15 2016 +1300
ldb controls: use uint8_t* for contextID binary blob
It is never a readable string.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit fe2bcf9d4155527112c9089fe81ac0b2bfbd2ecb
Author: Garming Sam <garming at catalyst.net.nz>
Date: Fri Mar 4 14:46:46 2016 +1300
ldap VLV: correct ASN1 parsing of VLV requests
As with the encoding, the ASN1_CONTEXT tag isn't followed by an
ASN1_SEQUENCE, though you wouldn't think that from reading the
specification.
Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 8ca1e349eb720f6be8d0d9aa0b800678813eb933
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Dec 30 12:07:35 2015 +1300
ASN1: use a talloc context in read_contextSimple
Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 8b650a5ab3601be96377022ce9f98b5817fb4aa3
Author: Garming Sam <garming at catalyst.net.nz>
Date: Thu Dec 17 10:33:54 2015 +1300
ldap: fix search control rule identifiers ASN.1 type
Wireshark and Windows both expect matching rule identifiers to be
given the ContextSimple type identifier instead of the Octet String.
As far as we can tell this is not formally specified anywhere.
Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 177ca764fc33e84f35fd6ffdf7c5dbb686704fb4
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Dec 23 17:34:15 2015 +1300
vlv: better syntax for parsing greater than or equal strings
This makes the gt_eq case different from the indexed case in the eyes
of sscanf().
Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit d2c6f7624b802825f0fa711a6254f16de071814d
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Dec 22 17:10:14 2015 +1300
ldap VLV: memdup, not strdup VLV context_id
The context ID is not a text string, it is an opaque binary field.
Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 5421d7070a8925104d9abc2039202983135acf64
Author: Garming Sam <garming at catalyst.net.nz>
Date: Tue Dec 22 17:07:38 2015 +1300
ldap VLV: use correct ASN.1 encoding for requests
The search reference points (either an integer index or a string
for comparison) are supposed to use ASN1_CONTEXT or ASN1_CONTEXT_SIMPLE
(respectively) ASN.1 types. We were using these types, but we also put
extra ones in too, which nobody else likes.
Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 78f8a89bddada072fd6fcb6aa3ec304f4a0cf27f
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Dec 22 16:34:53 2015 +1300
ldb controls: better error string for VLV control
Pair-programmed-with: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 2973d4cd0fe6863841b276d4f73e3c175319c942
Author: Garming Sam <garming at catalyst.net.nz>
Date: Tue Jan 26 13:07:48 2016 +1300
ldb controls: base64 encode VLV response context strings
Pair-programmed-with: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 182c87fb82faf2adc3553f2415b05cff07c2aa2e
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Tue Jan 26 13:34:58 2016 +1300
ldb paged_results: quieten a warning.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 4c38e74d7c044f2a05a87a430b45383d3c3744f7
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Jan 15 14:52:12 2016 +1300
dsdb: Introduce LDB_SYNTAX_SAMBA_OCTET_STRING
The sort order for this function is more expected than the sort order for
ldb_comparsion_binary()
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 407c812b2ab3b754b5cd7c79f0abc8baa11f6b74
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Fri Feb 19 15:39:38 2016 +1300
util/tests: add test for BINARY_ARRAY_SEARCH_V macro
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 5235f1facf551672d202e7400f1ba3bd85a8f7dc
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Fri Jan 29 17:53:20 2016 +1300
util/binsearch: macro for greater than or equal search
Sometimes you want to find the place where an item would be in a
sorted list, whether or not it is actually there.
The BINARY_ARRAY_SEARCH_GTE macro takes an extra 'next' pointer
argument over the other binsearch macros. This will end up pointing to
the next element in the case where there is not an exact match, or
NULL when there is. That is, searching the list
{ 2, 3, 4, 4, 9}
with a standard integer compare should give the following results:
search term *result *next
1 - 2
3 3 -
4 4 [1] -
7 - 9
9 9 -
10 - - [2]
Notes
[1] There are two fours, but you will always get the first one.
[2] The both NULL case means the search term is beyond the last list
item.
You can safely use the same pointer for both 'result' and 'next', if
you don't care to distinguish between the 'greater-than' and 'equals'
cases.
There is a torture test for this.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
commit 42fe66fa732d824d62db4b35739fdbdc93bbb312
Author: Garming Sam <garming at catalyst.net.nz>
Date: Tue Feb 23 10:59:15 2016 +1300
tests: Allow alternative error code for backupkey test
It appears that incorrect decryption triggers a different error code,
causing a test which fails every now and again, as sometimes the invalid
data will parse as a SID, and so pass one of the checks.
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit ca9bbc8cc5bdf83de532d7afe094e35cdeee788c
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Mar 9 14:08:41 2016 +1300
selftest: Avoid sorting issues on Ubuntu 10.04 vs 14.04
The unimportant lines starting with # sorted differently between these
two platforms.
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Garming Sam <garming at catalyst.net.nz>
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/wscript | 16 +
lib/ldb-samba/ldif_handlers.c | 92 ++++--
lib/ldb-samba/ldif_handlers.h | 1 +
lib/ldb/common/ldb_controls.c | 35 +-
lib/ldb/include/ldb.h | 4 +-
lib/ldb/modules/paged_results.c | 4 +-
lib/ldb/modules/sort.c | 44 ++-
lib/util/asn1.c | 7 +-
lib/util/asn1.h | 2 +-
lib/util/binsearch.h | 33 ++
lib/util/tests/binsearch.c | 168 ++++++++++
libcli/ldap/ldap_message.c | 10 +-
selftest/knownfail | 5 +
source4/dsdb/schema/schema_syntax.c | 9 +-
source4/dsdb/tests/python/sort.py | 363 +++++++++++++++++++++
source4/libcli/ldap/ldap_controls.c | 42 +--
.../expected-otherphone-after-dbcheck.ldif | 4 -
source4/selftest/tests.py | 3 +
source4/torture/ldap/ldap_sort.c | 1 +
source4/torture/local/local.c | 1 +
source4/torture/local/wscript_build | 2 +-
source4/torture/rpc/backupkey_heimdal.c | 6 +-
testprogs/blackbox/dbcheck-oldrelease.sh | 2 +-
23 files changed, 766 insertions(+), 88 deletions(-)
create mode 100644 lib/util/tests/binsearch.c
create mode 100644 source4/dsdb/tests/python/sort.py
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 586cc4b..8802e5a 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -402,6 +402,22 @@ def configure(conf):
addmain=False,
msg='Checking for library destructor support')
+ conf.CHECK_CODE('''
+ void test_attribute(void) __attribute__ (());
+
+ void test_attribute(void)
+ {
+ return;
+ }
+
+ int main(void) {
+ return 0;
+ }
+ ''',
+ 'HAVE___ATTRIBUTE__',
+ addmain=False,
+ msg='Checking for __attribute__')
+
if sys.platform.startswith('aix'):
conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
# Might not be needed if ALL_SOURCE is defined
diff --git a/lib/ldb-samba/ldif_handlers.c b/lib/ldb-samba/ldif_handlers.c
index 3b84084..fc13f07 100644
--- a/lib/ldb-samba/ldif_handlers.c
+++ b/lib/ldb-samba/ldif_handlers.c
@@ -1239,6 +1239,47 @@ static int samba_syntax_operator_fn(struct ldb_context *ldb, enum ldb_parse_op o
}
/*
+ compare two binary objects. This is correct for sorting as the sort order is:
+
+ a
+ aa
+ b
+ bb
+
+ rather than ldb_comparison_binary() which is:
+
+ a
+ b
+ aa
+ bb
+
+*/
+static int samba_ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2)
+{
+ return data_blob_cmp(v1, v2);
+}
+
+/*
+ when this operator_fn is set for a syntax, the backend calls is in
+ preference to the comparison function. We are told the exact
+ comparison operation that is needed, and we can return errors.
+
+ This mode optimises for ldb_comparison_binary() if we need equality,
+ as this should be faster as it can do a length-check first.
+ */
+static int samba_syntax_binary_operator_fn(struct ldb_context *ldb, enum ldb_parse_op operation,
+ const struct ldb_schema_attribute *a,
+ const struct ldb_val *v1, const struct ldb_val *v2, bool *matched)
+{
+ if (operation == LDB_OP_EQUALITY) {
+ *matched = (ldb_comparison_binary(ldb, NULL, v1, v2) == 0);
+ return LDB_SUCCESS;
+ }
+ return samba_syntax_operator_fn(ldb, operation, a, v1, v2, matched);
+}
+
+/*
see if two DNs match, comparing first by GUID, then by SID, and
finally by string components
*/
@@ -1334,8 +1375,8 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
.ldif_read_fn = ldif_read_ntSecurityDescriptor,
.ldif_write_fn = ldif_write_ntSecurityDescriptor,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_SDDL_SECURITY_DESCRIPTOR,
.ldif_read_fn = ldb_handler_copy,
@@ -1362,8 +1403,8 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_schemaInfo,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_PREFIX_MAP,
.ldif_read_fn = ldif_read_prefixMap,
@@ -1383,22 +1424,22 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_repsFromTo,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_REPLPROPERTYMETADATA,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_replPropertyMetaData,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_REPLUPTODATEVECTOR,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_replUpToDateVector,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_REVEALEDUSERS,
.ldif_read_fn = ldb_handler_copy,
@@ -1411,15 +1452,15 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_trustAuthInOutBlob,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_FORESTTRUSTINFO,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_ForestTrustInfo,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = DSDB_SYNTAX_BINARY_DN,
.ldif_read_fn = ldb_handler_copy,
@@ -1453,29 +1494,36 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_dnsRecord,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_DNSPROPERTY,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_dnsProperty,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_SUPPLEMENTALCREDENTIALS,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_supplementalCredentialsBlob,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
},{
.name = LDB_SYNTAX_SAMBA_PARTIALATTRIBUTESET,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldif_write_partialAttributeSet,
.canonicalise_fn = ldb_handler_copy,
- .comparison_fn = ldb_comparison_binary,
- .operator_fn = samba_syntax_operator_fn
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
+ },{
+ .name = LDB_SYNTAX_SAMBA_OCTET_STRING,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_handler_copy,
+ .comparison_fn = samba_ldb_comparison_binary,
+ .operator_fn = samba_syntax_binary_operator_fn
}
};
diff --git a/lib/ldb-samba/ldif_handlers.h b/lib/ldb-samba/ldif_handlers.h
index 5ba6f12..8b2ade6 100644
--- a/lib/ldb-samba/ldif_handlers.h
+++ b/lib/ldb-samba/ldif_handlers.h
@@ -20,6 +20,7 @@
#define LDB_SYNTAX_SAMBA_TRUSTAUTHINOUTBLOB "LDB_SYNTAX_SAMBA_TRUSTAUTHINOUTBLOB"
#define LDB_SYNTAX_SAMBA_FORESTTRUSTINFO "LDB_SYNTAX_SAMBA_FORESTTRUSTINFO"
#define LDB_SYNTAX_SAMBA_PARTIALATTRIBUTESET "LDB_SYNTAX_SAMBA_PARTIALATTRIBUTESET"
+#define LDB_SYNTAX_SAMBA_OCTET_STRING "LDB_SYNTAX_SAMBA_OCTET_STRING"
#include "lib/ldb-samba/ldif_handlers_proto.h"
#undef _PRINTF_ATTRIBUTE
diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c
index af056d0..7da0cf0 100644
--- a/lib/ldb/common/ldb_controls.c
+++ b/lib/ldb/common/ldb_controls.c
@@ -310,14 +310,19 @@ char *ldb_control_to_string(TALLOC_CTX *mem_ctx, const struct ldb_control *contr
struct ldb_vlv_resp_control *rep_control = talloc_get_type(control->data,
struct ldb_vlv_resp_control);
- res = talloc_asprintf(mem_ctx, "%s:%d:%d:%d:%d:%d:%s",
+ char *cookie;
+
+ cookie = ldb_base64_encode(mem_ctx,
+ (char *)rep_control->contextId,
+ rep_control->ctxid_len);
+
+ res = talloc_asprintf(mem_ctx, "%s:%d:%d:%d:%d:%s",
LDB_CONTROL_VLV_RESP_NAME,
control->critical,
rep_control->targetPosition,
rep_control->contentCount,
rep_control->vlv_result,
- rep_control->ctxid_len,
- rep_control->contextId);
+ cookie);
return res;
}
@@ -457,13 +462,25 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
ctxid[0] = '\0';
p = &(control_strings[sizeof(LDB_CONTROL_VLV_REQ_NAME)]);
ret = sscanf(p, "%d:%d:%d:%d:%d:%1023[^$]", &crit, &bc, &ac, &os, &cc, ctxid);
- if (ret < 5) {
- ret = sscanf(p, "%d:%d:%d:%1023[^:]:%1023[^$]", &crit, &bc, &ac, attr, ctxid);
+ /* We allow 2 ways to encode the GT_EQ case, because the
+ comparison string might contain null bytes or colons, which
+ would break sscanf (or indeed any parsing mechanism). */
+ if (ret == 3) {
+ ret = sscanf(p, "%d:%d:%d:>=%1023[^:]:%1023[^$]", &crit, &bc, &ac, attr, ctxid);
}
-
+ if (ret == 3) {
+ int len;
+ ret = sscanf(p, "%d:%d:%d:base64>=%1023[^:]:%1023[^$]", &crit, &bc, &ac, attr, ctxid);
+ len = ldb_base64_decode(attr);
+ if (len < 0) {
+ ret = -1;
+ }
+ }
+
if ((ret < 4) || (crit < 0) || (crit > 1)) {
- error_string = talloc_asprintf(mem_ctx, "invalid server_sort control syntax\n");
- error_string = talloc_asprintf_append(error_string, " syntax: crit(b):bc(n):ac(n):<os(n):cc(n)|attr(s)>[:ctxid(o)]\n");
+ error_string = talloc_asprintf(mem_ctx, "invalid VLV control syntax\n");
+ error_string = talloc_asprintf_append(error_string, " syntax: crit(b):bc(n):ac(n):"
+ "{os(n):cc(n)|>=val(s)|base64>=val(o)}[:ctxid(o)]\n");
error_string = talloc_asprintf_append(error_string, " note: b = boolean, n = number, s = string, o = b64 binary blob");
ldb_set_errstring(ldb, error_string);
talloc_free(error_string);
@@ -491,7 +508,7 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
}
if (ctxid[0]) {
control->ctxid_len = ldb_base64_decode(ctxid);
- control->contextId = (char *)talloc_memdup(control, ctxid, control->ctxid_len);
+ control->contextId = talloc_memdup(control, ctxid, control->ctxid_len);
} else {
control->ctxid_len = 0;
control->contextId = NULL;
diff --git a/lib/ldb/include/ldb.h b/lib/ldb/include/ldb.h
index e715b92..7422d46 100644
--- a/lib/ldb/include/ldb.h
+++ b/lib/ldb/include/ldb.h
@@ -849,7 +849,7 @@ struct ldb_vlv_req_control {
} gtOrEq;
} match;
int ctxid_len;
- char *contextId;
+ uint8_t *contextId;
};
struct ldb_vlv_resp_control {
@@ -857,7 +857,7 @@ struct ldb_vlv_resp_control {
int contentCount;
int vlv_result;
int ctxid_len;
- char *contextId;
+ uint8_t *contextId;
};
struct ldb_verify_name_control {
diff --git a/lib/ldb/modules/paged_results.c b/lib/ldb/modules/paged_results.c
index 2d6c62f..de014a3 100644
--- a/lib/ldb/modules/paged_results.c
+++ b/lib/ldb/modules/paged_results.c
@@ -67,7 +67,7 @@ struct results_store {
};
struct private_data {
- unsigned int next_free_id;
+ uint32_t next_free_id;
struct results_store *store;
};
@@ -96,7 +96,7 @@ static int store_destructor(struct results_store *del)
static struct results_store *new_store(struct private_data *priv)
{
struct results_store *newr;
- unsigned int new_id = priv->next_free_id++;
+ uint32_t new_id = priv->next_free_id++;
/* TODO: we should have a limit on the number of
* outstanding paged searches
diff --git a/lib/ldb/modules/sort.c b/lib/ldb/modules/sort.c
index 1b762f7..19cf60b 100644
--- a/lib/ldb/modules/sort.c
+++ b/lib/ldb/modules/sort.c
@@ -56,6 +56,7 @@ struct sort_context {
char **referrals;
unsigned int num_msgs;
unsigned int num_refs;
+ const char *extra_sort_key;
const struct ldb_schema_attribute *a;
int sort_result;
@@ -162,7 +163,9 @@ static int server_sort_results(struct sort_context *ac)
ares->type = LDB_REPLY_ENTRY;
ares->message = talloc_move(ares, &ac->msgs[i]);
-
+ if (ac->extra_sort_key) {
+ ldb_msg_remove_attr(ares->message, ac->extra_sort_key);
+ }
ret = ldb_module_send_entry(ac->req, ares->message, ares->controls);
if (ret != LDB_SUCCESS) {
return ret;
@@ -256,6 +259,9 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
struct sort_context *ac;
struct ldb_context *ldb;
int ret;
+ const char * const *attrs;
+ size_t n_attrs, i;
+ const char *sort_attr;
ldb = ldb_module_get_ctx(module);
@@ -303,6 +309,40 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
}
}
+ /* We are asked to sort on an attribute, and if that attribute is not
+ already in the search attributes we need to add it (and later
+ remove it on the return journey).
+ */
+ sort_attr = sort_ctrls[0]->attributeName;
+ if (req->op.search.attrs == NULL) {
+ /* This means all non-operational attributes, which means
+ there's nothing to add. */
+ attrs = NULL;
+ } else {
+ n_attrs = 0;
+ while (req->op.search.attrs[n_attrs] != NULL) {
+ if (sort_attr &&
+ strcmp(req->op.search.attrs[n_attrs], sort_attr) == 0) {
+ sort_attr = NULL;
+ }
+ n_attrs++;
+ }
+
+ if (sort_attr == NULL) {
+ attrs = req->op.search.attrs;
+ } else {
+ const char **tmp = talloc_array(ac, const char *, n_attrs + 2);
+
+ for (i = 0; i < n_attrs; i++) {
+ tmp[i] = req->op.search.attrs[i];
+ }
+ ac->extra_sort_key = sort_attr;
+ tmp[n_attrs] = sort_attr;
+ tmp[n_attrs + 1] = NULL;
+ attrs = tmp;
+ }
+ }
+
ac->attributeName = sort_ctrls[0]->attributeName;
ac->orderingRule = sort_ctrls[0]->orderingRule;
ac->reverse = sort_ctrls[0]->reverse;
@@ -311,7 +351,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
- req->op.search.attrs,
+ attrs,
req->controls,
ac,
server_sort_search_callback,
diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index 9d6d416..d3b46aa 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -927,7 +927,8 @@ bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLO
return false;
}
-bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob)
+bool asn1_read_ContextSimple(struct asn1_data *data, TALLOC_CTX *mem_ctx, uint8_t num,
+ DATA_BLOB *blob)
{
int len;
ZERO_STRUCTP(blob);
@@ -937,12 +938,14 @@ bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blo
data->has_error = true;
return false;
}
- *blob = data_blob(NULL, len);
+ *blob = data_blob_talloc(mem_ctx, NULL, len + 1);
if ((len != 0) && (!blob->data)) {
data->has_error = true;
return false;
}
if (!asn1_read(data, blob->data, len)) return false;
+ blob->length--;
+ blob->data[len] = 0;
return asn1_end_tag(data);
}
diff --git a/lib/util/asn1.h b/lib/util/asn1.h
index 95e7dbf..ddd6986 100644
--- a/lib/util/asn1.h
+++ b/lib/util/asn1.h
@@ -87,7 +87,7 @@ bool asn1_check_OID(struct asn1_data *data, const char *OID);
bool asn1_read_LDAPString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s);
bool asn1_read_GeneralString(struct asn1_data *data, TALLOC_CTX *mem_ctx, char **s);
bool asn1_read_OctetString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob);
-bool asn1_read_ContextSimple(struct asn1_data *data, uint8_t num, DATA_BLOB *blob);
+bool asn1_read_ContextSimple(struct asn1_data *data, TALLOC_CTX *mem_ctx, uint8_t num, DATA_BLOB *blob);
bool asn1_read_implicit_Integer(struct asn1_data *data, int *i);
bool asn1_read_Integer(struct asn1_data *data, int *i);
bool asn1_read_BitString(struct asn1_data *data, TALLOC_CTX *mem_ctx, DATA_BLOB *blob, uint8_t *padding);
diff --git a/lib/util/binsearch.h b/lib/util/binsearch.h
index f85d116..001f2c5 100644
--- a/lib/util/binsearch.h
+++ b/lib/util/binsearch.h
@@ -81,4 +81,37 @@
if (_r < 0) _e = _i - 1; else _b = _i + 1; \
}} } while (0)
+
+/*
+ like BINARY_ARRAY_SEARCH_V, but if an exact result is not found, the 'next'
+ argument will point to the element after the place where the exact result
+ would have been. If an exact result is found, 'next' will be NULL. If the
+ target is beyond the end of the list, both 'result' and 'next' will be NULL.
+ Unlike other binsearch macros, where there are several elements that compare
+ the same, the result will always point to the first one.
+
+ If you don't care to distinguish between the 'greater than' and 'equals'
+ cases, you can use the same pointer for both 'result' and 'next'.
+
+ As with all the binsearch macros, the comparison function is always called
+ with the search term first.
+ */
+#define BINARY_ARRAY_SEARCH_GTE(array, array_size, target, comparison_fn, \
+ result, next) do { \
+ int32_t _b, _e; \
+ (result) = NULL; (next) = NULL; \
+ if ((array_size) > 0) { \
+ for (_b = 0, _e = (array_size)-1; _b <= _e; ) { \
+ int32_t _i = (_b + _e) / 2; \
+ int _r = comparison_fn(target, array[_i]); \
+ if (_r == 0) { \
+ (result) = &array[_i]; \
+ _e = _i - 1; \
+ } else if (_r < 0) { _e = _i - 1; \
+ } else { _b = _i + 1; } \
+ } \
+ if ((result) == NULL &&_b < (array_size)) { \
+ (next) = &array[_b]; \
+ } } } while (0)
+
#endif
diff --git a/lib/util/tests/binsearch.c b/lib/util/tests/binsearch.c
new file mode 100644
index 0000000..c6ef47e
--- /dev/null
+++ b/lib/util/tests/binsearch.c
@@ -0,0 +1,168 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Tests for binsearch.h macros.
+
+ Copyright Catalyst IT 2016.
+
+ Written by Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
--
Samba Shared Repository
More information about the samba-cvs
mailing list