summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-12-17 10:20:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:40 -0500
commit35657ac39e27d6b8268430015c2750a3c8c1ce1e (patch)
tree4675d616c7a64bcd1da1b296cbbadc8a95038373
parentefe5a8eb0bb8805d1630663ad827ef3a68565f37 (diff)
downloadsamba-35657ac39e27d6b8268430015c2750a3c8c1ce1e.tar.gz
samba-35657ac39e27d6b8268430015c2750a3c8c1ce1e.tar.bz2
samba-35657ac39e27d6b8268430015c2750a3c8c1ce1e.zip
r4254: Add an undocumented hack. I had to delete a wrong mapping (a user that had
ended up as a gid in winbindd_idmap.tdb) from winbindd_idmap.tdb. Stopping winbind was not an option on that machine.... net idmap delete <idmap-file> <SID> Thanks, Volker (This used to be commit 27c16733c13bb1c91d356f1c9f5c1f069e24cca2)
-rw-r--r--source3/utils/net_idmap.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index b4f4cdb0a8..f7ebd94f34 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -235,6 +235,57 @@ static int net_idmap_restore(int argc, const char **argv)
return NT_STATUS_IS_OK(net_idmap_fixup_hwm()) ? 0 : -1;
}
+/***********************************************************
+ Delete a SID mapping from a winbindd_idmap.tdb
+ **********************************************************/
+static int net_idmap_delete(int argc, const char **argv)
+{
+ TDB_CONTEXT *idmap_tdb;
+ TDB_DATA key, data;
+ fstring sid;
+
+ if (argc != 2)
+ return net_help_idmap(argc, argv);
+
+ idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDWR, 0);
+
+ if (idmap_tdb == NULL) {
+ d_printf("Could not open idmap: %s\n", argv[0]);
+ return -1;
+ }
+
+ fstrcpy(sid, argv[1]);
+
+ if (strncmp(sid, "S-1-5-", strlen("S-1-5-")) != 0) {
+ d_printf("Can only delete SIDs, %s is does not start with "
+ "S-1-5-\n", sid);
+ return -1;
+ }
+
+ key.dptr = sid;
+ key.dsize = strlen(key.dptr)+1;
+
+ data = tdb_fetch(idmap_tdb, key);
+
+ if (data.dptr == NULL) {
+ d_printf("Could not find sid %s\n", argv[1]);
+ return -1;
+ }
+
+ if (tdb_delete(idmap_tdb, key) != 0) {
+ d_printf("Could not delete key %s\n", argv[1]);
+ return -1;
+ }
+
+ if (tdb_delete(idmap_tdb, data) != 0) {
+ d_printf("Could not delete key %s\n", data.dptr);
+ return -1;
+ }
+
+ return 0;
+}
+
+
int net_help_idmap(int argc, const char **argv)
{
d_printf("net idmap dump filename"\
@@ -243,6 +294,8 @@ int net_help_idmap(int argc, const char **argv)
d_printf("net idmap restore"\
"\n Restore entries from stdin to current local idmap\n");
+ /* Deliberately *not* document net idmap delete */
+
return -1;
}
@@ -254,6 +307,7 @@ int net_idmap(int argc, const char **argv)
struct functable func[] = {
{"dump", net_idmap_dump},
{"restore", net_idmap_restore},
+ {"delete", net_idmap_delete},
{"help", net_help_idmap},
{NULL, NULL}
};