The branch, master has been updated
       via  133fb0e s3-spoolss: Use get_session_info_system().
       via  b77f626 s3-spoolss: Free the info2 structure in _spoolss_GetPrinter.
       via  f26441d s3-spoolss: Use tmp_ctx everywhere in 
_spoolss_DeletePrinterDriverEx.
       via  fea4a31 s3-spoolss: Use tmp_ctx in winreg_enum_printer_key_internal.
       via  c58c0ba s3-spoolss: Use tmp_ctx in 
winreg_printer_deleteform1_internal.
       via  80c1a8e s3-spoolss: Use tmp_ctx in winreg_printer_setform1_internal.
       via  baccb06 s3-spoolss: Use tmp_ctx in winreg_printer_addform1_internal.
       via  a6ea154 s3-spoolss: Use tmp_ctx in winreg_printer_getform1_internal.
       via  f49917a s3-spoolss: Use tmp_ctx in 
winreg_printer_enumforms1_internal.
       via  81eae6e s3-spoolss: Use tmp_ctx in 
winreg_set_printer_secdesc_internal.
       via  41c2e71 s3-spoolss: Use tmp_ctx in 
winreg_get_printer_secdesc_internal.
       via  022a13f s3-spoolss: Use tmp_ctx in winreg_add_driver_internal.
       via  ff6294e s3-spoolss: Use tmp_ctx in winreg_del_driver_internal.
       via  72ac68e s3-spoolss: Use tmp_ctx in winreg_get_driver_list_internal.
       via  2e2631f s3-spoolss: Use tmp_ctx in winreg_get_driver_internal.
       via  1068295 s3-spoolss: Use tmp_ctx in 
winreg_delete_printer_dataex_internal.
       via  e6e80ea s3-spoolss: Use tmp_ctx in 
winreg_get_printer_dataex_internal.
       via  7aef2f6 s3-spoolss: Use tmp_ctx in 
winreg_enum_printer_dataex_internal.
       via  311d6db s3-spoolss: Use tmp_ctx in 
winreg_set_printer_dataex_internal.
       via  2b0adab s3-spoolss: Use tmp_ctx in winreg_update_printer_internal.
       via  34dc5a5 s3-spoolss: Use tmp_ctx in winreg_create_printer_internal.
       via  f9359a2 s3-spoolss: Use tmp_ctx in winreg_get_printer_internal.
       via  20afdee s3-spoolss: Use tmp_ctx in 
winreg_printer_get_changeid_internal.
       via  ba74c5d s3-spoolss: Use tmp_ctx in 
winreg_printer_update_changeid_internal.
       via  43604dd s3-spoolss: Use tmp_ctx in 
winreg_delete_printer_key_internal.
       via  bed0672 s3-spoolss: Free local in winreg_printer_binding_handle.
       via  99e03be s3-spoolss: Improve memory efficiency.
       via  8831402 s3-rpc_client: Fix memory context in 
winreg_enum_printer_dataex().
       via  5045281 s3-rpc_client: Close policy handles before creating 
defaults.
       via  f8afaa7 s3-rpc_client: Close the hive handle before we open it 
again.
       via  a0597b7 s3-rpc_client: Close hive if opening of the key fails.
       via  fe7e4ac s3-rpc_server: Copy correct local tsocket address.
      from  3276060 s3:idmap_tdb2: remove the undocumented option of the silly 
name "tdb:idmap2.tdb"

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 133fb0ebcc070bd3ae4aebcc3a759eca98101495
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Jul 26 10:40:40 2011 +0200

    s3-spoolss: Use get_session_info_system().
    
    Autobuild-User: Andreas Schneider <a...@cryptomilk.org>
    Autobuild-Date: Wed Jul 27 10:38:34 CEST 2011 on sn-devel-104

commit b77f626def8cd4bf20eb15b98bc8655aab22c32a
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:52:29 2011 +0200

    s3-spoolss: Free the info2 structure in _spoolss_GetPrinter.

commit f26441d8ba8cf89f6b08b64ae40e75d6ab2d2aa3
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:48:40 2011 +0200

    s3-spoolss: Use tmp_ctx everywhere in _spoolss_DeletePrinterDriverEx.

commit fea4a3111be2550550194dfa56272feb5688407b
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:41:14 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_enum_printer_key_internal.

commit c58c0ba0bdf470233a35bb105abf7e3ad9e927f1
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:40:12 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_deleteform1_internal.

commit 80c1a8e04e4d287bcd58091d65549e499c2fa11a
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:39:01 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_setform1_internal.

commit baccb06658fde3d49b58c6aeb17f0e9c320dbd01
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:38:12 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_addform1_internal.

commit a6ea1542c549d33f56877fdac0dfd87a76518778
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:37:25 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_getform1_internal.

commit f49917ade0c4dda99d7188e8556b35a76f3f39b0
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:36:34 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_enumforms1_internal.

commit 81eae6ebd4746e4c14fe86e7a77ce78a172d9234
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:35:24 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_set_printer_secdesc_internal.

commit 41c2e711bd04892c68a94d62c98e51bf95af33e8
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:33:22 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_get_printer_secdesc_internal.

commit 022a13f1e0775a6abba4d6a834e09257f6491c26
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:32:22 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_add_driver_internal.

commit ff6294ef0f5dc9ba6d2b989377d825f0be01b509
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:31:32 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_del_driver_internal.

commit 72ac68e7467f9a28389f9487b93096bb2e7c1622
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:15:36 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_get_driver_list_internal.

commit 2e2631f55442f1bff4a9a7c22dbdbde77053d2c8
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:14:45 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_get_driver_internal.

commit 106829545c1d4a687c5c45e51d7d38a04fa4b0d4
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:13:46 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_delete_printer_dataex_internal.

commit e6e80ea137c5d3c936803303c7527d2ae075de0d
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:12:43 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_get_printer_dataex_internal.

commit 7aef2f63085557d473a26bb52efb9896a2c885a9
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:11:50 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_enum_printer_dataex_internal.

commit 311d6dbeb7f6bd72ba26020d39d2ddb04f15546d
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:10:25 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_set_printer_dataex_internal.

commit 2b0adab76ea6dc366ed1672f98a035a0e1c9e088
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:09:17 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_update_printer_internal.

commit 34dc5a57f942a9e24e7b5ed7886f9f78c932ff0d
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:08:10 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_create_printer_internal.

commit f9359a2dc9cc94bf52d568825a79995732299759
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:07:21 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_get_printer_internal.

commit 20afdeec3c685fb7e03a902bba6141ae69678536
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:07:00 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_get_changeid_internal.

commit ba74c5df2daeeaaf4eff46c4d633e03ff80995d9
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:06:34 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_printer_update_changeid_internal.

commit 43604dd3214a5acfca3be3c520e0930356aefab3
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 21:06:02 2011 +0200

    s3-spoolss: Use tmp_ctx in winreg_delete_printer_key_internal.

commit bed0672b036f6b2f77abbc2ec566d0657fe2042e
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Jul 26 11:02:05 2011 +0200

    s3-spoolss: Free local in winreg_printer_binding_handle.

commit 99e03bee7ae5de37280a4e571caf36b0a8553fae
Author: Simo Sorce <i...@samba.org>
Date:   Fri Jul 22 11:59:41 2011 -0400

    s3-spoolss: Improve memory efficiency.
    
    p->mem_ctx is a relatively long lived context as it will not be freed until
    a full request is served. In spoolss we do a lot of operations including
    opening new pipes to connect to winreg.
    Use more shortlived temporary contexts to avoid leaking a lot of memory on
    p->mem_ctx and carrying it around untill all the operations in the current 
call
    are done.
    
    Signed-off-by: Andreas Schneider <a...@samba.org>

commit 8831402596fab30f56ce6600c72a575e2e73e4d3
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 19:41:31 2011 +0200

    s3-rpc_client: Fix memory context in winreg_enum_printer_dataex().

commit 5045281e17d7f90e1f31b7bf9ffdea9b59b99373
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 22:16:20 2011 +0200

    s3-rpc_client: Close policy handles before creating defaults.
    
    We reopen the hive and key so close them before reopen.

commit f8afaa76f225e4e7a477a59fa0a4b8f040afb2b6
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 17:48:08 2011 +0200

    s3-rpc_client: Close the hive handle before we open it again.

commit a0597b75e6794d8bfe7e43bf36378b2421afc9c7
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Jul 25 22:31:08 2011 +0200

    s3-rpc_client: Close hive if opening of the key fails.

commit fe7e4ac462608200a98c64338e7b5cddda2fda71
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Jul 26 11:04:48 2011 +0200

    s3-rpc_server: Copy correct local tsocket address.

-----------------------------------------------------------------------

Summary of changes:
 source3/rpc_client/cli_winreg_spoolss.c       |   54 ++-
 source3/rpc_server/rpc_handles.c              |    2 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c   |  434 ++++++++++++---------
 source3/rpc_server/spoolss/srv_spoolss_util.c |  540 +++++++++++++++++++------
 4 files changed, 706 insertions(+), 324 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/rpc_client/cli_winreg_spoolss.c 
b/source3/rpc_client/cli_winreg_spoolss.c
index 9b7c724..2a6a8d1 100644
--- a/source3/rpc_client/cli_winreg_spoolss.c
+++ b/source3/rpc_client/cli_winreg_spoolss.c
@@ -298,9 +298,19 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx,
                                               &result);
        }
        if (!NT_STATUS_IS_OK(status)) {
-               return ntstatus_to_werror(status);
+               result = ntstatus_to_werror(status);
        }
        if (!W_ERROR_IS_OK(result)) {
+               WERROR ignore;
+
+               if (is_valid_policy_hnd(hive_handle)) {
+                       dcerpc_winreg_CloseKey(binding_handle,
+                                              mem_ctx,
+                                              hive_handle,
+                                              &ignore);
+               }
+               ZERO_STRUCTP(hive_handle);
+
                return result;
        }
 
@@ -589,6 +599,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
        uint32_t i, count = ARRAY_SIZE(subkeys);
        uint32_t info2_mask = 0;
        WERROR result = WERR_OK;
+       WERROR ignore;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
@@ -624,6 +635,13 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, 
&ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, 
&ignore);
+       }
+
        /* Create the main key */
        result = winreg_printer_openkey(tmp_ctx,
                                        winreg_handle,
@@ -892,15 +910,11 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                                       secdesc);
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, 
&key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, 
&hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, 
&ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, 
&ignore);
        }
 
        talloc_free(tmp_ctx);
@@ -1652,6 +1666,21 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
        }
        if (!W_ERROR_IS_OK(result)) {
                if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+                       WERROR ignore;
+
+                       if (is_valid_policy_hnd(&key_hnd)) {
+                               dcerpc_winreg_CloseKey(winreg_handle,
+                                                      tmp_ctx,
+                                                      &key_hnd,
+                                                      &ignore);
+                       }
+
+                       if (is_valid_policy_hnd(&hive_hnd)) {
+                               dcerpc_winreg_CloseKey(winreg_handle,
+                                                      tmp_ctx,
+                                                      &hive_hnd,
+                                                      &ignore);
+                       }
                        goto create_default;
                }
                goto done;
@@ -2158,9 +2187,8 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
                }
        }
 
-       enum_names = talloc_move(mem_ctx, &enum_names);
-       enum_types = talloc_move(mem_ctx, &enum_types);
-       enum_data_blobs = talloc_move(mem_ctx, &enum_data_blobs);
+       talloc_steal(enum_values, enum_names);
+       talloc_steal(enum_values, enum_data_blobs);
 
        *pnum_values = num_values;
        if (penum_values) {
diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c
index c40029b..f9251ee 100644
--- a/source3/rpc_server/rpc_handles.c
+++ b/source3/rpc_server/rpc_handles.c
@@ -76,7 +76,7 @@ int make_base_pipes_struct(TALLOC_CTX *mem_ctx,
        }
 
        if (local_address) {
-               p->local_address = tsocket_address_copy(remote_address, p);
+               p->local_address = tsocket_address_copy(local_address, p);
                if (p->local_address == NULL) {
                        talloc_free(p);
                        return ENOMEM;
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c 
b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index cdacd5e..afd78f1 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -1536,9 +1536,8 @@ void do_drv_upgrade_printer(struct messaging_context *msg,
                            DATA_BLOB *data)
 {
        TALLOC_CTX *tmp_ctx;
-       struct auth_session_info *session_info = NULL;
+       const struct auth_session_info *session_info = 
get_session_info_system();
        struct spoolss_PrinterInfo2 *pinfo2;
-       NTSTATUS status;
        WERROR result;
        const char *drivername;
        int snum;
@@ -1548,13 +1547,6 @@ void do_drv_upgrade_printer(struct messaging_context 
*msg,
        tmp_ctx = talloc_new(NULL);
        if (!tmp_ctx) return;
 
-       status = make_session_info_system(tmp_ctx, &session_info);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("do_drv_upgrade_printer: "
-                         "Could not create system session_info\n"));
-               goto done;
-       }
-
        drivername = talloc_strndup(tmp_ctx, (const char *)data->data, 
data->length);
        if (!drivername) {
                DEBUG(0, ("do_drv_upgrade_printer: Out of memoery ?!\n"));
@@ -2087,6 +2079,7 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
        int                             version;
        WERROR                          status;
        struct dcerpc_binding_handle *b;
+       TALLOC_CTX *tmp_ctx = NULL;
 
        /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
           and not a printer admin, then fail */
@@ -2105,18 +2098,24 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
 
        /* check that we have a valid driver name first */
 
-       if ((version = get_version_id(r->in.architecture)) == -1)
+       if ((version = get_version_id(r->in.architecture)) == -1) {
                return WERR_INVALID_ENVIRONMENT;
+       }
+
+       tmp_ctx = talloc_new(p->mem_ctx);
+       if (!tmp_ctx) {
+               return WERR_NOMEM;
+       }
 
-       status = winreg_printer_binding_handle(p->mem_ctx,
+       status = winreg_printer_binding_handle(tmp_ctx,
                                               get_session_info_system(),
                                               p->msg_ctx,
                                               &b);
        if (!W_ERROR_IS_OK(status)) {
-               return status;
+               goto done;
        }
 
-       status = winreg_get_driver(p->mem_ctx, b,
+       status = winreg_get_driver(tmp_ctx, b,
                                   r->in.architecture, r->in.driver,
                                   version, &info);
        if (!W_ERROR_IS_OK(status)) {
@@ -2125,7 +2124,7 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
                if ( version == 2 ) {
                        version = 3;
 
-                       status = winreg_get_driver(p->mem_ctx, b,
+                       status = winreg_get_driver(tmp_ctx, b,
                                                   r->in.architecture,
                                                   r->in.driver,
                                                   version, &info);
@@ -2142,7 +2141,7 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
 
        }
 
-       if (printer_driver_in_use(p->mem_ctx,
+       if (printer_driver_in_use(tmp_ctx,
                                  get_session_info_system(),
                                  p->msg_ctx,
                                  info)) {
@@ -2151,14 +2150,14 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
        }
 
        if (version == 2) {
-               status = winreg_get_driver(p->mem_ctx, b,
+               status = winreg_get_driver(tmp_ctx, b,
                                           r->in.architecture,
                                           r->in.driver, 3, &info_win2k);
                if (W_ERROR_IS_OK(status)) {
                        /* if we get to here, we now have 2 driver info 
structures to remove */
                        /* remove the Win2k driver first*/
 
-                       status = winreg_del_driver(p->mem_ctx, b,
+                       status = winreg_del_driver(tmp_ctx, b,
                                                   info_win2k, 3);
                        talloc_free(info_win2k);
 
@@ -2169,11 +2168,11 @@ WERROR _spoolss_DeletePrinterDriver(struct pipes_struct 
*p,
                }
        }
 
-       status = winreg_del_driver(p->mem_ctx, b,
+       status = winreg_del_driver(tmp_ctx, b,
                                   info, version);
 
 done:
-       talloc_free(info);
+       talloc_free(tmp_ctx);
 
        return status;
 }
@@ -2191,6 +2190,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
        bool                            delete_files;
        WERROR                          status;
        struct dcerpc_binding_handle *b;
+       TALLOC_CTX *tmp_ctx = NULL;
 
        /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
           and not a printer admin, then fail */
@@ -2212,18 +2212,24 @@ WERROR _spoolss_DeletePrinterDriverEx(struct 
pipes_struct *p,
                return WERR_INVALID_ENVIRONMENT;
        }
 
-       if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
+       if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) {
                version = r->in.version;
+       }
+
+       tmp_ctx = talloc_new(p->mem_ctx);
+       if (!tmp_ctx) {
+               return WERR_NOMEM;
+       }
 
-       status = winreg_printer_binding_handle(p->mem_ctx,
+       status = winreg_printer_binding_handle(tmp_ctx,
                                               get_session_info_system(),
                                               p->msg_ctx,
                                               &b);
        if (!W_ERROR_IS_OK(status)) {
-               return status;
+               goto done;
        }
 
-       status = winreg_get_driver(p->mem_ctx, b,
+       status = winreg_get_driver(tmp_ctx, b,
                                   r->in.architecture,
                                   r->in.driver,
                                   version,
@@ -2243,7 +2249,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
                /* try for Win2k driver if "Windows NT x86" */
 
                version = 3;
-               status = winreg_get_driver(info, b,
+               status = winreg_get_driver(tmp_ctx, b,
                                           r->in.architecture,
                                           r->in.driver,
                                           version, &info);
@@ -2253,7 +2259,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
                }
        }
 
-       if (printer_driver_in_use(info,
+       if (printer_driver_in_use(tmp_ctx,
                                  get_session_info_system(),
                                  p->msg_ctx,
                                  info)) {
@@ -2279,7 +2285,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
 
        if (delete_files &&
            (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
-           printer_driver_files_in_use(info,
+           printer_driver_files_in_use(tmp_ctx,
                                        get_session_info_system(),
                                        p->msg_ctx,
                                        info)) {
@@ -2292,7 +2298,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
        /* also check for W32X86/3 if necessary; maybe we already have? */
 
        if ( (version == 2) && ((r->in.delete_flags & 
DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION)  ) {
-               status = winreg_get_driver(info, b,
+               status = winreg_get_driver(tmp_ctx, b,
                                           r->in.architecture,
                                           r->in.driver, 3, &info_win2k);
                if (W_ERROR_IS_OK(status)) {
@@ -2312,7 +2318,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
                        /* if we get to here, we now have 2 driver info 
structures to remove */
                        /* remove the Win2k driver first*/
 
-                       status = winreg_del_driver(info, b,
+                       status = winreg_del_driver(tmp_ctx, b,
                                                   info_win2k,
                                                   3);
 
@@ -2334,7 +2340,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
                }
        }
 
-       status = winreg_del_driver(info, b,
+       status = winreg_del_driver(tmp_ctx, b,
                                   info,
                                   version);
        if (!W_ERROR_IS_OK(status)) {
@@ -2351,7 +2357,7 @@ WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct 
*p,
        }
 
 done:
-       talloc_free(info);
+       talloc_free(tmp_ctx);
        return status;
 }
 
@@ -4230,16 +4236,8 @@ static WERROR construct_printer_info7(TALLOC_CTX 
*mem_ctx,
                                      struct spoolss_PrinterInfo7 *r,
                                      int snum)
 {
-       struct auth_session_info *session_info;
+       const struct auth_session_info *session_info = 
get_session_info_system();
        struct GUID guid;
-       NTSTATUS status;
-
-       status = make_session_info_system(mem_ctx, &session_info);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("construct_printer_info7: "
-                         "Could not create system session_info\n"));
-               return WERR_NOMEM;
-       }
 
        if (is_printer_published(mem_ctx, session_info, msg_ctx,
                                 servername,
@@ -4252,7 +4250,6 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
        }
        W_ERROR_HAVE_NO_MEMORY(r->guid);
 
-       TALLOC_FREE(session_info);
        return WERR_OK;
 }
 
@@ -4313,6 +4310,12 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX 
*mem_ctx,
        uint32_t count = 0;
        WERROR result = WERR_OK;
        struct dcerpc_binding_handle *b = NULL;
+       TALLOC_CTX *tmp_ctx = NULL;
+
+       tmp_ctx = talloc_new(mem_ctx);
+       if (!tmp_ctx) {
+               return WERR_NOMEM;
+       }
 
        *count_p = 0;
        *info_p = NULL;
@@ -4332,7 +4335,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX 
*mem_ctx,
                        printer, snum));
 
                if (b == NULL) {
-                       result = winreg_printer_binding_handle(mem_ctx,
+                       result = winreg_printer_binding_handle(tmp_ctx,
                                                               session_info,
                                                               msg_ctx,
                                                               &b);
@@ -4341,13 +4344,13 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX 
*mem_ctx,
                        }
                }
 
-               result = winreg_create_printer(mem_ctx, b,
+               result = winreg_create_printer(tmp_ctx, b,
                                               printer);
                if (!W_ERROR_IS_OK(result)) {
                        goto out;
                }
 
-               info = talloc_realloc(mem_ctx, info,
+               info = talloc_realloc(tmp_ctx, info,
                                            union spoolss_PrinterInfo,
                                            count + 1);
                if (!info) {
@@ -4355,7 +4358,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX 
*mem_ctx,
                        goto out;
                }
 
-               result = winreg_get_printer(mem_ctx, b,
+               result = winreg_get_printer(tmp_ctx, b,
                                            printer, &info2);
                if (!W_ERROR_IS_OK(result)) {
                        goto out;
@@ -4401,18 +4404,15 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX 
*mem_ctx,
                count++;
        }
 
-       *count_p = count;
-       *info_p = info;
-
- out:
-       if (!W_ERROR_IS_OK(result)) {
-               TALLOC_FREE(info);
-               return result;
+out:
+       if (W_ERROR_IS_OK(result)) {
+               *info_p = talloc_move(mem_ctx, &info);
+               *count_p = count;
        }
 
-       *info_p = info;
+       talloc_free(tmp_ctx);
 
-       return WERR_OK;
+       return result;
 }
 
 /********************************************************************
@@ -4836,6 +4836,7 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
                result = WERR_UNKNOWN_LEVEL;
                break;
        }
+       TALLOC_FREE(info2);
 
  out:
        if (!W_ERROR_IS_OK(result)) {
@@ -5546,20 +5547,26 @@ static WERROR 
construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
        struct spoolss_DriverInfo8 *driver;
        WERROR result;
        struct dcerpc_binding_handle *b;
+       TALLOC_CTX *tmp_ctx = NULL;
 
        if (level == 101) {
                return WERR_UNKNOWN_LEVEL;
        }
 
-       result = winreg_printer_binding_handle(mem_ctx,
+       tmp_ctx = talloc_new(mem_ctx);
+       if (!tmp_ctx) {
+               return WERR_NOMEM;
+       }
+
+       result = winreg_printer_binding_handle(tmp_ctx,
                                               session_info,
                                               msg_ctx,
                                               &b);
        if (!W_ERROR_IS_OK(result)) {
-               return result;
+               goto done;
        }
 
-       result = winreg_get_printer(mem_ctx, b,
+       result = winreg_get_printer(tmp_ctx, b,
                                    lp_const_servicename(snum),
                                    &pinfo2);
 
@@ -5567,10 +5574,11 @@ static WERROR 
construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
                win_errstr(result)));
 
        if (!W_ERROR_IS_OK(result)) {
-               return WERR_INVALID_PRINTER_NAME;
+               result = WERR_INVALID_PRINTER_NAME;
+               goto done;
        }
 
-       result = winreg_get_driver(mem_ctx, b,
+       result = winreg_get_driver(tmp_ctx, b,
                                   architecture,
                                   pinfo2->drivername, version, &driver);
 
@@ -5583,24 +5591,26 @@ static WERROR 
construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
                 */
 
                if (version < 3) {
-                       talloc_free(pinfo2);
-                       return WERR_UNKNOWN_PRINTER_DRIVER;
+                       result = WERR_UNKNOWN_PRINTER_DRIVER;
+                       goto done;
                }
 
                /* Yes - try again with a WinNT driver. */
                version = 2;
-               result = winreg_get_driver(mem_ctx, b,
+               result = winreg_get_driver(tmp_ctx, b,
                                           architecture,
                                           pinfo2->drivername,
                                           version, &driver);
                DEBUG(8,("construct_printer_driver_level: status: %s\n",
                        win_errstr(result)));
                if (!W_ERROR_IS_OK(result)) {


-- 
Samba Shared Repository

Reply via email to