summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndreas Schneider <asn@redhat.com>2010-03-15 12:30:05 +0100
committerGünther Deschner <gd@samba.org>2010-04-07 15:16:52 +0200
commit77d1b73a3e31f67dce28055603c34bd78e927616 (patch)
tree27314308f70793a074be5ac5171760f154a99896 /source3/rpc_server
parente498338f6f29ffdcca0f3108968e04f635c797d4 (diff)
downloadsamba-77d1b73a3e31f67dce28055603c34bd78e927616.tar.gz
samba-77d1b73a3e31f67dce28055603c34bd78e927616.tar.bz2
samba-77d1b73a3e31f67dce28055603c34bd78e927616.zip
s3-spoolss: Added a delete_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.c72
-rw-r--r--source3/rpc_server/srv_spoolss_util.h21
2 files changed, 90 insertions, 3 deletions
diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c
index 4c5f78526f..4837c1c3db 100644
--- a/source3/rpc_server/srv_spoolss_util.c
+++ b/source3/rpc_server/srv_spoolss_util.c
@@ -549,9 +549,6 @@ WERROR winreg_enum_printer_dataex(struct pipes_struct *p,
return WERR_NOMEM;
}
- ZERO_STRUCT(hive_hnd);
- ZERO_STRUCT(key_hnd);
-
result = winreg_printer_openkey(tmp_ctx,
p->server_info,
&winreg_pipe,
@@ -597,3 +594,72 @@ done:
TALLOC_FREE(tmp_ctx);
return result;
}
+
+/* Delete printer data over a winreg pipe. */
+WERROR winreg_delete_printer_dataex(struct pipes_struct *p,
+ const char *printer,
+ const char *key,
+ const char *value)
+{
+ 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);
+
+ result = winreg_printer_openkey(tmp_ctx,
+ p->server_info,
+ &winreg_pipe,
+ printer,
+ key,
+ false,
+ access_mask,
+ &hive_hnd,
+ &key_hnd);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("winreg_delete_printer_dataex: Could not open key %s: %s\n",
+ key, win_errstr(result)));
+ goto done;
+ }
+
+ wvalue.name = value;
+ status = rpccli_winreg_DeleteValue(winreg_pipe,
+ tmp_ctx,
+ &key_hnd,
+ wvalue,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("winreg_delete_printer_dataex: Could not delete 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 9be4a2be5d..2e6aa903f0 100644
--- a/source3/rpc_server/srv_spoolss_util.h
+++ b/source3/rpc_server/srv_spoolss_util.h
@@ -106,4 +106,25 @@ WERROR winreg_enum_printer_dataex(struct pipes_struct *p,
uint32_t *pnum_values,
struct spoolss_PrinterEnumValues **penum_values);
+/**
+ * @internal
+ *
+ * @brief Delete printer data over a 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 delete.
+ *
+ * @param[in] value The name of the value to delete.
+ *
+ * @return On success WERR_OK, a corresponding DOS error is
+ * something went wrong.
+ */
+WERROR winreg_delete_printer_dataex(struct pipes_struct *p,
+ const char *printer,
+ const char *key,
+ const char *value);
+
#endif /* _SRV_SPOOLSS_UITL_H */