summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndreas Schneider <asn@redhat.com>2010-03-15 12:24:59 +0100
committerGünther Deschner <gd@samba.org>2010-04-07 15:16:52 +0200
commitbc235459094f01e6fbf3b544bb4848427ceae9d5 (patch)
treeaec8441f95f1b96b93b2dd76ea644f407593a4ac /source3/rpc_server
parent4f3893f8148a36d11a4fa333c323fcf6f0176b2e (diff)
downloadsamba-bc235459094f01e6fbf3b544bb4848427ceae9d5.tar.gz
samba-bc235459094f01e6fbf3b544bb4848427ceae9d5.tar.bz2
samba-bc235459094f01e6fbf3b544bb4848427ceae9d5.zip
s3-spoolss: Added a set_printer_dataex function using the winreg pipe.
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_util.c76
-rw-r--r--source3/rpc_server/srv_spoolss_util.h30
2 files changed, 106 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c
index 63178b3c90..dbefd5343e 100644
--- a/source3/rpc_server/srv_spoolss_util.c
+++ b/source3/rpc_server/srv_spoolss_util.c
@@ -165,3 +165,79 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
+
+/* Set printer data over the winreg pipe. */
+WERROR winreg_set_printer_dataex(struct pipes_struct *p,
+ const char *printer,
+ const char *key,
+ const char *value,
+ enum winreg_Type type,
+ uint8_t *data,
+ uint32_t data_size)
+{
+ uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ struct rpc_pipe_client *winreg_pipe = NULL;
+ struct policy_handle hive_hnd, key_hnd;
+ struct winreg_String wvalue;
+ WERROR result = WERR_OK;
+ NTSTATUS status;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(p->mem_ctx);
+ if (tmp_ctx == NULL) {
+ return WERR_NOMEM;
+ }
+
+ ZERO_STRUCT(hive_hnd);
+ ZERO_STRUCT(key_hnd);
+
+ DEBUG(8, ("winreg_set_printer_dataex: Open printer key %s, value %s, access_mask: 0x%05x for [%s]\n",
+ key, value, access_mask, printer));
+ result = winreg_printer_openkey(tmp_ctx,
+ p->server_info,
+ &winreg_pipe,
+ printer,
+ key,
+ true,
+ access_mask,
+ &hive_hnd,
+ &key_hnd);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("winreg_set_printer_dataex: Could not open key %s: %s\n",
+ key, win_errstr(result)));
+ goto done;
+ }
+
+ wvalue.name = value;
+ status = rpccli_winreg_SetValue(winreg_pipe,
+ tmp_ctx,
+ &key_hnd,
+ wvalue,
+ type,
+ data,
+ data_size,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("winreg_set_printer_dataex: Could not set value %s: %s\n",
+ value, nt_errstr(status)));
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+ result = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ result = WERR_OK;
+done:
+ if (winreg_pipe != NULL) {
+ if (is_valid_policy_hnd(&key_hnd)) {
+ rpccli_winreg_CloseKey(winreg_pipe, tmp_ctx, &key_hnd, NULL);
+ }
+ if (is_valid_policy_hnd(&hive_hnd)) {
+ rpccli_winreg_CloseKey(winreg_pipe, tmp_ctx, &hive_hnd, NULL);
+ }
+ }
+
+ TALLOC_FREE(tmp_ctx);
+ return result;
+}
diff --git a/source3/rpc_server/srv_spoolss_util.h b/source3/rpc_server/srv_spoolss_util.h
index 3118bbc835..4faa35049f 100644
--- a/source3/rpc_server/srv_spoolss_util.h
+++ b/source3/rpc_server/srv_spoolss_util.h
@@ -22,4 +22,34 @@
#ifndef _SRV_SPOOLSS_UITL_H
#define _SRV_SPOOLSS_UITL_H
+/**
+ * @internal
+ *
+ * @brief Set printer data over the winreg pipe.
+ *
+ * @param[in] p The pipes structure to be able to open a new pipe.
+ *
+ * @param[in] printer The printer name.
+ *
+ * @param[in] key The key of the printer data to store the value.
+ *
+ * @param[in] value The value name to save.
+ *
+ * @param[in] type The type of the value to use.
+ *
+ * @param[in] data The data which sould be saved under the given value.
+ *
+ * @param[in] data_size The size of the data.
+ *
+ * @return On success WERR_OK, a corresponding DOS error is
+ * something went wrong.
+ */
+WERROR winreg_set_printer_dataex(struct pipes_struct *p,
+ const char *printer,
+ const char *key,
+ const char *value,
+ enum winreg_Type type,
+ uint8_t *data,
+ uint32_t data_size);
+
#endif /* _SRV_SPOOLSS_UITL_H */