From 0e9147029f0ca5b7e7d53235fe4bd81dd4fb1b3d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2006 18:50:12 +0000 Subject: r18536: fixed the loading of external binary files from ldif into ldb (This used to be commit fbe13ed83e2f3508db6d77f4bd65a913ef12ff02) --- source4/lib/ldb/common/ldb_ldif.c | 8 +++++++- source4/lib/ldb/tests/test-generic.sh | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 593a895262..c5084aaa6c 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -50,8 +50,14 @@ static int ldb_read_data_file(void *mem_ctx, struct ldb_val *value) int count, size, bytes; int ret; int f; + const char *fname = (const char *)value->data; - f = open((const char *)value->data, O_RDONLY); + if (strncmp(fname, "file://", 7) != 0) { + return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; + } + fname += 7; + + f = open(fname, O_RDONLY); if (f == -1) { return -1; } diff --git a/source4/lib/ldb/tests/test-generic.sh b/source4/lib/ldb/tests/test-generic.sh index c1e0039b97..d1cbc80938 100755 --- a/source4/lib/ldb/tests/test-generic.sh +++ b/source4/lib/ldb/tests/test-generic.sh @@ -73,9 +73,12 @@ fi echo "Testing binary file attribute value" cp $LDBDIR/tests/samba4.png tests/tmp/samba4.png -#$VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1 -#exit 1 -#$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto +$VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1 +count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto || grep '^dn' | wc -l` +if [ $count != 1 ]; then + echo returned $count records - expected 1 + exit 1 +fi rm -f tests/tmp/samba4.png echo "*TODO* Testing UTF8 upper lower case searches !!" -- cgit