s3:net: add new subcommand "net registry getsd_sddl" to print secdesc in sddl format
authorMichael Adam <obnox@samba.org>
Fri, 26 Feb 2010 08:37:45 +0000 (09:37 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 3 Mar 2010 08:16:37 +0000 (09:16 +0100)
Michael

source3/utils/net_registry.c

index 2a13ebd6bd3247a8aa39fadc321d0cf351680ed7..bf65c4de381e9aa20008bb6a4373f7bd27f2f33e 100644 (file)
@@ -502,6 +502,38 @@ done:
        return ret;
 }
 
        return ret;
 }
 
+static int net_registry_getsd_sddl(struct net_context *c,
+                                  int argc, const char **argv)
+{
+       WERROR werr;
+       int ret = -1;
+       struct security_descriptor *secdesc = NULL;
+       TALLOC_CTX *ctx = talloc_stackframe();
+
+       if (argc != 1 || c->display_usage) {
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net registry getsd_sddl <path>\n"));
+               d_printf("%s\n%s",
+                        _("Example:"),
+                        _("net registry getsd_sddl 'HKLM\\Software\\Samba'\n"));
+               goto done;
+       }
+
+       werr = net_registry_getsd_internal(c, ctx, argv[0], &secdesc);
+       if (!W_ERROR_IS_OK(werr)) {
+               goto done;
+       }
+
+       d_printf("%s\n", sddl_encode(ctx, secdesc, get_global_sam_sid()));
+
+       ret = 0;
+
+done:
+       TALLOC_FREE(ctx);
+       return ret;
+}
+
 int net_registry(struct net_context *c, int argc, const char **argv)
 {
        int ret = -1;
 int net_registry(struct net_context *c, int argc, const char **argv)
 {
        int ret = -1;
@@ -571,6 +603,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
                        N_("net registry getsd\n"
                           "    Get security descriptor")
                },
                        N_("net registry getsd\n"
                           "    Get security descriptor")
                },
+               {
+                       "getsd_sddl",
+                       net_registry_getsd_sddl,
+                       NET_TRANSPORT_LOCAL,
+                       N_("Get security descriptor in sddl format"),
+                       N_("net registry getsd_sddl\n"
+                          "    Get security descriptor in sddl format")
+               },
        { NULL, NULL, 0, NULL, NULL }
        };
 
        { NULL, NULL, 0, NULL, NULL }
        };