summaryrefslogtreecommitdiff
path: root/lib/ntdb/test/api-83-openhook.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2013-03-23 17:27:57 +1030
committerRusty Russell <rusty@rustcorp.com.au>2013-03-23 09:39:50 +0100
commit068e0e2b38fb109eb1d1306c6d74bfa86ec0c4b8 (patch)
tree0be134c7602aaf0a2abf0fdb591af3c82c75cfbb /lib/ntdb/test/api-83-openhook.c
parentfd6d0361d6fef5f8175967ddbae4a2b1d79dfcad (diff)
downloadsamba-068e0e2b38fb109eb1d1306c6d74bfa86ec0c4b8.tar.gz
samba-068e0e2b38fb109eb1d1306c6d74bfa86ec0c4b8.tar.bz2
samba-068e0e2b38fb109eb1d1306c6d74bfa86ec0c4b8.zip
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 <rusty@rustcorp.com.au> Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au> Autobuild-Date(master): Sat Mar 23 09:39:50 CET 2013 on sn-devel-104
Diffstat (limited to 'lib/ntdb/test/api-83-openhook.c')
-rw-r--r--lib/ntdb/test/api-83-openhook.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/ntdb/test/api-83-openhook.c b/lib/ntdb/test/api-83-openhook.c
index 31c789ead8..3816eef209 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 = prepare_external_agent();
- plan_tests(sizeof(flags) / sizeof(flags[0]) * 13);
+ plan_tests(sizeof(flags) / sizeof(flags[0]) * 16);
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
/* Create it */
ntdb = ntdb_open("run-83-openhook.ntdb", flags[i]|MAYBE_NOSYNC,
@@ -83,6 +83,15 @@ int main(int argc, char *argv[])
/* Still exists for us too. */
ok1(ntdb_exists(ntdb, key));
+ /* Nested open should not erase db. */
+ ntdb2 = ntdb_open("run-83-openhook.ntdb", flags[i]|MAYBE_NOSYNC,
+ O_RDWR, 0, &cif);
+ ok1(ntdb_exists(ntdb2, key));
+ ok1(ntdb_exists(ntdb, key));
+ ntdb_close(ntdb2);
+
+ ok1(ntdb_exists(ntdb, key));
+
/* Close it, now agent should clear it. */
ntdb_close(ntdb);