[PATCH 1/6] s3-printing: leave driver files as is during migration

David Disseldorp ddiss at suse.de
Fri Jun 17 05:39:16 MDT 2011


move_driver_file_to_download_area() assumes that files corresponding
to an AddPrinterDriver request are staged in the $architecture
subdirectory of the print$ share path.

This assumption is incorrect when an AddPrinterDriver is issued to
upgrade internal printing tdbs to the new registry format, as performed
by migrate_driver().

This fix adds a new internal add printer driver flag to skip
manipulation of printer driver files in this case.

https://bugzilla.samba.org/show_bug.cgi?id=8214
---
 librpc/idl/spoolss.idl                      |    3 ++-
 source3/printing/nt_printing_migrate.c      |   11 ++++++-----
 source3/rpc_server/spoolss/srv_spoolss_nt.c |   22 +++++++++++++---------
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index 4599e3a..e3b2743 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -3074,7 +3074,8 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor")
 		APD_COPY_FROM_DIRECTORY		= 0x00000010,
 		APD_DONT_COPY_FILES_TO_CLUSTER	= 0x00001000,
 		APD_COPY_TO_ALL_SPOOLERS	= 0x00002000,
-		APD_RETURN_BLOCKING_STATUS_CODE = 0x00010000
+		APD_RETURN_BLOCKING_STATUS_CODE = 0x00010000,
+		APD_SKIP_FILES			= 0x80000000 /* internal */
 	} spoolss_AddPrinterDriverExFlags;
 
 	[public] WERROR spoolss_AddPrinterDriverEx(
diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c
index f56fa9a..4d01671 100644
--- a/source3/printing/nt_printing_migrate.c
+++ b/source3/printing/nt_printing_migrate.c
@@ -188,11 +188,12 @@ static NTSTATUS migrate_driver(TALLOC_CTX *mem_ctx,
 	d.level = 3;
 	d.info.info3 = &d3;
 
-	status = dcerpc_spoolss_AddPrinterDriver(b,
-						 mem_ctx,
-						 srv_name_slash,
-						 &d,
-						 &result);
+	status = dcerpc_spoolss_AddPrinterDriverEx(b,
+						   mem_ctx,
+						   srv_name_slash,
+						   &d,
+						   APD_SKIP_FILES,
+						   &result);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(2, ("dcerpc_spoolss_AddPrinterDriver(%s) refused -- %s.\n",
 			  d3.driver_name, nt_errstr(status)));
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 7980072..67f4f44 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -8023,13 +8023,15 @@ WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
 	/*
 	 * we only support the semantics of AddPrinterDriver()
 	 * i.e. only copy files that are newer than existing ones
+	 * APD_SKIP_FILES is used internally to modify driver meta-data only
 	 */
 
 	if (r->in.flags == 0) {
 		return WERR_INVALID_PARAM;
 	}
 
-	if (r->in.flags != APD_COPY_NEW_FILES) {
+	if ((r->in.flags != APD_COPY_NEW_FILES)
+	 && (r->in.flags != APD_SKIP_FILES)) {
 		return WERR_ACCESS_DENIED;
 	}
 
@@ -8043,15 +8045,17 @@ WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
 		return WERR_UNKNOWN_LEVEL;
 	}
 
-	DEBUG(5,("Cleaning driver's information\n"));
-	err = clean_up_driver_struct(p->mem_ctx, p->session_info, r->in.info_ctr);
-	if (!W_ERROR_IS_OK(err))
-		goto done;
+	if (r->in.flags != APD_SKIP_FILES) {
+		DEBUG(5,("Cleaning driver's information\n"));
+		err = clean_up_driver_struct(p->mem_ctx, p->session_info, r->in.info_ctr);
+		if (!W_ERROR_IS_OK(err))
+			goto done;
 
-	DEBUG(5,("Moving driver to final destination\n"));
-	err = move_driver_to_download_area(p->session_info, r->in.info_ctr);
-	if (!W_ERROR_IS_OK(err)) {
-		goto done;
+		DEBUG(5,("Moving driver to final destination\n"));
+		err = move_driver_to_download_area(p->session_info, r->in.info_ctr);
+		if (!W_ERROR_IS_OK(err)) {
+			goto done;
+		}
 	}
 
 	err = winreg_add_driver(p->mem_ctx,
-- 
1.7.1



More information about the samba-technical mailing list