diff options
author | Günther Deschner <gd@samba.org> | 2016-09-10 00:06:27 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2016-09-22 12:29:27 +0200 |
commit | 302cb086a671dfe97d749c4672aecfe61238f350 (patch) | |
tree | c57bd57d1352338ceb275a3770b7b2edf5825bbf /source3/rpc_client | |
parent | e207febf1526d4ac852426cf95ddb72912074c35 (diff) | |
download | samba-302cb086a671dfe97d749c4672aecfe61238f350.tar.gz |
s3-rpc_client: add winreg_get_printserver_secdesc.
Guenther
Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_winreg_spoolss.c | 52 | ||||
-rw-r--r-- | source3/rpc_client/cli_winreg_spoolss.h | 17 |
2 files changed, 56 insertions, 13 deletions
diff --git a/source3/rpc_client/cli_winreg_spoolss.c b/source3/rpc_client/cli_winreg_spoolss.c index f1df336c895..cbb22a3e2ed 100644 --- a/source3/rpc_client/cli_winreg_spoolss.c +++ b/source3/rpc_client/cli_winreg_spoolss.c @@ -1606,15 +1606,15 @@ done: return result; } -WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx, - struct dcerpc_binding_handle *winreg_handle, - const char *sharename, - struct spoolss_security_descriptor **psecdesc) +static WERROR winreg_get_secdesc(TALLOC_CTX *mem_ctx, + struct dcerpc_binding_handle *winreg_handle, + const char *path, + const char *attribute, + struct spoolss_security_descriptor **psecdesc) { struct spoolss_security_descriptor *secdesc; uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED; struct policy_handle hive_hnd, key_hnd; - const char *path; TALLOC_CTX *tmp_ctx; NTSTATUS status; WERROR result; @@ -1625,12 +1625,6 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx, return WERR_NOMEM; } - path = winreg_printer_data_keyname(tmp_ctx, sharename); - if (path == NULL) { - talloc_free(tmp_ctx); - return WERR_NOMEM; - } - ZERO_STRUCT(hive_hnd); ZERO_STRUCT(key_hnd); @@ -1652,7 +1646,7 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx, status = dcerpc_winreg_query_sd(tmp_ctx, winreg_handle, &key_hnd, - "Security", + attribute, &secdesc, &result); if (!NT_STATUS_IS_OK(status)) { @@ -1741,7 +1735,7 @@ create_default: status = dcerpc_winreg_set_sd(tmp_ctx, winreg_handle, &key_hnd, - "Security", + attribute, secdesc, &result); if (!NT_STATUS_IS_OK(status)) { @@ -1768,6 +1762,38 @@ done: return result; } +WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx, + struct dcerpc_binding_handle *winreg_handle, + const char *sharename, + struct spoolss_security_descriptor **psecdesc) +{ + WERROR result; + char *path; + + path = winreg_printer_data_keyname(mem_ctx, sharename); + if (path == NULL) { + return WERR_NOMEM; + } + + result = winreg_get_secdesc(mem_ctx, winreg_handle, + path, + "Security", + psecdesc); + talloc_free(path); + + return result; +} + +WERROR winreg_get_printserver_secdesc(TALLOC_CTX *mem_ctx, + struct dcerpc_binding_handle *winreg_handle, + struct spoolss_security_descriptor **psecdesc) +{ + return winreg_get_secdesc(mem_ctx, winreg_handle, + TOP_LEVEL_CONTROL_KEY, + "ServerSecurityDescriptor", + psecdesc); +} + WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx, struct dcerpc_binding_handle *winreg_handle, const char *sharename, diff --git a/source3/rpc_client/cli_winreg_spoolss.h b/source3/rpc_client/cli_winreg_spoolss.h index aa4d98f681f..279e585855a 100644 --- a/source3/rpc_client/cli_winreg_spoolss.h +++ b/source3/rpc_client/cli_winreg_spoolss.h @@ -146,6 +146,23 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx, struct spoolss_security_descriptor **psecdesc); /** + * @brief Get the security descriptor for a printserver. + * + * @param[in] mem_ctx The talloc memory context to use. + * + * @param[in] b The dcerpc binding handle + * + * @param[out] psecdesc A pointer to store the security descriptor. + * + * @return On success WERR_OK, a corresponding DOS error is + * something went wrong. + */ + +WERROR winreg_get_printserver_secdesc(TALLOC_CTX *mem_ctx, + struct dcerpc_binding_handle *winreg_handle, + struct spoolss_security_descriptor **psecdesc); + +/** * @brief Set the security descriptor for a printer. * * @param[in] mem_ctx The talloc memory context to use. |