[SCM] Samba Shared Repository - branch master updated

2013-03-23 Thread Rusty Russell
The branch, master has been updated
   via  068e0e2 ntdb: don't call open hook when re-opening an existing 
database.
   via  fd6d036 vfs_btrfs: fix compile on 32-bit platforms.
  from  12ebb1b smbd: Tune dir a bit.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 068e0e2b38fb109eb1d1306c6d74bfa86ec0c4b8
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Mar 23 17:27:57 2013 +1030

ntdb: don't call open hook when re-opening an existing database.

In particular, the Samba dbwrap wrapper can do this for schannel_store,
with the openhook set to clear the database if it can get the lock
(which, being in the same process, it can).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Sat Mar 23 09:39:50 CET 2013 on sn-devel-104

commit fd6d0361d6fef5f8175967ddbae4a2b1d79dfcad
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Mar 23 17:26:57 2013 +1030

vfs_btrfs: fix compile on 32-bit platforms.

uint64_t are not unsigned longs on 32-bit platforms:

[3265/3996] Compiling source3/modules/vfs_btrfs.c
../source3/modules/vfs_btrfs.c: In function ‘btrfs_copy_chunk_send’:
../source3/modules/vfs_btrfs.c:118:3: error: format ‘%lu’ expects argument 
of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Werror=format]
../source3/modules/vfs_btrfs.c:118:3: error: format ‘%ld’ expects argument 
of type ‘long int’, but argument 4 has type ‘int64_t’ [-Werror=format]
../source3/modules/vfs_btrfs.c:118:3: error: format ‘%lu’ expects argument 
of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ [-Werror=format]
../source3/modules/vfs_btrfs.c:118:3: error: format ‘%lu’ expects argument 
of type ‘long unsigned int’, but argument 7 has type ‘uint64_t’ [-Werror=format]
../source3/modules/vfs_btrfs.c: In function ‘btrfs_copy_chunk_recv’:
../source3/modules/vfs_btrfs.c:180:2: error: format ‘%lu’ expects argument 
of type ‘long unsigned int’, but argument 2 has type ‘off_t’ [-Werror=format]
cc1: some warnings being treated as errors

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ntdb/open.c |   22 +++---
 lib/ntdb/test/api-83-openhook.c |   13 +++--
 source3/modules/vfs_btrfs.c |9 +
 3 files changed, 27 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ntdb/open.c b/lib/ntdb/open.c
index abec117..2a265af 100644
--- a/lib/ntdb/open.c
+++ b/lib/ntdb/open.c
@@ -679,6 +679,17 @@ _PUBLIC_ struct ntdb_context *ntdb_open(const char *name, 
int ntdb_flags,
 
ntdb-file-device = st.st_dev;
ntdb-file-inode = st.st_ino;
+
+   /* call their open hook if they gave us one. */
+   if (ntdb-openhook) {
+   ecode = ntdb-openhook(ntdb-file-fd, 
ntdb-openhook_data);
+   if (ecode != NTDB_SUCCESS) {
+   ntdb_logerr(ntdb, ecode, NTDB_LOG_ERROR,
+   ntdb_open: open hook failed);
+   goto fail;
+   }
+   open_flags |= O_CREAT;
+   }
} else {
/* ensure there is only one process initialising at once */
ecode = ntdb_lock_open(ntdb, openlock,
@@ -689,17 +700,6 @@ _PUBLIC_ struct ntdb_context *ntdb_open(const char *name, 
int ntdb_flags,
}
}
 
-   /* call their open hook if they gave us one. */
-   if (ntdb-openhook) {
-   ecode = ntdb-openhook(ntdb-file-fd, ntdb-openhook_data);
-   if (ecode != NTDB_SUCCESS) {
-   ntdb_logerr(ntdb, ecode, NTDB_LOG_ERROR,
-  ntdb_open: open hook failed);
-   goto fail;
-   }
-   open_flags |= O_CREAT;
-   }
-
/* If they used O_TRUNC, read will return 0. */
rlen = pread(ntdb-file-fd, hdr, sizeof(hdr), 0);
if (rlen == 0  (open_flags  O_CREAT)) {
diff --git a/lib/ntdb/test/api-83-openhook.c b/lib/ntdb/test/api-83-openhook.c
index 31c789e..3816eef 100644
--- a/lib/ntdb/test/api-83-openhook.c
+++ b/lib/ntdb/test/api-83-openhook.c
@@ -44,7 +44,7 @@ static enum NTDB_ERROR clear_if_first(int fd, void *arg)
 int main(int argc, char *argv[])
 {
unsigned int i;
-   struct ntdb_context *ntdb;
+   struct ntdb_context *ntdb, *ntdb2;
struct agent *agent;
union ntdb_attribute cif;
NTDB_DATA key = ntdb_mkdata(KEY_STR, strlen(KEY_STR));
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
cif.openhook.data = clear_if_first;
 
agent

[SCM] Samba Shared Repository - branch master updated

2013-03-23 Thread Rusty Russell
The branch, master has been updated
   via  d27f00c vfs-btrfs: Fix build on 32 bit platforms by using long long 
types
   via  c202dc9 Revert vfs_btrfs: fix compile on 32-bit platforms.
  from  068e0e2 ntdb: don't call open hook when re-opening an existing 
database.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit d27f00cd4cd14b7729861121ed221e3cf2ecf9ba
Author: Andrew Bartlett abart...@samba.org
Date:   Wed Mar 20 12:46:22 2013 +1100

vfs-btrfs: Fix build on 32 bit platforms by using long long types

Reviewed-by: Rusty Russell ru...@rustcorp.com.au
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Sun Mar 24 06:17:55 CET 2013 on sn-devel-104

commit c202dc9705cf87542094ee1930e5dab9923c605b
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sun Mar 24 13:58:02 2013 +1030

Revert vfs_btrfs: fix compile on 32-bit platforms.

This reverts commit fd6d0361d6fef5f8175967ddbae4a2b1d79dfcad.

Unreviewed, and Andrew has a better fix.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 source3/modules/vfs_btrfs.c |   17 ++---
 1 files changed, 10 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index eed5456..f854f2a 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -115,11 +115,14 @@ static struct tevent_req *btrfs_copy_chunk_send(struct 
vfs_handle_struct *handle
 * cloning. Which is 4096 by default, therefore fall back to
 * manual read/write on failure.
 */
-   DEBUG(5, (BTRFS_IOC_CLONE_RANGE failed: %s, length %lu, 
- src fd: %ld off: %lu, dest fd: %d off: %lu\n,
- strerror(errno), (long)cr_args.src_length,
- (long)cr_args.src_fd, (long)cr_args.src_offset,
- dest_fsp-fh-fd, (long)cr_args.dest_offset));
+   DEBUG(5, (BTRFS_IOC_CLONE_RANGE failed: %s, length %llu, 
+ src fd: %lld off: %llu, dest fd: %d off: %llu\n,
+ strerror(errno),
+ (unsigned long long)cr_args.src_length,
+ (long long)cr_args.src_fd,
+ (unsigned long long)cr_args.src_offset,
+ dest_fsp-fh-fd,
+ (unsigned long long)cr_args.dest_offset));
cc_state-subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle,
cc_state, ev,
src_fsp,
@@ -177,8 +180,8 @@ static NTSTATUS btrfs_copy_chunk_recv(struct 
vfs_handle_struct *handle,
return status;
}
 
-   DEBUG(10, (server side copy chunk copied %lu\n,
-  (long)cc_state-copied));
+   DEBUG(10, (server side copy chunk copied %llu\n,
+  (unsigned long long)cc_state-copied));
*copied = cc_state-copied;
tevent_req_received(req);
return NT_STATUS_OK;


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2013-02-19 Thread Rusty Russell
The branch, master has been updated
   via  2f4b21b ntdb: switch between secrets.tdb and secrets.ntdb depending 
on 'use ntdb'
   via  3c9c302 param: 'use ntdb' flag (off by default).
   via  e201033 tdb_wrap: prevent tdbs called .ntdb or without extensions.
   via  53aac0b dbwrap_local_open: never open the .tdb if there is an .ntdb
   via  f3c0d1d dbwrap_local_open: open NTDB if extension is .ntdb
   via  48a4270 source3: explicitly disable NTDB support.
   via  63a6381 dbwrap: dbwrap_ntdb.c
   via  3d82f78 ntdb: fix database corruption when transaction doesn't 
change anything.
  from  85b6329 s3:selftest: generate ${SELFTESTPREFIX}/subunit with the 
raw output

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 2f4b21bb57c4f96c5f5b57a69d022c142d8088d5
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

ntdb: switch between secrets.tdb and secrets.ntdb depending on 'use ntdb'

Since we open with dbwrap, it auto-converts old tdbs (which it will
rename to secrets.tdb.bak once it's done).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Wed Feb 20 07:09:19 CET 2013 on sn-devel-104

commit 3c9c3029f2bcf10ef614dd9f923d02232db3ac8d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

param: 'use ntdb' flag (off by default).

For simplicity, we use this in the caller to choose between filenames.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit e201033e84b54b13acc751db2b67cff159e12a0e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

tdb_wrap: prevent tdbs called .ntdb or without extensions.

This is another belt-and-braces check in case someone decides to turn
on the fancy new .ntdb extension, and we haven't converted it to ntdb.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit 53aac0bc9384db68c5ff469b07ae757ca1051cec
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

dbwrap_local_open: never open the .tdb if there is an .ntdb

This provides an extra safety check that everyone is using one or the
other: you can't create a tdb file if there's an ntdb file.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit f3c0d1d7fe71be7e8b2d1a9780586f8654b46469
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

dbwrap_local_open: open NTDB if extension is .ntdb

This switches dbwrap_local_open() based on the extension of the
database name, so it handles both TDB and NTDB files.

Moreover, if asked to open a .ntdb, and there's no ntdb file but
there's a .tdb file, it converts that then moves it to .tdb.bak before
opening, and turn the .tdb file into a dangling symlink to make sure
it's never accidentally re-created or used:

$ ls -l secrets.tdb
lrwxrwxrwx 1 rusty rusty 23 Feb 11 11:31 secrets.tdb - This is now in 
an NTDB

This provides transparent upgrade if people decide to use NTDB on a
database.  Downgrade would be manual, eg:

ntdbdump foo.ntdb | tdbrestore foo.tdb  mv foo.ntdb foo.ntdb.bak

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit 48a42708aead320bfbcee16ae76d095c014802de
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:59:42 2013 +1030

source3: explicitly disable NTDB support.

The next patch make dbwrap_local_open() call the ntdb backend for ntdb
files, but we don't want to add ntdb support to the old autoconf
build.  It's cleaner to use the existing DISABLE_NTDB flag rather than
test for _SAMBA_BUILD_ in dbwrap_local_open.c.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit 63a6381a26171f069cdc7465ca753f0b3c5d26f2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 20 14:58:59 2013 +1030

dbwrap: dbwrap_ntdb.c

This is a dbwrap backend for ntdb.  It's a fairly straight conversion from
the tdb version.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
Reviewed-by: Andrew Bartlett abart...@samba.org

commit 3d82f786ecdd6747e90fe480a15de8c3fcea5f7b
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sun Feb 17 20:56:34 2013 +1030

ntdb: fix database corruption when transaction doesn't change anything.

ntdb's transaction code has an optimization which tdb's doesnt: it
only writes the parts of blocks

[SCM] Samba Shared Repository - branch master updated

2012-10-16 Thread Rusty Russell
The branch, master has been updated
   via  0296548 ccan: check for all the used config.h defines
  from  05a5974 libcli/dns: Time out requests after a while

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 029654897d721308c9ee782aee420abddce7edee
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sun Oct 14 16:05:58 2012 +1030

ccan: check for all the used config.h defines

In particular, not checking for byteswap.h meant we defined duplicates:
https://bugzilla.samba.org/show_bug.cgi?id=9286

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Wed Oct 17 01:55:14 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/ccan/libccan.m4 |   16 
 lib/ccan/wscript|   21 +
 2 files changed, 37 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/libccan.m4 b/lib/ccan/libccan.m4
index 0d391ad..7b27c69 100644
--- a/lib/ccan/libccan.m4
+++ b/lib/ccan/libccan.m4
@@ -23,6 +23,8 @@ AC_SUBST(CCAN_CFLAGS)
 # fairly harmless.
 AC_CHECK_HEADERS(err.h)
 
+AC_CHECK_HEADERS(byteswap.h)
+
 AC_CACHE_CHECK([whether we can compile with __attribute__((cold))],
   samba_cv_attribute_cold,
   [
@@ -270,6 +272,19 @@ if test x$samba_cv_compound_literals = xyes ; then
 [whether we have compound literals])
 fi
 
+AC_CACHE_CHECK([whether we have flexible array members],
+  samba_cv_have_flex_arr_member,
+  [
+AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+   [struct foo { unsigned int x; int arr@:@@:@; }; ])],
+   samba_cv_have_flex_arr_member=yes)
+   ])
+
+if test x$samba_cv_have_flex_arr_member = xyes ; then
+   AC_DEFINE(HAVE_FLEXIBLE_ARRAY_MEMBER, 1,
+[whether we have flexible array member support])
+fi
+
 AC_CACHE_CHECK([whether we have isblank],
   samba_cv_have_isblank,
   [
@@ -331,3 +346,4 @@ if test x$samba_cv_warn_unused_result = xyes ; then
AC_DEFINE(HAVE_WARN_UNUSED_RESULT, 1,
 [whether we have __attribute__((warn_unused_result))])
 fi
+AC_HAVE_DECL(bswap_64, [#include byteswap.h])
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 334f8fe..4af9dd4 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -5,6 +5,9 @@ import Logs, sys, Options
 def configure(conf):
 conf.DEFINE('HAVE_CCAN', 1)
 conf.CHECK_HEADERS('err.h')
+conf.CHECK_HEADERS('byteswap.h')
+conf.CHECK_FUNCS('bswap_64', link=False, headers=byteswap.h)
+
 # FIXME: if they don't have -Werror, these will all fail.  But they
 # probably will anyway...
 conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
@@ -107,6 +110,9 @@ def configure(conf):
 define='HAVE_BUILTIN_TYPES_COMPATIBLE_P')
 conf.CHECK_CODE('int *foo = (int[]) { 1, 2, 3, 4 }; return foo[0] ? 0 : 
1;',
 define='HAVE_COMPOUND_LITERALS')
+conf.CHECK_CODE('struct foo { unsigned int x; int arr[]; };',
+addmain=False, link=False,
+define='HAVE_FLEXIBLE_ARRAY_MEMBER')
 conf.CHECK_CODE(#include ctype.h
  int main(void) { return isblank(' ') ? 0 : 1; },
 link=True, addmain=False, add_headers=False,
@@ -121,6 +127,21 @@ def configure(conf):
 # backtrace could be in libexecinfo or in libc
 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', 
checklibc=True, headers='execinfo.h')
 
+# Only check for FILE_OFFSET_BITS=64 if off_t is normally small:
+# use raw routines because wrappers include previous _GNU_SOURCE
+# or _FILE_OFFSET_BITS defines.
+conf.check(fragment=#include sys/types.h
+   int main(void) { return !(sizeof(off_t)  8); },
+   execute=True, msg='Checking for small off_t',
+   define_name='SMALL_OFF_T')
+# Unreliable return value above, hence use define.
+if conf.CONFIG_SET('SMALL_OFF_T'):
+conf.check(fragment=#include sys/types.h
+   int main(void) { return !(sizeof(off_t) = 8); },
+   execute=True, msg='Checking for -D_FILE_OFFSET_BITS=64',
+   ccflags='-D_FILE_OFFSET_BITS=64',
+   define_name='HAVE_FILE_OFFSET_BITS')
+
 def ccan_module(bld, name, deps=''):
 bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
 source=bld.path.ant_glob('%s/*.c' % name),


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-10-07 Thread Rusty Russell
The branch, master has been updated
   via  899cdc4 ntdb: remove unused local variable.
  from  9fc42da s3: Add two tests a CLEAR_IF_FIRST crash

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 899cdc4503696cbe1030f3023fe259ce0740a55c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Oct 8 11:26:43 2012 +1030

ntdb: remove unused local variable.

Reported-by: Matthieu Patou m...@samba.org
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Mon Oct  8 04:43:37 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/ntdb/free.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ntdb/free.c b/lib/ntdb/free.c
index 470c376..0d0e25f 100644
--- a/lib/ntdb/free.c
+++ b/lib/ntdb/free.c
@@ -683,7 +683,6 @@ static ntdb_off_t lock_and_alloc(struct ntdb_context *ntdb,
 
while (off) {
const struct ntdb_free_record *r;
-   ntdb_len_t len;
ntdb_off_t next;
 
r = ntdb_access_read(ntdb, off, sizeof(*r), true);
@@ -715,7 +714,6 @@ static ntdb_off_t lock_and_alloc(struct ntdb_context *ntdb,
multiplier *= 1.01;
 
next = r-next;
-   len = frec_len(r);
ntdb_access_release(ntdb, r);
off = next;
}


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-10-03 Thread Rusty Russell
The branch, master has been updated
   via  100d38d tdb: add -e option to tdbdump (and docment it).
   via  ffde867 tdb: tdbdump should log errors, and fail in that case.
   via  90f463b tdb: add tdb_rescue()
  from  fe38a93 Correct fix for bug #9222 - smbd ignores the server 
signing = no setting for SMB2.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 100d38d6e0fae1dc666ae43941570c9f106b73c2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 4 09:04:23 2012 +0930

tdb: add -e option to tdbdump (and docment it).

This allows for an emergency best-effort dump.  It's a little better than
strings(1).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Thu Oct  4 03:16:06 CEST 2012 on sn-devel-104

commit ffde8678910ae838588ab380b48a544333f81241
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 4 09:04:23 2012 +0930

tdb: tdbdump should log errors, and fail in that case.

Dumping a corrupt database should not exit silently with 0 status!

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 90f463b25f7bb0bc944732773c56e356834ea203
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 4 09:04:19 2012 +0930

tdb: add tdb_rescue()

This allows for an emergency best-effort dump.  It's a little better than
strings(1).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/ABI/{tdb-1.2.10.sigs = tdb-1.2.11.sigs} |1 +
 lib/tdb/common/rescue.c  |  349 ++
 lib/tdb/include/tdb.h|   22 ++
 lib/tdb/libtdb.m4|2 +-
 lib/tdb/manpages/tdbdump.8.xml   |   31 ++
 lib/tdb/test/run-rescue-find_entry.c |   50 +++
 lib/tdb/test/run-rescue.c|  126 
 lib/tdb/tools/tdbdump.c  |   65 -
 lib/tdb/wscript  |   10 +-
 9 files changed, 647 insertions(+), 9 deletions(-)
 copy lib/tdb/ABI/{tdb-1.2.10.sigs = tdb-1.2.11.sigs} (97%)
 create mode 100644 lib/tdb/common/rescue.c
 create mode 100644 lib/tdb/test/run-rescue-find_entry.c
 create mode 100644 lib/tdb/test/run-rescue.c


Changeset truncated at 500 lines:

diff --git a/lib/tdb/ABI/tdb-1.2.10.sigs b/lib/tdb/ABI/tdb-1.2.11.sigs
similarity index 97%
copy from lib/tdb/ABI/tdb-1.2.10.sigs
copy to lib/tdb/ABI/tdb-1.2.11.sigs
index 61f6c19..d727f21 100644
--- a/lib/tdb/ABI/tdb-1.2.10.sigs
+++ b/lib/tdb/ABI/tdb-1.2.11.sigs
@@ -45,6 +45,7 @@ tdb_remove_flags: void (struct tdb_context *, unsigned int)
 tdb_reopen: int (struct tdb_context *)
 tdb_reopen_all: int (int)
 tdb_repack: int (struct tdb_context *)
+tdb_rescue: int (struct tdb_context *, void (*)(TDB_DATA, TDB_DATA, void *), 
void *)
 tdb_set_logging_function: void (struct tdb_context *, const struct 
tdb_logging_context *)
 tdb_set_max_dead: void (struct tdb_context *, int)
 tdb_setalarm_sigptr: void (struct tdb_context *, volatile sig_atomic_t *)
diff --git a/lib/tdb/common/rescue.c b/lib/tdb/common/rescue.c
new file mode 100644
index 000..03ae8d6
--- /dev/null
+++ b/lib/tdb/common/rescue.c
@@ -0,0 +1,349 @@
+ /*
+   Unix SMB/CIFS implementation.
+
+   trivial database library, rescue attempt code.
+
+   Copyright (C) Rusty Russell2012
+
+ ** NOTE! The following LGPL license applies to the tdb
+ ** 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
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+*/
+#include tdb_private.h
+#include assert.h
+
+
+struct found {
+   tdb_off_t head; /* 0 - invalid. */
+   struct tdb_record rec;
+   TDB_DATA key;
+   bool in_hash;
+   bool in_free;
+};
+
+struct found_table {
+   /* As an ordered array (by head offset). */
+   struct found *arr;
+   unsigned int num, max;
+};
+
+static bool looks_like_valid_record(struct tdb_context *tdb,
+   tdb_off_t off,
+   const struct tdb_record *rec

[SCM] Samba Shared Repository - branch master updated

2012-07-18 Thread Rusty Russell
The branch, master has been updated
   via  127352c source4/torture: add talloc_stackframe()
   via  06731bc source3/netapi: fix only caller which doesn't set up a 
talloc_stackframe()
   via  d54ebd3 source3/passdb/py_passdb.c: wrap all calls in 
talloc_stackframe()
   via  9927233 source3/passdb/py_passdb.c: don't steal from 
talloc_stackframe().
   via  51ec59d source3/torture/pdbtest: allocate talloc_stackframe()
   via  1f8b574 talloc_stack: abort in developer me if no stackframe on 
talloc_tos()
   via  fe72740 loadparm: make the source3/ lp_ functions take an explicit 
TALLOC_CTX *.
   via  c809eec source3/utils/net_conf.c: fix stackframe leak
   via  aa2e02e source3/winbindd/winbindd_pam.c: fix stackframe leak
   via  f3001e8 source3/lib/smbconf/testsuite.c: fix stackframe leak
   via  15faffc source3/registry/reg_backend_db.c: fix stackframe leak
   via  5716570 source3/winbindd/idmap_tdb_common.c: fix stackframe leak
   via  32c69e6 source3/rpc_server/svcctl/srv_svcctl_reg.c: fix stackframe 
leak
   via  bdc59fb source3/modules/vfs_xattr_tdb.c: fix stackframe leak
   via  a620fc0 lib/util/modules.c: fix stackframe leak.
   via  2314c60 source3/winbindd/winbindd_util.c: fix stackframe leak
   via  7a65910 nt_printing_tdb_migrate(): fix stackframe leak.
   via  dcec7c1 source3/client/client.c: fix stackframe leak.
   via  634a63d smbpasswd: always free frame.
   via  84fb37f talloc_stack: report lazy freeing (panic if DEVELOPER).
   via  f9b51ff talloc_stack: always include the location when creating a 
talloc_stackframe().
   via  311281c talloc_stack: handle more than one talloc_stackframe_pool()
   via  4f33187 talloc: don't allow a talloc_pool inside a talloc_pool.
   via  8893215 talloc: use a struct for pool headers.
  from  d1a5a5b s3-linux-aio: Fix error handling

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 127352c78c0328d59d742f0b4520ebaac6307854
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 18 15:07:28 2012 +0930

source4/torture: add talloc_stackframe()

We need a stackframe to call lp_load().

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Wed Jul 18 09:31:07 CEST 2012 on sn-devel-104

commit 06731bc28f5bff963f75451a0d7dd7445e94407c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 18 15:07:28 2012 +0930

source3/netapi: fix only caller which doesn't set up a talloc_stackframe()

libnetapi_free() needs a stackframe too; looked like Andrew and Günther
missed this in a37de9a95974c138d264d9cb0c7829bb426bb2d6.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit d54ebd36cc95ae13844bd00d5bbb2e3ff1a06285
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 18 15:07:28 2012 +0930

source3/passdb/py_passdb.c: wrap all calls in talloc_stackframe()

dbwrap needs it.  Some calls were already wrapped, but they checked the
talloc_stackframe() return unnecessarily: it can never be NULL.

This is the coccinelle patch I used:

// Add in a stackframe to every function: be sure to free it on (every) 
return
@rule0@
identifier func;
@@
func(...) {
+TALLOC_CTX *frame = talloc_stackframe();
...
+talloc_free(frame);
return ...;
...
}

// Get rid of tframe allocation/frees, replace usage with frame.
@rule1@
identifier func;
identifier oldframe;
@@
func(...) {
...
-TALLOC_CTX *oldframe;
...
-if ((oldframe = talloc_stackframe()) == NULL) {
-   ...
-}
...
-talloc_free(oldframe);
...
}

// Get rid of tframe (variant 2)
@rule2@
identifier func;
identifier oldframe;
@@
func(...) {
...
-TALLOC_CTX *oldframe;
...
-oldframe = talloc_stackframe();
-if (oldframe == NULL) {
-   ...
-}
...
-talloc_free(oldframe);
...
}

// Change tframe to frame
@rule3@
identifier func;
@@
func(...) {
...
-tframe
+frame
...
}

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 99272331c60afa900852d996196b434ecd897287
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 18 15:07:28 2012 +0930

source3/passdb/py_passdb.c: don't steal from talloc_stackframe().

If you want a stack-style allocation, use talloc_stackframe().  If you
don't, don't use it.  In particular, talloc_stackframe() here is actually
inside a pool, and stealing from pools is a bad idea.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 51ec59db10306fd90211c237fd672acf3ab3304a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 18 15:07:28 2012 +0930

source3/torture/pdbtest

[SCM] Samba Shared Repository - branch master updated

2012-07-04 Thread Rusty Russell
The branch, master has been updated
   via  74bf0c6 ntdb: make --disable-ntdb work properly.
  from  6449022 Add waf/configure tests for openat.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 74bf0c6ec63955156f7acf673e2c5846bb8b212a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 4 13:51:07 2012 +0930

ntdb: make --disable-ntdb work properly.

As per bug #9024, make --disable-ntdb work again.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Wed Jul  4 08:11:33 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/dbwrap/dbwrap_local_open.c |2 ++
 lib/util/wscript_build |   13 +++--
 wscript|2 ++
 3 files changed, 11 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/dbwrap/dbwrap_local_open.c b/lib/dbwrap/dbwrap_local_open.c
index bb0df48..fb5f17e 100644
--- a/lib/dbwrap/dbwrap_local_open.c
+++ b/lib/dbwrap/dbwrap_local_open.c
@@ -22,7 +22,9 @@
 #include dbwrap/dbwrap.h
 #include dbwrap/dbwrap_tdb.h
 #include tdb.h
+#ifndef DISABLE_NTDB
 #include lib/util/util_ntdb.h
+#endif
 #include lib/param/param.h
 #include system/filesys.h
 #include ccan/str/str.h
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index e601ecd..340cf12 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -45,12 +45,13 @@ bld.SAMBA_LIBRARY('util_tdb',
private_library=True
)
 
-bld.SAMBA_LIBRARY('util_ntdb',
-   source='util_ntdb.c',
-   local_include=False,
-   public_deps='ntdb talloc samba-util samba-hostconfig',
-   private_library=True
-   )
+if not bld.env.disable_ntdb:
+bld.SAMBA_LIBRARY('util_ntdb',
+   source='util_ntdb.c',
+   local_include=False,
+   public_deps='ntdb talloc samba-util samba-hostconfig',
+   private_library=True
+   )
 
 bld.SAMBA_LIBRARY('tevent-util',
source='tevent_unix.c tevent_ntstatus.c tevent_werror.c',
diff --git a/wscript b/wscript
index 1238eb6..727374d 100755
--- a/wscript
+++ b/wscript
@@ -132,6 +132,8 @@ def configure(conf):
 conf.env.disable_ntdb = getattr(Options.options, 'disable_ntdb', False)
 if not Options.options.disable_ntdb:
 conf.RECURSE('lib/ntdb')
+else:
+conf.DEFINE('DISABLE_NTDB', 1)
 conf.RECURSE('lib/zlib')
 conf.RECURSE('lib/util/charset')
 conf.RECURSE('source4/auth')


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-06-30 Thread Rusty Russell
The branch, master has been updated
   via  8150f69 ccan: make it a grouping library.
  from  5679ba1 Don't allow asynchronous creates to be canceled in SMB2.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 8150f69dc4cf73adb6f7aebd6f06074502dfcd05
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Jun 30 17:05:38 2012 +0930

ccan: make it a grouping library.

Andrew Bartlett pointed out that making CCAN a non-library will break
the build in a different way in future: when two separate private
libraries start using the same CCAN module, the symbol duplicate
detection will fire (since private libaries don't use any symbol
hiding).  That doesn't happen yet, but it will surely happen
eventually.

So, for now at least, we build as a private library again.  This
unfortunately means the top-level build creates a libccan.so, which
contains all the ccan modules whether you need them or not.  Given the
size of the library, I don't think this is a win.  But it's simple.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Sat Jun 30 11:19:04 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/ccan/wscript |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index c9bb49b..be5eab2 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -125,8 +125,11 @@ def ccan_module(bld, name, deps=''):
 bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
 source=bld.path.ant_glob('%s/*.c' % name),
 deps=deps)
+bld.env.CCAN_MODS += 'ccan-%s ' % name
 
 def build(bld):
+bld.env.CCAN_MODS = 
+
 # These have actual C files.
 ccan_module(bld, 'hash', 'ccan-build_assert')
 ccan_module(bld, 'ilog', 'ccan-compiler');
@@ -159,3 +162,10 @@ def build(bld):
 ccan-err ccan-hash ccan-htable ccan-list
 ccan-read_write_all ccan-str ccan-time execinfo
 ''')
+
+# This is the complete CCAN collection as one group.
+bld.SAMBA_LIBRARY('ccan',
+  source='',
+  deps=bld.env.CCAN_MODS,
+  private_library=True,
+  grouping_library=True)


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-06-28 Thread Rusty Russell
The branch, master has been updated
   via  f3862b9 ccan: we're subsystems, not a library.
  from  485787f Move back to using per-thread credentials on Linux. Fixes 
the glibc native AIO lost wakeup problem.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit f3862b917168ade88a048cdee688986b0479fe37
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 29 12:09:06 2012 +0930

ccan: we're subsystems, not a library.

Don't expose a libccan.so; it would produce clashes if someone else
does the same thing.  Unfortunately, if we just change it from a
SAMBA_LIBRARY to a SAMBA_SUBSYSTEM, it doesn't create a static library
as we'd like, but links all the object files in.  This means we get
many duplicates (eg. everyone gets a copy of tally, even though only
ntdb wants it).

So, the solution is twofold:
1) Make the ccan modules separate.
2) Make the ccan modules SAMBA_SUBSYSTEMs not SAMBA_LIBRARYs so we don't
   build shared libraries which we can't share.
3) Make the places which uses ccan explicit.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Fri Jun 29 06:22:44 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/ccan/wscript   |   43 +++
 lib/ldb/wscript|5 +
 lib/ntdb/wscript   |   11 ++-
 lib/tdb_compat/wscript |4 +---
 source3/wscript_build  |5 ++---
 5 files changed, 41 insertions(+), 27 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index c1dae41..565a657 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -121,19 +121,38 @@ def configure(conf):
 # backtrace could be in libexecinfo or in libc
 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', 
checklibc=True, headers='execinfo.h')
 
+def ccan_module(bld, name, deps=''):
+bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
+source=bld.path.ant_glob('%s/*.c' % name),
+deps=deps)
+
 def build(bld):
+# These have actual C files.
+ccan_module(bld, 'hash', 'ccan-build_assert')
+ccan_module(bld, 'ilog', 'ccan-compiler');
+ccan_module(bld, 'read_write_all')
+ccan_module(bld, 'str', 'ccan-build_assert')
+ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
 
-for ccan_dir in [err, hash, htable, ilog, likely, list, 
read_write_all, str, tally, time]:
-bld.SAMBA_SUBSYSTEM('ccan-%s' % ccan_dir,
-source=bld.path.ant_glob('%s/*.c' % ccan_dir))
+# These are headers only.
+ccan_module(bld, 'array_size', 'ccan-build_assert')
+ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
+ccan_module(bld, 'build_assert')
+ccan_module(bld, 'cast', 'ccan-build_assert')
+ccan_module(bld, 'check_type', 'ccan-build_assert')
+ccan_module(bld, 'compiler')
+ccan_module(bld, 'endian')
+ccan_module(bld, 'likely', 'ccan-str')
+ccan_module(bld, 'typesafe_cb')
 
+# Failtest pulls in a lot of stuff, and it's only for unit tests.
 if bld.env.DEVELOPER_MODE:
-bld.SAMBA_LIBRARY('ccan-failtest',
-  source=bld.path.ant_glob('failtest/*.c'),
-  deps='execinfo ccan ccan-htable ccan-list 
ccan-read_write_all ccan-time',
-  private_library=True)
-
-bld.SAMBA_LIBRARY('ccan',
-  source='',
-  deps='ccan-err ccan-hash ccan-ilog ccan-likely 
ccan-tally',
-  private_library=True)
+ccan_module(bld, 'container_of', 'ccan-check_type')
+ccan_module(bld, 'err', 'ccan-compiler')
+ccan_module(bld, 'htable', 'ccan-compiler')
+ccan_module(bld, 'list', 'ccan-container_of')
+ccan_module(bld, 'time')
+ccan_module(bld, 'tcon')
+ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
+ccan_module(bld, 'failtest',
+ccan-err ccan-hash ccan-htable ccan-list 
ccan-read_write_all ccan-str ccan-time)
diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 94a9682..6cdddb3 100755
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -16,7 +16,7 @@ sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 import wafsamba, samba_dist, Options
 
 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
-lib/tdb:lib/tdb lib/tdb2:lib/tdb2 lib/tdb:lib/tdb 
lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
+lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent 
lib/popt:lib/popt
 buildtools:buildtools''')
 
 
@@ -39,9 +39,6 @@ def configure(conf):
 conf.check_python_version

[SCM] Samba Shared Repository - branch master updated

2012-06-27 Thread Rusty Russell
The branch, master has been updated
   via  f80e399 source4/smbd/pidfile: don't panic if pid file is corrupt.
  from  0a1aaca replace: define INT64_MAX when not defined

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit f80e399ab26ea23ba258f885cec7c6c28c62baaa
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Jun 28 11:04:25 2012 +0930

source4/smbd/pidfile: don't panic if pid file is corrupt.

In particular, on a virtual machine after a forced reboot, it
contained Ille instead of a valid PID.  Given it was the right
length, I'm assuming it was filesystem corruption.

process_exists_by_pid() then panics, when given a pid  1.

Reported-by: lostogre on #samba-technical
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Thu Jun 28 05:19:24 CEST 2012 on sn-devel-104

---

Summary of changes:
 source4/smbd/pidfile.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/smbd/pidfile.c b/source4/smbd/pidfile.c
index b7d1c27..32d3964 100644
--- a/source4/smbd/pidfile.c
+++ b/source4/smbd/pidfile.c
@@ -57,6 +57,9 @@ pid_t pidfile_pid(const char *piddir, const char *name)
}
 
ret = (pid_t)atoi(pidstr);
+   if (ret = 0) {
+   goto noproc;
+   }

if (!process_exists_by_pid(ret)) {
goto noproc;


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-06-26 Thread Rusty Russell
The branch, master has been updated
   via  66f59f0 tdb: finish weaning off err.h.
  from  d1aeb2d s3:test_net_registry_check: eliminate local keyword in 
shell

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 66f59f040984bef5023fc844097b85bebee88f09
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Jun 26 15:18:52 2012 +0930

tdb: finish weaning off err.h.

Commit 3c4263e7580143c69225729f5b67f09c00add2fd said it removed err.h
from tdb, unfortuntely it didn't: tap-interface.h still included it.

This finishes it properly!

Reported-by:Stefan Metzmacher me...@samba.org
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Tue Jun 26 10:22:03 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/tdb/test/external-agent.c  |   12 
 lib/tdb/test/run-corrupt.c |   12 
 lib/tdb/test/run-die-during-transaction.c  |   16 ++--
 lib/tdb/test/run-nested-traverse.c |2 --
 lib/tdb/test/run-open-during-transaction.c |2 --
 lib/tdb/test/run-traverse-in-transaction.c |2 --
 lib/tdb/test/tap-interface.h   |5 ++---
 7 files changed, 28 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/test/external-agent.c b/lib/tdb/test/external-agent.c
index 139de76..8140e70 100644
--- a/lib/tdb/test/external-agent.c
+++ b/lib/tdb/test/external-agent.c
@@ -108,12 +108,16 @@ struct agent *prepare_external_agent(void)
int command[2], response[2];
char name[1+PATH_MAX];
 
-   if (pipe(command) != 0 || pipe(response) != 0)
-   return NULL;
+   if (pipe(command) != 0 || pipe(response) != 0) {
+   fprintf(stderr, pipe failed: %s\n, strerror(errno));
+   exit(1);
+   }
 
pid = fork();
-   if (pid  0)
-   return NULL;
+   if (pid  0) {
+   fprintf(stderr, fork failed: %s\n, strerror(errno));
+   exit(1);
+   }
 
if (pid != 0) {
struct agent *agent = malloc(sizeof(*agent));
diff --git a/lib/tdb/test/run-corrupt.c b/lib/tdb/test/run-corrupt.c
index 584f789..1a3c769 100644
--- a/lib/tdb/test/run-corrupt.c
+++ b/lib/tdb/test/run-corrupt.c
@@ -41,11 +41,15 @@ static void tdb_flip_bit(struct tdb_context *tdb, unsigned 
int bit)
((unsigned char *)tdb-map_ptr)[off] ^= mask;
else {
unsigned char c;
-   if (pread(tdb-fd, c, 1, off) != 1)
-   err(1, pread);
+   if (pread(tdb-fd, c, 1, off) != 1) {
+   fprintf(stderr, pread: %s\n, strerror(errno));
+   exit(1);
+   }
c ^= mask;
-   if (pwrite(tdb-fd, c, 1, off) != 1)
-   err(1, pwrite);
+   if (pwrite(tdb-fd, c, 1, off) != 1) {
+   fprintf(stderr, pwrite: %s\n, strerror(errno));
+   exit(1);
+   }
}
 }
 
diff --git a/lib/tdb/test/run-die-during-transaction.c 
b/lib/tdb/test/run-die-during-transaction.c
index 19c9dbe..6e3a70d 100644
--- a/lib/tdb/test/run-die-during-transaction.c
+++ b/lib/tdb/test/run-die-during-transaction.c
@@ -164,12 +164,18 @@ reset:
key.dsize--;
 
ret = external_agent_operation(agent, OPEN, TEST_DBNAME);
-   if (ret != SUCCESS)
-   errx(1, Agent failed to open: %s, agent_return_name(ret));
+   if (ret != SUCCESS) {
+   fprintf(stderr, Agent failed to open: %s\n,
+   agent_return_name(ret));
+   exit(1);
+   }
 
ret = external_agent_operation(agent, FETCH, KEY_STRING);
-   if (ret != SUCCESS)
-   errx(1, Agent failed find key: %s, agent_return_name(ret));
+   if (ret != SUCCESS) {
+   fprintf(stderr, Agent failed find key: %s\n,
+   agent_return_name(ret));
+   exit(1);
+   }
 
in_transaction = true;
if (tdb_transaction_start(tdb) != 0)
@@ -215,8 +221,6 @@ int main(int argc, char *argv[])
unlock_callback = maybe_die;
 
agent = prepare_external_agent();
-   if (!agent)
-   err(1, preparing agent);
 
for (i = 0; i  sizeof(ops)/sizeof(ops[0]); i++) {
diag(Testing %s after death, operation_name(ops[i]));
diff --git a/lib/tdb/test/run-nested-traverse.c 
b/lib/tdb/test/run-nested-traverse.c
index 86f2913..37d57c0 100644
--- a/lib/tdb/test/run-nested-traverse.c
+++ b/lib/tdb/test/run-nested-traverse.c
@@ -62,8 +62,6 @@ int main(int argc, char *argv[])
 
plan_tests(17);
agent = prepare_external_agent();
-   if (!agent

[SCM] Samba Shared Repository - branch master updated

2012-06-22 Thread Rusty Russell
The branch, master has been updated
   via  3c4263e tdb: don't use err.h in tests.
   via  1783fe3 tdb: make TDB_NOSYNC merely disable sync.
   via  945473a dbwrap: dbwrap_hash_size().
   via  e92cb55 dbwrap: dbwrap_name().
   via  41f799d dbwrap: dbwrap_transaction_start_nonblock().
   via  f6eb187 dbwrap: dbwrap_fetch_locked_timeout().
   via  431667b dbwrap: add dbwrap_check() function.
   via  9d97bf3 dbwrap: dbwrap_local_open()
   via  1acf548 dbwrap: remove get_flags().
   via  fc9b298 util_tdb: move timeout chainlock variants from 
source3/lib/util/util_tdb.c
   via  02bacf1 util: util_ntdb ntdb_fetch_int32/ntdb_store_int32 and 
ntdb_add_int32_atomic
   via  348159d util: util_ntdb.c gets NTDB_ERROR = NTSTATUS map.
   via  88ad365 util: util_ntdb.c gains bystring functions.
   via  8113d53 util: ntdb_new() supports NTDB_CLEAR_IF_FIRST.
   via  735290f util: util_ntdb.c
   via  7c1d9fb ntdb: take advantage of direct access across expand.
   via  4c51ee1 ntdb: test arbitrary operations during ntdb_parse_record().
   via  01ec4a7 ntdb: make database read-only during ntdb_parse() callback.
   via  bd5c061 ntdb: allow direct access for NTDB_INTERNAL dbs during 
expansion.
   via  0a34f34 ntdb: enhancement to allow direct access to the ntdb map 
during expansion.
   via  66d151d ntdb: don't munmap the database on every close.
   via  406bd2d ntdb: hand correct error code when alloc_read allocation 
fails.
   via  f7f6992c autobuild: always set TDB_NO_FSYNC.
   via  0265837 ntdb: respect TDB_NO_FSYNC flag for 'make test'
  from  0c54e7c s4:torture/smb2: add smb2.durable-open.lock-oplock

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 3c4263e7580143c69225729f5b67f09c00add2fd
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

tdb: don't use err.h in tests.

It's not portable.  While we could use ccan/err, it seems overkill since
we actually only use it in one test (I obviously cut  paste the #include).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Fri Jun 22 09:22:28 CEST 2012 on sn-devel-104

commit 1783fe34433f9bb4b939de3231a7c296390ec426
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

tdb: make TDB_NOSYNC merely disable sync.

(As suggested by Stefan Metzmacher, based on the change to ntdb.)

Since commit ec96ea690edbe3398d690b4a953d487ca1773f1c, we handle the case
where a process dies during a transaction commit.  Unfortunately, TDB_NOSYNC
means this no longer works, as it disables the recovery area as well as the
actual msync/fsync.  We should do everything except the syncs.

This also means we can do a complete test with $TDB_NO_FSYNC set; just
to get more complete coverage, we disable it explicitly for one test
(where we override the actual sync calls anyway).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 945473aac0abffd8509bbeef3ed5a32737b7df51
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

dbwrap: dbwrap_hash_size().

Implemented for ntdb and tdb; falls back to 0 for others.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit e92cb556fdb5faee71f614475aaade846dcd0aed
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

dbwrap: dbwrap_name().

Useful for debug messages: particularly once we start switching between .tdb
and .ntdb files.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 41f799d877961d095401a628307e0c690dfbc124
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

dbwrap: dbwrap_transaction_start_nonblock().

Implemented for ntdb and tdb; falls back to the blocking variant
for others.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit f6eb187fdab6b8088bb065e418fe604c4eba7751
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:44 2012 +0930

dbwrap: dbwrap_fetch_locked_timeout().

Implemented for ntdb and tdb; falls back to the non-timeout variant
for others.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 431667b47c0eac3069ba1e643996619ab61975e5
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:43 2012 +0930

dbwrap: add dbwrap_check() function.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 9d97bf3f47a591a71e96cad8a87ef13a2b277c9c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 22 15:07:43 2012 +0930

dbwrap: dbwrap_local_open()

This simply opens a tdb: it will eventually switch depending on the
extension.

Signed

[SCM] Samba Shared Repository - branch master updated

2012-06-20 Thread Rusty Russell
The branch, master has been updated
   via  5ec4305 ntdb: fix occasional abort in testing.
  from  ab96359 script/autobuild: delay start of small projects by 60 to 
600 seconds

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 5ec43055103f8890e957a163f094431fcdbcbd74
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 20 21:31:21 2012 +0930

ntdb: fix occasional abort in testing.

Occasionally, the capability test inserts multiple used records and they
clash, but our primitive test layout engine doesn't handle hash clashes
and aborts.

Force a seed value which we know doesn't clash.

Reported-by: Andrew Bartlett abart...@samba.org
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Wed Jun 20 16:50:20 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/ntdb/test/run-capabilities.c |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ntdb/test/run-capabilities.c b/lib/ntdb/test/run-capabilities.c
index cb03746..6503214 100644
--- a/lib/ntdb/test/run-capabilities.c
+++ b/lib/ntdb/test/run-capabilities.c
@@ -30,6 +30,12 @@ static void create_ntdb(const char *name,
struct ntdb_layout *layout;
struct ntdb_context *ntdb;
int fd, clen;
+   union ntdb_attribute seed_attr;
+
+   /* Force a seed which doesn't allow records to clash! */
+   seed_attr.base.attr = NTDB_ATTRIBUTE_SEED;
+   seed_attr.base.next = tap_log_attr;
+   seed_attr.seed.seed = 0;
 
key = ntdb_mkdata(Hello, 5);
data = ntdb_mkdata(world, 5);
@@ -61,7 +67,7 @@ static void create_ntdb(const char *name,
va_end(ap);
 
/* We open-code this, because we need to use the failtest write. */
-   ntdb = ntdb_layout_get(layout, failtest_free, tap_log_attr);
+   ntdb = ntdb_layout_get(layout, failtest_free, seed_attr);
 
fd = open(name, O_RDWR|O_TRUNC|O_CREAT, 0600);
if (fd  0)


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-06-09 Thread Rusty Russell
The branch, master has been updated
   via  36353a9 tdb2: use ccan/err instead of err.h
   via  aeb3ff5 ccan: make failtest use ccan/err.
   via  d9ce876 ccan: import err module.from ccan revision 
5add556a1cb64b49a664506aa76216d885b22c97
  from  8a338c6 s3:smbd: change set_file_oplock() to return NTSTATUS

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 36353a9fc359e8156cfd2e7e4288021aba789b74
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Jun 9 16:18:57 2012 +0930

tdb2: use ccan/err instead of err.h

Solaris has no err.h, so use CCAN replacement.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Sat Jun  9 12:07:15 CEST 2012 on sn-devel-104

commit aeb3ff5c8667328f7f837412e9ec4365e3853cce
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Jun 9 15:41:23 2012 +0930

ccan: make failtest use ccan/err.

As per CCAN commit 48b700953f9c856102e91596103238f5da9ea079.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit d9ce876ea97d59d66c8d2892b43b7cc8392470a0
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Jun 9 15:37:20 2012 +0930

ccan: import err module.from ccan revision 
5add556a1cb64b49a664506aa76216d885b22c97

This allows us to avoid err.h in failtest.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/err/.depends|1 +
 lib/ccan/err/_info   |   41 ++
 lib/ccan/err/err.c   |   64 +
 lib/ccan/err/err.h   |   87 
 lib/ccan/err/test/run.c  |  153 ++
 lib/ccan/failtest/_info  |1 +
 lib/ccan/failtest/failtest.c |2 +-
 lib/ccan/wscript |6 +-
 lib/tdb2/_info   |2 +-
 lib/tdb2/test/api-83-openhook.c  |1 -
 lib/tdb2/test/external-agent.c   |2 +-
 lib/tdb2/test/helprun-layout.c   |2 +-
 lib/tdb2/test/run-30-exhaust-before-expand.c |1 -
 lib/tdb2/test/run-56-open-during-transaction.c   |1 -
 lib/tdb2/test/run-57-die-during-transaction.c|1 -
 lib/tdb2/test/run-capabilities.c |1 -
 lib/tdb2/test/run-lockall.c  |2 +-
 lib/tdb2/test/run-tdb1-3G-file.c |1 -
 lib/tdb2/test/run-tdb1-bad-tdb-header.c  |1 -
 lib/tdb2/test/run-tdb1-check.c   |1 -
 lib/tdb2/test/run-tdb1-corrupt.c |1 -
 lib/tdb2/test/run-tdb1-endian.c  |1 -
 lib/tdb2/test/run-tdb1-hashsize.c|1 -
 lib/tdb2/test/run-tdb1-incompatible.c|1 -
 lib/tdb2/test/run-tdb1-nested-transactions.c |1 -
 lib/tdb2/test/run-tdb1-nested-traverse.c |1 -
 lib/tdb2/test/run-tdb1-no-lock-during-traverse.c |1 -
 lib/tdb2/test/run-tdb1-oldhash.c |1 -
 lib/tdb2/test/run-tdb1-readonly-check.c  |1 -
 lib/tdb2/test/run-tdb1-rwlock-check.c|1 -
 lib/tdb2/test/run-tdb1-seqnum-wrap.c |1 -
 lib/tdb2/test/run-tdb1-summary.c |1 -
 lib/tdb2/test/run-tdb1-traverse-in-transaction.c |1 -
 lib/tdb2/test/run-tdb1-wronghash-fail.c  |1 -
 lib/tdb2/test/run-tdb1-zero-append.c |1 -
 lib/tdb2/test/run-tdb1.c |1 -
 lib/tdb2/test/tap-interface.h|2 +-
 lib/tdb2/test/tdb1-external-agent.c  |1 -
 lib/tdb2/tools/growtdb-bench.c   |2 +-
 lib/tdb2/tools/mktdb2.c  |2 +-
 lib/tdb2/tools/speed.c   |2 +-
 lib/tdb2/tools/tdb2torture.c |2 +-
 42 files changed, 360 insertions(+), 38 deletions(-)
 create mode 100644 lib/ccan/err/.depends
 create mode 100644 lib/ccan/err/_info
 create mode 100644 lib/ccan/err/err.c
 create mode 100644 lib/ccan/err/err.h
 create mode 100644 lib/ccan/err/test/run.c


Changeset truncated at 500 lines:

diff --git a/lib/ccan/err/.depends b/lib/ccan/err/.depends
new file mode 100644
index 000..ee4f1e4
--- /dev/null
+++ b/lib/ccan/err/.depends
@@ -0,0 +1 @@
+ccan/compiler
diff --git a/lib/ccan/err/_info b/lib/ccan/err/_info
new file mode 100644
index 000..97bc0f9
--- /dev/null
+++ b/lib/ccan/err/_info
@@ -0,0 +1,41 @@
+#include stdio.h
+#include string.h
+#include config.h
+
+/**
+ * err - err(), errx(), warn() and warnx(), as per BSD's err.h.
+ *
+ * A few platforms don't provide err.h; for those, this provides replacements.
+ * For most

[SCM] Samba Shared Repository - branch master updated

2012-06-08 Thread Rusty Russell
The branch, master has been updated
   via  03767f5 samba_util: mark smb_panic as _NORETURN_.
  from  0ea7152 s3-winbindd: call dump_core_setup after command line option 
has been parsed

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 03767f5f5ac0293ef61d960ad980636898bd64ba
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Jun 8 08:08:00 2012 +0930

samba_util: mark smb_panic as _NORETURN_.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Fri Jun  8 09:14:26 CEST 2012 on sn-devel-104

---

Summary of changes:
 lib/util/samba_util.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index f4ffe64..274dde8 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -76,7 +76,7 @@ _PUBLIC_ void fault_configure(smb_panic_handler_t 
panic_handler);
 _PUBLIC_ void fault_setup(void);
 _PUBLIC_ void fault_setup_disable(void);
 _PUBLIC_ void dump_core_setup(const char *progname, const char *logfile);
-_PUBLIC_ void smb_panic(const char *reason);
+_PUBLIC_ _NORETURN_ void smb_panic(const char *reason);
 
 
 /**


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-06-07 Thread Rusty Russell
The branch, master has been updated
   via  35a2d02 ccan: Only build ccan-failtest when we are in developer mode
   via  4c9126d lib/tdb2: build tests when built at toplevel.
  from  e102350 waf: fix parsing krb5-config --version for MIT krb5

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 35a2d020a0c3b0ba638874bc0cdbd215c76bf606
Author: Andrew Bartlett abart...@samba.org
Date:   Thu Jun 7 22:37:52 2012 +0930

ccan: Only build ccan-failtest when we are in developer mode

From: Andrew Bartlett abart...@samba.org

This code is incredibly useful, but is only needed in test code and may not 
be
perfectly portable.  It has compiled on all systems bar Solaris so far, but
rather than make it a requirement to build Samba, just keep it for 
development.

Andrew Bartlett

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User(master): Rusty Russell ru...@rustcorp.com.au
Autobuild-Date(master): Thu Jun  7 18:53:12 CEST 2012 on sn-devel-104

commit 4c9126daa98cd35a416f435e088943d94823e550
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Jun 7 22:24:07 2012 +0930

lib/tdb2: build tests when built at toplevel.

They weren't being built when we were at top-level, because the globs
were wrong.  Just open-code the test names, which always works.

Reported-by: Andrew Bartlett
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/wscript |   18 +-
 lib/tdb2/wscript |  161 --
 2 files changed, 134 insertions(+), 45 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 24034bb..8a2b3e7 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import Logs, sys
+import Logs, sys, Options
 
 def configure(conf):
 conf.DEFINE('HAVE_CCAN', 1)
@@ -121,8 +121,18 @@ def configure(conf):
 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', 
checklibc=True, headers='execinfo.h')
 
 def build(bld):
+
+for ccan_dir in [hash, htable, ilog, likely, list, 
read_write_all, str, tally, time]:
+bld.SAMBA_SUBSYSTEM('ccan-%s' % ccan_dir,
+source=bld.path.ant_glob('%s/*.c' % ccan_dir))
+
+if bld.env.DEVELOPER_MODE:
+bld.SAMBA_LIBRARY('ccan-failtest',
+  source=bld.path.ant_glob('failtest/*.c'),
+  deps='execinfo ccan ccan-failtest ccan-htable 
ccan-list ccan-read_write_all ccan-time',
+  private_library=True)
+
 bld.SAMBA_LIBRARY('ccan',
-  vnum=0.1-init-1161-g661d41f,
-  source=bld.path.ant_glob('*/*.c'),
-  deps='execinfo',
+  source='',
+  deps='ccan-hash ccan-ilog ccan-likely ccan-tally',
   private_library=True)
diff --git a/lib/tdb2/wscript b/lib/tdb2/wscript
index 63d27fe..b925893 100644
--- a/lib/tdb2/wscript
+++ b/lib/tdb2/wscript
@@ -21,6 +21,9 @@ def set_options(opt):
 opt.BUILTIN_DEFAULT('replace,ccan')
 opt.PRIVATE_EXTENSION_DEFAULT('tdb2', noextension='tdb2')
 opt.RECURSE('lib/replace')
+opt.add_option('--enable-developer',
+   help=(Turn on developer warnings and debugging),
+   action=store_true, dest='developer', default=False)
 opt.add_option('--enable-tdb2',
help=(Use tdb2 API instead of tdb1 [True]),
action=store_true, dest='BUILD_TDB2', default=True)
@@ -39,6 +42,92 @@ def set_options(opt):
action=store_true, dest='disable_python', 
default=False)
 
 def configure(conf):
+if Options.options.developer:
+conf.env.DEVELOPER_MODE = True
+
+conf.env.TEST_RUN_SRC=['test/run-001-encode.c',
+   'test/run-001-fls.c',
+   'test/run-01-new_database.c',
+   'test/run-02-expand.c',
+   'test/run-03-coalesce.c',
+   'test/run-04-basichash.c',
+   'test/run-05-readonly-open.c',
+   'test/run-10-simple-store.c',
+   'test/run-11-simple-fetch.c',
+   'test/run-12-check.c',
+   'test/run-15-append.c',
+   'test/run-20-growhash.c',
+   'test/run-25-hashoverload.c',
+   'test/run-30-exhaust-before-expand.c',
+   'test/run-35-convert.c',
+   'test/run-50-multiple-freelists.c',
+   'test/run-56-open-during-transaction.c

[SCM] Samba Shared Repository - branch master updated

2012-03-29 Thread Rusty Russell
The branch, master has been updated
   via  f74ae32 cast: make sure suncc sees a constant.
   via  be25ab9 cast: test/compile_fail-cast_static.c should fail without 
COMPOUND_LITERALS.
   via  3acce70 tdb2: fix prototype in tdb1 code.
  from  e36622f s4-upgradedns: Make sure the attribute exists before 
accessing it

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit f74ae3257a2edb9756d9f0442c1314306e936759
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 29 14:58:33 2012 +1030

cast: make sure suncc sees a constant.

cast_const() et. al. are supposed to be a constant expression, so you can 
do things like:
static char *p = cast_const(char *, (const char *)hello);

Unfortunately, a cast to intptr_t and arithmetic makes suncc reject it as
a constant expression.  We need the cast, because (1) the expression could 
be
a void *, so we can't just add to it, and (2) gcc complains with -Wcast-qual
without it.

So instead of adding BUILD_BUG_OR_ZERO, we use a ? :, which keeps everyone 
happy.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 74859ab18b10aaf990848e49d7789ff5c6cf96c6)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Mar 29 08:18:57 CEST 2012 on sn-devel-104

commit be25ab9c8df2f96ee10929fdfee582935b2f0e06
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Mar 27 15:40:45 2012 +1030

cast: test/compile_fail-cast_static.c should fail without COMPOUND_LITERALS.

It still gave a warning on gcc, because casting a char to a char* gives a 
warning.  Not so on sun CC.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 6569a707d169a629e25e10710c760c8dc84525c7)

commit 3acce707a32a28c309133583b8cd1a554f19a8b3
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Mar 26 14:33:17 2012 +1030

tdb2: fix prototype in tdb1 code.

We were handing an int-returning function where we should hand an enum 
TDB_ERROR
returning function.  Worse, it was returning 0/-1 instead of 0/TDB_ERR_*.

Fortunately, it's only compared against success, but the Solaris compiler
warns about it, and it's not correct anyway.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/cast/cast.h  |   20 
 lib/ccan/cast/test/compile_fail-cast_static.c |   12 +---
 lib/ccan/cast/test/compile_ok-static.c|   10 ++
 lib/tdb2/tdb1_tdb.c   |   10 +-
 4 files changed, 36 insertions(+), 16 deletions(-)
 create mode 100644 lib/ccan/cast/test/compile_ok-static.c


Changeset truncated at 500 lines:

diff --git a/lib/ccan/cast/cast.h b/lib/ccan/cast/cast.h
index b108b0c..1f3a7aa 100644
--- a/lib/ccan/cast/cast.h
+++ b/lib/ccan/cast/cast.h
@@ -15,8 +15,8 @@
  * only differs in signed/unsigned, not in type or const-ness.
  */
 #define cast_signed(type, expr)
\
-   ((type)(expr)   \
-+ BUILD_ASSERT_OR_ZERO(cast_sign_compatible(type, (expr
+   (0 ? BUILD_ASSERT_OR_ZERO(cast_sign_compatible(type, (expr))) : \
+(type)(expr))
 
 /**
  * cast_const - remove a const qualifier from a pointer.
@@ -26,6 +26,10 @@
  * This ensures that you are only removing the const qualifier from an
  * expression.  The expression must otherwise match @type.
  *
+ * We cast via intptr_t to suppress gcc's -Wcast-qual (which SAMBA
+ * uses), and via the ? : so Sun CC doesn't complain about the result
+ * not being constant.
+ *
  * If @type is a pointer to a pointer, you must use cast_const2 (etc).
  *
  * Example:
@@ -40,8 +44,8 @@
  * }
  */
 #define cast_const(type, expr) \
-   ((type)((intptr_t)(expr)\
-   + BUILD_ASSERT_OR_ZERO(cast_const_compat1((expr), type
+(0 ? BUILD_ASSERT_OR_ZERO(cast_const_compat1((expr), type)) :   \
+ (type)(intptr_t)(expr))
 
 /**
  * cast_const2 - remove a const qualifier from a pointer to a pointer.
@@ -52,8 +56,8 @@
  * expression.  The expression must otherwise match @type.
  */
 #define cast_const2(type, expr)
\
-   ((type)((intptr_t)(expr)\
-   + BUILD_ASSERT_OR_ZERO(cast_const_compat2((expr), type
+(0 ? BUILD_ASSERT_OR_ZERO(cast_const_compat2((expr), type)) :   \
+(type)(intptr_t)(expr))
 
 /**
  * cast_const3 - remove a const from a pointer to a pointer to a pointer..
@@ -64,8 +68,8 @@
  * expression.  The expression must otherwise match @type.
  */
 #define

[SCM] Samba Shared Repository - branch master updated

2012-03-29 Thread Rusty Russell
The branch, master has been updated
   via  593e731 lib/tdb: Update ABI
   via  3fdeaa3 lib/tdb: Add/expose lock functions to support CTDB
  from  f74ae32 cast: make sure suncc sees a constant.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 593e731097bc6f2fd50034f5e3ddac017894e584
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Mar 27 09:44:59 2012 +1100

lib/tdb: Update ABI

Signed-off-by: Amitay Isaacs ami...@gmail.com

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Mar 29 13:12:46 CEST 2012 on sn-devel-104

commit 3fdeaa3992bb0599613e20d8e3248c478897531f
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Mar 27 09:44:33 2012 +1100

lib/tdb: Add/expose lock functions to support CTDB

This patch adds two lock functions used by CTDB to perform asynchronous
locking. These functions do not actually perform any fcntl operations,
but only increment internal counters.

 - tdb_transaction_write_lock_mark()
 - tdb_transaction_write_lock_unmark()

It also exposes two internal functions
 - tdb_lock_nonblock()
 - tdb_unlock()

These functions are NOT exposed in include/tdb.h to prevent any further
uses of these functions. If you ever need to use these functions, consider
using tdb2.

Signed-off-by: Amitay Isaacs ami...@gmail.com

---

Summary of changes:
 lib/tdb/ABI/{tdb-1.2.9.sigs = tdb-1.2.10.sigs} |4 
 lib/tdb/common/lock.c   |   18 --
 lib/tdb/wscript |2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)
 copy lib/tdb/ABI/{tdb-1.2.9.sigs = tdb-1.2.10.sigs} (93%)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/ABI/tdb-1.2.9.sigs b/lib/tdb/ABI/tdb-1.2.10.sigs
similarity index 93%
copy from lib/tdb/ABI/tdb-1.2.9.sigs
copy to lib/tdb/ABI/tdb-1.2.10.sigs
index 9e4149b..61f6c19 100644
--- a/lib/tdb/ABI/tdb-1.2.9.sigs
+++ b/lib/tdb/ABI/tdb-1.2.10.sigs
@@ -25,6 +25,7 @@ tdb_get_seqnum: int (struct tdb_context *)
 tdb_hash_size: int (struct tdb_context *)
 tdb_increment_seqnum_nonblock: void (struct tdb_context *)
 tdb_jenkins_hash: unsigned int (TDB_DATA *)
+tdb_lock_nonblock: int (struct tdb_context *, int, int)
 tdb_lockall: int (struct tdb_context *)
 tdb_lockall_mark: int (struct tdb_context *)
 tdb_lockall_nonblock: int (struct tdb_context *)
@@ -54,8 +55,11 @@ tdb_transaction_commit: int (struct tdb_context *)
 tdb_transaction_prepare_commit: int (struct tdb_context *)
 tdb_transaction_start: int (struct tdb_context *)
 tdb_transaction_start_nonblock: int (struct tdb_context *)
+tdb_transaction_write_lock_mark: int (struct tdb_context *)
+tdb_transaction_write_lock_unmark: int (struct tdb_context *)
 tdb_traverse: int (struct tdb_context *, tdb_traverse_func, void *)
 tdb_traverse_read: int (struct tdb_context *, tdb_traverse_func, void *)
+tdb_unlock: int (struct tdb_context *, int, int)
 tdb_unlockall: int (struct tdb_context *)
 tdb_unlockall_read: int (struct tdb_context *)
 tdb_validate_freelist: int (struct tdb_context *, int *)
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index c6a2485..88a52e9 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -380,7 +380,7 @@ int tdb_lock(struct tdb_context *tdb, int list, int ltype)
 }
 
 /* lock a list in the database. list -1 is the alloc list. non-blocking lock */
-int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype)
+_PUBLIC_ int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype)
 {
return tdb_lock_list(tdb, list, ltype, TDB_LOCK_NOWAIT);
 }
@@ -445,7 +445,7 @@ int tdb_nest_unlock(struct tdb_context *tdb, uint32_t 
offset, int ltype,
return ret;
 }
 
-int tdb_unlock(struct tdb_context *tdb, int list, int ltype)
+_PUBLIC_ int tdb_unlock(struct tdb_context *tdb, int list, int ltype)
 {
/* a global lock allows us to avoid per chain locks */
if (tdb-allrecord_lock.count 
@@ -859,3 +859,17 @@ void tdb_release_transaction_locks(struct tdb_context *tdb)
SAFE_FREE(tdb-lockrecs);
}
 }
+
+/* Following functions are added specifically to support CTDB. */
+
+/* Don't do actual fcntl locking, just mark tdb locked */
+_PUBLIC_ int tdb_transaction_write_lock_mark(struct tdb_context *tdb)
+{
+   return tdb_transaction_lock(tdb, F_WRLCK, TDB_LOCK_MARK_ONLY);
+}
+
+/* Don't do actual fcntl unlocking, just mark tdb unlocked */
+_PUBLIC_ int tdb_transaction_write_lock_unmark(struct tdb_context *tdb)
+{
+   return tdb_nest_unlock(tdb, TRANSACTION_LOCK, F_WRLCK, true);
+}
diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index 871c5c4..d475204 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'tdb'
-VERSION = '1.2.9'
+VERSION

[SCM] Samba Shared Repository - branch master updated

2012-03-22 Thread Rusty Russell
The branch, master has been updated
   via  4442c0b lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.
   via  c12970c lib/tdb: fix test/run-die-during-transaction when 
HAVE_INCOHERENT_MMAP.
   via  330e3e1 lib/tdb: fix missing return 0 code.
  from  8718c7b s3:vfs_gpfs: fix some compiler warnings

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4442c0b2c92e4b2e88661e1508c5f6547112
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Mar 23 10:45:18 2012 +1030

lib/tdb: fix transaction issue for HAVE_INCOHERENT_MMAP.

We unmap the tdb on expand, the remap.  But when we have INCOHERENT_MMAP
(ie. OpenBSD) and we're inside a transaction, doing the expand can mean
we need to read from the database to partially fill a transaction block.
This fails, because if mmap is incoherent we never allow accessing the
database via read/write.

The solution is not to unmap and remap until we've actually written the
padding at the end of the file.

Reported-by: Amitay Isaacs ami...@gmail.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Fri Mar 23 02:53:15 CET 2012 on sn-devel-104

commit c12970cc91cb4da8976801e194e29e33e02b340a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Mar 23 10:43:48 2012 +1030

lib/tdb: fix test/run-die-during-transaction when HAVE_INCOHERENT_MMAP.

Since we force mmap on, we don't intercept writes to the db, so we never
see it in an inconsistent state.  #ifdef over the check that we should have
recovered it at least once.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 330e3e1b91ecbf99af3b598b324f21b5eff933fd
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Mar 23 10:41:55 2012 +1030

lib/tdb: fix missing return 0 code.

fde694274e1e5a11d1473695e7ec7a97f95d39e4 made tdb_mmap return an int,
but didn't put the return 0 on the internal db case.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/io.c   |   23 +++
 lib/tdb/test/run-die-during-transaction.c |5 +
 2 files changed, 16 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 24c2d61..3131f4f 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -244,7 +244,7 @@ static bool should_mmap(const struct tdb_context *tdb)
 int tdb_mmap(struct tdb_context *tdb)
 {
if (tdb-flags  TDB_INTERNAL)
-   return;
+   return 0;
 
 #ifdef HAVE_MMAP
if (should_mmap(tdb)) {
@@ -381,37 +381,36 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 
size = tdb_expand_adjust(tdb-map_size, size, tdb-page_size);
 
-   if (!(tdb-flags  TDB_INTERNAL))
-   tdb_munmap(tdb);
-
/* expand the file itself */
if (!(tdb-flags  TDB_INTERNAL)) {
if (tdb-methods-tdb_expand_file(tdb, tdb-map_size, size) != 
0)
goto fail;
}
 
-   tdb-map_size += size;
+   /* form a new freelist record */
+   offset = tdb-map_size;
+   memset(rec,'\0',sizeof(rec));
+   rec.rec_len = size - sizeof(rec);
 
if (tdb-flags  TDB_INTERNAL) {
char *new_map_ptr = (char *)realloc(tdb-map_ptr,
-   tdb-map_size);
+   tdb-map_size + size);
if (!new_map_ptr) {
-   tdb-map_size -= size;
goto fail;
}
tdb-map_ptr = new_map_ptr;
+   tdb-map_size += size;
} else {
+   /* Explicitly remap: if we're in a transaction, this won't
+* happen automatically! */
+   tdb_munmap(tdb);
+   tdb-map_size += size;
if (tdb_mmap(tdb) != 0) {
goto fail;
}
}
 
-   /* form a new freelist record */
-   memset(rec,'\0',sizeof(rec));
-   rec.rec_len = size - sizeof(rec);
-
/* link it into the free list */
-   offset = tdb-map_size - size;
if (tdb_free(tdb, offset, rec) == -1)
goto fail;
 
diff --git a/lib/tdb/test/run-die-during-transaction.c 
b/lib/tdb/test/run-die-during-transaction.c
index d6502f4..ae7dafc 100644
--- a/lib/tdb/test/run-die-during-transaction.c
+++ b/lib/tdb/test/run-die-during-transaction.c
@@ -194,7 +194,12 @@ reset:
return false;
}
 
+#ifdef HAVE_INCOHERENT_MMAP
+   /* This means we always mmap, which makes this test a noop. */
+   ok1(1);
+#else
ok1(needed_recovery

[SCM] Samba Shared Repository - branch master updated

2012-03-21 Thread Rusty Russell
The branch, master has been updated
   via  4816ffa lib/tdb2: fix -Wcast-qual warnings.
   via  4ea9f8d lib/tdb2: fix -Wshadow warnings.
   via  a93e03d lib/tdb2: fix OpenBSD incoherent mmap (tdb2 version)
   via  aa53786 lib/tdb2: fix OpenBSD incoherent mmap (tdb1 version)
   via  fde6942 lib/tdb: fix OpenBSD incoherent mmap.
   via  584b996 lib/replace: test for incoherent mmap.
   via  b3a6ffd lib/ccan/failtest: compile fix for OpenBSD
   via  6755932 lib/ccan: namespacize ccan/list to avoid conflict with 
OpenIndiana's sys/list.h
   via  eafd837 lib/tdb: fix up run-die-during-transaction test cases on 
Solaris.
  from  4882a4c docs:man:vfs_gpfs: fix formatting of values for gpfs:syncio

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4816ffacb81d3234231730149c7b0629bb3646a4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:27 2012 +1030

lib/tdb2: fix -Wcast-qual warnings.

We use tdb_mkdata() to get rid of many of them from the tests, and
explicit cast_const() in a few places.

tlist_for_each() still causes a warning, but that needs to be fixed in
CCAN.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Mar 22 03:29:32 CET 2012 on sn-devel-104

commit 4ea9f8d4c0d08343910d85f44eebdd2d7bff6571
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:27 2012 +1030

lib/tdb2: fix -Wshadow warnings.

These warnings clutter things up, even though they're of marginal
utility.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit a93e03d27de573988263aa4e39e55e7edbe34069
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:27 2012 +1030

lib/tdb2: fix OpenBSD incoherent mmap (tdb2 version)

This handles incoherent mmaps for TDB2 native databases, by forcing
mmap on for such systems, just like we did for tdb1.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit aa5378602d8da099a435a6457245b13c2677
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:26 2012 +1030

lib/tdb2: fix OpenBSD incoherent mmap (tdb1 version)

This is a direct port of the previous patch, to the TDB2 codebase.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit fde694274e1e5a11d1473695e7ec7a97f95d39e4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:26 2012 +1030

lib/tdb: fix OpenBSD incoherent mmap.

This comment appears in two places in the code (commit
4c6a8273c6dd3e2aeda5a63c4a62aa55bc133099 from 2001):

/*
 * We must ensure the file is unmapped before doing this
 * to ensure consistency with systems like OpenBSD where
 * writes and mmaps are not consistent.
 */

But this doesn't help, because if one process is using mmap and another
using pwrite, we get incoherent results.  As demonstrated by OpenBSD's
failure on the tdb unit tests.

Rather than disable mmap on OpenBSD, we test for this issue and force mmap
to be enabled.  This means that we will fail on very large TDBs on 32-bit
systems, but it's better than the horrendous performance penalty on every
OpenBSD system.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 584b996a1a27870dad30eb422d375bb08b57c64c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 22 10:47:24 2012 +1030

lib/replace: test for incoherent mmap.

We test for other mmap features here, and both tdb1 and tdb2 want this 
check.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit b3a6ffd7b269f7a34334d24b54591c225da773a5
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 21 11:20:06 2012 +1030

lib/ccan/failtest: compile fix for OpenBSD

OpenBSD doesn't idempotent-wrap sys/mman.h, so when we #define mmap to
an alternative, it fails to compile when sys/mman.h is included again.

Workaround is not to #define mmap to add arguments on Open BSD.

(Imported from CCAN commit e18e80fe175422d26efe689addc0f67bdba0e097)

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 675593221c25dbebaaf8e4ce9f4271a8fb0171d0
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 21 00:58:14 2012 +1030

lib/ccan: namespacize ccan/list to avoid conflict with OpenIndiana's 
sys/list.h

CCAN includes a little utility called namespacize which prepends ccan_ to
all public methods of a module, and fixes up any dependencies it finds.  
It's
a little primitive, but it works here.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit eafd83736918bc5953e4a91cf2d893e68f2da2a2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 21 00:57:14 2012 +1030

lib/tdb: fix up run-die

[SCM] Samba Shared Repository - branch master updated

2012-03-14 Thread Rusty Russell
The branch, master has been updated
   via  3272ba0 lib/tdb: remove unnecessary XOPEN and FILE_OFFSET_BITS 
defines in test/
   via  4d613d9 lib/tdb2: remove unneccessary _FILE_OFFSET_BITS define in 
test/.
  from  442f1c8 autoconf: make autoconf build work on OS X 10.6

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 3272ba0d2d63e6a7d00972bc2c052aee84f073fd
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 14 15:31:01 2012 +1030

lib/tdb: remove unnecessary XOPEN and FILE_OFFSET_BITS defines in test/

These were relics: they don't need to be defined here as long as we are
careful to include the replace headers before any standard headers (we are).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Mar 14 10:12:26 CET 2012 on sn-devel-104

commit 4d613d9ceb99effdaac51e275f2b7c838148261c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 14 15:29:55 2012 +1030

lib/tdb2: remove unneccessary _FILE_OFFSET_BITS define in test/.

This was a relic from testing; it can interfere with compile.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/test/run-3G-file.c |3 ---
 lib/tdb/test/run-bad-tdb-header.c  |1 -
 lib/tdb/test/run-check.c   |1 -
 lib/tdb/test/run-corrupt.c |1 -
 lib/tdb/test/run-die-during-transaction.c  |1 -
 lib/tdb/test/run-endian.c  |1 -
 lib/tdb/test/run-incompatible.c|1 -
 lib/tdb/test/run-nested-transactions.c |1 -
 lib/tdb/test/run-nested-traverse.c |1 -
 lib/tdb/test/run-no-lock-during-traverse.c |2 --
 lib/tdb/test/run-oldhash.c |1 -
 lib/tdb/test/run-readonly-check.c  |1 -
 lib/tdb/test/run-rwlock-check.c|1 -
 lib/tdb/test/run-traverse-in-transaction.c |1 -
 lib/tdb/test/run-wronghash-fail.c  |1 -
 lib/tdb/test/run-zero-append.c |1 -
 lib/tdb/test/run.c |1 -
 lib/tdb2/test/run-tdb1-3G-file.c   |2 --
 18 files changed, 0 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/test/run-3G-file.c b/lib/tdb/test/run-3G-file.c
index 5ea4fcf..cc700c2 100644
--- a/lib/tdb/test/run-3G-file.c
+++ b/lib/tdb/test/run-3G-file.c
@@ -1,6 +1,3 @@
-/* We need this otherwise fcntl locking fails. */
-#define _FILE_OFFSET_BITS 64
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-bad-tdb-header.c 
b/lib/tdb/test/run-bad-tdb-header.c
index 8d3accb..9dbb622 100644
--- a/lib/tdb/test/run-bad-tdb-header.c
+++ b/lib/tdb/test/run-bad-tdb-header.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-check.c b/lib/tdb/test/run-check.c
index b9246b6..455731d 100644
--- a/lib/tdb/test/run-check.c
+++ b/lib/tdb/test/run-check.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-corrupt.c b/lib/tdb/test/run-corrupt.c
index 039e6a9..5d86e71 100644
--- a/lib/tdb/test/run-corrupt.c
+++ b/lib/tdb/test/run-corrupt.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-die-during-transaction.c 
b/lib/tdb/test/run-die-during-transaction.c
index c4fb3f4..e65f811 100644
--- a/lib/tdb/test/run-die-during-transaction.c
+++ b/lib/tdb/test/run-die-during-transaction.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include unistd.h
 #include lock-tracking.h
 static ssize_t pwrite_check(int fd, const void *buf, size_t count, off_t 
offset);
diff --git a/lib/tdb/test/run-endian.c b/lib/tdb/test/run-endian.c
index 43d4b13..bf6e713 100644
--- a/lib/tdb/test/run-endian.c
+++ b/lib/tdb/test/run-endian.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-incompatible.c b/lib/tdb/test/run-incompatible.c
index 31d4f99..6097026 100644
--- a/lib/tdb/test/run-incompatible.c
+++ b/lib/tdb/test/run-incompatible.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common/tdb_private.h
 #include ../common/io.c
 #include ../common/tdb.c
diff --git a/lib/tdb/test/run-nested-transactions.c 
b/lib/tdb/test/run-nested-transactions.c
index c4765de..45bc563 100644
--- a/lib/tdb/test/run-nested-transactions.c
+++ b/lib/tdb/test/run-nested-transactions.c
@@ -1,4 +1,3 @@
-#define _XOPEN_SOURCE 500
 #include ../common

[SCM] Samba Shared Repository - branch master updated

2012-03-13 Thread Rusty Russell
The branch, master has been updated
   via  6dea4f2 lib/tdb2: make summary handle capabilities properly.
   via  5ba2e4f lib/tdb2: fix error string formatting.
   via  ee0d1da lib/tdb2: Add gcc-style format attribute to tdb_logerr.
  from  2d35fd7 Fix bug #8811 - sd_has_inheritable_components segfaults on 
an SD that se_access_check accepts.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 6dea4f24dc023a8234de01bbdcd012df29d3abf9
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 14 13:51:26 2012 +1030

lib/tdb2: make summary handle capabilities properly.

Another PPC issue (endian?) revealed that the summary code did not handle
capabilities correctly: in fact, it went into an endless loop.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Mar 14 06:51:43 CET 2012 on sn-devel-104

commit 5ba2e4fc391e3f894b9d939b9ae65f664e32bb0c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 14 13:37:51 2012 +1030

lib/tdb2: fix error string formatting.

This caused a crash on PPC64 when we failed the mmap (found by failtest,
reported by Amitay)

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit ee0d1daa279049a1b38b1ef4b3a1b29b1344b212
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Mar 14 13:08:58 2012 +1030

lib/tdb2: Add gcc-style format attribute to tdb_logerr.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb2/io.c |4 ++--
 lib/tdb2/private.h|9 +
 lib/tdb2/summary.c|   44 +---
 lib/tdb2/tdb1_check.c |3 ++-
 lib/tdb2/tdb1_io.c|5 +++--
 5 files changed, 25 insertions(+), 40 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/io.c b/lib/tdb2/io.c
index b4a6f0b..5634922 100644
--- a/lib/tdb2/io.c
+++ b/lib/tdb2/io.c
@@ -134,8 +134,8 @@ static enum TDB_ERROR tdb_oob(struct tdb_context *tdb,
return TDB_SUCCESS;
 
tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-  tdb_oob len %llu beyond eof at %zu,
-  (long long)(off + len), st.st_size);
+  tdb_oob len %llu beyond eof at %llu,
+  (long long)(off + len), (long long)st.st_size);
return TDB_ERR_IO;
}
 
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 31790bc..04a433b 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -740,10 +740,11 @@ TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
 TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
 
 /* tdb.c: */
-enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
-  enum TDB_ERROR ecode,
-  enum tdb_log_level level,
-  const char *fmt, ...);
+enum TDB_ERROR COLD PRINTF_FMT(4, 5)
+   tdb_logerr(struct tdb_context *tdb,
+  enum TDB_ERROR ecode,
+  enum tdb_log_level level,
+  const char *fmt, ...);
 
 #ifdef TDB_TRACE
 void tdb_trace(struct tdb_context *tdb, const char *op);
diff --git a/lib/tdb2/summary.c b/lib/tdb2/summary.c
index 8ddd26e..4a1d688 100644
--- a/lib/tdb2/summary.c
+++ b/lib/tdb2/summary.c
@@ -73,7 +73,8 @@ static enum TDB_ERROR summarize(struct tdb_context *tdb,
struct tally *data,
struct tally *extra,
struct tally *uncoal,
-   struct tally *chains)
+   struct tally *chains,
+   size_t *num_caps)
 {
tdb_off_t off;
tdb_len_t len;
@@ -140,6 +141,11 @@ static enum TDB_ERROR summarize(struct tdb_context *tdb,
+ rec_extra_padding(p-u);
tally_add(chains, 1);
tally_add(extra, rec_extra_padding(p-u));
+   } else if (rec_magic(p-u) == TDB_CAP_MAGIC) {
+   len = sizeof(p-u)
+   + rec_data_length(p-u)
+   + rec_extra_padding(p-u);
+   (*num_caps)++;
} else {
len = dead_space(tdb, off);
if (TDB_OFF_IS_ERR(len)) {
@@ -153,30 +159,7 @@ static enum TDB_ERROR summarize(struct tdb_context *tdb,
return TDB_SUCCESS;
 }
 
-static size_t num_capabilities(struct tdb_context *tdb)
-{
-   tdb_off_t off, next;
-   const struct tdb_capability *cap;
-   size_t count = 0;
-
-   off = tdb_read_off(tdb, offsetof(struct tdb_header, capabilities));
-   if (TDB_OFF_IS_ERR(off

[SCM] Samba Shared Repository - branch master updated

2012-03-09 Thread Rusty Russell
The branch, master has been updated
   via  583ffea lib/tdb: fix tests for standalone out-of-tree.
  from  7320a5c samba.tests.samba_tool.base: Avoid unnecessary call to 
testtools.matchers.Contains.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 583ffeae404cc632eebc43fed054391a59dffee2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Mar 10 14:08:48 2012 +1030

lib/tdb: fix tests for standalone out-of-tree.

Commit 4d58d0fa8f936e7efdc02e31c053d42a47b3e62a didn't work for lib/tdb
outside the build tree: symlink was pointing to wrong place.

Copy simplification from lib/tdb2, and fix the build farm.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Sat Mar 10 07:07:45 CET 2012 on sn-devel-104

---

Summary of changes:
 lib/tdb/wscript |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index 9eeb3c8..871c5c4 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -183,7 +183,8 @@ def testonly(ctx):
 # Symlink back to source dir so it can find tests in test/
 link = os.path.join(testdir, 'test')
 if not os.path.exists(link):
-
os.symlink(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(Utils.g_module.root_path),
 Utils.g_module.srcdir, 'lib', 'tdb', 'test'))), link)
+os.symlink(os.path.abspath(os.path.join(env.cwd, 'test')), link)
+
 for f in 'tdb1-run-3G-file', 'tdb1-run-bad-tdb-header', 'tdb1-run', 
'tdb1-run-check', 'tdb1-run-corrupt', 'tdb1-run-die-during-transaction', 
'tdb1-run-endian', 'tdb1-run-incompatible', 'tdb1-run-nested-transactions', 
'tdb1-run-nested-traverse', 'tdb1-run-no-lock-during-traverse', 
'tdb1-run-oldhash', 'tdb1-run-open-during-transaction', 
'tdb1-run-readonly-check', 'tdb1-run-rwlock-check', 'tdb1-run-summary', 
'tdb1-run-transaction-expand', 'tdb1-run-traverse-in-transaction', 
'tdb1-run-wronghash-fail', 'tdb1-run-zero-append':
 cmd = cd  + testdir ++ 
os.path.abspath(os.path.join(Utils.g_module.blddir, f)) +   test-output 21
 print(... + f)


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-03-07 Thread Rusty Russell
The branch, master has been updated
   via  b442e37 failtest: don't assume FD_SETSIZE is maximum runtime fd.
  from  256e2df s4-selftest: create the st/provision if it didn't exists 
already

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit b442e375256d93637b38f997a78e330ba4774c43
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Mar 8 14:14:22 2012 +1030

failtest: don't assume FD_SETSIZE is maximum runtime fd.

This breaks when rlimit is less.  Unfortunately, valgrind (32 bit x86,
3.7.0.SVN, Ubuntu) fails to set the file limit properly on the test:
reducing it to the obvious getrlimit/setrlimit/getrlimit works fine,
so leaving diagnostics for another day.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit a85a809bb17af6b6cf6fa31b300c6622f64ee700)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Mar  8 06:30:48 CET 2012 on sn-devel-104

---

Summary of changes:
 lib/ccan/failtest/_info   |3 ++
 lib/ccan/failtest/failtest.c  |   17 --
 lib/ccan/failtest/test/run-with-fdlimit.c |   51 +
 3 files changed, 68 insertions(+), 3 deletions(-)
 create mode 100644 lib/ccan/failtest/test/run-with-fdlimit.c


Changeset truncated at 500 lines:

diff --git a/lib/ccan/failtest/_info b/lib/ccan/failtest/_info
index 14dcb78..4a5b97c 100644
--- a/lib/ccan/failtest/_info
+++ b/lib/ccan/failtest/_info
@@ -54,6 +54,9 @@
  *
  * License: LGPL
  * Author: Rusty Russell ru...@rustcorp.com.au
+ * Ccanlint:
+ * // valgrind seems to mess up rlimit.
+ * tests_pass_valgrind test/run-with-fdlimit.c:FAIL
  */
 int main(int argc, char *argv[])
 {
diff --git a/lib/ccan/failtest/failtest.c b/lib/ccan/failtest/failtest.c
index 701586e..5f68394 100644
--- a/lib/ccan/failtest/failtest.c
+++ b/lib/ccan/failtest/failtest.c
@@ -14,6 +14,7 @@
 #include sys/stat.h
 #include sys/time.h
 #include sys/mman.h
+#include sys/resource.h
 #include signal.h
 #include assert.h
 #include ccan/time/time.h
@@ -194,11 +195,21 @@ static struct failtest_call *add_history_(enum 
failtest_call_type type,
 static int move_fd_to_high(int fd)
 {
int i;
+   struct rlimit lim;
+   int max;
 
-   for (i = FD_SETSIZE - 1; i = 0; i--) {
+   if (getrlimit(RLIMIT_NOFILE, lim) == 0) {
+   max = lim.rlim_cur;
+   printf(Max is %i\n, max);
+   } else
+   max = FD_SETSIZE;
+
+   for (i = max - 1; i  fd; i--) {
if (fcntl(i, F_GETFL) == -1  errno == EBADF) {
-   if (dup2(fd, i) == -1)
-   err(1, Failed to dup fd %i to %i, fd, i);
+   if (dup2(fd, i) == -1) {
+   warn(Failed to dup fd %i to %i, fd, i);
+   continue;
+   }
close(fd);
return i;
}
diff --git a/lib/ccan/failtest/test/run-with-fdlimit.c 
b/lib/ccan/failtest/test/run-with-fdlimit.c
new file mode 100644
index 000..6b4483f
--- /dev/null
+++ b/lib/ccan/failtest/test/run-with-fdlimit.c
@@ -0,0 +1,51 @@
+/* Include the C files directly. */
+#include ccan/failtest/failtest.c
+#include stdlib.h
+#include err.h
+#include ccan/tap/tap.h
+
+int main(void)
+{
+   int fd, pfd[2], ecode;
+   struct rlimit lim;
+
+   if (getrlimit(RLIMIT_NOFILE, lim) != 0)
+   err(1, getrlimit RLIMIT_NOFILE fail?);
+
+   printf(rlimit = %lu/%lu (inf=%lu)\n,
+  (long)lim.rlim_cur, (long)lim.rlim_max,
+  (long)RLIM_INFINITY);
+   lim.rlim_cur /= 2;
+   if (lim.rlim_cur  8)
+   errx(1, getrlimit limit %li too low, (long)lim.rlim_cur);
+   if (setrlimit(RLIMIT_NOFILE, lim) != 0)
+   err(1, setrlimit RLIMIT_NOFILE (%li/%li),
+   (long)lim.rlim_cur, (long)lim.rlim_max);
+
+   plan_tests(2);
+   failtest_init(0, NULL);
+
+   if (pipe(pfd))
+   abort();
+
+   fd = failtest_open(run-with-fdlimit-scratch, run-with_fdlimit.c, 1,
+  O_RDWR|O_CREAT, 0600);
+   if (fd == -1) {
+   /* We are the child: write error code for parent to check. */
+   ecode = errno;
+   if (write(pfd[1], ecode, sizeof(ecode)) != sizeof(ecode))
+   abort();
+   failtest_exit(0);
+   }
+
+   /* Check child got correct errno. */
+   ok1(read(pfd[0], ecode, sizeof(ecode)) == sizeof(ecode));
+   ok1(ecode == EACCES);
+
+   /* Clean up. */
+   failtest_close(fd, run-open.c, 1);
+   close(pfd[0]);
+   close(pfd[1]);
+
+   return exit_status();
+}


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-02-26 Thread Rusty Russell
The branch, master has been updated
   via  90c03cc lib/tdb2: rename tdb2.pc to tdb.pc
  from  47c62ee upgradehelpers: Simplify transaction handling.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 90c03ccf4c7bb33ac8b6c1338ec97642bcf8251b
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Feb 27 14:15:47 2012 +1030

lib/tdb2: rename tdb2.pc to tdb.pc

The library is called tdb, so the pc file must have the same name.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Feb 27 06:59:58 CET 2012 on sn-devel-104

---

Summary of changes:
 lib/tdb2/{tdb2.pc.in = tdb.pc.in} |0
 lib/tdb2/wscript   |2 +-
 2 files changed, 1 insertions(+), 1 deletions(-)
 rename lib/tdb2/{tdb2.pc.in = tdb.pc.in} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/tdb2.pc.in b/lib/tdb2/tdb.pc.in
similarity index 100%
rename from lib/tdb2/tdb2.pc.in
rename to lib/tdb2/tdb.pc.in
diff --git a/lib/tdb2/wscript b/lib/tdb2/wscript
index a7edda4..28fda3f 100644
--- a/lib/tdb2/wscript
+++ b/lib/tdb2/wscript
@@ -92,7 +92,7 @@ def build(bld):
   vnum=VERSION,
   public_headers='tdb2.h',
   public_headers_install=not private_library,
-  pc_files='tdb2.pc',
+  pc_files='tdb.pc',
   private_library=private_library)
 
 bld.SAMBA_BINARY('tdbtorture',


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-02-20 Thread Rusty Russell
The branch, master has been updated
   via  89586ed lib/tdb2: 2.0.0 ABI
   via  abc7472 lib/tdb2: Convert tdb2 to a standalone library
   via  f7b999f lib/tdb2: Fix wscript
   via  4e90726 lib/tdb2: Mark public function as such
   via  a63d731 lib/tdb2: Do not include config.h in (to-be) public 
library, use replace.
   via  e6901fa lib/tdb2: tools should use config.h, and replace where 
available.
   via  fb8cf56 lib/ccan: define HAVE_CCAN.
  from  0528cb5 s3: Fix bug 8567 -- segfault in dom_sid_compare

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 89586ed1643101b3b94bba1fdcdc821026a00e65
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Feb 21 15:29:52 2012 +1030

lib/tdb2: 2.0.0 ABI

Signed-off-by: Amitay Isaacs ami...@gmail.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Feb 21 07:43:55 CET 2012 on sn-devel-104

commit abc74723cebcab30987bb16e359645ba37eb6c95
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Feb 21 15:29:52 2012 +1030

lib/tdb2: Convert tdb2 to a standalone library

Adds a Makefile, configure script, and tdb2.pc.in.

Signed-off-by: Amitay Isaacs ami...@gmail.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit f7b999fac0b6d00c8e60012eba3de2fd59d8c854
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Feb 21 15:29:30 2012 +1030

lib/tdb2: Fix wscript

Particularly fix the upcoming standalone build.

Signed-off-by: Amitay Isaacs ami...@gmail.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 4e9072660a96324f8d9421f35593057b730ca185
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Feb 21 15:29:22 2012 +1030

lib/tdb2: Mark public function as such

Signed-off-by: Amitay Isaacs ami...@gmail.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit a63d731ae05af78bdc33db58880387169429753e
Author: Amitay Isaacs ami...@gmail.com
Date:   Tue Feb 21 15:29:17 2012 +1030

lib/tdb2: Do not include config.h in (to-be) public library, use replace.

Like tdb1, it's the caller's responsibility to set up various config
options (eg. by #include config.h) before including the public
header.

We use HAVE_CCAN for including the (private) CCAN headers, otherwise
dummy macros are used.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit e6901fa35069e234044c94b87ac9df4064b31d1c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 21 15:29:12 2012 +1030

lib/tdb2: tools should use config.h, and replace where available.

The tdb2 tools should #include config.h before tdb2.h (about to
become a requirement) and use libreplace where available.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit fb8cf568caf43615f7a06a623209a0fade629a35
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 21 15:29:06 2012 +1030

lib/ccan: define HAVE_CCAN.

This allows public headers to use CCAN if available, and dummy macros
if not (eg. tdb2).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/wscript   |1 +
 lib/tdb2/ABI/tdb-2.0.0.sigs|   40 +++
 lib/{tdb = tdb2}/Makefile |0
 lib/tdb2/check.c   |2 +-
 lib/{replace = tdb2}/configure|0
 lib/tdb2/hash.c|8 ++--
 lib/tdb2/lock.c|8 ++--
 lib/tdb2/open.c|   12 ++--
 lib/tdb2/private.h |5 ++
 lib/tdb2/summary.c |2 +-
 lib/tdb2/tdb.c |   30 ++--
 lib/tdb2/tdb1_hash.c   |2 +-
 lib/tdb2/tdb2.h|   19 +++-
 lib/{tdb/tdb.pc.in = tdb2/tdb2.pc.in} |2 +-
 lib/tdb2/tools/tdb2backup.c|1 +
 lib/tdb2/tools/tdb2dump.c  |7 +++
 lib/tdb2/tools/tdb2restore.c   |6 ++
 lib/tdb2/tools/tdb2tool.c  |8 +++
 lib/tdb2/tools/tdb2torture.c   |7 ++-
 lib/tdb2/transaction.c |8 ++--
 lib/tdb2/traverse.c|8 ++--
 lib/tdb2/wscript   |   82 ---
 22 files changed, 185 insertions(+), 73 deletions(-)
 create mode 100644 lib/tdb2/ABI/tdb-2.0.0.sigs
 copy lib/{tdb = tdb2}/Makefile (100%)
 copy lib/{replace = tdb2}/configure (100%)
 copy lib/{tdb/tdb.pc.in = tdb2/tdb2.pc.in} (89%)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 9daf091..59fe93a 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -3,6 +3,7 @@
 import Logs, sys
 
 def configure(conf):
+conf.DEFINE

[SCM] Samba Shared Repository - branch master updated

2012-02-13 Thread Rusty Russell
The branch, master has been updated
   via  4d58d0f tdb: build and run unit tests in tdb/test/
   via  205242e tdb/test: fix up tests for use in SAMBA tdb code.
   via  8fa345d tdb: wean CCAN-style unit tests off of tap.
   via  0802791 tdb: import unit tests from CCAN into tdb/test/
   via  390b9a2 tdb: make tdb_private.h idempotent.
  from  ad2a2c4 s4:torture: add another SMB2 rename test

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4d58d0fa8f936e7efdc02e31c053d42a47b3e62a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 14 14:45:29 2012 +1030

tdb: build and run unit tests in tdb/test/

Now we can build the test binaries: the CCAN style is to compile
everything called compile_ok*.c, compile and run everything called
run*.c, compile, link with the module, and run everything called
api*.c, and link any other C files (presumably test helpers) into
all the tests.

Unfortunately, actually passing that between the various parts of
wscript is painful, so I open-coded the names.

Also, the tests expect to be run in a (temporary) directory they can
pollute, with the test directory found in test/ (to find the canned
TDB files, for example).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Feb 14 06:53:46 CET 2012 on sn-devel-104

commit 205242e1769f96e0e8fccd52378965d35dd02093
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 14 14:45:21 2012 +1030

tdb/test: fix up tests for use in SAMBA tdb code.

1) Make sure we include tdb_private.h first, to get the right headers
   (esp. the correct setting of _FILE_OFFSET_BITS before unistd.h).
2) Fix 3G file test since expand logic has changed.
3) Fix nested transaction test, since default is to allow nesting.
4) Capture fdatasync, which was slowing down transaction expand.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 8fa345d952328c5866f3a0f835f3599343c51b00
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 14 14:45:19 2012 +1030

tdb: wean CCAN-style unit tests off of tap.

We could use subunit, but that's overkill.  Just print messages when
we fail, and use exit status.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 0802791081ba39298aa93f0e6860c3b62800df73
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 14 04:05:43 2012 +1030

tdb: import unit tests from CCAN into tdb/test/

I pulled tdb into CCAN as an experiment a while ago; it doesn't belong
there, but it has accumulated some important unit tests.

These are copied from CCAN version init-1486-gc438ec1 with #include ../
changed to #include ../common/.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 390b9a2dd8447ecd16e3957c02fa886781797733
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Feb 14 04:04:43 2012 +1030

tdb: make tdb_private.h idempotent.

The most convenient way to write unit tests in C is to directly
#include the C files (CCAN uses this, for example).  That works quite
well, but it means that tdb_private.h now needs to be protected
against multiple inclusions.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/Makefile   |2 +-
 lib/tdb/common/tdb_private.h   |3 +
 lib/tdb/test/external-agent.c  |  195 +
 lib/tdb/test/external-agent.h  |   41 
 .../test/jenkins-be-hash.tdb}  |  Bin 696 - 696 bytes
 .../test/jenkins-le-hash.tdb}  |  Bin 696 - 696 bytes
 lib/tdb/test/lock-tracking.c   |  146 +
 lib/{tdb2 = tdb}/test/lock-tracking.h |0
 lib/tdb/test/logging.c |   33 +++
 lib/tdb/test/logging.h |   11 +
 .../test/old-nohash-be.tdb}|  Bin 696 - 696 bytes
 .../test/old-nohash-le.tdb}|  Bin 696 - 696 bytes
 lib/tdb/test/run-3G-file.c |  129 +++
 lib/tdb/test/run-bad-tdb-header.c  |   60 ++
 lib/tdb/test/run-check.c   |   66 ++
 lib/tdb/test/run-corrupt.c |  129 +++
 lib/tdb/test/run-die-during-transaction.c  |  225 
 lib/tdb/test/run-endian.c  |   65 ++
 lib/tdb/test/run-incompatible.c|  187 
 lib/tdb/test/run-nested-transactions.c |   80 +++
 lib/tdb/test/run-nested-traverse.c |   91

[SCM] Samba Shared Repository - branch master updated

2012-02-01 Thread Rusty Russell
The branch, master has been updated
   via  b3fb115 tdb2: add --disable-tdb2
  from  c892217 smbtorture: Do not leak child processes when exiting

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit b3fb115a3932423267022152a04fa5cfcd059239
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Feb 2 11:36:49 2012 +1030

tdb2: add --disable-tdb2

I thought you could --disable-tdb2=false, apparently not!  Thanks
Michael Adam...

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Feb  2 03:43:08 CET 2012 on sn-devel-104

---

Summary of changes:
 lib/tdb2/wscript |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/wscript b/lib/tdb2/wscript
index 1211523..e4fb62b 100644
--- a/lib/tdb2/wscript
+++ b/lib/tdb2/wscript
@@ -24,6 +24,9 @@ def set_options(opt):
 opt.add_option('--enable-tdb2',
help=(Use tdb2 API instead of tdb1 [True]),
action=store_true, dest='BUILD_TDB2', default=True)
+opt.add_option('--disable-tdb2',
+   help=(Use old tdb1 API instead of tdb2),
+   action=store_false, dest='BUILD_TDB2')
 if opt.IN_LAUNCH_DIR():
 opt.add_option('--disable-python',
help=(disable the pytdb module),


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2012-01-29 Thread Rusty Russell
The branch, master has been updated
   via  7c6713e tdb2: make --enable-tdb2 the default.
   via  e1665c9 tdb2: add -1 and -2 options to tdbtorture
   via  1023082 tdb2:tdbtorture: use TEST_DATA_PREFIX for files
   via  45ae436 tdb2: name tools the same as TDB1 tools.
   via  23f1f5e tdb2: tools/tdb2backup
   via  641beb3 samdb: use compat wrappers for tdb_fetch().
   via  dd1d573 tdb_compat: only use hashsize attribute when O_CREAT
   via  ae62d46 ldb_wrap.c: fix TDB2-incompatible API usage.
   via  efbf52b tdb2: copy tdb1's changed expansion logic.
   via  205e198 tdb2: careful on wrap.
  from  697a6e9 auth: provide private pointer and do not return original 
PAC signatures

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 7c6713e78ff22ebf0aa1caa10697bad9d4cc885e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 15:59:18 2012 +1030

tdb2: make --enable-tdb2 the default.

We still use the tdb1 on-disk format, but we do so via the tdb2 library.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Jan 30 08:02:43 CET 2012 on sn-devel-104

commit e1665c94ac290e030321f7d243e3e70661874778
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 15:59:16 2012 +1030

tdb2: add -1 and -2 options to tdbtorture

(For now, -1 is the default).

commit 10230829df5c5624edaa5fabaf84c9ac5bc31285
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 15:31:05 2012 +1030

tdb2:tdbtorture: use TEST_DATA_PREFIX for files

TDB2 version of commit b83672b36c1ea8c35833c40c3919b63809f16624.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 45ae436b19925930b4a60fd8078edcec9ef45e96
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 10:07:18 2012 +1030

tdb2: name tools the same as TDB1 tools.

Otherwise, when we switch everyone's scripts will break (including our
own tests!).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 23f1f5e0e3516092c47e942c03cef42f4256bf2a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 10:07:17 2012 +1030

tdb2: tools/tdb2backup

Minor changes from tdb/tools/tdbbackup.c.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 641beb35bff243bab5651a1cab8aa4b305ecefa4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 10:07:17 2012 +1030

samdb: use compat wrappers for tdb_fetch().

TDB2's tdb_fetch() returns an error code; use tdb_fetch_compat() for now.
Similarly, tdb_errorstr() - tdb_errorstr_compat().

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit dd1d57370d6d83473a7ada3ceb8d250d357ff429
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 10:06:55 2012 +1030

tdb_compat: only use hashsize attribute when O_CREAT

tdb2 complains if you specify a tdb1 hashsize, and you're not actually
trying to create a new database.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit ae62d46a9fcfee9db177ddb3d0f1f2c28c889a35
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 09:25:50 2012 +1030

ldb_wrap.c: fix TDB2-incompatible API usage.

Auditing revealed one place still expecting a -1 return on failure:
tdb2 returns the (negative) errcode directly, so the portable way to
do this is to check for != 0.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit efbf52b4fe62eeed085961d7e2689b869bae63dc
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 09:24:50 2012 +1030

tdb2: copy tdb1's changed expansion logic.

TDB2 uses the same expansion logic as TDB1, which got factored out
recently.  So update TDB2 to match.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit c438ec17d7b2efe76e56e5fc5ab88bd4a02735e8)

commit 205e198471a481b849d05b5756261f1739c0c8b2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jan 30 09:23:50 2012 +1030

tdb2: careful on wrap.

It's much harder to wrap a 64-bit tdb2 than a 32-bit tdb1, but we should 
still
take care against bugs.

Also, we should *not* cast the length to a size_t when comparing it to
the stat result, in case size_t is 32 bit.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 6f7cb26e589cea081e71c59801eae87178967861)

---

Summary of changes:
 lib/ldb-samba/ldb_wrap.c   |2 +-
 lib/tdb2/check.c   |4 +-
 lib/tdb2/free.c|   57 +
 lib/tdb2/io.c  |   29 +++--
 lib/tdb2/open.c|2

[SCM] Samba Shared Repository - branch master updated

2011-12-20 Thread Rusty Russell
The branch, master has been updated
   via  5767224 tdb: don't free old recovery area when expanding if already 
at EOF.
   via  3a2a755 tdb: use same expansion factor logic when expanding for new 
recovery area.
  from  c23f1ee Allow an object to be deleted from a directory if the 
caller has DELETE_CHILD access even if we don't have access to read the ACL on 
the object. Fixes bug #8673 - NT ACL issue. Different fix needed for 3.6.x.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 5767224b7f4703c3195aa69eef4352d80980f95e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Dec 21 14:17:25 2011 +1030

tdb: don't free old recovery area when expanding if already at EOF.

We allocate a new recovery area by expanding the file.  But if the
recovery area is already at the end of file (as shown in at least one
client case), we can simply expand the record, rather than freeing it
and creating a new one.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Dec 21 06:25:40 CET 2011 on sn-devel-104

commit 3a2a755e3380a8f81374009d463cd06161352507
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Dec 21 14:17:16 2011 +1030

tdb: use same expansion factor logic when expanding for new recovery area.

If we're expanding because the current recovery area is too small, we
expand only the amount we need.  This can quickly lead to exponential
growth when we have a slowly-expanding record (hence a
slowly-expanding transaction size).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/io.c  |   48 ++---
 lib/tdb/common/tdb_private.h |1 +
 lib/tdb/common/transaction.c |   53 +++--
 3 files changed, 64 insertions(+), 38 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index a2db3bf..ac21e3f 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -313,41 +313,49 @@ static int tdb_expand_file(struct tdb_context *tdb, 
tdb_off_t size, tdb_off_t ad
 }
 
 
-/* expand the database at least size bytes by expanding the underlying
-   file and doing the mmap again if necessary */
-int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
+/* You need 'size', this tells you how much you should expand by. */
+tdb_off_t tdb_expand_adjust(tdb_off_t map_size, tdb_off_t size, int page_size)
 {
-   struct tdb_record rec;
-   tdb_off_t offset, new_size, top_size, map_size;
-
-   if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
-   TDB_LOG((tdb, TDB_DEBUG_ERROR, lock failed in tdb_expand\n));
-   return -1;
-   }
-
-   /* must know about any previous expansions by another process */
-   tdb-methods-tdb_oob(tdb, tdb-map_size, 1, 1);
+   tdb_off_t new_size, top_size;
 
/* limit size in order to avoid using up huge amounts of memory for
 * in memory tdbs if an oddball huge record creeps in */
if (size  100 * 1024) {
-   top_size = tdb-map_size + size * 2;
+   top_size = map_size + size * 2;
} else {
-   top_size = tdb-map_size + size * 100;
+   top_size = map_size + size * 100;
}
 
/* always make room for at least top_size more records, and at
   least 25% more space. if the DB is smaller than 100MiB,
   otherwise grow it by 10% only. */
-   if (tdb-map_size  100 * 1024 * 1024) {
-   map_size = tdb-map_size * 1.10;
+   if (map_size  100 * 1024 * 1024) {
+   new_size = map_size * 1.10;
} else {
-   map_size = tdb-map_size * 1.25;
+   new_size = map_size * 1.25;
}
 
/* Round the database up to a multiple of the page size */
-   new_size = MAX(top_size, map_size);
-   size = TDB_ALIGN(new_size, tdb-page_size) - tdb-map_size;
+   new_size = MAX(top_size, new_size);
+   return TDB_ALIGN(new_size, page_size) - map_size;
+}
+
+/* expand the database at least size bytes by expanding the underlying
+   file and doing the mmap again if necessary */
+int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
+{
+   struct tdb_record rec;
+   tdb_off_t offset;
+
+   if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
+   TDB_LOG((tdb, TDB_DEBUG_ERROR, lock failed in tdb_expand\n));
+   return -1;
+   }
+
+   /* must know about any previous expansions by another process */
+   tdb-methods-tdb_oob(tdb, tdb-map_size, 1, 1);
+
+   size = tdb_expand_adjust(tdb-map_size, size, tdb-page_size);
 
if (!(tdb-flags  TDB_INTERNAL))
tdb_munmap(tdb);
diff --git a/lib

[SCM] Samba Shared Repository - branch master updated

2011-12-18 Thread Rusty Russell
The branch, master has been updated
   via  b644945 tdb: be more careful on 4G files.
   via  6260d8c patch tdb-oob-fix.patch
  from  9e2d4b6 s3-net: Fix the return codes. 0 on success, -1 on failure

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit b64494535dc62f4073fc6302847593ed6e6ec38b
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 19 15:47:50 2011 +1030

tdb: be more careful on 4G files.

I came across a tdb which had wrapped to 4G + 4K, and the contents had been
destroyed by processes which thought it only 4k long.  Fix this by checking
on open, and making tdb_oob() check for wrap itself.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Dec 19 07:52:01 CET 2011 on sn-devel-104

commit 6260d8c29b4828511ecd1c3fc176612e0a0c73ce
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 19 15:34:39 2011 +1030

patch tdb-oob-fix.patch

---

Summary of changes:
 lib/tdb/common/check.c   |6 ++--
 lib/tdb/common/freelist.c|2 +-
 lib/tdb/common/io.c  |   45 +
 lib/tdb/common/open.c|   10 +
 lib/tdb/common/tdb_private.h |2 +-
 lib/tdb/common/transaction.c |   11 +
 6 files changed, 53 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 3387fbd..313f55c 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -92,7 +92,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
 off, rec-next));
goto corrupt;
}
-   if (tdb-methods-tdb_oob(tdb, rec-next+sizeof(*rec), 0))
+   if (tdb-methods-tdb_oob(tdb, rec-next, sizeof(*rec), 0))
goto corrupt;
 
/* Check rec_len: similar to rec-next, implies next record. */
@@ -110,7 +110,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
goto corrupt;
}
/* OOB allows right at the end access, so this works for last rec. */
-   if (tdb-methods-tdb_oob(tdb, off+sizeof(*rec)+rec-rec_len, 0))
+   if (tdb-methods-tdb_oob(tdb, off, sizeof(*rec)+rec-rec_len, 0))
goto corrupt;
 
/* Check tailer. */
@@ -345,7 +345,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
}
 
/* Make sure we know true size of the underlying file. */
-   tdb-methods-tdb_oob(tdb, tdb-map_size + 1, 1);
+   tdb-methods-tdb_oob(tdb, tdb-map_size, 1, 1);
 
/* Header must be OK: also gets us the recovery ptr, if any. */
if (!tdb_check_header(tdb, recovery_start))
diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 927078a..6358f64 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -56,7 +56,7 @@ int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, 
struct tdb_record
   rec-magic, off));
return -1;
}
-   if (tdb-methods-tdb_oob(tdb, rec-next+sizeof(*rec), 0) != 0)
+   if (tdb-methods-tdb_oob(tdb, rec-next, sizeof(*rec), 0) != 0)
return -1;
return 0;
 }
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 78bbf2e..a2db3bf 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -31,19 +31,29 @@
 /* check for an out of bounds access - if it is out of bounds then
see if the database has been expanded by someone else and expand
if necessary 
-   note that len is the minimum length needed for the db
 */
-static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe)
+static int tdb_oob(struct tdb_context *tdb, tdb_off_t off, tdb_len_t len,
+  int probe)
 {
struct stat st;
-   if (len = tdb-map_size)
+   if (len + off  len) {
+   if (!probe) {
+   /* Ensure ecode is set for log fn. */
+   tdb-ecode = TDB_ERR_IO;
+   TDB_LOG((tdb, TDB_DEBUG_FATAL,tdb_oob off %d len %d 
wrap\n,
+(int)off, (int)len));
+   }
+   return -1;
+   }
+
+   if (off + len = tdb-map_size)
return 0;
if (tdb-flags  TDB_INTERNAL) {
if (!probe) {
/* Ensure ecode is set for log fn. */
tdb-ecode = TDB_ERR_IO;
-   TDB_LOG((tdb, TDB_DEBUG_FATAL,tdb_oob len %d beyond 
internal malloc size %d\n,
-(int)len, (int)tdb-map_size));
+   TDB_LOG((tdb, TDB_DEBUG_FATAL,tdb_oob len %u beyond 
internal malloc size %u\n,
+(int)(off + len), (int)tdb-map_size

[SCM] Samba Shared Repository - branch master updated

2011-12-14 Thread Rusty Russell
The branch, master has been updated
   via  0429471 lib/ccan: Fix some typos in libccan.m4
   via  fef4f51 lib/ccan: fix m4 tests for builtin_expect and compound 
literals.
  from  fdcbb7e s3-includes: remove PRIMARY_* SID_INDEX defines defined 
elsewhere already.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 0429471fe478b86a9857511a7b841601640c8bac
Author: Martin Schwenke mar...@meltin.net
Date:   Thu Dec 15 15:31:47 2011 +1100

lib/ccan: Fix some typos in libccan.m4

Signed-off-by: Martin Schwenke mar...@meltin.net

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Dec 15 07:40:33 CET 2011 on sn-devel-104

commit fef4f5193b68598c99949ee2fbd9bee93daf70b1
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Dec 15 15:34:55 2011 +1030

lib/ccan: fix m4 tests for builtin_expect and compound literals.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/libccan.m4 |   23 ---
 1 files changed, 12 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/libccan.m4 b/lib/ccan/libccan.m4
index 7dbea58..1efa0f0 100644
--- a/lib/ccan/libccan.m4
+++ b/lib/ccan/libccan.m4
@@ -196,7 +196,7 @@ AC_CACHE_CHECK([whether we have __builtin_expect],
   [
 AC_LINK_IFELSE(
[int main(void) {
-   return __builtin_expect(main != 0) ? 0 : 1;
+   return __builtin_expect(main != 0, 1) ? 0 : 1;
}],
samba_cv_builtin_expect=yes)
])
@@ -236,14 +236,14 @@ if test x$samba_cv_builtin_types_compatible_p = xyes ; 
then
 [whether we have __builtin_types_compatible_p])
 fi
 
-AC_CACHE_CHECK([whether we have __builtin_choose_exptr],
+AC_CACHE_CHECK([whether we have __builtin_choose_expr],
   samba_cv_builtin_choose_expr,
   [
 AC_LINK_IFELSE(
[int main(void) {
return __builtin_choose_expr(1, 0, garbage);
}],
-   samba_cv_builtin_types_choose_expr=yes)
+   samba_cv_builtin_choose_expr=yes)
])
 
 if test x$samba_cv_builtin_choose_expr = xyes ; then
@@ -251,20 +251,21 @@ if test x$samba_cv_builtin_choose_expr = xyes ; then
 [whether we have __builtin_choose_expr])
 fi
 
-AC_CACHE_CHECK([whether we have __builtin_compound_literals],
-  samba_cv_builtin_compound_literals,
+# We use @:@ and @:@ here for embedded [ and ].
+AC_CACHE_CHECK([whether we have compound literals],
+  samba_cv_compound_literals,
   [
 AC_COMPILE_IFELSE(
[int main(void) {
-   int *foo = (int[]) { 1, 2, 3, 4 };
-   return foo[0] == 1 ? 0 : 1;
+   int *foo = (int@:@@:@) { 1, 2, 3, 4 };
+   return foo@:@0@:@ == 1 ? 0 : 1;
}],
-   samba_cv_builtin_compound_literals=yes)
+   samba_cv_compound_literals=yes)
])
 
-if test x$samba_cv_builtin_compound_literals = xyes ; then
-   AC_DEFINE(HAVE_BUILTIN_COMPOUND_LITERALS, 1,
-[whether we have __builtin_compound_literals])
+if test x$samba_cv_compound_literals = xyes ; then
+   AC_DEFINE(HAVE_COMPOUND_LITERALS, 1,
+[whether we have compound literals])
 fi
 
 AC_CACHE_CHECK([whether we have __builtin_have_isblank],


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-12-11 Thread Rusty Russell
The branch, master has been updated
   via  08019a0 tdb2: don't use TDB2 versions of test tdb files.
  from  422494a vfs: Make function pointer names consistent. They all end 
in _fn

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 08019a0973fb2ccf1ee4fa8c6523808033058456
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sun Dec 11 01:01:46 2011 +1030

tdb2: don't use TDB2 versions of test tdb files.

Now tdb2 handles tdb1 files, we don't need most of commit
5eecc854236f0b943aaa89e0c3a46f9fbd208ca9 which added TDB2 versions of
all the testing tdbs.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Dec 12 06:33:44 CET 2011 on sn-devel-104

---

Summary of changes:
 selftest/target/Samba3.pm |6 +-
 source3/selftest/ktest-secrets.tdb2   |  Bin 14592 - 0 bytes
 source4/scripting/python/samba/samba3/__init__.py |7 ++-
 testdata/samba3/account_policy.tdb2   |  Bin 12192 - 0 bytes
 testdata/samba3/group_mapping.tdb2|  Bin 14592 - 0 bytes
 testdata/samba3/passdb.tdb2   |  Bin 11392 - 0 bytes
 testdata/samba3/registry.tdb2 |  Bin 15392 - 0 bytes
 testdata/samba3/secrets.tdb2  |  Bin 17792 - 0 bytes
 testdata/samba3/share_info.tdb2   |  Bin 11392 - 0 bytes
 testdata/samba3/winbindd_idmap.tdb2   |  Bin 15392 - 0 bytes
 10 files changed, 3 insertions(+), 10 deletions(-)
 delete mode 100644 source3/selftest/ktest-secrets.tdb2
 delete mode 100644 testdata/samba3/account_policy.tdb2
 delete mode 100644 testdata/samba3/group_mapping.tdb2
 delete mode 100644 testdata/samba3/passdb.tdb2
 delete mode 100644 testdata/samba3/registry.tdb2
 delete mode 100644 testdata/samba3/secrets.tdb2
 delete mode 100644 testdata/samba3/share_info.tdb2
 delete mode 100644 testdata/samba3/winbindd_idmap.tdb2


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 3c0fbe9..211bbb6 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -451,11 +451,7 @@ $ret-{USERNAME} = KTEST\\Administrator
 #Samba4 DC with the same parameters as are being used here.  The
 #domain SID is S-1-5-21-1071277805-689288055-3486227160
 
-   if (defined($ENV{BUILD_TDB2})) {
-   system(cp $self-{srcdir}/source3/selftest/ktest-secrets.tdb2 
$prefix/private/secrets.tdb);
-   } else {
-   system(cp $self-{srcdir}/source3/selftest/ktest-secrets.tdb 
$prefix/private/secrets.tdb);
-   }
+   system(cp $self-{srcdir}/source3/selftest/ktest-secrets.tdb 
$prefix/private/secrets.tdb);
chmod 0600, $prefix/private/secrets.tdb;
 
 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 
with:
diff --git a/source3/selftest/ktest-secrets.tdb2 
b/source3/selftest/ktest-secrets.tdb2
deleted file mode 100644
index 2af58b1..000
Binary files a/source3/selftest/ktest-secrets.tdb2 and /dev/null differ
diff --git a/source4/scripting/python/samba/samba3/__init__.py 
b/source4/scripting/python/samba/samba3/__init__.py
index dd2f927..a955be1 100644
--- a/source4/scripting/python/samba/samba3/__init__.py
+++ b/source4/scripting/python/samba/samba3/__init__.py
@@ -53,12 +53,9 @@ class TdbDatabase(object):
 def __init__(self, file):
 Open a file.
 
-:param file: Path of the file to open (appending 2 if TDB2 enabled).
+:param file: Path of the file to open.
 
-if tdb.__version__.startswith(2):
-self.tdb = tdb.Tdb(file + 2, flags=os.O_RDONLY)
-else:
-self.tdb = tdb.Tdb(file, flags=os.O_RDONLY)
+self.tdb = tdb.Tdb(file, flags=os.O_RDONLY)
 self._check_version()
 
 def _check_version(self):
diff --git a/testdata/samba3/account_policy.tdb2 
b/testdata/samba3/account_policy.tdb2
deleted file mode 100644
index 434787e..000
Binary files a/testdata/samba3/account_policy.tdb2 and /dev/null differ
diff --git a/testdata/samba3/group_mapping.tdb2 
b/testdata/samba3/group_mapping.tdb2
deleted file mode 100644
index 1a6466e..000
Binary files a/testdata/samba3/group_mapping.tdb2 and /dev/null differ
diff --git a/testdata/samba3/passdb.tdb2 b/testdata/samba3/passdb.tdb2
deleted file mode 100644
index 4ef87ed..000
Binary files a/testdata/samba3/passdb.tdb2 and /dev/null differ
diff --git a/testdata/samba3/registry.tdb2 b/testdata/samba3/registry.tdb2
deleted file mode 100644
index d747c3d..000
Binary files a/testdata/samba3/registry.tdb2 and /dev/null differ
diff --git a/testdata/samba3/secrets.tdb2 b/testdata/samba3/secrets.tdb2
deleted file mode 100644
index 5f88d6a..000
Binary files a/testdata/samba3/secrets.tdb2

[SCM] Samba Shared Repository - branch master updated

2011-12-05 Thread Rusty Russell
The branch, master has been updated
   via  372dd3b tdb2: tlist: remove type arg from tlist_top(), tlist_tail()
   via  c6133b4 tdb2: display capability information in tdb_summary()
   via  80c3ba8 tdb2: add a capability list from the header.
   via  3f99fc1 tdb2: provide tdb_layout_write() rather than implying it by 
new_tdb_layout arg.
   via  eff985b tdb2: add an internal TDB_CANT_CHECK flag.
   via  6e3c405 tdb2: suppress failtest more than once on mmap.
   via  bb09b32 tdb2: simplify failtest helper.
   via  6d24853 tdb2: failtest: use a linked list for history, not an array.
   via  7f95ad0 tdb2: consolidate testing failtest suppression routines.
   via  d552422 tdb2: fix intermittant failure in 
run-50-multiple-freelists-fail.c
   via  71384d5 lib/ccan/cast: fix warnings with -Wextra (specifically 
-Wmissing-field-initializers)
   via  3b390b7 lib/ccan/compiler, ilog: IDEMPOTENT idempotent does not 
mean what you think it means
   via  ab2c07b lib/ccan/asearch: fix example on 64 bit platforms.
   via  18cd3dd lib/ccan/htable: benchmark against hsearch(3)
   via  5917d97 lib/ccan/likely: use htable_type
   via  e137404 lib/ccan/htable: HTABLE_INITIALIZER() for static 
initialization.
   via  0ac7dee lib/ccan/htable: clean up interface, document htable_type 
better.
   via  19409dd lib/ccan/htable: start empty.
   via  1beb793 lib/ccan/htable, strset: benchmarking tools.
   via  00b226b lib/ccan/str: fix warnings.
   via  ed349ea lib/ccan/str: relicense to public domain.
   via  4e377c2 lib/ccan/typesafe_cb: fix example macro ordering in 
typesafe_cb_preargs documentation.
   via  a0bff7d lib/ccan/htable: fix tools/speed.
   via  11c9046 lib/ccan/build_assert: Remove stale LGPL license comment.
   via  bc31858 lib/ccan/array_size: relicense under public domain.
  from  6be10cb Revert fac5c654e2fe17c2c11d150b16088e8a51f6be20

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 372dd3b7d0c81f6f85b0633fa3aaabd8f216bdf4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:31 2011 +1030

tdb2: tlist: remove type arg from tlist_top(), tlist_tail()

With the type canary, it's unnecessary.  Though the implementation is
a bit more awkward since they longer map directly through to list_top/tail.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit a6b5111fe6948e51114c33aa34785c9fd0d403e6)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Dec  5 12:13:08 CET 2011 on sn-devel-104

commit c6133b4755dfcea6e566479abb67ddb94c447d04
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:30 2011 +1030

tdb2: display capability information in tdb_summary()

This means we know they're there in future, and what restrictions they
carry.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit b3ca95351517e76b635347b39382b059a66f8388)

commit 80c3ba8123ed6708ebf3afad9ed78037e571a81d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:30 2011 +1030

tdb2: add a capability list from the header.

This allows even more extensibility in future: in particular, the top
bits of each capability tell us what to do if we don't understand it:
fail the open, fail to open for write, or don't try to check the
format.

tdb_check needs to understand the capability list so it can know to
skip over it: each element in the list is prefixed with the type tag
and the length.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 35f198de1851a7d57064546b7ced677b6fabee27)

commit 3f99fc16a0a3aead82cf8cdfb9703f8f18388623
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:30 2011 +1030

tdb2: provide tdb_layout_write() rather than implying it by new_tdb_layout 
arg.

Neater API.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 79d603a5f73dfbb655d8d08f67eecb5f2da542d5)

commit eff985b7ef3f1adb3da383baaea013f7f3797bb2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:30 2011 +1030

tdb2: add an internal TDB_CANT_CHECK flag.

This will be used shortly to indicate that a TDB2 file indicates it
cannot be checked.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit e01d795c8964b791def1e9f68c386b350b3a2a84)

commit 6e3c40500c9c786a5b20a02420fcf48ec0b9b5c4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 5 17:04:30 2011 +1030

tdb2: suppress failtest more than once on mmap.

Now we test failing mmap, ccanlint -v time has increased from 200 to
330 seconds.  Worse, tests no time out on my laptop.

Fix this, by preventing us from going down

[SCM] Samba Shared Repository - branch master updated

2011-11-02 Thread Rusty Russell
The branch, master has been updated
   via  6b11c91 tdb2: don't be fascist when TDB_VERSION1 is specified.
  from  a6ed907 dsdb: Handle the case when extended rights string is NULL

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 6b11c9119fa3e2ea401f86873273533d673e04fa
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Nov 2 10:08:32 2011 +1030

tdb2: don't be fascist when TDB_VERSION1 is specified.

We currently insist that a tdb file be a version1 file if tdb_open() is
passed the TDB_VERSION1 flag; we fail if it's actually a tdb2.

But that makes generic wrappers harder, and is unlikely to be what the
user wants: if they do, they can check tdb_get_flags()  TDB_VERSION1
after opening.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 9691464a16ef22d6acadfef209666381dfe22b2f)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Nov  2 08:38:38 CET 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb2/open.c   |7 +
 lib/tdb2/test/api-tdb1-flag-removal.c |   38 +
 2 files changed, 40 insertions(+), 5 deletions(-)
 create mode 100644 lib/tdb2/test/api-tdb1-flag-removal.c


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/open.c b/lib/tdb2/open.c
index 18e4cd8..b76bd24 100644
--- a/lib/tdb2/open.c
+++ b/lib/tdb2/open.c
@@ -647,12 +647,9 @@ struct tdb_context *tdb_open(const char *name, int 
tdb_flags,
goto fail;
}
 
+   /* This is a version2 tdb. */
if (tdb-flags  TDB_VERSION1) {
-   ecode = tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
-  tdb_open:
-   %s does not need TDB_VERSION1,
-  name);
-   goto fail;
+   tdb-flags = ~TDB_VERSION1;
}
 
tdb2_context_init(tdb);
diff --git a/lib/tdb2/test/api-tdb1-flag-removal.c 
b/lib/tdb2/test/api-tdb1-flag-removal.c
new file mode 100644
index 000..28f24e6
--- /dev/null
+++ b/lib/tdb2/test/api-tdb1-flag-removal.c
@@ -0,0 +1,38 @@
+#include ccan/tdb2/tdb2.h
+#include ccan/tap/tap.h
+#include ccan/hash/hash.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+
+#include logging.h
+
+int main(int argc, char *argv[])
+{
+   unsigned int i;
+   struct tdb_context *tdb;
+   int flags[] = { TDB_DEFAULT, TDB_NOMMAP,
+   TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT };
+
+   plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
+   for (i = 0; i  sizeof(flags) / sizeof(flags[0]); i++) {
+   tdb = tdb_open(run-12-store.tdb, flags[i],
+  O_RDWR|O_CREAT|O_TRUNC, 0600, tap_log_attr);
+   if (!ok1(tdb))
+   continue;
+
+   tdb_close(tdb);
+
+   tdb = tdb_open(run-12-store.tdb, flags[i] | TDB_VERSION1,
+  O_RDWR, 0600, tap_log_attr);
+   if (!ok1(tdb))
+   continue;
+   /* It's not a version1 */
+   ok1(!(tdb_get_flags(tdb)  TDB_VERSION1));
+
+   tdb_close(tdb);
+   }
+
+   ok1(tap_log_messages == 0);
+   return exit_status();
+}


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-10-31 Thread Rusty Russell
The branch, master has been updated
   via  4bc8b0c tdb2: use HAVE_LIBREPLACE instead of _SAMBA_BUILD_.
  from  c90870f s4:torture/smb2: fix compound.invalid2 against windows

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4bc8b0c19431072ae2b64a582fc70e491507ed1d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Nov 1 07:11:25 2011 +1030

tdb2: use HAVE_LIBREPLACE instead of _SAMBA_BUILD_.

This is what lib/tdb2 really wants: to know if it should use normal
headers or replace.h.  It currently uses _SAMBA_BUILD_, which is wrong
for ldb, for example.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Nov  1 03:19:58 CET 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb2/private.h |2 +-
 lib/tdb2/tdb.c |2 +-
 lib/tdb2/tdb2.h|6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 93ceb5f..87245a5 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -22,7 +22,7 @@
 #include ccan/likely/likely.h
 #include ccan/endian/endian.h
 
-#ifdef _SAMBA_BUILD_
+#ifdef HAVE_LIBREPLACE
 #include replace.h
 #include system/filesys.h
 #include system/time.h
diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index 6f38244..5e965ac 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -16,7 +16,7 @@
License along with this library; if not, see http://www.gnu.org/licenses/.
 */
 #include private.h
-#ifndef _SAMBA_BUILD_
+#ifndef HAVE_LIBREPLACE
 #include ccan/asprintf/asprintf.h
 #include stdarg.h
 #endif
diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h
index 6a7cab6..55ad309 100644
--- a/lib/tdb2/tdb2.h
+++ b/lib/tdb2/tdb2.h
@@ -29,8 +29,10 @@
 extern C {
 #endif
 
-#ifndef _SAMBA_BUILD_
 #include config.h
+#ifdef HAVE_LIBREPLACE
+#include replace.h
+#else
 #if HAVE_FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 64
 #endif
@@ -46,8 +48,6 @@ extern C {
 #include stdbool.h
 /* For memcmp */
 #include string.h
-#else
-#include replace.h
 #endif
 #include ccan/compiler/compiler.h
 #include ccan/typesafe_cb/typesafe_cb.h


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-10-13 Thread Rusty Russell
The branch, master has been updated
   via  5dcce64 config.h: define HAVE_LIBREPLACE
  from  88d997a samba-tool: Use self.outf in a few more places.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 5dcce64bbd64d1fbc81fa1135e77c87316691017
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 13 13:37:52 2011 +1030

config.h: define HAVE_LIBREPLACE

tdb2 wants to know if it should use replace.h.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Oct 13 08:58:35 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/replace/libreplace.m4 |2 ++
 lib/replace/wscript   |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index d644e50..bc2993a 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -71,6 +71,8 @@ AC_CHECK_HEADERS(setjmp.h utime.h)
 LIBREPLACE_PROVIDE_HEADER([stdint.h])
 LIBREPLACE_PROVIDE_HEADER([stdbool.h])
 
+AC_DEFINE(HAVE_LIBREPLACE, 1, [We have libreplace])
+
 AC_CHECK_TYPE(bool, 
 [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
 [
diff --git a/lib/replace/wscript b/lib/replace/wscript
index c24d6e7..57b10a9 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -29,6 +29,7 @@ def configure(conf):
 
 conf.env.standalone_replace = conf.IN_LAUNCH_DIR()
 
+conf.DEFINE('HAVE_LIBREPLACE', 1)
 conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
 
 # on Tru64 certain features are only available with _OSF_SOURCE set to 1


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-09-21 Thread Rusty Russell
The branch, master has been updated
   via  95b2e5a tdb2: change --enable-tdb2-breaks-compat to --enable-tdb2
   via  fb41dfb tdb_compat: add TDB_COMPAT_USE_TDB2 environment variable
   via  f08b323 tdb_compat: honour hashsize arg when using tdb2 with 
TDB_VERSION1 flag.
   via  10e6a32 tdb_compat: handle TDB_VOLATILE flag.
   via  36b455d9 tdb_compat: handle TDB_INCOMPATIBLE_HASH flag.
  from  ad3ac7e Try and fix bug #8472 - Crash in asn.1 parsing code.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 95b2e5aa56814e04f060403b8805c5c562805ee9
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 21 15:18:05 2011 +0930

tdb2: change --enable-tdb2-breaks-compat to --enable-tdb2

Since we no longer break compatibility, don't scare people.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Sep 21 09:25:11 CEST 2011 on sn-devel-104

commit fb41dfb77ff8b7822befcfb877e84ccdf06ab830
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 21 12:58:59 2011 +0930

tdb_compat: add TDB_COMPAT_USE_TDB2 environment variable

When BUILD_TDB2 is defined, add TDB_VERSION1 flag to all tdb_open()
calls, unless this flag is set.  This means we use the tdb1 on-disk
format unless the user specifically asks for tdb2.

We'd love to do this using loadparm, but we need to work with both
Samba 3 and Samba 4's loadparm, and they're not unified yet.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit f08b323a88658c3e52adce4fa346bc03274e2c36
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 21 12:57:59 2011 +0930

tdb_compat: honour hashsize arg when using tdb2 with TDB_VERSION1 flag.

We use the TDB_ATTRIBUTE_TDB1_HASHSIZE to set the hash size.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 10e6a3282098b3d4d94e72fa27f47825ef4e7f15
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 21 12:56:59 2011 +0930

tdb_compat: handle TDB_VOLATILE flag.

This is only meaningful when using the TDB_VERSION1 flag: we set the
attribute to control the maximum number of dead records (to 5, which is
what TDB_VOLATILE did for tdb1).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 36b455d95227f8ef2f08e3134e289b2862b319f9
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 21 12:55:59 2011 +0930

tdb_compat: handle TDB_INCOMPATIBLE_HASH flag.

This is only meaningful when using the TDB_VERSION1 flag: it is done
by using a magic hash value (which will fall back to the default hash
if that works instead).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb2/wscript|4 ++--
 lib/tdb_compat/tdb_compat.c |   35 +--
 lib/tdb_compat/tdb_compat.h |6 +++---
 3 files changed, 38 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/wscript b/lib/tdb2/wscript
index 0311caf..be5b8e2 100644
--- a/lib/tdb2/wscript
+++ b/lib/tdb2/wscript
@@ -21,8 +21,8 @@ def set_options(opt):
 opt.BUILTIN_DEFAULT('replace')
 opt.PRIVATE_EXTENSION_DEFAULT('tdb2', noextension='tdb2')
 opt.RECURSE('lib/replace')
-opt.add_option('--enable-tdb2-breaks-compat',
-   help=(Build tdb2 instead of tdb1 (BREAKS TDB1!) [False]),
+opt.add_option('--enable-tdb2',
+   help=(Use tdb2 API instead of tdb1 [False]),
action=store_true, dest='BUILD_TDB2', default=False)
 if opt.IN_LAUNCH_DIR():
 opt.add_option('--disable-python',
diff --git a/lib/tdb_compat/tdb_compat.c b/lib/tdb_compat/tdb_compat.c
index fd3a687..b37e6cc 100644
--- a/lib/tdb_compat/tdb_compat.c
+++ b/lib/tdb_compat/tdb_compat.c
@@ -85,7 +85,7 @@ static enum TDB_ERROR clear_if_first(int fd, void *unused)
 }
 
 struct tdb_context *
-tdb_open_compat_(const char *name, int hash_size_unused,
+tdb_open_compat_(const char *name, int hash_size,
 int tdb_flags, int open_flags, mode_t mode,
 void (*log_fn)(struct tdb_context *,
enum tdb_log_level,
@@ -94,7 +94,11 @@ tdb_open_compat_(const char *name, int hash_size_unused,
void *data),
 void *log_data)
 {
-   union tdb_attribute cif, log, *attr = NULL;
+   union tdb_attribute cif, log, hash, max_dead, hsize, *attr = NULL;
+
+   if (!getenv(TDB_COMPAT_USE_TDB2)) {
+   tdb_flags |= TDB_VERSION1;
+   }
 
if (log_fn) {
log.log.base.attr = TDB_ATTRIBUTE_LOG;
@@ -112,6 +116,33 @@ tdb_open_compat_(const char *name, int hash_size_unused,
tdb_flags

[SCM] Samba Shared Repository - branch master updated

2011-09-20 Thread Rusty Russell
The branch, master has been updated
   via  92c022f tdb2: allow readonly changes even while holding locks.
  from  da5224a s3:dbwrap_ctdb: skip the internal __db_sequence_number__ 
key from (persistent) traverse and traverse_read

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 92c022f04392e731ee1e5389ed021b54317da141
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Sep 20 12:02:43 2011 +0930

tdb2: allow readonly changes even while holding locks.

This happens in SAMBA with the TDB_VERSION1, presumably due to a
read-only traverse nested inside a normal traverse (since it doesn't
occur without TDB_VERSION1).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 24e5ddb143fb5e79112649472258f5da67cc7362)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Sep 20 09:35:10 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb2/tdb.c |   10 --
 1 files changed, 0 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index 9447816..6f38244 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -369,16 +369,6 @@ static bool readonly_changable(struct tdb_context *tdb, 
const char *caller)
 caller);
return false;
}
-
-   if (tdb-file-allrecord_lock.count != 0
-   || tdb-file-num_lockrecs != 0) {
-   tdb-last_error = tdb_logerr(tdb, TDB_ERR_EINVAL,
-TDB_LOG_USE_ERROR,
-%s: can't change
- TDB_RDONLY holding locks,
-caller);
-   return false;
-   }
return true;
 }
 


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-09-13 Thread Rusty Russell
The branch, master has been updated
   via  cb064f2 tdb2: remove bogus leftover .orig file.
  from  fbbfdbd Fix bug #8229 - git patch attached against 3.6.0-rc2 to fix 
'widelinks' regression intro'd in 3.2

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit cb064f28f976dcc74993bcbb88313618d7bba741
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Sep 14 11:58:20 2011 +0930

tdb2: remove bogus leftover .orig file.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Sep 14 06:06:41 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb2/private.h.orig |  618 ---
 1 files changed, 0 insertions(+), 618 deletions(-)
 delete mode 100644 lib/tdb2/private.h.orig


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/private.h.orig b/lib/tdb2/private.h.orig
deleted file mode 100644
index 38d5b50..000
--- a/lib/tdb2/private.h.orig
+++ /dev/null
@@ -1,618 +0,0 @@
-#ifndef TDB_PRIVATE_H
-#define TDB_PRIVATE_H
- /*
-   Trivial Database 2: private types and prototypes
-   Copyright (C) Rusty Russell 2010
-
-   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
-   version 3 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see http://www.gnu.org/licenses/.
-*/
-
-#include tdb2.h
-#include ccan/likely/likely.h
-#include ccan/endian/endian.h
-
-#ifdef _SAMBA_BUILD_
-#include replace.h
-#include system/filesys.h
-#include system/time.h
-#include system/shmem.h
-#include system/select.h
-#include system/wait.h
-#else
-#include stdint.h
-#include stdbool.h
-#include stdlib.h
-#include stddef.h
-#include sys/time.h
-#include sys/mman.h
-#include unistd.h
-#include fcntl.h
-#include errno.h
-#include stdio.h
-#include utime.h
-#include unistd.h
-#endif
-
-#ifndef TEST_IT
-#define TEST_IT(cond)
-#endif
-
-/* #define TDB_TRACE 1 */
-
-#ifndef __STRING
-#define __STRING(x)#x
-#endif
-
-#ifndef __STRINGSTRING
-#define __STRINGSTRING(x) __STRING(x)
-#endif
-
-#ifndef __location__
-#define __location__ __FILE__ : __STRINGSTRING(__LINE__)
-#endif
-
-typedef uint64_t tdb_len_t;
-typedef uint64_t tdb_off_t;
-
-#define TDB_MAGIC_FOOD TDB file\n
-#define TDB_VERSION ((uint64_t)(0x26011967 + 7))
-#define TDB_USED_MAGIC ((uint64_t)0x1999)
-#define TDB_HTABLE_MAGIC ((uint64_t)0x1888)
-#define TDB_CHAIN_MAGIC ((uint64_t)0x1777)
-#define TDB_FTABLE_MAGIC ((uint64_t)0x1666)
-#define TDB_FREE_MAGIC ((uint64_t)0xFE)
-#define TDB_HASH_MAGIC (0xA1ABE11A01092008ULL)
-#define TDB_RECOVERY_MAGIC (0xf53bc0e7ad124589ULL)
-#define TDB_RECOVERY_INVALID_MAGIC (0x0ULL)
-
-#define TDB_OFF_IS_ERR(off) unlikely(off = (tdb_off_t)TDB_ERR_LAST)
-
-/* Packing errors into pointers and v.v. */
-#define TDB_PTR_IS_ERR(ptr) \
-   unlikely((unsigned long)(ptr) = (unsigned long)TDB_ERR_LAST)
-#define TDB_PTR_ERR(p) ((enum TDB_ERROR)(long)(p))
-#define TDB_ERR_PTR(err) ((void *)(long)(err))
-
-/* Common case of returning true, false or -ve error. */
-typedef int tdb_bool_err;
-
-/* Prevent others from opening the file. */
-#define TDB_OPEN_LOCK 0
-/* Doing a transaction. */
-#define TDB_TRANSACTION_LOCK 1
-/* Expanding file. */
-#define TDB_EXPANSION_LOCK 2
-/* Hash chain locks. */
-#define TDB_HASH_LOCK_START 64
-
-/* Range for hash locks. */
-#define TDB_HASH_LOCK_RANGE_BITS 30
-#define TDB_HASH_LOCK_RANGE (1  TDB_HASH_LOCK_RANGE_BITS)
-
-/* We have 1024 entries in the top level. */
-#define TDB_TOPLEVEL_HASH_BITS 10
-/* And 64 entries in each sub-level: thus 64 bits exactly after 9 levels. */
-#define TDB_SUBLEVEL_HASH_BITS 6
-/* And 8 entries in each group, ie 8 groups per sublevel. */
-#define TDB_HASH_GROUP_BITS 3
-/* This is currently 10: beyond this we chain. */
-#define TDB_MAX_LEVELS (1+(64-TDB_TOPLEVEL_HASH_BITS) / TDB_SUBLEVEL_HASH_BITS)
-
-/* Extend file by least 100 times larger than needed. */
-#define TDB_EXTENSION_FACTOR 100
-
-/* We steal bits from the offsets to store hash info. */
-#define TDB_OFF_HASH_GROUP_MASK ((1ULL  TDB_HASH_GROUP_BITS) - 1)
-/* We steal this many upper bits, giving a maximum offset of 64 exabytes. */
-#define TDB_OFF_UPPER_STEAL 8
-#define   TDB_OFF_UPPER_STEAL_EXTRA 7
-/* The bit number where we store extra hash bits. */
-#define TDB_OFF_HASH_EXTRA_BIT 57
-#define

[SCM] Samba Shared Repository - branch master updated

2011-08-31 Thread Rusty Russell
The branch, master has been updated
   via  80f4a93 tdb2: add full LGPL headers
  from  cdce324 MAINTAINERS.txt: ping me about CCAN changes

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 80f4a936f27ff457855dbc21979fc4c0306ffb76
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Jul 21 14:44:50 2011 +0930

tdb2: add full LGPL headers

This is for SAMBA, so we follow their rules and do full license
headers.  Two files were missing them.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au
(Imported from CCAN commit 58025731)

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Aug 31 09:52:43 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb2/open.c |   17 +
 lib/tdb2/tdb.c  |   17 +
 2 files changed, 34 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb2/open.c b/lib/tdb2/open.c
index c35598c..63076ec 100644
--- a/lib/tdb2/open.c
+++ b/lib/tdb2/open.c
@@ -1,3 +1,20 @@
+ /*
+   Trivial Database 2: opening and closing TDBs
+   Copyright (C) Rusty Russell 2010
+
+   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
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+*/
 #include private.h
 #include ccan/hash/hash.h
 #include assert.h
diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index 753ccb0..82b9c32 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -1,3 +1,20 @@
+ /*
+   Trivial Database 2: fetch, store and misc routines.
+   Copyright (C) Rusty Russell 2010
+
+   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
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+*/
 #include private.h
 #ifndef _SAMBA_BUILD_
 #include ccan/asprintf/asprintf.h


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-08-30 Thread Rusty Russell
The branch, master has been updated
   via  cdce324 MAINTAINERS.txt: ping me about CCAN changes
   via  b88e0c4 ccan: fix likely redefinition warnings with --enable-tdb2
   via  b10ad70 tdb2: fix build with --enable-tdb2
  from  480a031 smb2_constants: add SMB2_HDR_CREDIT_CHARGE

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit cdce32470a9e6f16da5149c91989382390012663
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Aug 31 13:58:14 2011 +0930

MAINTAINERS.txt: ping me about CCAN changes

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Aug 31 07:58:34 CEST 2011 on sn-devel-104

commit b88e0c40b777480e101a7524697656d6a03fb563
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Aug 31 13:57:14 2011 +0930

ccan: fix likely redefinition warnings with --enable-tdb2

When we do --enable-tdb2, we start clashing with the replace.h
version:

In file included from ../lib/tdb2/tools/../private.h:25:0,
 from ../lib/tdb2/tools/tdb2torture.c:60:
../lib/ccan/likely/likely.h:32:0: warning: likely redefined
../lib/replace/replace.h:762:0: note: this is the location of the previous 
definition
../lib/ccan/likely/likely.h:53:0: warning: unlikely redefined
../lib/replace/replace.h:765:0: note: this is the location of the previous 
definition

I don't like to #ifndef-protect them in general, since you don't want
different parts of the code to silently have different definitions,
but it's the simplest fix for now.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit b10ad70f8fd5ee359b4409b373ba93ff050c82d4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Aug 31 13:56:40 2011 +0930

tdb2: fix build with --enable-tdb2

tdb2 doesn't expost tdb_jenkins_hash; go straight to the source in
ccan/hash.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 MAINTAINERS.txt|5 +
 lib/ccan/likely/likely.h   |8 
 source3/modules/vfs_shadow_copy2.c |5 ++---
 3 files changed, 15 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/MAINTAINERS.txt b/MAINTAINERS.txt
index 36e1840..9e40103 100644
--- a/MAINTAINERS.txt
+++ b/MAINTAINERS.txt
@@ -72,6 +72,11 @@ policy:
  Other non-trivial (typo, etc) commits require pre- or post-push 
review by the
  maintainer or one of the maintainers of the containing subsystem.
 
+files: lib/ccan
+maintainers:
+ Rusty Russell ru...@samba.org
+policy:
+ Please ping me when changes made, so I can sync with CCAN project.
 
 ===
 
diff --git a/lib/ccan/likely/likely.h b/lib/ccan/likely/likely.h
index c43d276..3a9c6d4 100644
--- a/lib/ccan/likely/likely.h
+++ b/lib/ccan/likely/likely.h
@@ -30,7 +30,9 @@
  * return false;
  * }
  */
+#ifndef likely
 #define likely(cond) __builtin_expect(!!(cond), 1)
+#endif
 
 /**
  * unlikely - indicate that a condition is unlikely to be true.
@@ -51,11 +53,17 @@
  * fprintf(stderr, Overflow!);
  * }
  */
+#ifndef unlikely
 #define unlikely(cond) __builtin_expect(!!(cond), 0)
+#endif
 #else
+#ifndef likely
 #define likely(cond) (!!(cond))
+#endif
+#ifndef unlikely
 #define unlikely(cond) (!!(cond))
 #endif
+#endif
 #else /* CCAN_LIKELY_DEBUG versions */
 #define likely(cond) \
(_likely_trace(!!(cond), 1, stringify(cond), __FILE__, __LINE__))
diff --git a/source3/modules/vfs_shadow_copy2.c 
b/source3/modules/vfs_shadow_copy2.c
index ca33b6d..4ac9e84 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -99,7 +99,7 @@
 #include system/filesys.h
 #include include/ntioctl.h
 #include smbd/proto.h
-#include tdb.h
+#include ccan/hash/hash.h
 #include util_tdb.h
 
 #define GMT_NAME_LEN 24 /* length of a @GMT- name */
@@ -438,9 +438,8 @@ static void convert_sbuf(vfs_handle_struct *handle, const 
char *fname,
   without significant VFS changes
*/
uint32_t shash;
-   TDB_DATA data = string_tdb_data(fname);
 
-   shash = tdb_jenkins_hash(data)  0xFF00;
+   shash = hash(fname, strlen(fname), 0)  0xFF00;
if (shash == 0) {
shash = 1;
}


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-08-16 Thread Rusty Russell
The branch, master has been updated
   via  ee720fc tdb: increment sequence number in tdb_wipe_all().
  from  689f42a s3:registry: enhance debugging of deletekey_recursive

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit ee720fc19cebf9108711429dfe25ccaf192e2c7e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Aug 16 16:47:03 2011 +0930

tdb: increment sequence number in tdb_wipe_all().

TDB2 testing revealed that tdb1 doesn't do this.  It's minor, but fix it.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Aug 16 10:47:41 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb/common/tdb.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 66be555..3a3c99c 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -886,6 +886,8 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
}
}
 
+   tdb_increment_seqnum_nonblock(tdb);
+
if (tdb_unlockall(tdb) != 0) {
TDB_LOG((tdb, TDB_DEBUG_FATAL,tdb_wipe_all: failed to 
unlock\n));
goto failed;


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-07-25 Thread Rusty Russell
The branch, master has been updated
   via  6e72370 lib/ccan: update to init-1192-gdd04041
   via  91bc5a0 lib/ccan: add README
  from  188b28b s4:auth/kerberos: activate windows related krb5 flags

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 6e72370fd7d55950820a6a8332cd4364e97ba28a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jul 25 18:18:27 2011 +0930

lib/ccan: update to init-1192-gdd04041

This imports licensing clarifications and updates as discussed on
samba-technical (Subject: Re: ccan code breaks older build farm
systems).

In particular, the recent version have per-file license markers, and
some modules are relicenced more liberally: in particular Simo pointed
out that htable was GPL, and indirectly included by libtdb2, which
would have made that GPL as well.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Jul 25 12:03:40 CEST 2011 on sn-devel-104

commit 91bc5a0d75c94285093cd43b2d7ba3bf5c4b4085
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Jul 25 18:07:11 2011 +0930

lib/ccan: add README

README points out that these code snippets have their own licenses,
and that their home is elsewhere.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/ccan/README  |9 +
 lib/ccan/array_size/_info|2 +-
 lib/ccan/array_size/array_size.h |1 +
 lib/ccan/asearch/asearch.h   |1 +
 lib/ccan/build_assert/_info  |2 +-
 lib/ccan/build_assert/build_assert.h |1 +
 lib/ccan/cast/LICENSE|  661 +
 lib/ccan/cast/_info  |2 +-
 lib/ccan/cast/cast.h |1 +
 lib/ccan/compiler/_info  |2 +-
 lib/ccan/endian/_info|2 +-
 lib/ccan/endian/endian.h |1 +
 lib/ccan/htable/LICENSE  |  679 +-
 lib/ccan/htable/_info|2 +-
 lib/ccan/htable/htable.c |1 +
 lib/ccan/htable/htable.h |1 +
 lib/ccan/htable/htable_type.h|1 +
 lib/ccan/ilog/_info  |2 +-
 lib/ccan/ilog/ilog.c |3 +-
 lib/ccan/ilog/ilog.h |1 +
 lib/ccan/likely/_info|2 +-
 lib/ccan/likely/likely.c |1 +
 lib/ccan/likely/likely.h |1 +
 lib/ccan/str/_info   |2 +-
 lib/ccan/str/debug.c |1 +
 lib/ccan/str/str.c   |1 +
 lib/ccan/str/str.h   |1 +
 lib/ccan/str/str_debug.h |1 +
 lib/ccan/tally/_info |2 +-
 lib/ccan/tally/tally.c   |1 +
 lib/ccan/tally/tally.h   |1 +
 lib/ccan/typesafe_cb/_info   |2 +-
 lib/ccan/typesafe_cb/typesafe_cb.h   |1 +
 33 files changed, 968 insertions(+), 424 deletions(-)
 create mode 100644 lib/ccan/README


Changeset truncated at 500 lines:

diff --git a/lib/ccan/README b/lib/ccan/README
new file mode 100644
index 000..5ba0a32
--- /dev/null
+++ b/lib/ccan/README
@@ -0,0 +1,9 @@
+These files are from the CCAN project (http://ccan.ozlabs.org); the
+_info and LICENSE files in each directory indicate their (separate)
+licenses.
+
+I'm trying to keep them in sync with the upstream versions as much as
+possible, so please be careful!
+
+Thanks!
+Rusty Russell ru...@rustcorp.com.au
diff --git a/lib/ccan/array_size/_info b/lib/ccan/array_size/_info
index af7ef1c..56ba799 100644
--- a/lib/ccan/array_size/_info
+++ b/lib/ccan/array_size/_info
@@ -29,7 +29,7 @@
  * return 0;
  * }
  *
- * License: LGPL (2 or any later version)
+ * License: LGPL (v2.1 or any later version)
  * Author: Rusty Russell ru...@rustcorp.com.au
  */
 int main(int argc, char *argv[])
diff --git a/lib/ccan/array_size/array_size.h b/lib/ccan/array_size/array_size.h
index 0876945..ae6e378 100644
--- a/lib/ccan/array_size/array_size.h
+++ b/lib/ccan/array_size/array_size.h
@@ -1,3 +1,4 @@
+/* Licensed under LGPLv2.1+ - see LICENSE file for details */
 #ifndef CCAN_ARRAY_SIZE_H
 #define CCAN_ARRAY_SIZE_H
 #include config.h
diff --git a/lib/ccan/asearch/asearch.h b/lib/ccan/asearch/asearch.h
index d252284..aae6eed 100644
--- a/lib/ccan/asearch/asearch.h
+++ b/lib/ccan/asearch/asearch.h
@@ -1,3 +1,4 @@
+/* Licensed under LGPLv2.1+ - see LICENSE file for details */
 #ifndef CCAN_ASEARCH_H
 #define CCAN_ASEARCH_H
 #include stdlib.h
diff --git a/lib/ccan/build_assert/_info b/lib/ccan/build_assert/_info
index 0906af0..284c6cf 100644
--- a/lib/ccan/build_assert/_info
+++ b/lib/ccan/build_assert/_info
@@ -33,7 +33,7

[SCM] Samba Shared Repository - branch master updated

2011-07-06 Thread Rusty Russell
The branch, master has been updated
   via  c019302 ccan/tally: don't use SIZE_MAX.
  from  44a016c build: we no longer put #if _SAMBA_BUILD_ == 4 in public 
headers

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit c019302e65051f214c5ea2ef908aa0ef79c8b12e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jul 6 14:47:44 2011 +0930

ccan/tally: don't use SIZE_MAX.

Michael Adam points out this broke the build farm (ie. OSF1 axp V5.1 2650 
alpha)
so fixed in CCAN and imported from af7a902d74a7926693f55da9e21a67dde46931d4:

Turns out it's not standard (thanks Samba build farm!)
And the previous test had a hole in it anyway.  This one is more 
conservative.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Jul  6 08:34:05 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/ccan/tally/tally.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c
index b1839be..396474b 100644
--- a/lib/ccan/tally/tally.c
+++ b/lib/ccan/tally/tally.c
@@ -27,8 +27,8 @@ struct tally *tally_new(unsigned buckets)
if (buckets == 0)
buckets = 1;
 
-   /* Check for overflow. */
-   if (buckets  SIZE_MAX / buckets  sizeof(tally-counts[0]))
+   /* Overly cautious check for overflow. */
+   if (sizeof(*tally) * buckets / sizeof(*tally) != buckets)
return NULL;
tally = malloc(sizeof(*tally) + sizeof(tally-counts[0])*(buckets-1));
if (tally) {


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-07-04 Thread Rusty Russell
The branch, master has been updated
   via  4e63ac6 ccan: fix configure tests for __builtin_clz etc.
  from  73140a1 build: remove mktowscript

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4e63ac6191e55bc602c7cba6e12e01f35985c6b1
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Jul 5 13:08:09 2011 +0930

ccan: fix configure tests for __builtin_clz etc.

It's not enough to compile-test them: Michael Adam points out that 
nonexistant
functions merely cause a warning.  We have to try to link them.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Jul  5 07:08:55 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/ccan/libccan.m4 |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/libccan.m4 b/lib/ccan/libccan.m4
index 92676c3..df38d3b 100644
--- a/lib/ccan/libccan.m4
+++ b/lib/ccan/libccan.m4
@@ -135,7 +135,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_clz],
   samba_cv_builtin_clz,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_clz(1) == (sizeof(int)*8 - 1) 
? 0 : 1;
}],
@@ -150,7 +150,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_clzl],
   samba_cv_builtin_clzl,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_clzl(1) == (sizeof(int)*8 - 1) 
? 0 : 1;
}],
@@ -164,7 +164,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_clzll],
   samba_cv_builtin_clzll,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_clzll(1) == (sizeof(int)*8 - 
1) ? 0 : 1;
}],
@@ -179,7 +179,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_constant_p],
   samba_cv_builtin_constant_p,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_constant_p(1) ? 0 : 1;
}],
@@ -194,7 +194,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_expect],
   samba_cv_builtin_expect,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_expect(main != 0) ? 0 : 1;
}],
@@ -209,7 +209,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_popcountl],
   samba_cv_builtin_popcountl,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_popcountl(255L) == 8 ? 0 : 1;
}],
@@ -224,7 +224,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_types_compatible_p],
   samba_cv_builtin_types_compatible_p,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[int main(void) {
return __builtin_types_compatible_p(char *, 
int) ? 1 : 0;
}],
@@ -255,7 +255,7 @@ fi
 AC_CACHE_CHECK([whether we have __builtin_have_isblank],
   samba_cv_builtin_have_isblank,
   [
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[#include ctype.h
 int main(void) { return isblank(' ') ? 0 : 1; }
],


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-06-20 Thread Rusty Russell
The branch, master has been updated
   via  894b027 lib/ccan/tally.h: update for FreeBSD compile.
  from  233a622 s4-param Autogenerate the loadparm_globals and 
loadparm_service tables

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 894b0273fcff28dfaef80ce7be1bcc35d47aed65
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Jun 21 11:20:07 2011 +0930

lib/ccan/tally.h: update for FreeBSD compile.

Based on commit 0284423676209380a2e07086b9b356096a2f93e6 from CCAN:
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Jun 21 10:43:31 2011 +0930

tally: fix FreeBSD compile, memleak in tests.

Posix says ssize_t is in sys/types.h; on Linux stdlib.h is enough.

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Jun 21 05:52:12 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/ccan/tally/tally.c|2 +-
 lib/ccan/tally/tally.h|3 ++-
 lib/ccan/tally/test/run-mean.c|1 +
 lib/ccan/tally/test/run-median.c  |1 +
 lib/ccan/tally/test/run-min-max.c |1 +
 lib/ccan/tally/test/run-mode.c|1 +
 lib/ccan/tally/test/run-renormalize.c |1 +
 7 files changed, 8 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c
index 0d01907..b1839be 100644
--- a/lib/ccan/tally/tally.c
+++ b/lib/ccan/tally/tally.c
@@ -1,4 +1,3 @@
-#include config.h
 #include ccan/tally/tally.h
 #include ccan/build_assert/build_assert.h
 #include ccan/likely/likely.h
@@ -7,6 +6,7 @@
 #include string.h
 #include stdio.h
 #include assert.h
+#include stdlib.h
 
 #define SIZET_BITS (sizeof(size_t)*CHAR_BIT)
 
diff --git a/lib/ccan/tally/tally.h b/lib/ccan/tally/tally.h
index e715717..650e265 100644
--- a/lib/ccan/tally/tally.h
+++ b/lib/ccan/tally/tally.h
@@ -1,6 +1,7 @@
 #ifndef CCAN_TALLY_H
 #define CCAN_TALLY_H
-#include stdlib.h
+#include config.h
+#include sys/types.h
 
 struct tally;
 
diff --git a/lib/ccan/tally/test/run-mean.c b/lib/ccan/tally/test/run-mean.c
index a4a67cf..b43dea6 100644
--- a/lib/ccan/tally/test/run-mean.c
+++ b/lib/ccan/tally/test/run-mean.c
@@ -25,5 +25,6 @@ int main(void)
ok1(tally_mean(tally) == 0);
}
 
+   free(tally);
return exit_status();
 }
diff --git a/lib/ccan/tally/test/run-median.c b/lib/ccan/tally/test/run-median.c
index f461c2e..b12fd8a 100644
--- a/lib/ccan/tally/test/run-median.c
+++ b/lib/ccan/tally/test/run-median.c
@@ -40,6 +40,7 @@ int main(void)
ok1(median - (ssize_t)err = i/2
 median + (ssize_t)err = i/2);
}
+   free(tally);
 
return exit_status();
 }
diff --git a/lib/ccan/tally/test/run-min-max.c 
b/lib/ccan/tally/test/run-min-max.c
index ffb0f2e..c92f6d3 100644
--- a/lib/ccan/tally/test/run-min-max.c
+++ b/lib/ccan/tally/test/run-min-max.c
@@ -16,5 +16,6 @@ int main(void)
ok1(tally_max(tally) == i);
ok1(tally_min(tally) == -i);
}
+   free(tally);
return exit_status();
 }
diff --git a/lib/ccan/tally/test/run-mode.c b/lib/ccan/tally/test/run-mode.c
index 7216738..cd2f230 100644
--- a/lib/ccan/tally/test/run-mode.c
+++ b/lib/ccan/tally/test/run-mode.c
@@ -41,5 +41,6 @@ int main(void)
ok1(mode - (ssize_t)err = 0  mode + (ssize_t)err = 0);
}
 
+   free(tally);
return exit_status();
 }
diff --git a/lib/ccan/tally/test/run-renormalize.c 
b/lib/ccan/tally/test/run-renormalize.c
index 7c14152..8fe9dbc 100644
--- a/lib/ccan/tally/test/run-renormalize.c
+++ b/lib/ccan/tally/test/run-renormalize.c
@@ -21,5 +21,6 @@ int main(void)
ok1(tally-counts[0] == 2);
ok1(tally-counts[1] == 0);
 
+   free(tally);
return exit_status();
 }


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-06-08 Thread Rusty Russell
The branch, master has been updated
   via  4fa5125 tdb: enable VALGRIND to remove valgrind noise.
  from  4afe426 s4-ipv6: fill in pdc_ip in DsRGetDCNameEx2

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 4fa51257b283c2e8bb415cc7f9c001d64c8a2669
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 8 17:20:48 2011 +0930

tdb: enable VALGRIND to remove valgrind noise.

Andrew Bartlett complained that valgrind needs --partial-loads-ok=yes 
otherwise
the Jenkins hash makes it complain.

My benchmarking here revealed that at least with modern gcc (4.5) and CPU
(Intel i5 32 bit) there's no measurable performance penalty for the
correct code, so rip out the optimized one.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Jun  8 11:05:47 CEST 2011 on sn-devel-104

---

Summary of changes:
 lib/tdb/common/hash.c |   35 ---
 1 files changed, 0 insertions(+), 35 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/hash.c b/lib/tdb/common/hash.c
index 2472ed1..1eed722 100644
--- a/lib/tdb/common/hash.c
+++ b/lib/tdb/common/hash.c
@@ -214,9 +214,7 @@ static uint32_t hashlittle( const void *key, size_t length )
   u.ptr = key;
   if (HASH_LITTLE_ENDIAN  ((u.i  0x3) == 0)) {
 const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
-#ifdef VALGRIND
 const uint8_t  *k8;
-#endif
 
 /*-- all but last block: aligned reads and affect 32 bits of (a,b,c) */
 while (length  12)
@@ -230,36 +228,6 @@ static uint32_t hashlittle( const void *key, size_t length 
)
 }
 
 /*- handle the last (probably partial) block */
-/*
- * k[2]0xff actually reads beyond the end of the string, but
- * then masks off the part it's not allowed to read.  Because the
- * string is aligned, the masked-off tail is in the same word as the
- * rest of the string.  Every machine with memory protection I've seen
- * does it on word boundaries, so is OK with this.  But VALGRIND will
- * still catch it and complain.  The masking trick does make the hash
- * noticably faster for short strings (like English words).
- */
-#ifndef VALGRIND
-
-switch(length)
-{
-case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
-case 11: c+=k[2]0xff; b+=k[1]; a+=k[0]; break;
-case 10: c+=k[2]0x; b+=k[1]; a+=k[0]; break;
-case 9 : c+=k[2]0xff; b+=k[1]; a+=k[0]; break;
-case 8 : b+=k[1]; a+=k[0]; break;
-case 7 : b+=k[1]0xff; a+=k[0]; break;
-case 6 : b+=k[1]0x; a+=k[0]; break;
-case 5 : b+=k[1]0xff; a+=k[0]; break;
-case 4 : a+=k[0]; break;
-case 3 : a+=k[0]0xff; break;
-case 2 : a+=k[0]0x; break;
-case 1 : a+=k[0]0xff; break;
-case 0 : return c;  /* zero length strings require no mixing */
-}
-
-#else /* make valgrind happy */
-
 k8 = (const uint8_t *)k;
 switch(length)
 {
@@ -277,9 +245,6 @@ static uint32_t hashlittle( const void *key, size_t length )
 case 1 : a+=k8[0]; break;
 case 0 : return c;
 }
-
-#endif /* !valgrind */
-
   } else if (HASH_LITTLE_ENDIAN  ((u.i  0x1) == 0)) {
 const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
 const uint8_t  *k8;


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-06-02 Thread Rusty Russell
The branch, master has been updated
   via  43ab5aa lib/tdb/python/tests/simple.py: don't assume TDB ordering.
   via  2f67fae samba3sam.py: don't assume order of ldb results.
  from  e98fb2f Remove another PATH_MAX.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 43ab5aa390769ee9b57918cf5b57aa4a22586805
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Jun 2 14:19:38 2011 +0930

lib/tdb/python/tests/simple.py: don't assume TDB ordering.

TDB2 can break this assumption.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Thu Jun  2 12:07:40 CEST 2011 on sn-devel-104

commit 2f67fae18be13f4bfce009e8639bab74383844cb
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Jun 2 10:22:06 2011 +0930

samba3sam.py: don't assume order of ldb results.

Switching to tdb2 breaks this test horribly, because it relied on the
order of TDB1 traversal.  Fix it to sort te results (by db), then
check them.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/python/tests/simple.py|4 +-
 source4/scripting/python/samba/tests/samba3sam.py |  306 +++--
 2 files changed, 167 insertions(+), 143 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index f5484a0..99f31d2 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -105,7 +105,9 @@ class SimpleTdbTests(TestCase):
 def test_iterator(self):
 self.tdb[bla] = 1
 self.tdb[brainslug] = 2
-self.assertEquals([bla, brainslug], list(self.tdb))
+l = list(self.tdb)
+l.sort()
+self.assertEquals([bla, brainslug], l)
 
 def test_transaction_cancel(self):
 self.tdb[bloe] = 2
diff --git a/source4/scripting/python/samba/tests/samba3sam.py 
b/source4/scripting/python/samba/tests/samba3sam.py
index a34f0f6..99b9c06 100644
--- a/source4/scripting/python/samba/tests/samba3sam.py
+++ b/source4/scripting/python/samba/tests/samba3sam.py
@@ -30,6 +30,7 @@ from samba.tests import TestCaseInTempDir, env_loadparm
 import samba.dcerpc.security
 import samba.ndr
 from samba.auth import system_session
+from operator import attrgetter
 
 
 def read_datafile(filename):
@@ -439,34 +440,37 @@ objectSid: S-1-5-21-4231626423-2410014848-2360679739-552
 res = self.ldb.search(expression=(revision=x), scope=SCOPE_DEFAULT, 
 attrs=[dnsHostName, lastLogon])
 self.assertEquals(len(res), 2)
-self.assertEquals(str(res[0].dn), self.samba4.dn(cn=Y))
-self.assertEquals(str(res[0][dnsHostName]), y)
-self.assertEquals(str(res[0][lastLogon]), y)
-self.assertEquals(str(res[1].dn), self.samba4.dn(cn=X))
-self.assertEquals(str(res[1][dnsHostName]), x)
-self.assertEquals(str(res[1][lastLogon]), x)
+res = sorted(res, key=attrgetter('dn'))
+self.assertEquals(str(res[0].dn), self.samba4.dn(cn=X))
+self.assertEquals(str(res[0][dnsHostName]), x)
+self.assertEquals(str(res[0][lastLogon]), x)
+self.assertEquals(str(res[1].dn), self.samba4.dn(cn=Y))
+self.assertEquals(str(res[1][dnsHostName]), y)
+self.assertEquals(str(res[1][lastLogon]), y)
 
 # Search by kept attribute
 res = self.ldb.search(expression=(description=y), 
 scope=SCOPE_DEFAULT, attrs=[dnsHostName, lastLogon])
 self.assertEquals(len(res), 2)
-self.assertEquals(str(res[0].dn), self.samba4.dn(cn=Z))
-self.assertEquals(str(res[0][dnsHostName]), z)
+res = sorted(res, key=attrgetter('dn'))
+self.assertEquals(str(res[0].dn), self.samba4.dn(cn=C))
+self.assertTrue(not dnsHostName in res[0])
 self.assertEquals(str(res[0][lastLogon]), z)
-self.assertEquals(str(res[1].dn), self.samba4.dn(cn=C))
-self.assertTrue(not dnsHostName in res[1])
+self.assertEquals(str(res[1].dn), self.samba4.dn(cn=Z))
+self.assertEquals(str(res[1][dnsHostName]), z)
 self.assertEquals(str(res[1][lastLogon]), z)
 
 # Search by renamed attribute
 res = self.ldb.search(expression=(badPwdCount=x), 
scope=SCOPE_DEFAULT,
   attrs=[dnsHostName, lastLogon])
 self.assertEquals(len(res), 2)
-self.assertEquals(str(res[0].dn), self.samba4.dn(cn=B))
+res = sorted(res, key=attrgetter('dn'))
+self.assertEquals(str(res[0].dn), self.samba4.dn(cn=A))
 self.assertTrue(not dnsHostName in res[0])
-self.assertEquals(str(res[0][lastLogon]), y)
-self.assertEquals(str(res[1].dn), self.samba4.dn(cn=A))
+self.assertEquals(str(res

[SCM] Samba Shared Repository - branch master updated

2011-06-01 Thread Rusty Russell
The branch, master has been updated
   via  e340cd8 lib/tevent/tevent.h: minor documentation fix.
   via  c29069e libcli/cldap/cldap.c: don't hand huge values to 
tevent_timeval_add usecs
   via  0204ae6 lib/util/time.c: timeval_current_ofs_usec
   via  56e7233 lib/util/time.c: timeval_current_ofs_msec
  from  9bd695c samba-tool: update tests for new 'user enable' syntax

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit e340cd83f87a9ea02cacd9af520d154652c5afb1
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 1 12:20:11 2011 +0930

lib/tevent/tevent.h: minor documentation fix.

The usecs arguments are (of course) microseconds, not milliseconds.
This was added by Andreas Schneider in 6c1bcdc2 (tevent: Document the
tevent helper functions.).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Jun  1 11:47:38 CEST 2011 on sn-devel-104

commit c29069e079018853867d643b8de604edd95c94d9
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 1 12:20:08 2011 +0930

libcli/cldap/cldap.c: don't hand huge values to tevent_timeval_add usecs

state-request.delay is two million here, resulting in an invalid timeval.
Since tevent doesn't have a convenient wrapper to add arbitrary usecs,
do the arithmetic here (it's the sole caller of this function).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 0204ae6229bae3573b3194c3f657c8f385c0b940
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 1 11:24:51 2011 +0930

lib/util/time.c: timeval_current_ofs_usec

Several places want microseconds from current time, and several were
simply handing usecs values which could be over a million.

Using a helper to do this is safer and more readable.

I didn't replace any obviously correct callers (ie. constants).

I also renamed wait_nsec in source3/lib/util_sock.c; it's actually
microseconds not nanoseconds (introduced with this code in Volker's
19b783cc Async wrapper for open_socket_out_send/recv).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 56e72337b01216dc7cba418f040a5cc928e5fc6f
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Jun 1 11:21:15 2011 +0930

lib/util/time.c: timeval_current_ofs_msec

Several places want milliseconds from current time, and several were
simply doing msec * 1000 which can (and does in one place) result in
a usec value over 1 a million.

Using a helper to do this is safer and more readable.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tevent/tevent.h|6 +++---
 lib/util/time.c|   18 ++
 lib/util/time.h|   10 ++
 libcli/cldap/cldap.c   |6 --
 source3/lib/util_sock.c|   14 +++---
 source3/libsmb/async_smb.c |3 +--
 source3/nmbd/nmbd_processlogon.c   |3 +--
 source3/rpc_client/rpc_transport_tstream.c |6 +++---
 source3/smbd/blocking.c|3 +--
 source3/smbd/fileio.c  |2 +-
 source3/smbd/smb2_lock.c   |4 +---
 source4/lib/socket/connect_multi.c |2 +-
 source4/libcli/raw/clitransport.c  |2 +-
 source4/ntvfs/posix/pvfs_lock.c|3 +--
 source4/ntvfs/posix/pvfs_open.c|2 +-
 source4/ntvfs/posix/pvfs_write.c   |2 +-
 16 files changed, 55 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index f4eb60c..38a4a9c 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -1218,7 +1218,7 @@ struct timeval tevent_timeval_current(void);
  *
  * @param[in]  secs The seconds to set.
  *
- * @param[in]  usecsThe milliseconds to set.
+ * @param[in]  usecsThe microseconds to set.
  *
  * @return  A timeval structure with the given values.
  */
@@ -1253,7 +1253,7 @@ bool tevent_timeval_is_zero(const struct timeval *tv);
  *
  * @param[in]  secs  The seconds to add to the timeval.
  *
- * @param[in]  usecs The milliseconds to add to the timeval.
+ * @param[in]  usecs The microseconds to add to the timeval.
  *
  * @return   The timeval structure with the new time.
  */
@@ -1265,7 +1265,7 @@ struct timeval tevent_timeval_add(const struct timeval 
*tv, uint32_t secs,
  *
  * @param[in]  secs The seconds of the offset from now.
  *
- * @param[in]  usecsThe milliseconds of the offset from now.
+ * @param[in]  usecsThe microseconds of the offset from now.
  *
  * @return

[SCM] Samba Shared Repository - branch master updated

2011-05-10 Thread Rusty Russell
The branch, master has been updated
   via  87e3542 async_smb.c: convert cli-timeout properly
  from  0d93eb8 tdb_wrap.h: not a public header.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 87e35421744df568721a7f9c7fa141d62665d183
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue May 10 17:33:11 2011 +0930

async_smb.c: convert cli-timeout properly

I have a test failure on my 32-bit Ubuntu system, in that
samba3.smbtorture_s3.plain(s3dc).LOCK9 immediately times out (rather than
waiting 5 seconds for the child).

Debugging revealed this code: timeout is in ms and is set to  1000 in
various places.  The code dates from 2002, and other perturbations didn't
reveal why it breaks now, but fix it anyway.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue May 10 12:09:07 CEST 2011 on sn-devel-104

---

Summary of changes:
 source3/libsmb/async_smb.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 0e43924..82dbc74 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -426,7 +426,8 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
state-iov_count = iov_count + 3;
 
if (cli-timeout) {
-   endtime = timeval_current_ofs(0, cli-timeout * 1000);
+   endtime = timeval_current_ofs(cli-timeout / 1000,
+ (cli-timeout % 1000) * 1000);
if (!tevent_req_set_endtime(result, ev, endtime)) {
tevent_req_nomem(NULL, result);
}


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2011-05-09 Thread Rusty Russell
The branch, master has been updated
   via  0d93eb8 tdb_wrap.h: not a public header.
   via  7deeaca gencache: don't use CLEAR_IF_FIRST as fallback.
   via  3ccfe7c Add -fno-common where supported (WAF only)
  from  14f9916 build: Remove --disable-s3build so we can rely on these 
subsystems

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 0d93eb8f5501c348451a7d78e83516873d71cda0
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue May 10 11:46:53 2011 +0930

tdb_wrap.h: not a public header.

It is a private library, and OpenChange has their own which they use, so
it's not for them either.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue May 10 05:21:19 CEST 2011 on sn-devel-104

commit 7deeacae2bab03d5e2ea2642f028a4011ce3bec3
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Apr 19 12:06:05 2011 +0930

gencache: don't use CLEAR_IF_FIRST as fallback.

CLEAR_IF_FIRST only works if *all* openers use that flag.

So just truncate the file: it's racy, but that's what we're doing anyway.

We'd really need a TDB_OPENCHECK_OR_CLEAR flag to do this properly (or in
TDB2, a open hook at the right point).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 3ccfe7cb7be80cc6fa5b8fc437af72168515b892
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue May 10 11:37:30 2011 +0930

Add -fno-common where supported (WAF only)

Normally under UNIX, uninitialized non-static global variables get
placed in the common section, where they are merged at link time.
This means if two C files define int debug, they will end up
referring to the same variable.  Or if one does float level and the
other does int level you'll get an accidental union.

Such bugs can be hard to track down; fortunately GCC offers
-fno-common to disable this feature.  It didn't reveal any places
which need fixing, however).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 buildtools/wafsamba/samba_autoconf.py |2 +-
 lib/util/wscript_build|1 -
 source3/lib/gencache.c|   10 +++---
 source3/libsmb/samlogon_cache.c   |   13 +++--
 4 files changed, 7 insertions(+), 19 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_autoconf.py 
b/buildtools/wafsamba/samba_autoconf.py
index 174ca14..207d732 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -597,7 +597,7 @@ def SAMBA_CONFIG_H(conf, path=None):
 
 if Options.options.developer:
 # we add these here to ensure that -Wstrict-prototypes is not set 
during configure
-conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith 
-Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 
-Wno-format-y2k -Wmissing-prototypes',
+conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith 
-Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 
-Wno-format-y2k -Wmissing-prototypes -fno-common',
 testflags=True)
 if os.getenv('TOPLEVEL_BUILD'):
 conf.ADD_CFLAGS('-Wcast-qual', testflags=True)
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index fc5f4b5..740e68b 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -113,7 +113,6 @@ bld.SAMBA_SUBSYSTEM('UTIL_PW',
 bld.SAMBA_LIBRARY('tdb-wrap',
   source='tdb_wrap.c',
   deps='tdb talloc samba-util',
-  public_headers='tdb_wrap.h',
   private_library=True,
   local_include=False
   )
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 7a86063..8d4861a 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -81,14 +81,10 @@ again:
return false;
}
first_try = false;
-   DEBUG(0, (gencache_init: tdb_check(%s) failed - retry 
after CLEAR_IF_FIRST\n,
+   DEBUG(0, (gencache_init: tdb_check(%s) failed - retry 
after truncate\n,
  cache_fname));
-   cache = tdb_open_log(cache_fname, 0, 
TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, open_flags, 0644);
-   if (cache) {
-   tdb_close(cache);
-   cache = NULL;
-   goto again;
-   }
+   truncate(cache_fname, 0);
+   goto again;
}
}
 
diff --git a/source3

[SCM] Samba Shared Repository - branch master updated

2011-04-19 Thread Rusty Russell
The branch, master has been updated
   via  36cfa7b tdb: make sure we skip over recovery area correctly.
   via  cb88418 tdb_expand: limit the expansion with huge records
   via  094ab60 tdb: tdb_repack() only when it's worthwhile.
   via  6aa72da tdb: fix transaction recovery area for converted tdbs.
  from  dfb490d selftest Consolidate server wall clock time limits

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 36cfa7b79e36d880cdbf24d0769558be44d0edda
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Apr 19 21:00:59 2011 +0930

tdb: make sure we skip over recovery area correctly.

If it's really the recovery area, we can trust the rec_len field, and
don't have to go groping for bitpatterns.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Tue Apr 19 14:15:22 CEST 2011 on sn-devel-104

commit cb884186a55c9ef8aca6ee48b16423b3c881e689
Author: Simo Sorce i...@samba.org
Date:   Mon Apr 18 22:15:11 2011 +0930

tdb_expand: limit the expansion with huge records

ldb can create huge records when saving indexes.
Limit the tdb expansion to avoid consuming a lot of memory for
no good reason if the record being saved is huge.

commit 094ab60053bcc0bc3542af8144e394d83270053e
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Apr 18 22:15:11 2011 +0930

tdb: tdb_repack() only when it's worthwhile.

tdb_repack() is expensive and consumes memory, so we can spend some
effort to see if it's worthwhile.  In particular, tdbbackup doesn't
need to repack: it started with an empty database!

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 6aa72dae8fc341de5b497f831ded1f8f519fa8fb
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Apr 18 22:15:11 2011 +0930

tdb: fix transaction recovery area for converted tdbs.

This is why macros are dangerous; these were converting the pointers, not 
the
things pointed to!

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/io.c  |   25 ++--
 lib/tdb/common/summary.c |   13 +-
 lib/tdb/common/tdb_private.h |4 ++
 lib/tdb/common/transaction.c |   87 +++---
 4 files changed, 99 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 058ca6c..78bbf2e 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -299,7 +299,7 @@ static int tdb_expand_file(struct tdb_context *tdb, 
tdb_off_t size, tdb_off_t ad
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
 {
struct tdb_record rec;
-   tdb_off_t offset, new_size; 
+   tdb_off_t offset, new_size, top_size, map_size;
 
if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, lock failed in tdb_expand\n));
@@ -309,10 +309,25 @@ int tdb_expand(struct tdb_context *tdb, tdb_off_t size)
/* must know about any previous expansions by another process */
tdb-methods-tdb_oob(tdb, tdb-map_size + 1, 1);
 
-   /* always make room for at least 100 more records, and at
-   least 25% more space. Round the database up to a multiple
-   of the page size */
-   new_size = MAX(tdb-map_size + size*100, tdb-map_size * 1.25);
+   /* limit size in order to avoid using up huge amounts of memory for
+* in memory tdbs if an oddball huge record creeps in */
+   if (size  100 * 1024) {
+   top_size = tdb-map_size + size * 2;
+   } else {
+   top_size = tdb-map_size + size * 100;
+   }
+
+   /* always make room for at least top_size more records, and at
+  least 25% more space. if the DB is smaller than 100MiB,
+  otherwise grow it by 10% only. */
+   if (tdb-map_size  100 * 1024 * 1024) {
+   map_size = tdb-map_size * 1.10;
+   } else {
+   map_size = tdb-map_size * 1.25;
+   }
+
+   /* Round the database up to a multiple of the page size */
+   new_size = MAX(top_size, map_size);
size = TDB_ALIGN(new_size, tdb-page_size) - tdb-map_size;
 
if (!(tdb-flags  TDB_INTERNAL))
diff --git a/lib/tdb/common/summary.c b/lib/tdb/common/summary.c
index b222a59..171a1a2 100644
--- a/lib/tdb/common/summary.c
+++ b/lib/tdb/common/summary.c
@@ -86,12 +86,13 @@ static size_t get_hash_length(struct tdb_context *tdb, 
unsigned int i)
 
 _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
 {
-   tdb_off_t off;
+   tdb_off_t off, rec_off;
struct tally freet, keys, data, dead, extra, hash, uncoal;
struct tdb_record rec;
char *ret = NULL;
bool locked;
size_t len, unc

[SCM] Samba Shared Repository - branch master updated

2010-12-29 Thread Rusty Russell
The branch, master has been updated
   via  cac5732 tdb: tdb_summary() support.
  from  9b31f6ab Fix bug #7892 - open_file_fchmod() leaves a stale lock.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit cac57328a6077dc428396402036636095f139569
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Dec 29 12:50:47 2010 +1030

tdb: tdb_summary() support.

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Wed Dec 29 10:12:05 CET 2010 on sn-devel-104

---

Summary of changes:
 lib/tdb/common/check.c   |4 +-
 lib/tdb/common/summary.c |  192 ++
 lib/tdb/common/tdb_private.h |1 +
 lib/tdb/include/tdb.h|1 +
 lib/tdb/libtdb.m4|2 +-
 lib/tdb/tools/tdbtool.c  |   12 ++-
 lib/tdb/wscript  |4 +-
 7 files changed, 206 insertions(+), 10 deletions(-)
 create mode 100644 lib/tdb/common/summary.c


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index bbb566c..3387fbd 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -308,7 +308,7 @@ static bool tdb_check_free_record(struct tdb_context *tdb,
 }
 
 /* Slow, but should be very rare. */
-static size_t dead_space(struct tdb_context *tdb, tdb_off_t off)
+size_t tdb_dead_space(struct tdb_context *tdb, tdb_off_t off)
 {
size_t len;
 
@@ -406,7 +406,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
found_recovery = true;
break;
}
-   dead = dead_space(tdb, off);
+   dead = tdb_dead_space(tdb, off);
if (dead  sizeof(rec))
goto corrupt;
 
diff --git a/lib/tdb/common/summary.c b/lib/tdb/common/summary.c
new file mode 100644
index 000..29959f9
--- /dev/null
+++ b/lib/tdb/common/summary.c
@@ -0,0 +1,192 @@
+ /* 
+   Trivial Database: human-readable summary code
+   Copyright (C) Rusty Russell 2010
+   
+   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
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+*/
+#include tdb_private.h
+
+#define SUMMARY_FORMAT \
+   Size of file/data: %u/%zu\n \
+   Number of records: %zu\n \
+   Smallest/average/largest keys: %zu/%zu/%zu\n \
+   Smallest/average/largest data: %zu/%zu/%zu\n \
+   Smallest/average/largest padding: %zu/%zu/%zu\n \
+   Number of dead records: %zu\n \
+   Smallest/average/largest dead records: %zu/%zu/%zu\n \
+   Number of free records: %zu\n \
+   Smallest/average/largest free records: %zu/%zu/%zu\n \
+   Number of hash chains: %zu\n \
+   Smallest/average/largest hash chains: %zu/%zu/%zu\n \
+   Number of uncoalesced records: %zu\n \
+   Smallest/average/largest uncoalesced runs: %zu/%zu/%zu\n \
+   Percentage keys/data/padding/free/dead/rechdrstailers/hashes: 
%.0f/%.0f/%.0f/%.0f/%.0f/%.0f/%.0f\n
+
+/* We don't use tally module, to keep upstream happy. */
+struct tally {
+   size_t min, max, total;
+   size_t num;
+};
+
+static void tally_init(struct tally *tally)
+{
+   tally-total = 0;
+   tally-num = 0;
+   tally-min = tally-max = 0;
+}
+
+static void tally_add(struct tally *tally, size_t len)
+{
+   if (tally-num == 0)
+   tally-max = tally-min = len;
+   else if (len  tally-max)
+   tally-max = len;
+   else if (len  tally-min)
+   tally-min = len;
+   tally-num++;
+   tally-total += len;
+}
+
+static size_t tally_mean(const struct tally *tally)
+{
+   if (!tally-num)
+   return 0;
+   return tally-total / tally-num;
+}
+
+static size_t get_hash_length(struct tdb_context *tdb, unsigned int i)
+{
+   tdb_off_t rec_ptr;
+   size_t count = 0;
+
+   if (tdb_ofs_read(tdb, TDB_HASH_TOP(i), rec_ptr) == -1)
+   return 0;
+
+   /* keep looking until we find the right record */
+   while (rec_ptr) {
+   struct tdb_record r;
+   ++count;
+   if (tdb_rec_read(tdb, rec_ptr, r) == -1)
+   return 0;
+   rec_ptr = r.next;
+   }
+   return count;
+}
+
+_PUBLIC_

[SCM] Samba Shared Repository - branch master updated

2010-12-05 Thread Rusty Russell
The branch, master has been updated
   via  521e96c idtree: fix overflow for v. large ids on allocation and 
removal
  from  af5649d s4-repl_meta_data: Print function name when we can't find 
attribute in Schema cache

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 521e96ca751df072e5c71d3844ed5708b79ac69d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Dec 6 13:35:50 2010 +1030

idtree: fix overflow for v. large ids on allocation and removal

Chris Cowan tracked down a SEGV in sub_alloc: idp-level can actually
be equal to 7 (MAX_LEVEL) there, as it can be in sub_remove.

(We unfairly blamed a shift of a signed var for this crash in commit
 2db1987f5a3a).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@rustcorp.com.au
Autobuild-Date: Mon Dec  6 05:02:22 CET 2010 on sn-devel-104

---

Summary of changes:
 lib/util/idtree.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/idtree.c b/lib/util/idtree.c
index 6611992..3648761 100644
--- a/lib/util/idtree.c
+++ b/lib/util/idtree.c
@@ -104,7 +104,7 @@ static int sub_alloc(struct idr_context *idp, void *ptr, 
int *starting_id)
 {
int n, m, sh;
struct idr_layer *p, *pn;
-   struct idr_layer *pa[MAX_LEVEL];
+   struct idr_layer *pa[MAX_LEVEL+1];
unsigned int l, id, oid;
uint32_t bm;
 


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2010-10-06 Thread Rusty Russell
The branch, master has been updated
   via  2db1987 idtree: fix right shift of signed ints, crash on large ids 
on AIX
  from  58c1d0c s4-heimdal: disable using the system compile_et for now

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 2db1987f5a3a4268ce64fe570ff598e3bf4ecc73
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Oct 5 13:06:19 2010 +1030

idtree: fix right shift of signed ints, crash on large ids on AIX

Right-shifting signed integers in undefined; indeed it seems that on
AIX with their compiler, doing a 30-bit shift on (INT_MAX-200) gives
0, not 1 as we might expect.

The obvious fix is to make id and oid unsigned: l (level count) is also
logically unsigned.

(Note: Samba doesn't generally get to ids  1 billion, but ctdb does)

Reported-by: Chris Cowan c...@us.ibm.com
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

Autobuild-User: Rusty Russell ru...@samba.org
Autobuild-Date: Wed Oct  6 08:31:09 UTC 2010 on sn-devel-104

---

Summary of changes:
 lib/util/idtree.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/idtree.c b/lib/util/idtree.c
index c147961..6611992 100644
--- a/lib/util/idtree.c
+++ b/lib/util/idtree.c
@@ -105,7 +105,7 @@ static int sub_alloc(struct idr_context *idp, void *ptr, 
int *starting_id)
int n, m, sh;
struct idr_layer *p, *pn;
struct idr_layer *pa[MAX_LEVEL];
-   int l, id, oid;
+   unsigned int l, id, oid;
uint32_t bm;
 
memset(pa, 0, sizeof(pa));


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2010-09-26 Thread Rusty Russell
The branch, master has been updated
   via  2dcf76c tdb: TDB_INCOMPATIBLE_HASH, to allow safe changing of 
default hash.
   via  ccac258 tdb: automatically identify Jenkins hash tdbs
   via  3258cf3 tdb: add Bob Jenkins lookup3 hash as helper hash.
  from  7afa7b8 s3-waf: rework static and shared list handling a little.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 2dcf76c9247ff02a1779000dbbecdc418473ca41
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Sep 24 15:45:11 2010 +0930

tdb: TDB_INCOMPATIBLE_HASH, to allow safe changing of default hash.

This flag to tdb_open/tdb_open_ex effects creation of a new database:
1) Uses the Jenkins lookup3 hash instead of the old gdbm hash if none is
   specified,
2) Places a non-zero field in header-rwlocks, so older versions of TDB will
   refuse to open it.

This means that the caller (ie Samba) can set this flag to safely
change the hash function.  Versions of TDB from this one on will either
use the correct hash or refuse to open (if a different hash is specified).
Older TDB versions will see the nonzero rwlocks field and refuse to open
it under any conditions.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit ccac258d14dda7d8a994a7b80474ce6d85478a6d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Sep 24 15:39:43 2010 +0930

tdb: automatically identify Jenkins hash tdbs

If the caller to tdb_open_ex() doesn't specify a hash, and tdb_old_hash
doesn't match, try tdb_jenkins_hash.

This was Metze's idea: it makes life simpler, especially with the upcoming
TDB_INCOMPATIBLE_HASH flag.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 3258cf3f11bf7c68a2e69e1808c4551cc899725a
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Sep 24 15:34:06 2010 +0930

tdb: add Bob Jenkins lookup3 hash as helper hash.

This is a better hash than the default: shipping it with tdb makes it easy
for callers to use it as the hash by passing it to tdb_open_ex().

This version taken from CCAN and modified, which took it from
http://www.burtleburtle.net/bob/c/lookup3.c.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/ABI/{tdb-1.2.4.sigs = tdb-1.2.5.sigs} |1 +
 lib/tdb/common/check.c |2 +-
 lib/tdb/common/hash.c  |  380 
 lib/tdb/common/open.c  |   74 +++--
 lib/tdb/common/tdb_private.h   |2 +
 lib/tdb/configure.ac   |2 +-
 lib/tdb/include/tdb.h  |2 +
 lib/tdb/wscript|4 +-
 8 files changed, 433 insertions(+), 34 deletions(-)
 copy lib/tdb/ABI/{tdb-1.2.4.sigs = tdb-1.2.5.sigs} (98%)
 create mode 100644 lib/tdb/common/hash.c


Changeset truncated at 500 lines:

diff --git a/lib/tdb/ABI/tdb-1.2.4.sigs b/lib/tdb/ABI/tdb-1.2.5.sigs
similarity index 98%
copy from lib/tdb/ABI/tdb-1.2.4.sigs
copy to lib/tdb/ABI/tdb-1.2.5.sigs
index 043790d..1e01f3b 100644
--- a/lib/tdb/ABI/tdb-1.2.4.sigs
+++ b/lib/tdb/ABI/tdb-1.2.5.sigs
@@ -24,6 +24,7 @@ tdb_get_logging_private: void *(struct tdb_context *)
 tdb_get_seqnum: int (struct tdb_context *)
 tdb_hash_size: int (struct tdb_context *)
 tdb_increment_seqnum_nonblock: void (struct tdb_context *)
+tdb_jenkins_hash: unsigned int (TDB_DATA *)
 tdb_lockall: int (struct tdb_context *)
 tdb_lockall_mark: int (struct tdb_context *)
 tdb_lockall_nonblock: int (struct tdb_context *)
diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index b1b98d4..58c9c26 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -39,7 +39,7 @@ static bool tdb_check_header(struct tdb_context *tdb, 
tdb_off_t *recovery)
if (hdr.version != TDB_VERSION)
goto corrupt;
 
-   if (hdr.rwlocks != 0)
+   if (hdr.rwlocks != 0  hdr.rwlocks != TDB_HASH_RWLOCK_MAGIC)
goto corrupt;
 
tdb_header_hash(tdb, h1, h2);
diff --git a/lib/tdb/common/hash.c b/lib/tdb/common/hash.c
new file mode 100644
index 000..c07297e
--- /dev/null
+++ b/lib/tdb/common/hash.c
@@ -0,0 +1,380 @@
+ /*
+   Unix SMB/CIFS implementation.
+
+   trivial database library
+
+   Copyright (C) Rusty Russell2010
+
+ ** NOTE! The following LGPL license applies to the tdb
+ ** 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
+   version 3 of the License, or (at your option) any later version.
+
+   This library

[SCM] Samba Shared Repository - branch master updated

2010-09-26 Thread Rusty Russell
The branch, master has been updated
   via  b7cd6af tdb: fix non-WAF build, commit 1.2.6 ABI file.
  from  2dcf76c tdb: TDB_INCOMPATIBLE_HASH, to allow safe changing of 
default hash.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit b7cd6af5b45840a3588ad0cd50b4414f32f8b792
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Sep 27 11:06:51 2010 +0930

tdb: fix non-WAF build, commit 1.2.6 ABI file.

Sorry Jeremy.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/ABI/{tdb-1.2.5.sigs = tdb-1.2.6.sigs} |0
 lib/tdb/libtdb.m4  |2 +-
 2 files changed, 1 insertions(+), 1 deletions(-)
 copy lib/tdb/ABI/{tdb-1.2.5.sigs = tdb-1.2.6.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/ABI/tdb-1.2.5.sigs b/lib/tdb/ABI/tdb-1.2.6.sigs
similarity index 100%
copy from lib/tdb/ABI/tdb-1.2.5.sigs
copy to lib/tdb/ABI/tdb-1.2.6.sigs
diff --git a/lib/tdb/libtdb.m4 b/lib/tdb/libtdb.m4
index fb8913a..e650bc6 100644
--- a/lib/tdb/libtdb.m4
+++ b/lib/tdb/libtdb.m4
@@ -13,7 +13,7 @@ if test x$tdbdir = x; then
AC_MSG_ERROR([cannot find tdb source in $tdbpaths])
 fi
 TDB_OBJ=common/tdb.o common/dump.o common/transaction.o common/error.o 
common/traverse.o
-TDB_OBJ=$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o 
common/lock.o common/open.o common/check.o
+TDB_OBJ=$TDB_OBJ common/freelist.o common/freelistcheck.o common/io.o 
common/lock.o common/open.o common/check.o common/hash.o
 AC_SUBST(TDB_OBJ)
 AC_SUBST(LIBREPLACEOBJ)
 


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2010-09-13 Thread Rusty Russell
The branch, master has been updated
   via  d10b2c0 lib/tdb: change version to 1.2.4 after hash checking 
improvments
   via  786b726 tdb: put example hashes into header, so we notice incorrect 
hash_fn.
   via  f77708e tdb: fix tdb_check() on other-endian tdbs.
   via  82e5644 tdb: fix tdb_check() on read-only TDBs to actually work.
   via  9e0deff tdb: make check more robust against recovery failures.
  from  fe958c0 Revert s4:samldb LDB module - simplify the message 
handling on add and modify operations

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit d10b2c07be2cfdca09f07d3045ce891989d83a09
Author: Stefan Metzmacher me...@samba.org
Date:   Fri Sep 10 04:47:32 2010 +0200

lib/tdb: change version to 1.2.4 after hash checking improvments

lib/tdb: change version to 1.2.4 after hash checking improvments

metze

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 786b7263000dedcb97e7369402e2e9dc967e36c4
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Sep 13 20:05:59 2010 +0930

tdb: put example hashes into header, so we notice incorrect hash_fn.

This is Stefan Metzmacher me...@samba.org's patch with minor changes:
1) Use the TDB_MAGIC constant so both hashes aren't of strings.
2) Check the hash in tdb_check (paranoia, really).
3) Additional check in the (unlikely!) case where both examples hash to 0.
4) Cosmetic changes to var names and complaint message.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit f77708e96268d18abbfb038f4e78fe9e11a2856f
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Sep 13 19:59:18 2010 +0930

tdb: fix tdb_check() on other-endian tdbs.

We must not endian-convert the magic string, just the rest.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 82e5644c9dbf5c2e4b0c4183372e0a79203d32a5
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Sep 13 19:58:23 2010 +0930

tdb: fix tdb_check() on read-only TDBs to actually work.

Commit bc1c82ea137 Fix tdb_check() to work with read-only tdb databases.
claimed to do this, but tdb_lockall_read() fails on read-only databases.

Also make sure we can still do tdb_check() inside a transaction (weird,
but we previously allowed it so don't break the API).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 9e0deff904877068d19b41e965732f145c2554b9
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Mon Sep 13 19:55:26 2010 +0930

tdb: make check more robust against recovery failures.

We can end up with dead areas when we die during transaction commit;
tdb_check() fails on such a (valid) database.

This is particularly noticable now we no longer truncate on recovery;
if the recovery area was at the end of the file we used to remove it
that way.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/check.c   |   71 +++--
 lib/tdb/common/open.c|   55 -
 lib/tdb/common/tdb_private.h |6 +++-
 lib/tdb/configure.ac |2 +-
 lib/tdb/wscript  |2 +-
 5 files changed, 121 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 2c64043..b1b98d4 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -28,8 +28,9 @@
 static bool tdb_check_header(struct tdb_context *tdb, tdb_off_t *recovery)
 {
struct tdb_header hdr;
+   uint32_t h1, h2;
 
-   if (tdb-methods-tdb_read(tdb, 0, hdr, sizeof(hdr), DOCONV()) == -1)
+   if (tdb-methods-tdb_read(tdb, 0, hdr, sizeof(hdr), 0) == -1)
return false;
if (strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0)
goto corrupt;
@@ -41,6 +42,11 @@ static bool tdb_check_header(struct tdb_context *tdb, 
tdb_off_t *recovery)
if (hdr.rwlocks != 0)
goto corrupt;
 
+   tdb_header_hash(tdb, h1, h2);
+   if (hdr.magic1_hash  hdr.magic2_hash 
+   (hdr.magic1_hash != h1 || hdr.magic2_hash != h2))
+   goto corrupt;
+
if (hdr.hash_size == 0)
goto corrupt;
 
@@ -301,6 +307,21 @@ static bool tdb_check_free_record(struct tdb_context *tdb,
return true;
 }
 
+/* Slow, but should be very rare. */
+static size_t dead_space(struct tdb_context *tdb, tdb_off_t off)
+{
+   size_t len;
+
+   for (len = 0; off + len  tdb-map_size; len++) {
+   char c;
+   if (tdb-methods-tdb_read(tdb, off, c, 1, 0))
+   return 0;
+   if (c != 0  c != 0x42)
+   break;
+   }
+   return len;
+}
+
 int tdb_check(struct

[SCM] Samba Shared Repository - branch master updated

2010-08-13 Thread Rusty Russell
The branch, master has been updated
   via  11ab430... tdb: workaround starvation problem in locking entire 
database.
  from  f00b61c... s3-selftest: move make test to selftest.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 11ab43084b10cf53b530cdc3a6036c898b79ca38
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Sat Aug 14 02:13:26 2010 +0930

tdb: workaround starvation problem in locking entire database.

We saw tdb_lockall() take 71 seconds under heavy load; this is because Linux
(at least) doesn't prevent new small locks being obtained while we're 
waiting
for a big log.

The workaround is to do divide and conquer using non-blocking chainlocks: if
we get down to a single chain we block.  Using a simple test program where
children did hold lock for 100ms, sleep for 1 second the time to do
tdb_lockall() dropped signifiantly.  There are ln(hashsize) locks taken in
the contended case, but that's slow anyway.

More analysis is given in my blog at http://rusty.ozlabs.org/?p=120

This may also help transactions, though in that case it's the initial
read lock which uses this gradual locking routine; the update-to-write-lock
code is separate and still tries to update in one go.

Even though ABI doesn't change, minor version bumped so behavior change
can be easily detected.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/ABI/{tdb-1.2.2.sigs = tdb-1.2.3.sigs} |0 
 lib/tdb/common/lock.c  |   86 +++-
 lib/tdb/configure.ac   |2 +-
 lib/tdb/wscript|2 +-
 4 files changed, 71 insertions(+), 19 deletions(-)
 copy lib/tdb/ABI/{tdb-1.2.2.sigs = tdb-1.2.3.sigs} (100%)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/ABI/tdb-1.2.2.sigs b/lib/tdb/ABI/tdb-1.2.3.sigs
similarity index 100%
copy from lib/tdb/ABI/tdb-1.2.2.sigs
copy to lib/tdb/ABI/tdb-1.2.3.sigs
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index 285b7a3..803feee 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -152,14 +152,6 @@ int tdb_brlock(struct tdb_context *tdb,
return -1;
}
 
-   /* Sanity check */
-   if (tdb-transaction  offset = lock_offset(-1)  len != 0) {
-   tdb-ecode = TDB_ERR_RDONLY;
-   TDB_LOG((tdb, TDB_DEBUG_TRACE, tdb_brlock attempted in 
transaction at offset %d rw_type=%d flags=%d len=%d\n,
-offset, rw_type, flags, (int)len));
-   return -1;
-   }
-
do {
ret = fcntl_lock(tdb, rw_type, offset, len,
 flags  TDB_LOCK_WAIT);
@@ -486,11 +478,9 @@ int tdb_transaction_unlock(struct tdb_context *tdb, int 
ltype)
return tdb_nest_unlock(tdb, TRANSACTION_LOCK, ltype, false);
 }
 
-
-/* lock/unlock entire database.  It can only be upgradable if you have some
- * other way of guaranteeing exclusivity (ie. transaction write lock). */
-int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
-  enum tdb_lock_flags flags, bool upgradable)
+/* Returns 0 if all done, -1 if error, 1 if ok. */
+static int tdb_allrecord_check(struct tdb_context *tdb, int ltype,
+  enum tdb_lock_flags flags, bool upgradable)
 {
/* There are no locks on read-only dbs */
if (tdb-read_only || tdb-traverse_read) {
@@ -520,11 +510,73 @@ int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
tdb-ecode = TDB_ERR_LOCK;
return -1;
}
+   return 1;
+}
 
-   if (tdb_brlock(tdb, ltype, FREELIST_TOP, 0, flags)) {
-   if (flags  TDB_LOCK_WAIT) {
-   TDB_LOG((tdb, TDB_DEBUG_ERROR, tdb_lockall failed 
(%s)\n, strerror(errno)));
-   }
+/* We only need to lock individual bytes, but Linux merges consecutive locks
+ * so we lock in contiguous ranges. */
+static int tdb_chainlock_gradual(struct tdb_context *tdb,
+int ltype, enum tdb_lock_flags flags,
+size_t off, size_t len)
+{
+   int ret;
+   enum tdb_lock_flags nb_flags = (flags  ~TDB_LOCK_WAIT);
+
+   if (len = 4) {
+   /* Single record.  Just do blocking lock. */
+   return tdb_brlock(tdb, ltype, off, len, flags);
+   }
+
+   /* First we try non-blocking. */
+   ret = tdb_brlock(tdb, ltype, off, len, nb_flags);
+   if (ret == 0) {
+   return 0;
+   }
+
+   /* Try locking first half, then second. */
+   ret = tdb_chainlock_gradual(tdb, ltype, flags, off, len / 2);
+   if (ret == -1)
+   return -1;
+
+   ret = tdb_chainlock_gradual

[SCM] Samba Shared Repository - branch master updated

2010-07-28 Thread Rusty Russell
The branch, master has been updated
   via  bc1c82e... Fix tdb_check() to work with read-only tdb databases. 
The function tdb_lockall() uses F_WRLCK internally, which doesn't work on a fd 
opened with O_RDONLY. Use tdb_lockall_read() instead.
  from  39d287e... s4-test: Expand DSSYNC test to be executed against all 
partitions

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit bc1c82ea137e1bf6cb55139a666c56ebb2226b23
Author: Jeremy Allison j...@samba.org
Date:   Wed Jul 28 05:15:40 2010 -0700

Fix tdb_check() to work with read-only tdb databases. The function 
tdb_lockall() uses F_WRLCK internally, which doesn't work on a fd opened with 
O_RDONLY. Use tdb_lockall_read() instead.

Jeremy.

---

Summary of changes:
 lib/tdb/common/check.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 6bbfd7d..2c64043 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -311,7 +311,7 @@ int tdb_check(struct tdb_context *tdb,
struct tdb_record rec;
bool found_recovery = false;
 
-   if (tdb_lockall(tdb) == -1)
+   if (tdb_lockall_read(tdb) == -1)
return -1;
 
/* Make sure we know true size of the underlying file. */
@@ -412,12 +412,12 @@ int tdb_check(struct tdb_context *tdb,
}
 
free(hashes);
-   tdb_unlockall(tdb);
+   tdb_unlockall_read(tdb);
return 0;
 
 free:
free(hashes);
 unlock:
-   tdb_unlockall(tdb);
+   tdb_unlockall_read(tdb);
return -1;
 }


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2010-05-05 Thread Rusty Russell
The branch, master has been updated
   via  91e4a17... tdb: fix short write logic in tdb_new_database
  from  a9e008e... Fix bug #7263 - Unable to print using Samba 3.5.1 and 
cups-1.1.23-40.46 on SLES10.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 91e4a1760dee22e9a40ca52f1e5a1b549d9e066d
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed May 5 15:37:18 2010 +0930

tdb: fix short write logic in tdb_new_database

Commit 207a213c/24fed55d purported to fix the problem of signals during
tdb_new_database (which could cause a spurious short write, hence a 
failure).
However, the code is wrong: newdb+written is not correct.

Fix this by introducing a general tdb_write_all() and using it here and in
the tracing code.

Cc: Stefan Metzmacher me...@samba.org
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/open.c|   16 +---
 lib/tdb/common/tdb.c |   16 +++-
 lib/tdb/common/tdb_private.h |2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index dfe780d..3ff6b17 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -83,22 +83,8 @@ static int tdb_new_database(struct tdb_context *tdb, int 
hash_size)
/* Don't endian-convert the magic food! */
memcpy(newdb-magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
/* we still have ret == -1 here */
-   written = write(tdb-fd, newdb, size);
-   if (written == size) {
+   if (tdb_write_all(tdb-fd, newdb, size))
ret = 0;
-   } else if (written != -1) {
-   /* call write once again, this usually should return -1 and
-* set errno appropriately */
-   size -= written;
-   written = write(tdb-fd, newdb+written, size);
-   if (written == size) {
-   ret = 0;
-   } else if (written = 0) {
-   /* a second incomplete write - we give up.
-* guessing the errno... */
-   errno = ENOSPC;
-   }
-   }
 
   fail:
SAFE_FREE(newdb);
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index dac3f4e..4d8c5fc 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -989,10 +989,24 @@ int tdb_repack(struct tdb_context *tdb)
return 0;
 }
 
+/* Even on files, we can get partial writes due to signals. */
+bool tdb_write_all(int fd, const void *buf, size_t count)
+{
+   while (count) {
+   size_t ret;
+   ret = write(fd, buf, count);
+   if (ret  0)
+   return false;
+   buf = (const char *)buf + ret;
+   count -= ret;
+   }
+   return true;
+}
+
 #ifdef TDB_TRACE
 static void tdb_trace_write(struct tdb_context *tdb, const char *str)
 {
-   if (write(tdb-tracefd, str, strlen(str)) != strlen(str)) {
+   if (!tdb_write_alltdb-tracefd, str, strlen(str)) {
close(tdb-tracefd);
tdb-tracefd = -1;
}
diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h
index e216713..9d0f3bc 100644
--- a/lib/tdb/common/tdb_private.h
+++ b/lib/tdb/common/tdb_private.h
@@ -266,5 +266,5 @@ void tdb_io_init(struct tdb_context *tdb);
 int tdb_expand(struct tdb_context *tdb, tdb_off_t size);
 int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off,
  struct tdb_record *rec);
-
+bool tdb_write_all(int fd, const void *buf, size_t count);
 int tdb_transaction_recover(struct tdb_context *tdb);


-- 
Samba Shared Repository


[SCM] Samba Shared Repository - branch master updated

2010-02-23 Thread Rusty Russell
The branch, master has been updated
   via  ec96ea6... tdb: handle processes dying during transaction commit.
   via  1bf482b... patch tdb-refactor-tdb_lock-and-tdb_lock_nonblock.patch
   via  ececeff... tdb: add -k option to tdbtorture
   via  8c3fda4... tdb: don't truncate tdb on recovery
   via  9f295ee... tdb: remove lock ops
   via  a84222b... tdb: rename tdb_release_extra_locks() to 
tdb_release_transaction_locks()
   via  dd1b508... tdb: cleanup: remove ltype argument from 
_tdb_transaction_cancel.
   via  fca1621... tdb: 
tdb_allrecord_lock/tdb_allrecord_unlock/tdb_allrecord_upgrade
   via  caaf5c6... tdb: suppress record write locks when allrecord lock is 
taken.
   via  9341f23... tdb: cleanup: always grab allrecord lock to infinity.
   via  1ab8776... tdb: remove num_locks
   via  d48c3e4... tdb: use tdb_nest_lock() for seqnum lock.
   via  4738d47... tdb: use tdb_nest_lock() for active lock.
   via  9136818... tdb: use tdb_nest_lock() for open lock.
   via  e8fa70a... tdb: use tdb_nest_lock() for transaction lock.
   via  ce41411... tdb: cleanup: find_nestlock() helper.
   via  db27073... tdb: cleanup: tdb_release_extra_locks() helper
   via  fba42f1... tdb: cleanup: tdb_have_extra_locks() helper
   via  b754f61... tdb: don't suppress the transaction lock because of the 
allrecord lock.
   via  5d9de60... tdb: cleanup: tdb_nest_lock/tdb_nest_unlock
   via  e9114a7... tdb: cleanup: rename global_lock to allrecord_lock.
   via  7ab422d... tdb: cleanup: rename GLOBAL_LOCK to OPEN_LOCK.
   via  a6e0ef8... tdb: make _tdb_transaction_cancel static.
   via  452b4a5... tdb: cleanup: split brlock and brunlock methods.
  from  fffdce6... s4/schema: Move msDS-IntId implementation to samldb.c 
module

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit ec96ea690edbe3398d690b4a953d487ca1773f1c
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 13:23:58 2010 +1030

tdb: handle processes dying during transaction commit.

tdb transactions were designed to be robust against the machine
powering off, but interestingly were never designed to handle the case
where an administrator kill -9's a process during commit.  Because
recovery is only done on tdb_open, processes with the tdb already
mapped will simply use it despite it being corrupt and needing
recovery.

The solution to this is to check for recovery every time we grab a
data lock: we could have gained the lock because a process just died.
This has no measurable cost: here is the time for tdbtorture -s 0 -n 1
-l 1:

Before:
2.75 2.50 2.81 3.19 2.91 2.53 2.72 2.50 2.78 2.77 = Avg 2.75

After:
2.81 2.57 3.42 2.49 3.02 2.49 2.84 2.48 2.80 2.43 = Avg 2.74

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 1bf482b9ef9ec73dd7ee4387d7087aa3955503dd
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 13:18:06 2010 +1030

patch tdb-refactor-tdb_lock-and-tdb_lock_nonblock.patch

commit ececeffd85db1b27c07cdf91a921fd203006daf6
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 10:53:05 2010 +1030

tdb: add -k option to tdbtorture

To test the case of death of a process during transaction commit, add
a -k (kill random) option to tdbtorture.  The easiest way to do this
is to make every worker a child (unless there's only one child), which
is why this patch is bigger than you might expect.

Using -k without -t (always transactions) you expect corruption, though
it doesn't happen every time.  With -t, we currently get corruption but
the next patch fixes that.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 8c3fda4318adc71899bc41486d5616da3a91a688
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 10:50:41 2010 +1030

tdb: don't truncate tdb on recovery

The current recovery code truncates the tdb file on recovery.  This is
fine if recovery is only done on first open, but is a really bad idea
as we move to allowing recovery on live databases.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 9f295eecffd92e55584fc36539cd85cd32c832de
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 10:49:22 2010 +1030

tdb: remove lock ops

Now the transaction code uses the standard allrecord lock, that stops
us from trying to grab any per-record locks anyway.  We don't need to
have special noop lock ops for transactions.

This is a nice simplification: if you see brlock, you know it's really
going to grab a lock.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit a84222bbaf9ed2c7b9c61b8157b2e3c85f17fa32
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Wed Feb 24 11:02:55 2010 +1030

tdb

[SCM] Samba Shared Repository - branch master updated

2010-02-09 Thread Rusty Russell
The branch, master has been updated
   via  b37b452... tdb: fix recovery reuse after crash
   via  6269cdc... tdb: give a name to the invalid recovery area constant 
(0)
  from  f299fe5... s4:provision Just 'do the right thing' with empty 
smb.conf files

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit b37b452cb8c1f56b37b04abe7bffdede371ca361
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Feb 4 23:59:54 2010 +1030

tdb: fix recovery reuse after crash

If a process (or the machine) dies after just after writing the
recovery head (pointing at the end of file), the recovery record will filled
with 0x42.  This will not invoke a recovery on open, since rec.magic
!= TDB_RECOVERY_MAGIC.

Unfortunately, the first transaction commit will happily reuse that
area: tdb_recovery_allocate() doesn't check the magic.  The recovery
record has length 0x42424242, and it writes that back into the
now-valid-looking transaction header) for the next comer (which
happens to be tdb_wipe_all in my tests).

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 6269cdcd1538e2e3cead9e0f3c156b0363d607a0
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Fri Feb 5 00:00:24 2010 +1030

tdb: give a name to the invalid recovery area constant (0)

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/check.c   |2 +-
 lib/tdb/common/tdb_private.h |1 +
 lib/tdb/common/transaction.c |   20 +---
 3 files changed, 15 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index f0a15f8..6bbfd7d 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -370,7 +370,7 @@ int tdb_check(struct tdb_context *tdb,
goto free;
break;
case TDB_RECOVERY_MAGIC:
-   case 0: /* Used for invalid (or in-progress) recovery area. */
+   case TDB_RECOVERY_INVALID_MAGIC:
if (recovery_start != off) {
TDB_LOG((tdb, TDB_DEBUG_ERROR,
 Unexpected recovery record at offset 
%d\n,
diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h
index be9be72..0e74b10 100644
--- a/lib/tdb/common/tdb_private.h
+++ b/lib/tdb/common/tdb_private.h
@@ -49,6 +49,7 @@ typedef uint32_t tdb_off_t;
 #define TDB_FREE_MAGIC (~TDB_MAGIC)
 #define TDB_DEAD_MAGIC (0xFEE1DEAD)
 #define TDB_RECOVERY_MAGIC (0xf53bc0e7U)
+#define TDB_RECOVERY_INVALID_MAGIC (0x0)
 #define TDB_ALIGNMENT 4
 #define DEFAULT_HASH_SIZE 131
 #define FREELIST_TOP (sizeof(struct tdb_header))
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index b8988ea..67104ef 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -596,10 +596,10 @@ int _tdb_transaction_cancel(struct tdb_context *tdb)
 
if (tdb-transaction-magic_offset) {
const struct tdb_methods *methods = 
tdb-transaction-io_methods;
-   uint32_t zero = 0;
+   uint32_t invalid = TDB_RECOVERY_INVALID_MAGIC;
 
/* remove the recovery marker */
-   if (methods-tdb_write(tdb, tdb-transaction-magic_offset, 
zero, 4) == -1 ||
+   if (methods-tdb_write(tdb, tdb-transaction-magic_offset, 
invalid, 4) == -1 ||
transaction_sync(tdb, tdb-transaction-magic_offset, 4) == -1) 
{
TDB_LOG((tdb, TDB_DEBUG_FATAL, tdb_transaction_cancel: 
failed to remove recovery magic\n));
ret = -1;
@@ -695,10 +695,16 @@ static int tdb_recovery_allocate(struct tdb_context *tdb,
 
rec.rec_len = 0;
 
-   if (recovery_head != 0  
-   methods-tdb_read(tdb, recovery_head, rec, sizeof(rec), DOCONV()) 
== -1) {
-   TDB_LOG((tdb, TDB_DEBUG_FATAL, tdb_recovery_allocate: failed 
to read recovery record\n));
-   return -1;
+   if (recovery_head != 0) {
+   if (methods-tdb_read(tdb, recovery_head, rec, sizeof(rec), 
DOCONV()) == -1) {
+   TDB_LOG((tdb, TDB_DEBUG_FATAL, tdb_recovery_allocate: 
failed to read recovery record\n));
+   return -1;
+   }
+   /* ignore invalid recovery regions: can happen in crash */
+   if (rec.magic != TDB_RECOVERY_MAGIC 
+   rec.magic != TDB_RECOVERY_INVALID_MAGIC) {
+   recovery_head = 0;
+   }
}
 
*recovery_size = tdb_recovery_size(tdb);
@@ -793,7 +799,7 @@ static int transaction_setup_recovery(struct tdb_context 
*tdb,
rec = (struct tdb_record *)data;
memset(rec, 0, sizeof(*rec

[SCM] Samba Shared Repository - branch master updated

2009-10-28 Thread Rusty Russell
The branch, master has been updated
   via  83de5c8... tdb: update README a bit
   via  71a2139... tdb: add tests for double .close() in pytdb
   via  b4424f8... tdb: reset tdb-fd to -1 in tdb_close()
   via  cfed5f9... tdb: fix typo in python's Tdb.get() docstring
   via  ecbe5eb... tdb: kill last bits from swig
  from  04161b4... Fix map readonly in smb.conf, it is a single word

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 83de5c826313aa09c76131ae70550bd81b3521c5
Author: Kirill Smelkov k...@mns.spb.ru
Date:   Wed Oct 21 21:18:58 2009 +0400

tdb: update README a bit

While studying tdb, I've noticed a couple of mismatches between readme
and actual code:

- tdb_open_ex changed it's log_fn argument to log_ctx
- there is now no tdb_update(), which it seems was transformed into
  non-exported tdb_update_hash()

There were other mismatches, but I don't remember them now, sorry.

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 71a21393dd1bb61bded82b1581ac6d5bd3b0153c
Author: Kirill Smelkov k...@mns.spb.ru
Date:   Wed Oct 21 21:18:57 2009 +0400

tdb: add tests for double .close() in pytdb

The reason I do it is that when using older python-tdb as shipped in
Debian Lenny, python interpreter crashes on this test:

(gdb) bt
#0  0xb7f8c424 in __kernel_vsyscall ()
#1  0xb7df5640 in raise () from /lib/i686/cmov/libc.so.6
#2  0xb7df7018 in abort () from /lib/i686/cmov/libc.so.6
#3  0xb7e3234d in __libc_message () from /lib/i686/cmov/libc.so.6
#4  0xb7e38624 in malloc_printerr () from /lib/i686/cmov/libc.so.6
#5  0xb7e3a826 in free () from /lib/i686/cmov/libc.so.6
#6  0xb7b39c84 in tdb_close () from /usr/lib/libtdb.so.1
#7  0xb7b43e14 in ?? () from /var/lib/python-support/python2.5/_tdb.so
#8  0x0a038d08 in ?? ()
#9  0x in ?? ()

master's pytdb does not (we have a check for self-closed in obj_close()),
but still...

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit b4424f8234a78a79fb2d71d46ca208b4f12e0f9e
Author: Kirill Smelkov k...@mns.spb.ru
Date:   Wed Oct 21 21:18:56 2009 +0400

tdb: reset tdb-fd to -1 in tdb_close()

So that erroneous double tdb_close() calls do not try to close() same
fd again. This is like SAFE_FREE() but for fd.

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit cfed5f946de0992a594c189ee3c19cf98e59d380
Author: Kirill Smelkov k...@mns.spb.ru
Date:   Wed Oct 21 21:18:55 2009 +0400

tdb: fix typo in python's Tdb.get() docstring

It's Tdb.get(), not Tdb.fetch().

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit ecbe5ebd8d1c44a478c613eb1cace0521142d0d3
Author: Kirill Smelkov k...@mns.spb.ru
Date:   Wed Oct 21 21:18:54 2009 +0400

tdb: kill last bits from swig

We no longer use swig for pytdb, so there is no need for swig make
rules. Also pytdb.c header should be updated.

Signed-off-by: Kirill Smelkov k...@mns.spb.ru
Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/open.c  |4 +++-
 lib/tdb/docs/README|9 +
 lib/tdb/pytdb.c|4 ++--
 lib/tdb/python/tests/simple.py |9 +
 lib/tdb/rules.mk   |5 -
 5 files changed, 15 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 1ba2e7b..64efafe 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -403,8 +403,10 @@ int tdb_close(struct tdb_context *tdb)
tdb_munmap(tdb);
}
SAFE_FREE(tdb-name);
-   if (tdb-fd != -1)
+   if (tdb-fd != -1) {
ret = close(tdb-fd);
+   tdb-fd = -1;
+   }
SAFE_FREE(tdb-lockrecs);
 
/* Remove from contexts list */
diff --git a/lib/tdb/docs/README b/lib/tdb/docs/README
index 4eb809f..7bf4854 100644
--- a/lib/tdb/docs/README
+++ b/lib/tdb/docs/README
@@ -73,7 +73,7 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int 
tdb_flags,
 --
 TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags,
 int open_flags, mode_t mode,
-tdb_log_func log_fn,
+const struct tdb_logging_context *log_ctx,
 tdb_hash_func hash_fn)
 
 This is like tdb_open(), but allows you to pass an initial logging

[SCM] Samba Shared Repository - branch master updated

2009-10-21 Thread Rusty Russell
The branch, master has been updated
   via  7030043... lib/tdb: TDB_TRACE support (for developers)
  from  1467e5e... s4-ldb: allow for non-null terminated ldb_val in 
ldb_dn_from_ldb_val

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 703004340c3e0f43f741bd368d2525cfd187d590
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Tue Oct 20 12:19:41 2009 +1030

lib/tdb: TDB_TRACE support (for developers)

When TDB_TRACE is defined (in tdb_private.h), verbose tracing of tdb 
operations is enabled.
This can be replayed using replay_trace from 
http://ccan.ozlabs.org/info/tdb.

The majority of this patch comes from moving internal functions to 
_funcname to
avoid double-tracing.  There should be no additional overhead for the 
normal (!TDB_TRACE)
case.

Note that the verbose traces compress really well with rzip.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/lock.c|   34 +-
 lib/tdb/common/open.c|   31 +-
 lib/tdb/common/tdb.c |  232 +
 lib/tdb/common/tdb_private.h |   36 +++
 lib/tdb/common/transaction.c |   55 +++
 lib/tdb/common/traverse.c|   23 -
 lib/tdb/docs/tracing.txt |   46 
 7 files changed, 402 insertions(+), 55 deletions(-)
 create mode 100644 lib/tdb/docs/tracing.txt


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index 2c72ae1..3414049 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -422,48 +422,58 @@ static int _tdb_unlockall(struct tdb_context *tdb, int 
ltype)
 /* lock entire database with write lock */
 int tdb_lockall(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_lockall);
return _tdb_lockall(tdb, F_WRLCK, F_SETLKW);
 }
 
 /* lock entire database with write lock - mark only */
 int tdb_lockall_mark(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_lockall_mark);
return _tdb_lockall(tdb, F_WRLCK | TDB_MARK_LOCK, F_SETLKW);
 }
 
 /* unlock entire database with write lock - unmark only */
 int tdb_lockall_unmark(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_lockall_unmark);
return _tdb_unlockall(tdb, F_WRLCK | TDB_MARK_LOCK);
 }
 
 /* lock entire database with write lock - nonblocking varient */
 int tdb_lockall_nonblock(struct tdb_context *tdb)
 {
-   return _tdb_lockall(tdb, F_WRLCK, F_SETLK);
+   int ret = _tdb_lockall(tdb, F_WRLCK, F_SETLK);
+   tdb_trace_ret(tdb, tdb_lockall_nonblock, ret);
+   return ret;
 }
 
 /* unlock entire database with write lock */
 int tdb_unlockall(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_unlockall);
return _tdb_unlockall(tdb, F_WRLCK);
 }
 
 /* lock entire database with read lock */
 int tdb_lockall_read(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_lockall_read);
return _tdb_lockall(tdb, F_RDLCK, F_SETLKW);
 }
 
 /* lock entire database with read lock - nonblock varient */
 int tdb_lockall_read_nonblock(struct tdb_context *tdb)
 {
-   return _tdb_lockall(tdb, F_RDLCK, F_SETLK);
+   int ret = _tdb_lockall(tdb, F_RDLCK, F_SETLK);
+   tdb_trace_ret(tdb, tdb_lockall_read_nonblock, ret);
+   return ret;
 }
 
 /* unlock entire database with read lock */
 int tdb_unlockall_read(struct tdb_context *tdb)
 {
+   tdb_trace(tdb, tdb_unlockall_read);
return _tdb_unlockall(tdb, F_RDLCK);
 }
 
@@ -471,7 +481,9 @@ int tdb_unlockall_read(struct tdb_context *tdb)
contention - it cannot guarantee how many records will be locked */
 int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
 {
-   return tdb_lock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK);
+   int ret = tdb_lock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK);
+   tdb_trace_1rec(tdb, tdb_chainlock, key);
+   return ret;
 }
 
 /* lock/unlock one hash chain, non-blocking. This is meant to be used
@@ -479,33 +491,43 @@ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
locked */
 int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
 {
-   return tdb_lock_nonblock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK);
+   int ret = tdb_lock_nonblock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK);
+   tdb_trace_1rec_ret(tdb, tdb_chainlock_nonblock, key, ret);
+   return ret;
 }
 
 /* mark a chain as locked without actually locking it. Warning! use with great 
caution! */
 int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key)
 {
-   return tdb_lock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK | 
TDB_MARK_LOCK);
+   int ret = tdb_lock(tdb, BUCKET(tdb-hash_fn(key)), F_WRLCK | 
TDB_MARK_LOCK);
+   tdb_trace_1rec(tdb, tdb_chainlock_mark, key);
+   return ret;
 }
 
 /* unmark a chain as locked without actually locking it. Warning

[SCM] Samba Shared Repository - branch master updated

2009-10-21 Thread Rusty Russell
The branch, master has been updated
   via  0944931... lib/tdb: make tdbtool use tdb_check() for check command
   via  022b4d4... lib/tdb: add tdb_check()
   via  0fc6800... lib/tdb: add -t (always use transactions) option to 
tdbtorture
   via  b77f41d... lib/tdb: wean off TDB_ERRCODE.
  from  7030043... lib/tdb: TDB_TRACE support (for developers)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 094493115971cf3d5a3138ff10ebe02335824723
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 22 00:11:34 2009 +1030

lib/tdb: make tdbtool use tdb_check() for check command

Also, set logging function so we get more informative messages.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 022b4d4aa6861c1e3e6d76484d92555221cb6d14
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 22 00:10:34 2009 +1030

lib/tdb: add tdb_check()

ctdb wants a quick way to detect corrupt tdbs; particularly, tdbs with
loops in their hash chains.  tdb_check() provides this.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit 0fc685ffb532a5e5699c97f13f1de138d51f
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 22 00:10:54 2009 +1030

lib/tdb: add -t (always use transactions) option to tdbtorture

This means you can kill it at any time and expect no corruption.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

commit b77f41d58b05101e02d8ac0e54cb0e30807d89c2
Author: Rusty Russell ru...@rustcorp.com.au
Date:   Thu Oct 22 00:09:43 2009 +1030

lib/tdb: wean off TDB_ERRCODE.

It was a regrettable hack which I used to reduce line count in tdb; in fact 
it caused confusion as can be seen in this patch.
In particular, ecode now needs to be set before TDB_LOG anyway, and having 
it exposed in
the header is useless (the struct tdb_context isn't defined, so it's doubly 
useless).
Also, we should never set errno, as io.c was doing.

Signed-off-by: Rusty Russell ru...@rustcorp.com.au

---

Summary of changes:
 lib/tdb/common/check.c |  422 
 lib/tdb/common/freelist.c  |5 +-
 lib/tdb/common/freelistcheck.c |6 +-
 lib/tdb/common/io.c|   35 ++--
 lib/tdb/common/lock.c  |   30 ++-
 lib/tdb/common/open.c  |6 +-
 lib/tdb/common/tdb.c   |9 +-
 lib/tdb/common/transaction.c   |3 +-
 lib/tdb/common/traverse.c  |3 +-
 lib/tdb/config.mk  |2 +-
 lib/tdb/configure.ac   |2 +-
 lib/tdb/docs/README|   11 +
 lib/tdb/include/tdb.h  |5 +-
 lib/tdb/libtdb.m4  |2 +-
 lib/tdb/tdb.exports|1 +
 lib/tdb/tdb.signatures |1 +
 lib/tdb/tools/tdbtool.c|   44 +++--
 lib/tdb/tools/tdbtorture.c |   41 +++--
 source4/min_versions.m4|2 +-
 19 files changed, 560 insertions(+), 70 deletions(-)
 create mode 100644 lib/tdb/common/check.c


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
new file mode 100644
index 000..94240bb
--- /dev/null
+++ b/lib/tdb/common/check.c
@@ -0,0 +1,422 @@
+ /*
+   Unix SMB/CIFS implementation.
+
+   trivial database library
+
+   Copyright (C) Rusty Russell2009
+
+ ** NOTE! The following LGPL license applies to the tdb
+ ** 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
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+*/
+#include tdb_private.h
+
+/* Since we opened it, these shouldn't fail unless it's recent corruption. */
+static bool tdb_check_header(struct tdb_context *tdb, tdb_off_t *recovery)
+{
+   struct tdb_header hdr;
+
+   if (tdb-methods-tdb_read(tdb, 0, hdr, sizeof(hdr), DOCONV()) == -1)
+   return false;
+   if (strcmp(hdr.magic_food, TDB_MAGIC_FOOD) != 0)
+   goto corrupt;
+
+   CONVERT(hdr);
+   if (hdr.version != TDB_VERSION)
+   goto corrupt;
+
+   if (hdr.rwlocks != 0)
+   goto corrupt;
+
+   if (hdr.hash_size == 0)
+   goto corrupt;
+
+   if (hdr.hash_size != tdb