net: add "net idmap set config" command to store the autorid global config
authorAtul Kulkarni <atul.kulkarni@in.ibm.com>
Mon, 9 Sep 2013 23:47:46 +0000 (01:47 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 1 Oct 2013 08:49:22 +0000 (10:49 +0200)
Pair-Programmed-With: Michael Adam <obnox@samba.org>

Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com>
Signed-off-by: Michael Adam <obnox@samba.org>
source3/utils/net_idmap.c

index 3fbc4823d0d3e2e1c190b327d452c4bbf0e0a943..b17e819300cb27adf77238efa0c6149fdc88b09b 100644 (file)
@@ -736,6 +736,44 @@ 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 <config>"
+                          " [--db=<inputfile>]\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 updating config to the database \n" );
+               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 +785,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,