summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-04-21 09:38:39 -0400
committerGünther Deschner <gd@samba.org>2010-04-23 16:26:24 +0200
commit16e0f806872eaf620b12c375d25f0043d5dea704 (patch)
tree07d51e6853f166bf1cd281ab80a5d5488e83393e /source3
parenta91f6f8b03b5c9342853229dc634bd217e289d5d (diff)
downloadsamba-16e0f806872eaf620b12c375d25f0043d5dea704.tar.gz
samba-16e0f806872eaf620b12c375d25f0043d5dea704.tar.bz2
samba-16e0f806872eaf620b12c375d25f0043d5dea704.zip
s3-spoolss: Added a winreg_get_driver function.
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_spoolss_util.c255
-rw-r--r--source3/rpc_server/srv_spoolss_util.h26
2 files changed, 281 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_spoolss_util.c b/source3/rpc_server/srv_spoolss_util.c
index 54e78d110b..626cd41507 100644
--- a/source3/rpc_server/srv_spoolss_util.c
+++ b/source3/rpc_server/srv_spoolss_util.c
@@ -2633,3 +2633,258 @@ done:
return result;
}
+WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
+ struct auth_serversupplied_info *server_info,
+ const char *architecture,
+ const char *driver_name,
+ uint32_t driver_version,
+ struct spoolss_DriverInfo8 **_info8)
+{
+ uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ struct rpc_pipe_client *winreg_pipe = NULL;
+ struct policy_handle hive_hnd, key_hnd;
+ struct spoolss_DriverInfo8 i8, *info8;
+ struct spoolss_PrinterEnumValues *enum_values = NULL;
+ struct spoolss_PrinterEnumValues *v;
+ uint32_t num_values = 0;
+ TALLOC_CTX *tmp_ctx;
+ WERROR result;
+ uint32_t i;
+
+ ZERO_STRUCT(hive_hnd);
+ ZERO_STRUCT(key_hnd);
+ ZERO_STRUCT(i8);
+
+ tmp_ctx = talloc_new(mem_ctx);
+ if (tmp_ctx == NULL) {
+ return WERR_NOMEM;
+ }
+
+ if (driver_version == DRIVER_ANY_VERSION) {
+ /* look for Win2k first and then for NT4 */
+ result = winreg_printer_opendriver(tmp_ctx,
+ server_info,
+ driver_name,
+ architecture,
+ 3,
+ access_mask, false,
+ &winreg_pipe,
+ &hive_hnd,
+ &key_hnd);
+ if (!W_ERROR_IS_OK(result)) {
+ result = winreg_printer_opendriver(tmp_ctx,
+ server_info,
+ driver_name,
+ architecture,
+ 2,
+ access_mask, false,
+ &winreg_pipe,
+ &hive_hnd,
+ &key_hnd);
+ }
+ } else {
+ /* ok normal case */
+ result = winreg_printer_opendriver(tmp_ctx,
+ server_info,
+ driver_name,
+ architecture,
+ driver_version,
+ access_mask, false,
+ &winreg_pipe,
+ &hive_hnd,
+ &key_hnd);
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(5, ("winreg_get_driver: "
+ "Could not open driver key (%s,%s,%d): %s\n",
+ driver_name, architecture,
+ driver_version, win_errstr(result)));
+ goto done;
+ }
+
+ result = winreg_printer_enumvalues(tmp_ctx,
+ winreg_pipe,
+ &key_hnd,
+ &num_values,
+ &enum_values);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("winreg_get_driver: "
+ "Could not enumerate values for (%s,%s,%d): %s\n",
+ driver_name, architecture,
+ driver_version, win_errstr(result)));
+ goto done;
+ }
+
+ info8 = talloc_zero(tmp_ctx, struct spoolss_DriverInfo8);
+ if (!info8) {
+ result = WERR_NOMEM;
+ goto done;
+ }
+
+ result = WERR_OK;
+
+ for (i = 0; i < num_values; i++) {
+ const char *tmp_str;
+
+ v = &enum_values[i];
+
+#define CHECK_ERROR(result) \
+ if (W_ERROR_IS_OK(result)) continue; \
+ if (W_ERROR_EQUAL(result, WERR_NOT_FOUND)) result = WERR_OK; \
+ if (!W_ERROR_IS_OK(result)) break
+
+ result = winreg_enumval_to_dword(info8, v,
+ "Version",
+ &info8->version);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Driver",
+ &info8->driver_path);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Data File",
+ &info8->data_file);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Configuration File",
+ &info8->config_file);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Help File",
+ &info8->help_file);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_multi_sz(info8, v,
+ "Dependent Files",
+ &info8->dependent_files);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Monitor",
+ &info8->monitor_name);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Datatype",
+ &info8->default_datatype);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_multi_sz(info8, v,
+ "Previous Names",
+ &info8->previous_names);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "DriverDate",
+ &tmp_str);
+ if (W_ERROR_IS_OK(result)) {
+ result = winreg_printer_date_to_NTTIME(tmp_str,
+ &info8->driver_date);
+ }
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "DriverVersion",
+ &tmp_str);
+ if (W_ERROR_IS_OK(result)) {
+ result = winreg_printer_ver_to_dword(tmp_str,
+ &info8->driver_version);
+ }
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Manufacturer",
+ &info8->manufacturer_name);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "OEM URL",
+ &info8->manufacturer_url);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "HardwareID",
+ &info8->hardware_id);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Provider",
+ &info8->provider);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "Print Processor",
+ &info8->print_processor);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "VendorSetup",
+ &info8->vendor_setup);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_multi_sz(info8, v,
+ "Color Profiles",
+ &info8->color_profiles);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "InfPath",
+ &info8->inf_path);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_dword(info8, v,
+ "PrinterDriverAttributes",
+ &info8->printer_driver_attributes);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_multi_sz(info8, v,
+ "CoreDependencies",
+ &info8->core_driver_dependencies);
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "MinInboxDriverVerDate",
+ &tmp_str);
+ if (W_ERROR_IS_OK(result)) {
+ result = winreg_printer_date_to_NTTIME(tmp_str,
+ &info8->min_inbox_driver_ver_date);
+ }
+ CHECK_ERROR(result);
+
+ result = winreg_enumval_to_sz(info8, v,
+ "MinInboxDriverVerVersion",
+ &tmp_str);
+ if (W_ERROR_IS_OK(result)) {
+ result = winreg_printer_ver_to_dword(tmp_str,
+ &info8->min_inbox_driver_ver_version);
+ }
+ CHECK_ERROR(result);
+ }
+
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("winreg_enumval_to_TYPE() failed "
+ "for %s: %s\n", v->value_name,
+ win_errstr(result)));
+ goto done;
+ }
+
+ *_info8 = talloc_steal(mem_ctx, info8);
+ 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 c33e111300..4ff730db1e 100644
--- a/source3/rpc_server/srv_spoolss_util.h
+++ b/source3/rpc_server/srv_spoolss_util.h
@@ -351,4 +351,30 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
const char **driver_name,
uint32_t *driver_version);
+/**
+ * @brief This function gets printer driver information
+ *
+ * @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] driver_name The driver name.
+ *
+ * @param[in] driver_version The driver version.
+ *
+ * @param[out] _info8 The structure that holds the full driver information.
+ *
+ * @return On success WERR_OK, a corresponding DOS error is
+ * something went wrong.
+ */
+
+WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
+ struct auth_serversupplied_info *server_info,
+ const char *architecture,
+ const char *driver_name,
+ uint32_t driver_version,
+ struct spoolss_DriverInfo8 **_info8);
+
#endif /* _SRV_SPOOLSS_UITL_H */