summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2003-06-13 16:19:02 +0000
committerVolker Lendecke <vlendec@samba.org>2003-06-13 16:19:02 +0000
commit8ad364dd2e6918465c8bca6f91d01b6782693427 (patch)
treedac6dee00cdf53b07fd065b0517e3e2b29defd03
parent0a9396dcca1e30fa32fbcde3ee2dce86f586ba4b (diff)
downloadsamba-8ad364dd2e6918465c8bca6f91d01b6782693427.tar.gz
samba-8ad364dd2e6918465c8bca6f91d01b6782693427.tar.xz
samba-8ad364dd2e6918465c8bca6f91d01b6782693427.zip
Trivial extension to 'net' to dump current local idmap.
(This used to be commit 18f3a5efea7c60d764d5ed82f3a83e1608f8c34e)
-rw-r--r--source3/utils/net.c55
-rw-r--r--source3/utils/net_help.c7
2 files changed, 62 insertions, 0 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index aa245a920a7..a18d3e4285c 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -368,6 +368,60 @@ static int net_groupmap(int argc, const char **argv)
return net_help_groupmap( argc, argv );
}
+/***********************************************************
+ 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,
+ void *unused)
+{
+ if (strncmp(key.dptr, "S-", 2) != 0)
+ return 0;
+
+ printf("%s %s\n", data.dptr, key.dptr);
+ return 0;
+}
+
+/***********************************************************
+ Dump the current idmap
+ **********************************************************/
+static int net_idmap_dump(int argc, const char **argv)
+{
+ TDB_CONTEXT *idmap_tdb;
+
+ if ( argc != 1 )
+ return net_help_idmap( argc, argv );
+
+ idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
+
+ if (idmap_tdb == NULL) {
+ d_printf("Could not open idmap: %s\n", argv[0]);
+ return -1;
+ }
+
+ tdb_traverse(idmap_tdb, net_idmap_dump_one_entry, NULL);
+
+ tdb_close(idmap_tdb);
+
+ return 0;
+}
+
+/***********************************************************
+ Look at the current idmap
+ **********************************************************/
+static int net_idmap(int argc, const char **argv)
+{
+ if ( 0 == argc )
+ return net_help_idmap( argc, argv );
+
+ if ( !StrCaseCmp( argv[0], "dump" ) )
+ return net_idmap_dump(argc-1, argv+1);
+
+ return net_help_idmap( argc, argv );
+}
+
+
/*
Retrieve our local SID or the SID for the specified name
*/
@@ -544,6 +598,7 @@ static struct functable net_func[] = {
{"SETLOCALSID", net_setlocalsid},
{"GETDOMAINSID", net_getdomainsid},
{"MAXRID", net_maxrid},
+ {"IDMAP", net_idmap},
{"HELP", net_help},
{NULL, NULL}
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index f24367f246b..16db55480e7 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -118,6 +118,13 @@ int net_help_groupmap(int argc, const char **argv)
return -1;
}
+int net_help_idmap(int argc, const char **argv)
+{
+ d_printf("net idmap dump filename"\
+ "\n Dump current id mapping\n");
+
+ return -1;
+}
int net_help_join(int argc, const char **argv)
{