From a18cd32a3478d533b679bc134b7dda66e1869521 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 9 Apr 2010 12:36:37 +0200 Subject: s3-spoolss: Added winreg helper functions to write registry values. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner --- source3/rpc_server/srv_spoolss_util.c | 104 ++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'source3') diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c index 00a9820962..b7abae0ff8 100644 --- a/source3/rpc_server/srv_spoolss_util.c +++ b/source3/rpc_server/srv_spoolss_util.c @@ -720,6 +720,110 @@ done: return result; } +static WERROR winreg_printer_write_sz(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_handle, + struct policy_handle *key_handle, + const char *value, + const char *data) +{ + struct winreg_String wvalue; + DATA_BLOB blob; + WERROR result = WERR_OK; + NTSTATUS status; + + wvalue.name = value; + if (data == NULL) { + blob = data_blob_string_const(""); + } else { + if (!push_reg_sz(mem_ctx, NULL, &blob, data)) { + DEBUG(0, ("winreg_printer_write_sz: Could not marshall string %s for %s\n", + data, wvalue.name)); + return WERR_NOMEM; + } + } + status = rpccli_winreg_SetValue(pipe_handle, + mem_ctx, + key_handle, + wvalue, + REG_SZ, + blob.data, + blob.length, + &result); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("winreg_printer_write_sz: Could not set value %s: %s\n", + wvalue.name, win_errstr(result))); + if (!W_ERROR_IS_OK(result)) { + result = ntstatus_to_werror(status); + } + } + + return result; +} + +static WERROR winreg_printer_write_dword(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_handle, + struct policy_handle *key_handle, + const char *value, + uint32_t data) +{ + struct winreg_String wvalue; + DATA_BLOB blob; + WERROR result = WERR_OK; + NTSTATUS status; + + wvalue.name = value; + blob = data_blob_talloc(mem_ctx, NULL, 4); + SIVAL(blob.data, 0, data); + + status = rpccli_winreg_SetValue(pipe_handle, + mem_ctx, + key_handle, + wvalue, + REG_DWORD, + blob.data, + blob.length, + &result); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("winreg_printer_write_dword: Could not set value %s: %s\n", + wvalue.name, win_errstr(result))); + if (!W_ERROR_IS_OK(result)) { + result = ntstatus_to_werror(status); + } + } + + return result; +} + +static WERROR winreg_printer_write_binary(TALLOC_CTX *mem_ctx, + struct rpc_pipe_client *pipe_handle, + struct policy_handle *key_handle, + const char *value, + DATA_BLOB blob) +{ + struct winreg_String wvalue; + WERROR result = WERR_OK; + NTSTATUS status; + + wvalue.name = value; + status = rpccli_winreg_SetValue(pipe_handle, + mem_ctx, + key_handle, + wvalue, + REG_BINARY, + blob.data, + blob.length, + &result); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("winreg_printer_write_binary: Could not set value %s: %s\n", + wvalue.name, win_errstr(result))); + if (!W_ERROR_IS_OK(result)) { + result = ntstatus_to_werror(status); + } + } + + return result; +} + /******************************************************************** Public winreg function for spoolss ********************************************************************/ -- cgit