From 050fb746b3ed615af9572d975ba3449ffe6657e1 Mon Sep 17 00:00:00 2001 From: Atul Kulkarni Date: Tue, 10 Sep 2013 01:47:46 +0200 Subject: net: add "net idmap set config" command to store the autorid global config Pair-Programmed-With: Michael Adam Signed-off-by: Atul Kulkarni Signed-off-by: Michael Adam Reviewed-by: Volker Lendecke --- source3/utils/net_idmap.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'source3/utils') diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index c22c5d551d..80dc0424ce 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -736,6 +736,45 @@ static int net_idmap_secret(struct net_context *c, int argc, const char **argv) return 0; } +static int net_idmap_autorid_set_config(struct net_context *c, + int argc, const char **argv) +{ + int ret = -1; + NTSTATUS status; + TALLOC_CTX *mem_ctx; + struct db_context *db = NULL; + + if (argc != 1 || c->display_usage) { + d_printf("%s\n%s", + _("Usage:"), + _("net idmap set config " + " [--db=]\n" + " Update CONFIG entry in autorid.\n" + " config\tConfig string to be stored\n" + " inputfile\tTDB file to update config.\n")); + return c->display_usage ? 0 : -1; + } + + mem_ctx = talloc_stackframe(); + + if (!net_idmap_opendb_autorid(mem_ctx, c, false, &db)) { + goto done; + } + + status = idmap_autorid_saveconfigstr(db, argv[0]); + if (!NT_STATUS_IS_OK(status)) { + printf("Error storing the config in the database: %s\n", + nt_errstr(status)); + goto done; + } + + ret = 0; + +done: + TALLOC_FREE(mem_ctx); + return ret; +} + static int net_idmap_set(struct net_context *c, int argc, const char **argv) { struct functable func[] = { @@ -747,6 +786,14 @@ static int net_idmap_set(struct net_context *c, int argc, const char **argv) N_("net idmap set mapping\n" " Not implemented yet") }, + { + "config", + net_idmap_autorid_set_config, + NET_TRANSPORT_LOCAL, + N_("Save the global configuration in the autorid database"), + N_("net idmap set config \n" + " Save the global configuration in the autorid database ") + }, { "secret", net_idmap_secret, -- cgit