summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-02-08 17:20:03 +1100
committerAndrew Bartlett <abartlet@samba.org>2008-02-08 17:20:03 +1100
commite5d2ec1cb97d39a8056f34a4105fae5352677c1b (patch)
treea4eb973d2cdc8ebfa4f759c7dc59dcac1454a254
parent9e547f43036c2487e1a7e9fa3de9acb2d5bf579f (diff)
parent0efa783849ff4bd449cdcc5f643f0101d48746bb (diff)
downloadsamba-e5d2ec1cb97d39a8056f34a4105fae5352677c1b.tar.gz
samba-e5d2ec1cb97d39a8056f34a4105fae5352677c1b.tar.xz
samba-e5d2ec1cb97d39a8056f34a4105fae5352677c1b.zip
Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-local
(This used to be commit ae9d0343e0599ac62c3011a3d6c1948a9cb7a8f1)
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py8
-rw-r--r--source4/lib/tdb/common/tdb.c80
-rw-r--r--source4/samba4-knownfail1
-rw-r--r--source4/samba4-skip1
-rwxr-xr-xtestprogs/blackbox/test_kinit.sh2
5 files changed, 53 insertions, 39 deletions
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index d35f7767df..a425ddc830 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -523,12 +523,12 @@ member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + base_dn + """
assert len(res) == 0
print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
- res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base="cn=ldaptestcontainer2," + base_dn, scope=SCOPE_ONELEVEL)
- # FIXME: assert len(res) == 0
+ res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + base_dn), scope=SCOPE_ONELEVEL)
+ assert len(res) == 0
print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
- res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base="cn=ldaptestcontainer2," + base_dn, scope=SCOPE_SUBTREE)
- #FIXME: assert len(res) == 0
+ res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + base_dn), scope=SCOPE_SUBTREE)
+ assert len(res) == 0
print "Testing delete of subtree renamed "+("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn)
ldb.delete(("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn))
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c
index a25c3e7aca..767452c9b3 100644
--- a/source4/lib/tdb/common/tdb.c
+++ b/source4/lib/tdb/common/tdb.c
@@ -687,9 +687,35 @@ void tdb_enable_seqnum(struct tdb_context *tdb)
/*
+ add a region of the file to the freelist. Length is the size of the region in bytes,
+ which includes the free list header that needs to be added
+ */
+static int tdb_free_region(struct tdb_context *tdb, tdb_off_t offset, ssize_t length)
+{
+ struct list_struct rec;
+ if (length <= sizeof(rec)) {
+ /* the region is not worth adding */
+ return 0;
+ }
+ if (length + offset > tdb->map_size) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: adding region beyond end of file\n"));
+ return -1;
+ }
+ memset(&rec,'\0',sizeof(rec));
+ rec.rec_len = length - sizeof(rec);
+ if (tdb_free(tdb, offset, &rec) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_free_region: failed to add free record\n"));
+ return -1;
+ }
+ return 0;
+}
+
+/*
wipe the entire database, deleting all records. This can be done
very fast by using a global lock. The entire data portion of the
file becomes a single entry in the freelist.
+
+ This code carefully steps around the recovery area, leaving it alone
*/
int tdb_wipe_all(struct tdb_context *tdb)
{
@@ -735,43 +761,31 @@ int tdb_wipe_all(struct tdb_context *tdb)
goto failed;
}
- if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &offset) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write recovery head\n"));
- goto failed;
- }
-
- /* add all the rest of the file to the freelist */
- data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size)) - sizeof(struct list_struct);
- if (data_len < recovery_size+sizeof(tdb_off_t)) {
- recovery_size = 0;
- } else {
- data_len -= recovery_size;
- }
- if (data_len > 0) {
- struct list_struct rec;
- memset(&rec,'\0',sizeof(rec));
- rec.rec_len = data_len;
- if (tdb_free(tdb, TDB_DATA_START(tdb->header.hash_size), &rec) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to add free record\n"));
+ /* add all the rest of the file to the freelist, possibly leaving a gap
+ for the recovery area */
+ if (recovery_size == 0) {
+ /* the simple case - the whole file can be used as a freelist */
+ data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size));
+ if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
goto failed;
}
- }
-
- /* possibly add the recovery record */
- if (recovery_size != 0) {
- struct list_struct rec;
-
- recovery_head = tdb->map_size - recovery_size;
-
- ZERO_STRUCT(rec);
- rec.rec_len = recovery_size - sizeof(rec);
- if (tdb_rec_write(tdb, recovery_head, &rec) != 0) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to add recovery record\n"));
+ } else {
+ /* we need to add two freelist entries - one on either
+ side of the recovery area
+
+ Note that we cannot shift the recovery area during
+ this operation. Only the transaction.c code may
+ move the recovery area or we risk subtle data
+ corruption
+ */
+ data_len = (recovery_head - TDB_DATA_START(tdb->header.hash_size));
+ if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
goto failed;
}
- if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &recovery_head) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write recovery head\n"));
- goto failed;
+ /* and the 2nd free list entry after the recovery area - if any */
+ data_len = tdb->map_size - (recovery_head+recovery_size);
+ if (tdb_free_region(tdb, recovery_head+recovery_size, data_len) != 0) {
+ goto failed;
}
}
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 6b2217c467..b1b2140fec 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -34,4 +34,3 @@ RPC-NETLOGON.*.GetTrustPasswords
BASE-CHARSET.*.Testing partial surrogate
.*NET-API-DELSHARE.* # DelShare isn't implemented yet
RAP.*netservergetinfo
-RAW-OFFLINE # Samba 4 doesn't have much offline support yet
diff --git a/source4/samba4-skip b/source4/samba4-skip
index 8ce9c4f9cc..b53f444c9c 100644
--- a/source4/samba4-skip
+++ b/source4/samba4-skip
@@ -50,3 +50,4 @@ RPC-FRSAPI # Not provided by Samba 4
WINBIND # FIXME: This should not be skipped
NSS-TEST # Fails
samba4.samba3sam.python # Conversion from EJS not yet finished
+RAW-OFFLINE # Samba 4 doesn't have much offline support yet
diff --git a/testprogs/blackbox/test_kinit.sh b/testprogs/blackbox/test_kinit.sh
index db12fba2f8..d4eff07c8d 100755
--- a/testprogs/blackbox/test_kinit.sh
+++ b/testprogs/blackbox/test_kinit.sh
@@ -56,7 +56,7 @@ test_smbclient() {
return $status
}
-KRB5CCNAME=`pwd`/tmpccache
+KRB5CCNAME="$PREFIX/tmpccache"
export KRB5CCNAME
echo $PASSWORD > ./tmppassfile