summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-07-05 00:55:35 +0200
committerGünther Deschner <gd@samba.org>2011-07-07 18:06:02 +0200
commit72b1f8be5619ed778c4aa0b967f6a4f34d7e9de8 (patch)
tree9b82a9252c69476d80b1bfe30a6a2747aa7bb473 /source3/printing
parent0a1ec73b965f66977a90fb7febb3b56b52ebab20 (diff)
downloadsamba-72b1f8be5619ed778c4aa0b967f6a4f34d7e9de8.tar.gz
samba-72b1f8be5619ed778c4aa0b967f6a4f34d7e9de8.tar.bz2
samba-72b1f8be5619ed778c4aa0b967f6a4f34d7e9de8.zip
s3-printing: safe a ton of roundtrips by reusing existing winreg binding_handles.
Guenther Pair-Programmed-With: David Disseldorp <ddiss@suse.de>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c33
-rw-r--r--source3/printing/nt_printing_ads.c13
2 files changed, 38 insertions, 8 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 1887a61119..fd2ab2a197 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -32,6 +32,7 @@
#include "auth.h"
#include "messages.h"
#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "rpc_client/cli_winreg_spoolss.h"
/* Map generic permissions to printer object specific permissions */
@@ -1182,6 +1183,7 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
bool in_use = False;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
WERROR result;
+ struct dcerpc_binding_handle *b = NULL;
if (!r) {
return false;
@@ -1196,7 +1198,17 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
continue;
}
- result = winreg_get_printer_internal(mem_ctx, session_info, msg_ctx,
+ if (b == NULL) {
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return false;
+ }
+ }
+
+ result = winreg_get_printer(mem_ctx, b,
lp_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
@@ -1222,18 +1234,18 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
"Windows NT x86" version 2 or 3 left */
if (!strequal("Windows NT x86", r->architecture)) {
- werr = winreg_get_driver_internal(mem_ctx, session_info, msg_ctx,
+ werr = winreg_get_driver(mem_ctx, b,
"Windows NT x86",
r->driver_name,
DRIVER_ANY_VERSION,
&driver);
} else if (r->version == 2) {
- werr = winreg_get_driver_internal(mem_ctx, session_info, msg_ctx,
+ werr = winreg_get_driver(mem_ctx, b,
"Windows NT x86",
r->driver_name,
3, &driver);
} else if (r->version == 3) {
- werr = winreg_get_driver_internal(mem_ctx, session_info, msg_ctx,
+ werr = winreg_get_driver(mem_ctx, b,
"Windows NT x86",
r->driver_name,
2, &driver);
@@ -1412,6 +1424,7 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
uint32_t num_drivers;
const char **drivers;
WERROR result;
+ struct dcerpc_binding_handle *b;
if ( !info )
return False;
@@ -1424,7 +1437,15 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
/* get the list of drivers */
- result = winreg_get_driver_list_internal(mem_ctx, session_info, msg_ctx,
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return false;
+ }
+
+ result = winreg_get_driver_list(mem_ctx, b,
info->architecture, version,
&num_drivers, &drivers);
if (!W_ERROR_IS_OK(result)) {
@@ -1441,7 +1462,7 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
driver = NULL;
- result = winreg_get_driver_internal(mem_ctx, session_info, msg_ctx,
+ result = winreg_get_driver(mem_ctx, b,
info->architecture, drivers[i],
version, &driver);
if (!W_ERROR_IS_OK(result)) {
diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c
index c5e3f99fb6..beb5240423 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -399,8 +399,17 @@ bool is_printer_published(TALLOC_CTX *mem_ctx,
uint32_t data_size;
WERROR result;
NTSTATUS status;
+ struct dcerpc_binding_handle *b;
- result = winreg_get_printer_internal(mem_ctx, session_info, msg_ctx,
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return false;
+ }
+
+ result = winreg_get_printer(mem_ctx, b,
printer, &pinfo2);
if (!W_ERROR_IS_OK(result)) {
return false;
@@ -417,7 +426,7 @@ bool is_printer_published(TALLOC_CTX *mem_ctx,
/* fetching printer guids really ought to be a separate function. */
- result = winreg_get_printer_dataex_internal(mem_ctx, session_info, msg_ctx,
+ result = winreg_get_printer_dataex(mem_ctx, b,
printer,
SPOOL_DSSPOOLER_KEY, "objectGUID",
&type, &data, &data_size);