diff options
author | Andreas Schneider <asn@samba.org> | 2010-03-31 15:31:21 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-04-07 15:16:53 +0200 |
commit | 0d46ab0f3eb9662d7ee3eaf8f680632486878d46 (patch) | |
tree | 822c9807203dd78e8873dca3238f2d697a58390f /source3/rpc_server | |
parent | 93575d6d7051089b50e038a152750939130c6a72 (diff) | |
download | samba-0d46ab0f3eb9662d7ee3eaf8f680632486878d46.tar.gz samba-0d46ab0f3eb9662d7ee3eaf8f680632486878d46.tar.bz2 samba-0d46ab0f3eb9662d7ee3eaf8f680632486878d46.zip |
s3-spoolss: Added a winreg_deleteform1 function.
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_spoolss_util.c | 76 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_util.h | 14 |
2 files changed, 90 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c index b23514c394..f5d4b56011 100644 --- a/source3/rpc_server/srv_spoolss_util.c +++ b/source3/rpc_server/srv_spoolss_util.c @@ -1459,3 +1459,79 @@ done: TALLOC_FREE(tmp_ctx); return result; } + +WERROR winreg_printer_deleteform1(struct pipes_struct *p, + const char *form_name) +{ + 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; + uint32_t num_builtin = ARRAY_SIZE(builtin_forms1); + uint32_t i; + WERROR result = WERR_OK; + NTSTATUS status; + TALLOC_CTX *tmp_ctx; + + for (i = 0; i < num_builtin; i++) { + if (strequal(builtin_forms1[i].form_name, form_name)) { + return WERR_INVALID_PARAMETER; + } + } + + 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, + TOP_LEVEL_CONTROL_FORMS_KEY, + "", + false, + access_mask, + &hive_hnd, + &key_hnd); + if (!W_ERROR_IS_OK(result)) { + DEBUG(0, ("winreg_printer_deleteform1: Could not open key %s: %s\n", + TOP_LEVEL_CONTROL_FORMS_KEY, win_errstr(result))); + if (W_ERROR_EQUAL(result, WERR_BADFILE)) { + result = WERR_INVALID_FORM_NAME; + } + goto done; + } + + wvalue.name = form_name; + status = rpccli_winreg_DeleteValue(winreg_pipe, + tmp_ctx, + &key_hnd, + wvalue, + &result); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("winreg_printer_delteform1: Could not delete value %s: %s\n", + wvalue.name, 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 99cf68107c..e99de5fb63 100644 --- a/source3/rpc_server/srv_spoolss_util.h +++ b/source3/rpc_server/srv_spoolss_util.h @@ -204,4 +204,18 @@ WERROR winreg_printer_enumforms1(struct pipes_struct *p, uint32_t *pnum_info, union spoolss_FormInfo **pinfo); +/** + * @brief This function removes a form name from the list of supported forms. + * + * @param[in] p The pipes structure to be able to open a new pipe. + * + * @param[in] form_name The name of the form to delete. + * + * @return WERR_OK on success. + * WERR_INVALID_PARAM if the form is a builtin form. + * A corresponding DOS error is something went wrong. + */ +WERROR winreg_printer_deleteform1(struct pipes_struct *p, + const char *form_name); + #endif /* _SRV_SPOOLSS_UITL_H */ |