From 4b3e2adf8c8d8e507e66a8dd6fcd4b6d211c8388 Mon Sep 17 00:00:00 2001 From: Vicentiu Ciorbaru Date: Tue, 26 Jul 2011 13:24:58 +0300 Subject: s3-net: Created function net_rpc_conf_del_value Function is used to refactor some of the code used in delincludes and also to be used in the other key manipulating functions. Signed-off-by: Michael Adam --- source3/utils/net_rpc_conf.c | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_conf.c b/source3/utils/net_rpc_conf.c index ddf56772b3..3323e6b9b0 100644 --- a/source3/utils/net_rpc_conf.c +++ b/source3/utils/net_rpc_conf.c @@ -107,6 +107,77 @@ static int rpc_conf_delincludes_usage(struct net_context *c, int argc, return -1; } +static NTSTATUS rpc_conf_del_value(TALLOC_CTX *mem_ctx, + struct dcerpc_binding_handle *b, + struct policy_handle *parent_hnd, + const char *share_name, + const char *value, + WERROR *werr) +{ + + TALLOC_CTX *frame = talloc_stackframe(); + NTSTATUS status = NT_STATUS_OK; + WERROR result = WERR_OK; + WERROR _werr; + + struct winreg_String keyname, valuename; + struct policy_handle child_hnd; + + ZERO_STRUCT(child_hnd); + ZERO_STRUCT(keyname); + ZERO_STRUCT(valuename); + + keyname.name = share_name; + valuename.name = value; + + status = dcerpc_winreg_OpenKey(b, frame, parent_hnd, keyname, 0, + REG_KEY_WRITE, &child_hnd, &result); + + if (!(NT_STATUS_IS_OK(status))) { + d_fprintf(stderr, _("Failed to open key '%s': %s\n"), + keyname.name, nt_errstr(status)); + goto error; + } + + if (!(W_ERROR_IS_OK(result))) { + d_fprintf(stderr, _("Failed to open key '%s': %s\n"), + keyname.name, win_errstr(result)); + goto error; + } + + status = dcerpc_winreg_DeleteValue(b, + frame, + &child_hnd, + valuename, + &result); + + if (!(NT_STATUS_IS_OK(status))) { + d_fprintf(stderr, _("Failed to delete value %s\n"), + nt_errstr(status)); + goto error; + } + + if (!(W_ERROR_IS_OK(result))) { + if (W_ERROR_EQUAL(result, WERR_BADFILE)){ + result = WERR_OK; + goto error; + } + + d_fprintf(stderr, _("Failed to delete value %s\n"), + win_errstr(result)); + goto error; + } + +error: + *werr = result; + + dcerpc_winreg_CloseKey(b, frame, &child_hnd, &_werr); + + TALLOC_FREE(frame); + return status;; + +} + static NTSTATUS rpc_conf_get_share(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *b, struct policy_handle *parent_hnd, -- cgit