summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicentiu Ciorbaru <cvicentiu@gmail.com>2011-07-26 13:24:58 +0300
committerMichael Adam <obnox@samba.org>2011-08-22 13:59:27 +0200
commit4b3e2adf8c8d8e507e66a8dd6fcd4b6d211c8388 (patch)
treeb0efb382d5a120e3851e6061ed9b2f66b04c8b83
parent704d7d02ac9231d30977bbbd4f469fe83af4d71d (diff)
downloadsamba-4b3e2adf8c8d8e507e66a8dd6fcd4b6d211c8388.tar.gz
samba-4b3e2adf8c8d8e507e66a8dd6fcd4b6d211c8388.tar.bz2
samba-4b3e2adf8c8d8e507e66a8dd6fcd4b6d211c8388.zip
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 <obnox@samba.org>
-rw-r--r--source3/utils/net_rpc_conf.c71
1 files changed, 71 insertions, 0 deletions
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,