From cb5c86e5027fd7bca73e855bcf433846a7c680f3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 22 Sep 2010 06:27:49 +0200 Subject: s3:net: add subcommand net registry deletekey_recursive to delete a key including subkeys --- source3/utils/net_registry.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c index 6021fa08e11..7ea68f11262 100644 --- a/source3/utils/net_registry.c +++ b/source3/utils/net_registry.c @@ -240,8 +240,9 @@ done: return ret; } -static int net_registry_deletekey(struct net_context *c, int argc, - const char **argv) +static int net_registry_deletekey_internal(struct net_context *c, int argc, + const char **argv, + bool recursive) { WERROR werr; char *subkeyname; @@ -271,7 +272,11 @@ static int net_registry_deletekey(struct net_context *c, int argc, goto done; } - werr = reg_deletekey(hivekey, subkeyname); + if (recursive) { + werr = reg_deletekey_recursive(hivekey, subkeyname); + } else { + werr = reg_deletekey(hivekey, subkeyname); + } if (!W_ERROR_IS_OK(werr)) { d_fprintf(stderr, "reg_deletekey %s: %s\n", _("failed"), win_errstr(werr)); @@ -285,6 +290,18 @@ done: return ret; } +static int net_registry_deletekey(struct net_context *c, int argc, + const char **argv) +{ + return net_registry_deletekey_internal(c, argc, argv, false); +} + +static int net_registry_deletekey_recursive(struct net_context *c, int argc, + const char **argv) +{ + return net_registry_deletekey_internal(c, argc, argv, true); +} + static int net_registry_getvalue_internal(struct net_context *c, int argc, const char **argv, bool raw) { @@ -1123,6 +1140,14 @@ int net_registry(struct net_context *c, int argc, const char **argv) N_("net registry deletekey\n" " Delete a registry key") }, + { + "deletekey_recursive", + net_registry_deletekey_recursive, + NET_TRANSPORT_LOCAL, + N_("Delete a registry key with subkeys"), + N_("net registry deletekey_recursive\n" + " Delete a registry key with subkeys") + }, { "getvalue", net_registry_getvalue, -- cgit