svn commit: samba r23612 - in branches: SAMBA_3_0/source/utils
SAMBA_3_0_25/source/utils SAMBA_3_0_26/source/utils
vlendec at samba.org
vlendec at samba.org
Tue Jun 26 19:15:33 GMT 2007
Author: vlendec
Date: 2007-06-26 19:15:26 +0000 (Tue, 26 Jun 2007)
New Revision: 23612
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23612
Log:
Revert 'net idmap dump' to the 3.0.24 behaviour.
Modified:
branches/SAMBA_3_0/source/utils/net_idmap.c
branches/SAMBA_3_0_25/source/utils/net_idmap.c
branches/SAMBA_3_0_26/source/utils/net_idmap.c
Changeset:
Modified: branches/SAMBA_3_0/source/utils/net_idmap.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_idmap.c 2007-06-26 18:18:44 UTC (rev 23611)
+++ branches/SAMBA_3_0/source/utils/net_idmap.c 2007-06-26 19:15:26 UTC (rev 23612)
@@ -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((char *)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((char *)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((char *)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;
}
Modified: branches/SAMBA_3_0_25/source/utils/net_idmap.c
===================================================================
--- branches/SAMBA_3_0_25/source/utils/net_idmap.c 2007-06-26 18:18:44 UTC (rev 23611)
+++ branches/SAMBA_3_0_25/source/utils/net_idmap.c 2007-06-26 19:15:26 UTC (rev 23612)
@@ -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;
}
Modified: branches/SAMBA_3_0_26/source/utils/net_idmap.c
===================================================================
--- branches/SAMBA_3_0_26/source/utils/net_idmap.c 2007-06-26 18:18:44 UTC (rev 23611)
+++ branches/SAMBA_3_0_26/source/utils/net_idmap.c 2007-06-26 19:15:26 UTC (rev 23612)
@@ -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((char *)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((char *)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((char *)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;
}
More information about the samba-cvs
mailing list