summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-04-28 12:41:23 +0200
committerSimo Sorce <idra@samba.org>2010-07-27 10:27:10 -0400
commit48828ab154160489586fd07e442739db35103fca (patch)
tree9ca0c419d75c5883b356ffffabe1bdd10f5e29bc /source3/rpc_server
parenta1fe2ed68aef71083dc6a9938440e32e5a0cf63c (diff)
downloadsamba-48828ab154160489586fd07e442739db35103fca.tar.gz
samba-48828ab154160489586fd07e442739db35103fca.tar.bz2
samba-48828ab154160489586fd07e442739db35103fca.zip
s3-spoolss: Fixed the driver unc strings for dependent files.
Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c226
1 files changed, 162 insertions, 64 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 2967fe11e2..99257024c7 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -4258,30 +4258,52 @@ WERROR _spoolss_GetPrinter(pipes_struct *p,
/********************************************************************
********************************************************************/
-static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
+#define FILL_DRIVER_STRING(mem_ctx, in, out) \
+ do { \
+ if (in && strlen(in)) { \
+ out = talloc_strdup(mem_ctx, in); \
+ W_ERROR_HAVE_NO_MEMORY(out); \
+ } else { \
+ out = NULL; \
+ } \
+ } while (0);
+
+#define FILL_DRIVER_UNC_STRING(mem_ctx, server, arch, ver, in, out) \
+ do { \
+ if (in && strlen(in)) { \
+ out = talloc_asprintf(mem_ctx, "\\\\%s\\print$\\%s\\%d\\%s", server, get_short_archi(arch), ver, in); \
+ } else { \
+ out = talloc_strdup(mem_ctx, ""); \
+ } \
+ W_ERROR_HAVE_NO_MEMORY(out); \
+ } while (0);
+
+static WERROR string_array_from_driver_info(TALLOC_CTX *mem_ctx,
const char **string_array,
- const char *cservername)
+ const char ***presult,
+ const char *cservername,
+ const char *arch,
+ int version)
{
int i, num_strings = 0;
const char **array = NULL;
- if (!string_array) {
- return NULL;
+ if (string_array == NULL) {
+ return WERR_INVALID_PARAMETER;;
}
for (i=0; string_array[i] && string_array[i][0] != '\0'; i++) {
+ const char *str = NULL;
- const char *str = talloc_asprintf(mem_ctx, "\\\\%s%s",
- cservername, string_array[i]);
- if (!str) {
- TALLOC_FREE(array);
- return NULL;
+ if (cservername == NULL || arch == NULL) {
+ FILL_DRIVER_STRING(mem_ctx, string_array[i], str);
+ } else {
+ FILL_DRIVER_UNC_STRING(mem_ctx, cservername, arch, version, string_array[i], str);
}
-
if (!add_string_to_array(mem_ctx, str, &array, &num_strings)) {
TALLOC_FREE(array);
- return NULL;
+ return WERR_NOMEM;
}
}
@@ -4290,28 +4312,12 @@ static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
&array, &num_strings);
}
- return array;
-}
-
-#define FILL_DRIVER_STRING(mem_ctx, in, out) \
- do { \
- if (in && strlen(in)) { \
- out = talloc_strdup(mem_ctx, in); \
- W_ERROR_HAVE_NO_MEMORY(out); \
- } else { \
- out = NULL; \
- } \
- } while (0);
+ if (presult) {
+ *presult = array;
+ }
-#define FILL_DRIVER_UNC_STRING(mem_ctx, server, in, out) \
- do { \
- if (in && strlen(in)) { \
- out = talloc_asprintf(mem_ctx, "\\\\%s%s", server, in); \
- } else { \
- out = talloc_strdup(mem_ctx, ""); \
- } \
- W_ERROR_HAVE_NO_MEMORY(out); \
- } while (0);
+ return WERR_OK;
+}
/********************************************************************
* fill a spoolss_DriverInfo1 struct
@@ -4348,14 +4354,20 @@ static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
@@ -4381,18 +4393,26 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->help_file,
r->help_file);
@@ -4404,10 +4424,12 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
driver->default_datatype,
r->default_datatype);
- r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->dependent_files,
- cservername);
- return WERR_OK;
+ return string_array_from_driver_info(mem_ctx,
+ driver->dependent_files,
+ &r->dependent_files,
+ cservername,
+ driver->architecture,
+ driver->version);
}
/********************************************************************
@@ -4420,6 +4442,7 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
const char *servername)
{
const char *cservername = canon_servername(servername);
+ WERROR result;
r->version = driver->version;
@@ -4429,24 +4452,38 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->help_file,
r->help_file);
- r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->dependent_files,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->dependent_files,
+ &r->dependent_files,
+ cservername,
+ driver->architecture,
+ driver->version);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
FILL_DRIVER_STRING(mem_ctx,
driver->monitor_name,
@@ -4456,11 +4493,13 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
driver->default_datatype,
r->default_datatype);
- r->previous_names = string_array_from_driver_info(mem_ctx,
- driver->previous_names,
- cservername);
- return WERR_OK;
+ result = string_array_from_driver_info(mem_ctx,
+ driver->previous_names,
+ &r->previous_names,
+ NULL, NULL, 0);
+
+ return result;
}
/********************************************************************
@@ -4482,14 +4521,20 @@ static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
@@ -4509,6 +4554,7 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
const char *servername)
{
const char *cservername = canon_servername(servername);
+ WERROR result;
r->version = driver->version;
@@ -4518,18 +4564,26 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->help_file,
r->help_file);
@@ -4541,12 +4595,23 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
driver->default_datatype,
r->default_datatype);
- r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->dependent_files,
- cservername);
- r->previous_names = string_array_from_driver_info(mem_ctx,
- driver->previous_names,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->dependent_files,
+ &r->dependent_files,
+ cservername,
+ driver->architecture,
+ driver->version);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ result = string_array_from_driver_info(mem_ctx,
+ driver->previous_names,
+ &r->previous_names,
+ NULL, NULL, 0);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
r->driver_date = driver->driver_date;
r->driver_version = driver->driver_version;
@@ -4577,6 +4642,7 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
const char *servername)
{
const char *cservername = canon_servername(servername);
+ WERROR result;
r->version = driver->version;
@@ -4586,18 +4652,26 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->architecture);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->driver_path,
r->driver_path);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->data_file,
r->data_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->config_file,
r->config_file);
FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+ driver->architecture,
+ driver->version,
driver->help_file,
r->help_file);
@@ -4609,12 +4683,23 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
driver->default_datatype,
r->default_datatype);
- r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->dependent_files,
- cservername);
- r->previous_names = string_array_from_driver_info(mem_ctx,
- driver->previous_names,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->dependent_files,
+ &r->dependent_files,
+ cservername,
+ driver->architecture,
+ driver->version);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ result = string_array_from_driver_info(mem_ctx,
+ driver->previous_names,
+ &r->previous_names,
+ NULL, NULL, 0);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
r->driver_date = driver->driver_date;
r->driver_version = driver->driver_version;
@@ -4639,9 +4724,13 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
driver->vendor_setup,
r->vendor_setup);
- r->color_profiles = string_array_from_driver_info(mem_ctx,
- driver->color_profiles,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->color_profiles,
+ &r->color_profiles,
+ NULL, NULL, 0);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
FILL_DRIVER_STRING(mem_ctx,
driver->inf_path,
@@ -4649,9 +4738,13 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
r->printer_driver_attributes = driver->printer_driver_attributes;
- r->core_driver_dependencies = string_array_from_driver_info(mem_ctx,
- driver->core_driver_dependencies,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->core_driver_dependencies,
+ &r->core_driver_dependencies,
+ NULL, NULL, 0);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
r->min_inbox_driver_ver_date = driver->min_inbox_driver_ver_date;
r->min_inbox_driver_ver_version = driver->min_inbox_driver_ver_version;
@@ -4812,9 +4905,14 @@ static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
driver->default_datatype,
r->default_datatype);
- r->previous_names = string_array_from_driver_info(mem_ctx,
- driver->previous_names,
- cservername);
+ result = string_array_from_driver_info(mem_ctx,
+ driver->previous_names,
+ &r->previous_names,
+ NULL, NULL, 0);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
r->driver_date = driver->driver_date;
r->driver_version = driver->driver_version;