s3-printing: make sure to first migrate the printers then the security descriptor.
authorGünther Deschner <gd@samba.org>
Tue, 5 Jul 2011 12:01:40 +0000 (14:01 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 7 Jul 2011 16:06:02 +0000 (18:06 +0200)
Guenther

Pair-Programmed-With: David Disseldorp <ddiss@suse.de>

source3/printing/nt_printing_migrate_internal.c
source3/utils/net_printing.c

index 706249c..1bd6158 100644 (file)
@@ -143,6 +143,17 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
                        }
                        continue;
                }
+               SAFE_FREE(dbuf.dptr);
+       }
+
+       for (kbuf = tdb_firstkey_compat(tdb);
+            kbuf.dptr;
+            kbuf = tdb_nextkey_compat(tdb, kbuf))
+       {
+               dbuf = tdb_fetch_compat(tdb, kbuf);
+               if (!dbuf.dptr) {
+                       continue;
+               }
 
                if (strncmp((const char *) kbuf.dptr, SECDESC_PREFIX, strlen(SECDESC_PREFIX)) == 0) {
                        const char *secdesc_name = (const char *)(kbuf.dptr
@@ -154,16 +165,17 @@ static NTSTATUS migrate_internal(TALLOC_CTX *mem_ctx,
                                                 dbuf.dsize);
                        SAFE_FREE(dbuf.dptr);
                        /* 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));
+                       if (NT_STATUS_EQUAL(status, werror_to_ntstatus(WERR_INVALID_PRINTER_NAME)) ||
+                           NT_STATUS_EQUAL(status, werror_to_ntstatus(WERR_BADFILE))) {
+                               DEBUG(2, ("Skipping secdesc migration for non-existent "
+                                               "printer: %s\n", secdesc_name));
                        } else if (!NT_STATUS_IS_OK(status)) {
                                tdb_close(tdb);
                                return status;
                        }
                        continue;
                }
+               SAFE_FREE(dbuf.dptr);
        }
 
        tdb_close(tdb);
index cefbd6e..fd33ede 100644 (file)
@@ -284,6 +284,17 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
                        SAFE_FREE(dbuf.dptr);
                        continue;
                }
+               SAFE_FREE(dbuf.dptr);
+       }
+
+       for (kbuf = tdb_firstkey_compat(tdb);
+            kbuf.dptr;
+            kbuf = tdb_nextkey_compat(tdb, kbuf))
+       {
+               dbuf = tdb_fetch_compat(tdb, kbuf);
+               if (!dbuf.dptr) {
+                       continue;
+               }
 
                if (strncmp((const char *) kbuf.dptr, SECDESC_PREFIX, strlen(SECDESC_PREFIX)) == 0) {
                        printing_tdb_migrate_secdesc(tmp_ctx,
@@ -294,6 +305,7 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
                        SAFE_FREE(dbuf.dptr);
                        continue;
                }
+               SAFE_FREE(dbuf.dptr);
 
        }