a3a04f
From 7afb2ec722fa628a3b214252535a8e31aac16f12 Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Thu, 4 May 2017 17:48:42 +0200
a3a04f
Subject: [PATCH 1/3] s3:printing: Change to GUID dir if we deal with
a3a04f
 COPY_FROM_DIRECTORY
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12761
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
Reviewed-by: Guenther Deschner <gd@samba.org>
a3a04f
(cherry picked from commit 5b15c7e8908697b157d2593b7caa9be760594a05)
a3a04f
---
a3a04f
 source3/printing/nt_printing.c | 51 +++++++++++++++++++++++++++++-------------
a3a04f
 1 file changed, 35 insertions(+), 16 deletions(-)
a3a04f
a3a04f
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
a3a04f
index 394a3e5..49be5d9 100644
a3a04f
--- a/source3/printing/nt_printing.c
a3a04f
+++ b/source3/printing/nt_printing.c
a3a04f
@@ -666,16 +666,18 @@ Determine the correct cVersion associated with an architecture and driver
a3a04f
 static uint32_t get_correct_cversion(struct auth_session_info *session_info,
a3a04f
 				   const char *architecture,
a3a04f
 				   const char *driverpath_in,
a3a04f
+				   const char *driver_directory,
a3a04f
 				   WERROR *perr)
a3a04f
 {
a3a04f
 	int cversion = -1;
a3a04f
 	NTSTATUS          nt_status;
a3a04f
 	struct smb_filename *smb_fname = NULL;
a3a04f
-	char *driverpath = NULL;
a3a04f
 	files_struct      *fsp = NULL;
a3a04f
 	connection_struct *conn = NULL;
a3a04f
 	char *oldcwd;
a3a04f
 	char *printdollar = NULL;
a3a04f
+	char *printdollar_path = NULL;
a3a04f
+	char *working_dir = NULL;
a3a04f
 	int printdollar_snum;
a3a04f
 
a3a04f
 	*perr = WERR_INVALID_PARAMETER;
a3a04f
@@ -704,12 +706,33 @@ static uint32_t get_correct_cversion(struct auth_session_info *session_info,
a3a04f
 		return -1;
a3a04f
 	}
a3a04f
 
a3a04f
+	printdollar_path = lp_path(talloc_tos(), printdollar_snum);
a3a04f
+	if (printdollar_path == NULL) {
a3a04f
+		*perr = WERR_NOT_ENOUGH_MEMORY;
a3a04f
+		return -1;
a3a04f
+	}
a3a04f
+
a3a04f
+	working_dir = talloc_asprintf(talloc_tos(),
a3a04f
+				      "%s/%s",
a3a04f
+				      printdollar_path,
a3a04f
+				      architecture);
a3a04f
+	/*
a3a04f
+	 * If the driver has been uploaded into a temorpary driver
a3a04f
+	 * directory, switch to the driver directory.
a3a04f
+	 */
a3a04f
+	if (driver_directory != NULL) {
a3a04f
+		working_dir = talloc_asprintf(talloc_tos(), "%s/%s/%s",
a3a04f
+					      printdollar_path,
a3a04f
+					      architecture,
a3a04f
+					      driver_directory);
a3a04f
+	}
a3a04f
+
a3a04f
 	nt_status = create_conn_struct_cwd(talloc_tos(),
a3a04f
 					   server_event_context(),
a3a04f
 					   server_messaging_context(),
a3a04f
 					   &conn,
a3a04f
 					   printdollar_snum,
a3a04f
-					   lp_path(talloc_tos(), printdollar_snum),
a3a04f
+					   working_dir,
a3a04f
 					   session_info, &oldcwd);
a3a04f
 	if (!NT_STATUS_IS_OK(nt_status)) {
a3a04f
 		DEBUG(0,("get_correct_cversion: create_conn_struct "
a3a04f
@@ -731,18 +754,11 @@ static uint32_t get_correct_cversion(struct auth_session_info *session_info,
a3a04f
 		goto error_free_conn;
a3a04f
 	}
a3a04f
 
a3a04f
-	/* Open the driver file (Portable Executable format) and determine the
a3a04f
-	 * deriver the cversion. */
a3a04f
-	driverpath = talloc_asprintf(talloc_tos(),
a3a04f
-					"%s/%s",
a3a04f
-					architecture,
a3a04f
-					driverpath_in);
a3a04f
-	if (!driverpath) {
a3a04f
-		*perr = WERR_NOT_ENOUGH_MEMORY;
a3a04f
-		goto error_exit;
a3a04f
-	}
a3a04f
-
a3a04f
-	nt_status = driver_unix_convert(conn, driverpath, &smb_fname);
a3a04f
+	/*
a3a04f
+	 * We switch to the directory where the driver files are located,
a3a04f
+	 * so only work on the file names
a3a04f
+	 */
a3a04f
+	nt_status = driver_unix_convert(conn, driverpath_in, &smb_fname);
a3a04f
 	if (!NT_STATUS_IS_OK(nt_status)) {
a3a04f
 		*perr = ntstatus_to_werror(nt_status);
a3a04f
 		goto error_exit;
a3a04f
@@ -956,8 +972,11 @@ static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
a3a04f
 	 *	NT2K: cversion=3
a3a04f
 	 */
a3a04f
 
a3a04f
-	*version = get_correct_cversion(session_info, short_architecture,
a3a04f
-					*driver_path, &err;;
a3a04f
+	*version = get_correct_cversion(session_info,
a3a04f
+					short_architecture,
a3a04f
+					*driver_path,
a3a04f
+					*driver_directory,
a3a04f
+					&err;;
a3a04f
 	if (*version == -1) {
a3a04f
 		return err;
a3a04f
 	}
a3a04f
-- 
a3a04f
2.9.3
a3a04f
a3a04f
a3a04f
From f0c2a79e1312d2f8231940c12e08b09d65d03648 Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Fri, 5 May 2017 11:11:25 +0200
a3a04f
Subject: [PATCH 2/3] smbtorture:spoolss: Rename the copy_from_directory test
a3a04f
 for 64bit
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12761
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
Reviewed-by: Guenther Deschner <gd@samba.org>
a3a04f
(cherry picked from commit 86798a0fa16b4cc89c35d698bffe0b436fc4eb2e)
a3a04f
---
a3a04f
 source4/torture/rpc/spoolss.c | 16 +++++++++++-----
a3a04f
 1 file changed, 11 insertions(+), 5 deletions(-)
a3a04f
a3a04f
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
a3a04f
index 409ba57..c4b7bf1 100644
a3a04f
--- a/source4/torture/rpc/spoolss.c
a3a04f
+++ b/source4/torture/rpc/spoolss.c
a3a04f
@@ -11109,7 +11109,8 @@ static bool test_multiple_drivers(struct torture_context *tctx,
a3a04f
 }
a3a04f
 
a3a04f
 static bool test_driver_copy_from_directory(struct torture_context *tctx,
a3a04f
-					    struct dcerpc_pipe *p)
a3a04f
+					    struct dcerpc_pipe *p,
a3a04f
+					    const char *architecture)
a3a04f
 {
a3a04f
 	struct torture_driver_context *d;
a3a04f
 	struct spoolss_StringArray *a;
a3a04f
@@ -11125,8 +11126,7 @@ static bool test_driver_copy_from_directory(struct torture_context *tctx,
a3a04f
 	d = talloc_zero(tctx, struct torture_driver_context);
a3a04f
 	torture_assert_not_null(tctx, d, "ENOMEM");
a3a04f
 
a3a04f
-	d->local.environment		=
a3a04f
-		talloc_asprintf(d, SPOOLSS_ARCHITECTURE_x64);
a3a04f
+	d->local.environment		= talloc_strdup(d, architecture);
a3a04f
 	torture_assert_not_null_goto(tctx, d->local.environment, ok, done, "ENOMEM");
a3a04f
 
a3a04f
 	d->local.driver_directory	=
a3a04f
@@ -11208,6 +11208,12 @@ done:
a3a04f
 	return ok;
a3a04f
 }
a3a04f
 
a3a04f
+static bool test_driver_copy_from_directory_64(struct torture_context *tctx,
a3a04f
+					       struct dcerpc_pipe *p)
a3a04f
+{
a3a04f
+	return test_driver_copy_from_directory(tctx, p, SPOOLSS_ARCHITECTURE_x64);
a3a04f
+}
a3a04f
+
a3a04f
 static bool test_del_driver_all_files(struct torture_context *tctx,
a3a04f
 				      struct dcerpc_pipe *p)
a3a04f
 {
a3a04f
@@ -11401,8 +11407,8 @@ struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
a3a04f
 	torture_rpc_tcase_add_test(tcase, "multiple_drivers", test_multiple_drivers);
a3a04f
 
a3a04f
 	torture_rpc_tcase_add_test(tcase,
a3a04f
-				   "test_driver_copy_from_directory",
a3a04f
-				   test_driver_copy_from_directory);
a3a04f
+				   "test_driver_copy_from_directory_64",
a3a04f
+				   test_driver_copy_from_directory_64);
a3a04f
 
a3a04f
 	torture_rpc_tcase_add_test(tcase, "del_driver_all_files", test_del_driver_all_files);
a3a04f
 
a3a04f
-- 
a3a04f
2.9.3
a3a04f
a3a04f
a3a04f
From daca3311db095c96a471f49dcfe291e5e048ed19 Mon Sep 17 00:00:00 2001
a3a04f
From: Andreas Schneider <asn@samba.org>
a3a04f
Date: Fri, 5 May 2017 11:12:02 +0200
a3a04f
Subject: [PATCH 3/3] smbtorture:spoolss: Add a 32bit test for
a3a04f
 copy_from_directory
a3a04f
a3a04f
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12761
a3a04f
a3a04f
Signed-off-by: Andreas Schneider <asn@samba.org>
a3a04f
Reviewed-by: Guenther Deschner <gd@samba.org>
a3a04f
(cherry picked from commit 23009b97bf2f831811c4690141db7355537659d0)
a3a04f
---
a3a04f
 source4/torture/rpc/spoolss.c | 19 +++++++++++++++++--
a3a04f
 1 file changed, 17 insertions(+), 2 deletions(-)
a3a04f
a3a04f
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
a3a04f
index c4b7bf1..e17ac6f 100644
a3a04f
--- a/source4/torture/rpc/spoolss.c
a3a04f
+++ b/source4/torture/rpc/spoolss.c
a3a04f
@@ -11129,8 +11129,13 @@ static bool test_driver_copy_from_directory(struct torture_context *tctx,
a3a04f
 	d->local.environment		= talloc_strdup(d, architecture);
a3a04f
 	torture_assert_not_null_goto(tctx, d->local.environment, ok, done, "ENOMEM");
a3a04f
 
a3a04f
-	d->local.driver_directory	=
a3a04f
-		talloc_asprintf(d, "/usr/share/cups/drivers/x64");
a3a04f
+	if (strequal(architecture, SPOOLSS_ARCHITECTURE_x64)) {
a3a04f
+		d->local.driver_directory =
a3a04f
+			talloc_strdup(d, "/usr/share/cups/drivers/x64");
a3a04f
+	} else {
a3a04f
+		d->local.driver_directory =
a3a04f
+			talloc_strdup(d, "/usr/share/cups/drivers/i386");
a3a04f
+	}
a3a04f
 	torture_assert_not_null_goto(tctx, d->local.driver_directory, ok, done, "ENOMEM");
a3a04f
 
a3a04f
 	d->remote.driver_upload_directory = GUID_string2(d, &guid);
a3a04f
@@ -11214,6 +11219,12 @@ static bool test_driver_copy_from_directory_64(struct torture_context *tctx,
a3a04f
 	return test_driver_copy_from_directory(tctx, p, SPOOLSS_ARCHITECTURE_x64);
a3a04f
 }
a3a04f
 
a3a04f
+static bool test_driver_copy_from_directory_32(struct torture_context *tctx,
a3a04f
+					       struct dcerpc_pipe *p)
a3a04f
+{
a3a04f
+	return test_driver_copy_from_directory(tctx, p, SPOOLSS_ARCHITECTURE_NT_X86);
a3a04f
+}
a3a04f
+
a3a04f
 static bool test_del_driver_all_files(struct torture_context *tctx,
a3a04f
 				      struct dcerpc_pipe *p)
a3a04f
 {
a3a04f
@@ -11410,6 +11421,10 @@ struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
a3a04f
 				   "test_driver_copy_from_directory_64",
a3a04f
 				   test_driver_copy_from_directory_64);
a3a04f
 
a3a04f
+	torture_rpc_tcase_add_test(tcase,
a3a04f
+				   "test_driver_copy_from_directory_32",
a3a04f
+				   test_driver_copy_from_directory_32);
a3a04f
+
a3a04f
 	torture_rpc_tcase_add_test(tcase, "del_driver_all_files", test_del_driver_all_files);
a3a04f
 
a3a04f
 	torture_rpc_tcase_add_test(tcase, "del_driver_unused_files", test_del_driver_unused_files);
a3a04f
-- 
a3a04f
2.9.3
a3a04f