summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-06-14 12:25:11 +0200
committerMichael Adam <obnox@samba.org>2010-08-14 02:10:30 +0200
commit80bceab9cb53318387133edde4be888d7b3156b1 (patch)
tree8831a0b0f9648404250116e499cd4aa7193ea624 /source3/utils
parenta0920a5ee5f7b390b0177a0d2899bf7da43c17e1 (diff)
downloadsamba-80bceab9cb53318387133edde4be888d7b3156b1.tar.gz
samba-80bceab9cb53318387133edde4be888d7b3156b1.tar.bz2
samba-80bceab9cb53318387133edde4be888d7b3156b1.zip
s3:net: change "net idmap dump" to use dbwrap instead of direct tdb access
This way, it will also work in a samba-ctdb cluster.
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_idmap.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 702c6f9eee..d145693a22 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -32,25 +32,23 @@
/***********************************************************
Helper function for net_idmap_dump. Dump one entry.
**********************************************************/
-static int net_idmap_dump_one_entry(TDB_CONTEXT *tdb,
- TDB_DATA key,
- TDB_DATA data,
+static int net_idmap_dump_one_entry(struct db_record *rec,
void *unused)
{
- if (strcmp((char *)key.dptr, "USER HWM") == 0) {
- printf(_("USER HWM %d\n"), IVAL(data.dptr,0));
+ if (strcmp((char *)rec->key.dptr, "USER HWM") == 0) {
+ printf(_("USER HWM %d\n"), IVAL(rec->value.dptr,0));
return 0;
}
- if (strcmp((char *)key.dptr, "GROUP HWM") == 0) {
- printf(_("GROUP HWM %d\n"), IVAL(data.dptr,0));
+ if (strcmp((char *)rec->key.dptr, "GROUP HWM") == 0) {
+ printf(_("GROUP HWM %d\n"), IVAL(rec->value.dptr,0));
return 0;
}
- if (strncmp((char *)key.dptr, "S-", 2) != 0)
+ if (strncmp((char *)rec->key.dptr, "S-", 2) != 0)
return 0;
- printf("%s %s\n", data.dptr, key.dptr);
+ printf("%s %s\n", rec->value.dptr, rec->key.dptr);
return 0;
}
@@ -59,7 +57,8 @@ static int net_idmap_dump_one_entry(TDB_CONTEXT *tdb,
**********************************************************/
static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
{
- TDB_CONTEXT *idmap_tdb;
+ struct db_context *db;
+ TALLOC_CTX *mem_ctx;
if ( argc != 1 || c->display_usage) {
d_printf("%s\n%s",
@@ -70,16 +69,19 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
return c->display_usage?0:-1;
}
- idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
+ mem_ctx = talloc_stackframe();
- if (idmap_tdb == NULL) {
- d_fprintf(stderr, _("Could not open idmap: %s\n"), argv[0]);
+ db = db_open(mem_ctx, argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
+ if (db == NULL) {
+ d_fprintf(stderr, _("Could not open idmap db (%s): %s\n"),
+ argv[0], strerror(errno));
+ talloc_free(mem_ctx);
return -1;
}
- tdb_traverse(idmap_tdb, net_idmap_dump_one_entry, NULL);
+ db->traverse_read(db, net_idmap_dump_one_entry, NULL);
- tdb_close(idmap_tdb);
+ talloc_free(mem_ctx);
return 0;
}