summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-10-04 11:02:52 +0200
committerGünther Deschner <gd@samba.org>2010-10-11 14:31:06 +0000
commitc8a295ab7f1ba96b1a1f44004b581770c0da51ad (patch)
treead37d7aa429db99579f9389a92d8862699b63bdb /source3/rpc_server
parentfe724c70d2b8b916cb7ca77b7370d77e8e5b80de (diff)
downloadsamba-c8a295ab7f1ba96b1a1f44004b581770c0da51ad.tar.gz
samba-c8a295ab7f1ba96b1a1f44004b581770c0da51ad.tar.bz2
samba-c8a295ab7f1ba96b1a1f44004b581770c0da51ad.zip
s3-spoolss: convert open_printer_hnd to return WERROR.
Guenther
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index e63c63e1c5..5237352c13 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -721,8 +721,10 @@ static bool set_printer_hnd_name(TALLOC_CTX *mem_ctx,
Find first available printer slot. creates a printer handle for you.
****************************************************************************/
-static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
- const char *name, uint32_t access_granted)
+static WERROR open_printer_hnd(struct pipes_struct *p,
+ struct policy_handle *hnd,
+ const char *name,
+ uint32_t access_granted)
{
struct printer_handle *new_printer;
@@ -730,14 +732,14 @@ static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
new_printer = talloc_zero(p->mem_ctx, struct printer_handle);
if (new_printer == NULL) {
- return false;
+ return WERR_NOMEM;
}
talloc_set_destructor(new_printer, printer_entry_destructor);
/* This also steals the printer_handle on the policy_handle */
if (!create_policy_hnd(p, hnd, new_printer)) {
TALLOC_FREE(new_printer);
- return false;
+ return WERR_INVALID_HANDLE;
}
/* Add to the internal list. */
@@ -747,7 +749,7 @@ static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
if (!set_printer_hnd_printertype(new_printer, name)) {
close_printer_handle(p, hnd);
- return false;
+ return WERR_INVALID_HANDLE;
}
if (!set_printer_hnd_name(p->mem_ctx,
@@ -755,7 +757,7 @@ static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
p->msg_ctx,
new_printer, name)) {
close_printer_handle(p, hnd);
- return false;
+ return WERR_INVALID_HANDLE;
}
new_printer->access_granted = access_granted;
@@ -763,7 +765,7 @@ static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
DEBUG(5, ("%d printer handles active\n",
(int)num_pipe_handles(p)));
- return true;
+ return WERR_OK;
}
/***************************************************************************
@@ -1683,6 +1685,7 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
{
int snum;
struct printer_handle *Printer=NULL;
+ WERROR result;
if (!r->in.printername) {
return WERR_INVALID_PARAM;
@@ -1693,11 +1696,12 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
DEBUGADD(3,("checking name: %s\n", r->in.printername));
- if (!open_printer_hnd(p, r->out.handle, r->in.printername, 0)) {
+ result = open_printer_hnd(p, r->out.handle, r->in.printername, 0);
+ if (!W_ERROR_IS_OK(result)) {
DEBUG(0,("_spoolss_OpenPrinterEx: Cannot open a printer handle "
"for printer %s\n", r->in.printername));
ZERO_STRUCTP(r->out.handle);
- return WERR_INVALID_PRINTER_NAME;
+ return result;
}
Printer = find_printer_index_by_hnd(p, r->out.handle);
@@ -7853,10 +7857,11 @@ static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p,
return err;
}
- if (!open_printer_hnd(p, handle, info2->printername, PRINTER_ACCESS_ADMINISTER)) {
+ err = open_printer_hnd(p, handle, info2->printername, PRINTER_ACCESS_ADMINISTER);
+ if (!W_ERROR_IS_OK(err)) {
/* Handle open failed - remove addition. */
ZERO_STRUCTP(handle);
- return WERR_ACCESS_DENIED;
+ return err;
}
return WERR_OK;