diff options
author | Simo Sorce <idra@samba.org> | 2010-04-19 21:50:52 -0400 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-04-23 16:30:57 +0200 |
commit | 8cb79bf4cd577468dd891106ce6e0d01969b2233 (patch) | |
tree | 01c33572bbef4f5775e4193bdff68ff42f525475 /source3 | |
parent | 8db203a4a60a8d043e36138873ed457f48acce72 (diff) | |
download | samba-8cb79bf4cd577468dd891106ce6e0d01969b2233.tar.gz samba-8cb79bf4cd577468dd891106ce6e0d01969b2233.tar.bz2 samba-8cb79bf4cd577468dd891106ce6e0d01969b2233.zip |
s3-spoolss: Added a winreg_get_driver_list function.
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/rpc_server/srv_spoolss_util.c | 67 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_util.h | 27 |
2 files changed, 94 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c index d6312864a8..f06b30bcc7 100644 --- a/source3/rpc_server/srv_spoolss_util.c +++ b/source3/rpc_server/srv_spoolss_util.c @@ -2973,3 +2973,70 @@ done: TALLOC_FREE(tmp_ctx); return result; } + +WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + const char *architecture, + uint32_t version, + uint32_t *num_drivers, + const char ***drivers) +{ + uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + struct rpc_pipe_client *winreg_pipe = NULL; + struct policy_handle hive_hnd, key_hnd; + TALLOC_CTX *tmp_ctx; + WERROR result; + + ZERO_STRUCT(hive_hnd); + ZERO_STRUCT(key_hnd); + + tmp_ctx = talloc_new(mem_ctx); + if (tmp_ctx == NULL) { + return WERR_NOMEM; + } + + /* use NULL for the driver name so we open the key that is + * parent of all drivers for this architecture and version */ + result = winreg_printer_opendriver(tmp_ctx, + server_info, + NULL, + architecture, + version, + access_mask, false, + &winreg_pipe, + &hive_hnd, + &key_hnd); + if (!W_ERROR_IS_OK(result)) { + DEBUG(5, ("winreg_get_driver_list: " + "Could not open key (%s,%u): %s\n", + architecture, version, win_errstr(result))); + goto done; + } + + result = winreg_printer_enumkeys(tmp_ctx, + winreg_pipe, + &key_hnd, + num_drivers, + drivers); + if (!W_ERROR_IS_OK(result)) { + DEBUG(0, ("winreg_get_driver_list: " + "Could not enumerate drivers for (%s,%u): %s\n", + architecture, version, win_errstr(result))); + 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 fad5f3a8bf..35a47283e2 100644 --- a/source3/rpc_server/srv_spoolss_util.h +++ b/source3/rpc_server/srv_spoolss_util.h @@ -397,4 +397,31 @@ WERROR winreg_del_driver(TALLOC_CTX *mem_ctx, struct spoolss_DriverInfo8 *info8, uint32_t version); +/** + * @brief This function gets printer drivers list for the specified + * architecture and type version + * + * @param[in] mem_ctx A talloc memory context. + * + * @param[in] server_info Auth info to open the pipe. + * + * @param[in] architecture The architecture type. + * + * @param[in] version The driver version. + * + * @param[out] num_drivers The number of drivers. + * + * @param[out] version The drivers names. + * + * @return On success WERR_OK, a corresponding DOS error is + * something went wrong. + */ + +WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info *server_info, + const char *architecture, + uint32_t version, + uint32_t *num_drivers, + const char ***drivers); + #endif /* _SRV_SPOOLSS_UITL_H */ |