summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-06-26 19:23:07 +0000
committerGerald Carter <jerry@samba.org>2007-06-26 19:23:07 +0000
commitcdc8ffc7b86578bec1562c39aa49613298d7d3a4 (patch)
treed76f3b45c555c08a681903648f3185df56e733b8
parentd6a0865daf0f0ff2736ec20ff5b0aabc4df345bd (diff)
downloadsamba-cdc8ffc7b86578bec1562c39aa49613298d7d3a4.tar.gz
r23613: pull in net idmap change from the 3.0.25 tree
-rw-r--r--WHATSNEW.txt4
-rw-r--r--source/utils/net_idmap.c63
2 files changed, 35 insertions, 32 deletions
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 17e6b9199d0..d49b68e2149 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -76,7 +76,9 @@ o Steve Langasek <vorlon@debian.org>
o Volker Lendecke <vl@samba.org>
* Fix record state check error when reviewing entries in nmbd's
WINS database.
-
+ * Revert 'net idmap dump' behavior to 3.0.24 behavior to fix change
+ in command line syntax that would overwrite winbindd_idmap.tdb.
+
o Justin Maggard <jmaggard@infrant.com>
* Don't expire a password if it's explicitly set as ACB_PWNOTREQ.
diff --git a/source/utils/net_idmap.c b/source/utils/net_idmap.c
index dd16c4b02d9..1f70dafcfe8 100644
--- a/source/utils/net_idmap.c
+++ b/source/utils/net_idmap.c
@@ -28,50 +28,51 @@
} } while(0)
/***********************************************************
- Dump the current idmap
+ Helper function for net_idmap_dump. Dump one entry.
**********************************************************/
-static int net_idmap_dump(int argc, const char **argv)
+static int net_idmap_dump_one_entry(TDB_CONTEXT *tdb,
+ TDB_DATA key,
+ TDB_DATA data,
+ void *unused)
{
- TALLOC_CTX *ctx;
- char *filename;
-
- if (argc != 1) {
- return net_help_idmap(argc, argv);
+ if (strcmp(key.dptr, "USER HWM") == 0) {
+ printf("USER HWM %d\n", IVAL(data.dptr,0));
+ return 0;
}
- if (! winbind_ping()) {
- d_fprintf(stderr, "To use net idmap Winbindd must be running.\n");
- return -1;
+ if (strcmp(key.dptr, "GROUP HWM") == 0) {
+ printf("GROUP HWM %d\n", IVAL(data.dptr,0));
+ return 0;
}
- ctx = talloc_new(NULL);
- ALLOC_CHECK(ctx);
+ if (strncmp(key.dptr, "S-", 2) != 0)
+ return 0;
- filename = talloc_strdup(ctx, argv[0]);
- ALLOC_CHECK(filename);
+ printf("%s %s\n", data.dptr, key.dptr);
+ return 0;
+}
- /* filename must be absolute */
- if (*filename != '/') {
- char path[4096];
-
- filename = getcwd(path, 4095);
- if ( ! filename) {
- d_fprintf(stderr, "Failed to obtain full output file path");
- talloc_free(ctx);
- return -1;
- }
+/***********************************************************
+ Dump the current idmap
+ **********************************************************/
+static int net_idmap_dump(int argc, const char **argv)
+{
+ TDB_CONTEXT *idmap_tdb;
- filename = talloc_asprintf(ctx, "%s/%s", path, argv[0]);
- ALLOC_CHECK(filename);
- }
+ if ( argc != 1 )
+ return net_help_idmap( argc, argv );
- if ( ! winbind_idmap_dump_maps(ctx, filename)) {
- d_fprintf(stderr, "Failed to obtain idmap data from winbindd\n");
- talloc_free(ctx);
+ idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
+
+ if (idmap_tdb == NULL) {
+ d_fprintf(stderr, "Could not open idmap: %s\n", argv[0]);
return -1;
}
- talloc_free(ctx);
+ tdb_traverse(idmap_tdb, net_idmap_dump_one_entry, NULL);
+
+ tdb_close(idmap_tdb);
+
return 0;
}