summaryrefslogtreecommitdiff
path: root/source4/rpc_server
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-07-01 04:17:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:50 -0500
commitc08a2a9e10fc5d53865e4ab08e749b1c207be9ed (patch)
tree19c305229ef146f2b8325991cabc4620a882d214 /source4/rpc_server
parent091ad8631599b312558b0c956208325e8e133e00 (diff)
downloadsamba-c08a2a9e10fc5d53865e4ab08e749b1c207be9ed.tar.gz
samba-c08a2a9e10fc5d53865e4ab08e749b1c207be9ed.tar.bz2
samba-c08a2a9e10fc5d53865e4ab08e749b1c207be9ed.zip
r1313: Split up OpenPrinterEx into functions to handle opening printers and print
servers. (This used to be commit 0edf17ac38b43cadb07dc0840730cd9b4e381713)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c56
1 files changed, 44 insertions, 12 deletions
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 330d6c09da..e3f4279669 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -897,24 +897,18 @@ static WERROR spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx
}
-/*
- spoolss_OpenPrinterEx
-*/
-static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct spoolss_OpenPrinterEx *r)
+static WERROR spoolss_OpenPrinterEx_server(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct spoolss_OpenPrinterEx *r)
{
struct spoolss_openprinter_state *state;
struct dcesrv_handle *handle;
TALLOC_CTX *op_mem_ctx;
- ZERO_STRUCTP(r->out.handle);
-
- /* Check printername is either \\\\SERVER, \\\\SERVERIP or
- \\\\SERVER.FQ.DN */
+ /* Check printername is our name */
- if (!strequal(r->in.printername, lp_netbios_name())) {
+ if (!strequal(r->in.printername + 2, lp_netbios_name()))
return WERR_INVALID_PRINTER_NAME;
- }
op_mem_ctx = talloc_init("spoolss_OpenPrinter");
if (!op_mem_ctx) {
@@ -940,7 +934,45 @@ static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_C
state->access_mask = r->in.access_required;
*r->out.handle = handle->wire_handle;
- return WERR_OK;
+ return WERR_OK;
+}
+
+static WERROR spoolss_OpenPrinterEx_printer(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct spoolss_OpenPrinterEx *r)
+{
+ char *server = talloc_strdup(mem_ctx, r->in.printername + 2);
+ char *pos, *printer;
+
+ pos = strchr(server, '\\');
+ *pos = 0;
+ printer = talloc_strdup(mem_ctx, pos + 1);
+
+ if (!strequal(server, lp_netbios_name()))
+ return WERR_INVALID_PRINTER_NAME;
+
+ DEBUG(0, ("looking for server %s, printer %s\n", server, printer));
+
+ return WERR_INVALID_PRINTER_NAME;
+}
+
+/*
+ spoolss_OpenPrinterEx
+*/
+static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct spoolss_OpenPrinterEx *r)
+{
+ ZERO_STRUCTP(r->out.handle);
+
+ /* Printername must start with \\ */
+
+ if (!strnequal(r->in.printername, "\\\\", 2))
+ return WERR_INVALID_PARAM;
+
+ if (strchr_m(r->in.printername + 2, '\\'))
+ return spoolss_OpenPrinterEx_server(dce_call, mem_ctx, r);
+
+ return spoolss_OpenPrinterEx_printer(dce_call, mem_ctx, r);
}