summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-05-29 18:04:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:55 -0500
commita9503016859dc4bc3f68eb302c1adf37bf311187 (patch)
treedba8ebac7ee8cac923c6816467365523bb442ddd
parentd807dec0f465c8735bd4964b196ff6109d8df408 (diff)
downloadsamba-a9503016859dc4bc3f68eb302c1adf37bf311187.tar.gz
samba-a9503016859dc4bc3f68eb302c1adf37bf311187.tar.bz2
samba-a9503016859dc4bc3f68eb302c1adf37bf311187.zip
r23220: Add traverse_read to dbwrap
(This used to be commit b38dc5ffdfe9fdc2879c57dc181815f06b4747fe)
-rw-r--r--source3/include/dbwrap.h4
-rw-r--r--source3/lib/dbwrap_file.c1
-rw-r--r--source3/lib/dbwrap_tdb.c41
-rw-r--r--source3/smbd/session.c2
4 files changed, 47 insertions, 1 deletions
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h
index 17d36b8f42..eae53e8ed4 100644
--- a/source3/include/dbwrap.h
+++ b/source3/include/dbwrap.h
@@ -38,6 +38,10 @@ struct db_context {
int (*f)(struct db_record *db,
void *private_data),
void *private_data);
+ int (*traverse_read)(struct db_context *db,
+ int (*f)(struct db_record *db,
+ void *private_data),
+ void *private_data);
int (*get_seqnum)(struct db_context *db);
void *private_data;
};
diff --git a/source3/lib/dbwrap_file.c b/source3/lib/dbwrap_file.c
index 9e18c6b8fe..0ac7586e48 100644
--- a/source3/lib/dbwrap_file.c
+++ b/source3/lib/dbwrap_file.c
@@ -367,6 +367,7 @@ struct db_context *db_open_file(TALLOC_CTX *mem_ctx,
result->private_data = ctx;
result->fetch_locked = db_file_fetch_locked;
result->traverse = db_file_traverse;
+ result->traverse_read = db_file_traverse;
ctx->locked_record = NULL;
if (!(ctx->dirname = talloc_strdup(ctx, name))) {
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index 2b09e3ccab..028bad36e6 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -174,6 +174,46 @@ static int db_tdb_traverse(struct db_context *db,
return tdb_traverse(db_ctx->tdb, db_tdb_traverse_func, &ctx);
}
+static NTSTATUS db_tdb_store_deny(struct db_record *rec, TDB_DATA data, int flag)
+{
+ return NT_STATUS_MEDIA_WRITE_PROTECTED;
+}
+
+static NTSTATUS db_tdb_delete_deny(struct db_record *rec)
+{
+ return NT_STATUS_MEDIA_WRITE_PROTECTED;
+}
+
+static int db_tdb_traverse_read_func(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
+ void *private_data)
+{
+ struct db_tdb_traverse_ctx *ctx =
+ (struct db_tdb_traverse_ctx *)private_data;
+ struct db_record rec;
+
+ rec.key = kbuf;
+ rec.value = dbuf;
+ rec.store = db_tdb_store_deny;
+ rec.delete_rec = db_tdb_delete_deny;
+ rec.private_data = ctx->db->private_data;
+
+ return ctx->f(&rec, ctx->private_data);
+}
+
+static int db_tdb_traverse_read(struct db_context *db,
+ int (*f)(struct db_record *rec, void *private_data),
+ void *private_data)
+{
+ struct db_tdb_ctx *db_ctx =
+ talloc_get_type_abort(db->private_data, struct db_tdb_ctx);
+ struct db_tdb_traverse_ctx ctx;
+
+ ctx.db = db;
+ ctx.f = f;
+ ctx.private_data = private_data;
+ return tdb_traverse_read(db_ctx->tdb, db_tdb_traverse_read_func, &ctx);
+}
+
static int db_tdb_get_seqnum(struct db_context *db)
{
@@ -222,6 +262,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
talloc_set_destructor(db_tdb, db_tdb_ctx_destr);
result->fetch_locked = db_tdb_fetch_locked;
result->traverse = db_tdb_traverse;
+ result->traverse_read = db_tdb_traverse_read;
result->get_seqnum = db_tdb_get_seqnum;
return result;
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index 837c37a49f..d5973ef5c3 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -275,7 +275,7 @@ static BOOL session_traverse(int (*fn)(struct db_record *db,
return False;
}
- ctx->traverse(ctx, fn, private_data);
+ ctx->traverse_read(ctx, fn, private_data);
return True;
}