diff options
author | Andreas Schneider <asn@samba.org> | 2010-04-09 12:36:37 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-04-23 16:07:09 +0200 |
commit | a18cd32a3478d533b679bc134b7dda66e1869521 (patch) | |
tree | 5217fcdb1b44806cd852495551a684f5c094ad4e | |
parent | b320fad6e4c6991f636e3635aeba3d5e1a7a9ed5 (diff) | |
download | samba-a18cd32a3478d533b679bc134b7dda66e1869521.tar.gz samba-a18cd32a3478d533b679bc134b7dda66e1869521.tar.bz2 samba-a18cd32a3478d533b679bc134b7dda66e1869521.zip |
s3-spoolss: Added winreg helper functions to write registry values.
Signed-off-by: Günther Deschner <gd@samba.org>
-rw-r--r-- | source3/rpc_server/srv_spoolss_util.c | 104 |
1 files changed, 104 insertions, 0 deletions
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 ********************************************************************/ |