[PATCH 4/6] s3-printing: skip migration of non-existent printers

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


Skip tdb migration of printer and security descriptor entries which
refer to non-existent printers.
---
 source3/printing/nt_printing_migrate.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c
index 2eeccb7..bb1473d 100644
--- a/source3/printing/nt_printing_migrate.c
+++ b/source3/printing/nt_printing_migrate.c
@@ -460,10 +460,6 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
 			  key_name, nt_errstr(status)));
 		return status;
 	}
-	if (W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME, result)) {
-		DEBUG(3, ("Ignoring missing printer %s\n", key_name));
-		return NT_STATUS_OK;
-	}
 	if (!W_ERROR_IS_OK(result)) {
 		DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
 			  key_name, win_errstr(result)));
@@ -589,13 +585,20 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
 		}
 
 		if (strncmp((const char *) kbuf.dptr, PRINTERS_PREFIX, strlen(PRINTERS_PREFIX)) == 0) {
+			const char *printer_name = (const char *)(kbuf.dptr
+						    + strlen(PRINTERS_PREFIX));
 			status = migrate_printer(mem_ctx,
 						 pipe_hnd,
-						 (const char *) kbuf.dptr + strlen(PRINTERS_PREFIX),
+						 printer_name,
 						 dbuf.dptr,
 						 dbuf.dsize);
 			SAFE_FREE(dbuf.dptr);
-			if (!NT_STATUS_IS_OK(status)) {
+			/* currently no WERR_INVALID_PRINTER_NAME equivalent */
+			if (NT_STATUS_EQUAL(status,
+			       werror_to_ntstatus(WERR_INVALID_PRINTER_NAME))) {
+				DEBUG(2, ("Skipping migration for non-existent "
+						"printer: %s\n", printer_name));
+			} else if (!NT_STATUS_IS_OK(status)) {
 				tdb_close(tdb);
 				return status;
 			}
@@ -603,13 +606,20 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
 		}
 
 		if (strncmp((const char *) kbuf.dptr, SECDESC_PREFIX, strlen(SECDESC_PREFIX)) == 0) {
+			const char *secdesc_name = (const char *)(kbuf.dptr
+						    + strlen(SECDESC_PREFIX));
 			status = migrate_secdesc(mem_ctx,
 						 pipe_hnd,
-						 (const char *) kbuf.dptr + strlen(SECDESC_PREFIX),
+						 secdesc_name,
 						 dbuf.dptr,
 						 dbuf.dsize);
 			SAFE_FREE(dbuf.dptr);
-			if (!NT_STATUS_IS_OK(status)) {
+			/* currently no WERR_INVALID_PRINTER_NAME equivalent */
+			if (NT_STATUS_EQUAL(status,
+			       werror_to_ntstatus(WERR_INVALID_PRINTER_NAME))) {
+				DEBUG(2, ("Skipping migration for non-existent "
+						"secdesc: %s\n", secdesc_name));
+			} else if (!NT_STATUS_IS_OK(status)) {
 				tdb_close(tdb);
 				return status;
 			}
-- 
1.7.1



More information about the samba-technical mailing list