summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in28
-rw-r--r--source3/include/proto.h26
-rwxr-xr-xsource3/include/rpc_spoolss.h35
-rw-r--r--source3/rpc_client/cli_spoolss.c163
-rw-r--r--source3/rpc_parse/parse_spoolss.c92
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c30
-rw-r--r--source3/rpcclient/cmd_spoolss.c91
-rw-r--r--source3/rpcclient/rpcclient.c13
8 files changed, 370 insertions, 108 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 96e28e8eb2..cc254dd97f 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -156,9 +156,9 @@ RPC_CLIENT_OBJ = \
rpc_client/cli_netlogon_sync.o \
rpc_client/cli_reg.o \
rpc_client/cli_pipe.o \
+ rpc_client/cli_spoolss.o \
rpc_client/cli_lsarpc.o \
rpc_client/cli_wkssvc.o \
- rpc_client/cli_spoolss.o \
rpc_client/cli_srvsvc.o \
rpc_client/cli_svcctl.o \
rpc_client/cli_samr.o \
@@ -248,19 +248,19 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(UBIQX_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(LIB_OBJ)
RPCCLIENT_OBJ = rpcclient/rpcclient.o \
- rpcclient/display.o \
- rpcclient/cmd_lsarpc.o \
- rpcclient/cmd_spoolss.o \
- rpcclient/cmd_wkssvc.o \
- rpcclient/cmd_samr.o \
- rpcclient/cmd_reg.o \
- rpcclient/cmd_srvsvc.o \
- rpcclient/cmd_svcctl.o \
- rpcclient/cmd_netlogon.o \
- rpcclient/cmd_atsvc.o \
- rpcclient/cmd_eventlog.o \
- $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
- $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ)
+ rpcclient/display.o \
+ rpcclient/cmd_lsarpc.o \
+ rpcclient/cmd_wkssvc.o \
+ rpcclient/cmd_samr.o \
+ rpcclient/cmd_reg.o \
+ rpcclient/cmd_srvsvc.o \
+ rpcclient/cmd_svcctl.o \
+ rpcclient/cmd_netlogon.o \
+ rpcclient/cmd_atsvc.o \
+ rpcclient/cmd_spoolss.o \
+ rpcclient/cmd_eventlog.o \
+ $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
+ $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ)
SMBWRAPPER_OBJ = smbwrapper/smbw.o smbwrapper/wrapped.o \
smbwrapper/smbw_dir.o smbwrapper/smbw_stat.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e9880b55c3..c382d2d6ed 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2037,12 +2037,13 @@ BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum,
/*The following definitions come from rpc_client/cli_spoolss.c */
-BOOL spoolss_get_printer_data(struct cli_state *cli, uint16 fnum,
- PRINTER_HND *hnd,
- char *value_name, uint32 size);
-BOOL spoolss_get_printer(struct cli_state *cli, uint16 fnum,
- PRINTER_HND *hnd, uint32 level,
- uint32 buf_size);
+BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
+ char *printername,
+ uint32 cbbuf, uint32 devmod, uint32 des_access,
+ char *station,
+ char *username,
+ PRINTER_HND *hnd);
+BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd);
/*The following definitions come from rpc_client/cli_srvsvc.c */
@@ -2926,20 +2927,20 @@ BOOL sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth);
BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime);
BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
prs_struct *ps, int depth);
-BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth);
-BOOL make_spoolss_io_q_open_printer(SPOOL_Q_OPEN_PRINTER *q_u,
- uint32 unk_0,
+BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth);
+BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
char *printername,
- uint32 unk_1, uint32 cbbuf, uint32 devmod, uint32 des_access,
+ uint32 cbbuf, uint32 devmod, uint32 des_access,
char *station,
char *username);
-BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth);
+BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
PRINTER_HND *handle,
char *valuename,
uint32 size);
BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth);
+BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, PRINTER_HND *hnd);
BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth);
@@ -3414,8 +3415,7 @@ void cmd_sam_enum_groups(struct client_info *info);
/*The following definitions come from rpcclient/cmd_spoolss.c */
-void cmd_spoolss_getprinterdata(struct client_info *info);
-void cmd_spoolss_getprinter(struct client_info *info);
+void cmd_spoolss_open_printer_ex(struct client_info *info);
/*The following definitions come from rpcclient/cmd_srvsvc.c */
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index e48d114dd1..0afc8d2b5d 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -506,37 +506,40 @@ typedef struct s_buffer
typedef struct printer_policy_info
{
uint8 data[PRINTER_HND_SIZE]; /* printer handle */
+
} PRINTER_HND;
-/* SPOOL_Q_OPEN_PRINTER request to open a printer */
-typedef struct spool_q_open_printer
+/* SPOOL_Q_OPEN_PRINTER_EX request to open a printer */
+typedef struct spool_q_open_printer_ex
{
- uint32 unknown0;
+ uint32 ptr;
UNISTR2 printername;
- uint32 unknown1;
+ uint32 unknown0;
uint32 cbbuf;
uint32 devmod;
uint32 access_required;
+ uint32 unknown1; /* 0x0000 0001 */
uint32 unknown2; /* 0x0000 0001 */
- uint32 unknown3; /* 0x0000 0001 */
- uint32 unknown4; /* ??? */
- uint32 unknown5; /* 0x0000 001c */
- uint32 unknown6; /* ??? */
- uint32 unknown7; /* ??? */
- uint32 unknown8; /* 0x0000 0565 */
- uint32 unknown9; /* 0x0000 0002 */
+ uint32 unknown3; /* ??? pointer? */
+ uint32 unknown4; /* 0x0000 001c */
+ uint32 unknown5; /* ??? e.g 0xb94dd0 */
+ uint32 unknown6; /* ??? pointer? */
+ uint32 unknown7; /* 0x0000 0565 */
+ uint32 unknown8; /* 0x0000 0002 */
+ uint32 unknown9; /* 0x0000 0000 */
uint32 unknown10; /* 0x0000 0000 */
- uint32 unknown11; /* ??? */
UNISTR2 station;
UNISTR2 username;
-} SPOOL_Q_OPEN_PRINTER;
-/* SPOOL_Q_OPEN_PRINTER reply to an open printer */
-typedef struct spool_r_open_printer
+} SPOOL_Q_OPEN_PRINTER_EX;
+
+/* SPOOL_Q_OPEN_PRINTER_EX reply to an open printer */
+typedef struct spool_r_open_printer_ex
{
PRINTER_HND handle; /* handle used along all transactions (20*uint8) */
uint32 status;
-} SPOOL_R_OPEN_PRINTER;
+
+} SPOOL_R_OPEN_PRINTER_EX;
typedef struct spool_q_getprinterdata
{
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
new file mode 100644
index 0000000000..adb850673f
--- /dev/null
+++ b/source3/rpc_client/cli_spoolss.c
@@ -0,0 +1,163 @@
+
+/*
+ * Unix SMB/Netbios implementation.
+ * Version 1.9.
+ * RPC Pipe client / server routines
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
+ * Copyright (C) Paul Ashton 1997.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifdef SYSLOG
+#undef SYSLOG
+#endif
+
+#include "includes.h"
+
+extern int DEBUGLEVEL;
+
+
+/****************************************************************************
+do a SPOOLSS Open Printer Ex
+****************************************************************************/
+BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
+ char *printername,
+ uint32 cbbuf, uint32 devmod, uint32 des_access,
+ char *station,
+ char *username,
+ PRINTER_HND *hnd)
+{
+ prs_struct rbuf;
+ prs_struct buf;
+ SPOOL_Q_OPEN_PRINTER_EX q_o;
+ BOOL valid_pol = False;
+
+ if (hnd == NULL) return False;
+
+ prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
+
+ /* create and send a MSRPC command with api SPOOLSS_OPENPRINTEREX */
+
+ DEBUG(5,("SPOOLSS Open Printer Ex\n"));
+
+ make_spoolss_q_open_printer_ex(&q_o, printername,
+ cbbuf, devmod, des_access,
+ station, username);
+
+ /* turn parameters into data stream */
+ spoolss_io_q_open_printer_ex("", &q_o, &buf, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, fnum, SPOOLSS_OPENPRINTEREX, &buf, &rbuf))
+ {
+ SPOOL_R_OPEN_PRINTER_EX r_o;
+ BOOL p;
+
+ spoolss_io_r_open_printer_ex("", &r_o, &rbuf, 0);
+ p = rbuf.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(5,("SPOOLSS_OPENPRINTEREX: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ /* ok, at last: we're happy. return the policy handle */
+ memcpy(hnd, r_o.handle.data, sizeof(hnd->data));
+ valid_pol = True;
+ }
+ }
+
+ prs_mem_free(&rbuf);
+ prs_mem_free(&buf );
+
+ return valid_pol;
+}
+
+/****************************************************************************
+do a SPOOL Close
+****************************************************************************/
+BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd)
+{
+ prs_struct rbuf;
+ prs_struct buf;
+ SPOOL_Q_CLOSEPRINTER q_c;
+ BOOL valid_close = False;
+
+ if (hnd == NULL) return False;
+
+ /* create and send a MSRPC command with api SPOOLSS_CLOSEPRINTER */
+
+ prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
+
+ DEBUG(4,("SPOOL Close Printer\n"));
+
+ /* store the parameters */
+ make_spoolss_q_closeprinter(&q_c, hnd);
+
+ /* turn parameters into data stream */
+ spoolss_io_q_closeprinter("", &q_c, &buf, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, fnum, SPOOLSS_CLOSEPRINTER, &buf, &rbuf))
+ {
+ SPOOL_R_CLOSEPRINTER r_c;
+ BOOL p;
+
+ spoolss_io_r_closeprinter("", &r_c, &rbuf, 0);
+ p = rbuf.offset != 0;
+
+ if (p && r_c.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("SPOOL_CLOSEPRINTER: %s\n", get_nt_error_msg(r_c.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ /* check that the returned policy handle is all zeros */
+ uint32 i;
+ valid_close = True;
+
+ for (i = 0; i < sizeof(r_c.handle.data); i++)
+ {
+ if (r_c.handle.data[i] != 0)
+ {
+ valid_close = False;
+ break;
+ }
+ }
+ if (!valid_close)
+ {
+ DEBUG(0,("SPOOL_CLOSEPRINTER: non-zero handle returned\n"));
+ }
+ }
+ }
+
+ prs_mem_free(&rbuf);
+ prs_mem_free(&buf );
+
+ return valid_close;
+}
+
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index c1d8e54afb..d58a4868e6 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -393,13 +393,14 @@ static BOOL smb_io_notify_info(char *desc, SPOOL_NOTIFY_INFO *info,
/*******************************************************************
* write a structure.
- * called from spoolss_r_open_printer (srv_spoolss.c)
+ * called from static spoolss_r_open_printer_ex (srv_spoolss.c)
+ * called from spoolss_open_printer_ex (cli_spoolss.c)
********************************************************************/
-BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth)
+BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth)
{
if (r_u == NULL) return False;
- prs_debug(ps, depth, desc, "spoolss_io_r_open_printer");
+ prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex");
depth++;
prs_align(ps);
@@ -413,73 +414,67 @@ BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct
return True;
}
-#if 0
/*******************************************************************
* make a structure.
********************************************************************/
-BOOL make_spoolss_io_q_open_printer(SPOOL_Q_OPEN_PRINTER *q_u,
- uint32 unk_0,
+BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
char *printername,
- uint32 unk_1, uint32 cbbuf, uint32 devmod, uint32 des_access,
+ uint32 cbbuf, uint32 devmod, uint32 des_access,
char *station,
char *username)
{
int len_name = printername != NULL ? strlen(printername) : 0;
+ int len_sta = station != NULL ? strlen(station ) : 0;
+ int len_user = username != NULL ? strlen(username ) : 0;
if (q_u == NULL) return False;
- DEBUG(5,("make_spoolss_io_q_open_printer\n"));
+ DEBUG(5,("make_spoolss_io_q_open_printer_ex\n"));
- q_u->unknown0 = unk_0;
- make_unistr2(&(q_u->uni_domain), dom_name, len_name);
+ q_u->ptr = 1;
+ make_unistr2(&(q_u->printername), printername, len_name);
+ q_u->unknown0 = 0x0; /* 0x0000 0000 */
+ q_u->cbbuf = cbbuf; /* 0x0000 0000 */
+ q_u->devmod = devmod; /* 0x0000 0000 */
+ q_u->access_required = des_access;
- prs_uint32("unknown1", ps, depth, &(q_u->unknown1));
- prs_uint32("cbbuf", ps, depth, &(q_u->cbbuf));
- prs_uint32("devmod", ps, depth, &(q_u->devmod));
- prs_uint32("access required", ps, depth, &(q_u->access_required));
-
- /* don't care to decode end of packet by now */
- /* but when acl will be implemented, it will be useful */
-
- prs_uint32("unknown2", ps, depth, &(q_u->unknown2));
- prs_uint32("unknown3", ps, depth, &(q_u->unknown3));
- prs_uint32("unknown4", ps, depth, &(q_u->unknown4));
- prs_uint32("unknown5", ps, depth, &(q_u->unknown5));
- prs_uint32("unknown6", ps, depth, &(q_u->unknown6));
- prs_uint32("unknown7", ps, depth, &(q_u->unknown7));
- prs_uint32("unknown8", ps, depth, &(q_u->unknown8));
- prs_uint32("unknown9", ps, depth, &(q_u->unknown9));
- prs_uint32("unknown10", ps, depth, &(q_u->unknown10));
- prs_uint32("unknown11", ps, depth, &(q_u->unknown11));
+ q_u->unknown1 = 0x1;
+ q_u->unknown2 = 0x1;
+ q_u->unknown3 = 0x149f7d8; /* looks like a pointer */
+ q_u->unknown4 = 0x1c;
+ q_u->unknown5 = 0x00b94dd0;
+ q_u->unknown6 = 0x0149f5cc; /* looks like _another_ pointer */
+ q_u->unknown7 = 0x00000565;
+ q_u->unknown8 = 0x2;
+ q_u->unknown9 = 0x0;
+ q_u->unknown10 = 0x0;
- smb_io_unistr2("", &(q_u->station),True,ps,depth);
- prs_align(ps);
- smb_io_unistr2("", &(q_u->username),True,ps,depth);
+ make_unistr2(&(q_u->station), station, len_sta);
+ make_unistr2(&(q_u->username), username, len_user);
return True;
}
-#endif
/*******************************************************************
* read a structure.
- * called from spoolss_q_open_printer (srv_spoolss.c)
+ * called from spoolss_q_open_printer_ex (srv_spoolss.c)
********************************************************************/
-BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth)
+BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth)
{
if (q_u == NULL) return False;
- prs_debug(ps, depth, desc, "spoolss_io_q_open_printer");
+ prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex");
depth++;
prs_align(ps);
- prs_uint32("unknown0", ps, depth, &(q_u->unknown0));
+ prs_uint32("ptr", ps, depth, &(q_u->ptr));
smb_io_unistr2("", &(q_u->printername),True,ps,depth);
prs_align(ps);
- prs_uint32("unknown1", ps, depth, &(q_u->unknown1));
+ prs_uint32("unknown0", ps, depth, &(q_u->unknown0));
prs_uint32("cbbuf", ps, depth, &(q_u->cbbuf));
prs_uint32("devmod", ps, depth, &(q_u->devmod));
prs_uint32("access required", ps, depth, &(q_u->access_required));
@@ -487,6 +482,7 @@ BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct
/* don't care to decode end of packet by now */
/* but when acl will be implemented, it will be useful */
+ prs_uint32("unknown1", ps, depth, &(q_u->unknown1));
prs_uint32("unknown2", ps, depth, &(q_u->unknown2));
prs_uint32("unknown3", ps, depth, &(q_u->unknown3));
prs_uint32("unknown4", ps, depth, &(q_u->unknown4));
@@ -496,11 +492,11 @@ BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct
prs_uint32("unknown8", ps, depth, &(q_u->unknown8));
prs_uint32("unknown9", ps, depth, &(q_u->unknown9));
prs_uint32("unknown10", ps, depth, &(q_u->unknown10));
- prs_uint32("unknown11", ps, depth, &(q_u->unknown11));
smb_io_unistr2("", &(q_u->station),True,ps,depth);
prs_align(ps);
smb_io_unistr2("", &(q_u->username),True,ps,depth);
+ prs_align(ps);
return True;
}
@@ -576,8 +572,23 @@ BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_st
}
/*******************************************************************
+ * make a structure.
+ ********************************************************************/
+BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, PRINTER_HND *hnd)
+{
+ if (q_u == NULL) return False;
+
+ DEBUG(5,("make_spoolss_q_closeprinter\n"));
+
+ memcpy(&(q_u->handle), hnd, sizeof(q_u->handle));
+
+ return True;
+}
+
+/*******************************************************************
* read a structure.
- * called from spoolss_q_closeprinter (srv_spoolss.c)
+ * called from static spoolss_q_closeprinter (srv_spoolss.c)
+ * called from spoolss_closeprinter (cli_spoolss.c)
********************************************************************/
BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth)
{
@@ -595,7 +606,8 @@ BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct
/*******************************************************************
* write a structure.
- * called from spoolss_r_closeprinter (srv_spoolss.c)
+ * called from static spoolss_r_closeprinter (srv_spoolss.c)
+ * called from spoolss_closeprinter (cli_spoolss.c)
********************************************************************/
BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth)
{
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 166ac5a452..5883c9baac 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -28,8 +28,8 @@
extern int DEBUGLEVEL;
extern pstring global_myname;
-#ifndef MAX_OPEN_PRINTERS
-#define MAX_OPEN_PRINTERS 50
+#ifndef MAX_OPEN_PRINTER_EXS
+#define MAX_OPEN_PRINTER_EXS 50
#endif
#define PRINTER_HANDLE_IS_PRINTER 0
@@ -61,9 +61,9 @@ static struct
uint32 access;
uint32 number_of_notify;
SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY];
-} Printer[MAX_OPEN_PRINTERS];
+} Printer[MAX_OPEN_PRINTER_EXS];
-#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTERS))
+#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS))
#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open)
/****************************************************************************
@@ -72,7 +72,7 @@ static struct
void init_printer_hnd(void)
{
int i;
- for (i = 0; i < MAX_OPEN_PRINTERS; i++)
+ for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++)
{
Printer[i].open = False;
}
@@ -115,7 +115,7 @@ static BOOL open_printer_hnd(PRINTER_HND *hnd)
{
int i;
- for (i = 0; i < MAX_OPEN_PRINTERS; i++)
+ for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++)
{
if (!Printer[i].open)
{
@@ -139,7 +139,7 @@ static int find_printer_index_by_hnd(PRINTER_HND *hnd)
{
int i;
- for (i = 0; i < MAX_OPEN_PRINTERS; i++)
+ for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++)
{
if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0)
{
@@ -383,9 +383,9 @@ static BOOL handle_is_printer(PRINTER_HND *handle)
*
* called from the spoolss dispatcher
********************************************************************/
-static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rdata)
+static void spoolss_reply_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *rdata)
{
- SPOOL_R_OPEN_PRINTER r_u;
+ SPOOL_R_OPEN_PRINTER_EX r_u;
BOOL printer_open = False;
fstring name;
@@ -420,7 +420,7 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd
clear_handle(&(r_u.handle));
}
- spoolss_io_r_open_printer("",&r_u,rdata,0);
+ spoolss_io_r_open_printer_ex("",&r_u,rdata,0);
}
/********************************************************************
@@ -428,15 +428,15 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd
*
* called from the spoolss dispatcher
********************************************************************/
-static void api_spoolss_open_printer(pipes_struct *p, prs_struct *data, prs_struct *rdata)
+static void api_spoolss_open_printer_ex(pipes_struct *p, prs_struct *data, prs_struct *rdata)
{
- SPOOL_Q_OPEN_PRINTER q_u;
+ SPOOL_Q_OPEN_PRINTER_EX q_u;
/* grab the spoolss open policy */
- spoolss_io_q_open_printer("", &q_u, data, 0);
+ spoolss_io_q_open_printer_ex("", &q_u, data, 0);
/* construct reply. always indicate success */
- spoolss_reply_open_printer(&q_u, rdata);
+ spoolss_reply_open_printer_ex(&q_u, rdata);
}
/********************************************************************
@@ -3818,7 +3818,7 @@ static void api_spoolss_getjob(pipes_struct *p, prs_struct *data,
********************************************************************/
struct api_struct api_spoolss_cmds[] =
{
- {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer },
+ {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
{"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
{"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
{"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
new file mode 100644
index 0000000000..0e931d4a39
--- /dev/null
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -0,0 +1,91 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ NT Domain Authentication SMB / MSRPC client
+ Copyright (C) Andrew Tridgell 1994-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996-1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#ifdef SYSLOG
+#undef SYSLOG
+#endif
+
+#include "includes.h"
+#include "nterr.h"
+
+extern int DEBUGLEVEL;
+
+#define DEBUG_TESTING
+
+extern FILE* out_hnd;
+
+extern struct cli_state *smb_cli;
+extern int smb_tidx;
+
+/****************************************************************************
+nt spoolss query
+****************************************************************************/
+void cmd_spoolss_open_printer_ex(struct client_info *info)
+{
+ uint16 nt_pipe_fnum;
+ fstring srv_name;
+ fstring printer_name;
+ PRINTER_HND hnd;
+
+ BOOL res = True;
+
+ if (!next_token(NULL, printer_name, NULL, sizeof(printer_name)))
+ {
+ report(out_hnd, "spoolopen <printer name>\n");
+ return;
+ }
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->myhostname);
+ strupper(srv_name);
+
+ DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
+ printer_name, srv_name, smb_cli->user_name));
+
+ DEBUG(5, ("cmd_spoolss_open_printer_ex: smb_cli->fd:%d\n", smb_cli->fd));
+
+ /* open SPOOLSS session. */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SPOOLSS, &nt_pipe_fnum) : False;
+
+ res = res ? spoolss_open_printer_ex(smb_cli, nt_pipe_fnum,
+ printer_name,
+ 0, 0, 0,
+ srv_name, smb_cli->user_name,
+ &hnd) : False;
+
+ res = res ? spoolss_closeprinter(smb_cli, nt_pipe_fnum, &hnd) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli, nt_pipe_fnum);
+
+ if (res)
+ {
+ DEBUG(5,("cmd_spoolss_open_printer_ex: query succeeded\n"));
+ report(out_hnd, "OK\n");
+ }
+ else
+ {
+ DEBUG(5,("cmd_spoolss_open_printer_ex: query failed\n"));
+ }
+}
+
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index cb6ea0529d..681ebb42fa 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -236,18 +236,11 @@ commands[] =
*/
{
- "spoolgetprinterdata",
- cmd_spoolss_getprinterdata,
- "Spool Printer Data Test",
+ "spoolopen",
+ cmd_spoolss_open_printer_ex,
+ "Spool Printer Open Test",
{COMPL_NONE, COMPL_NONE}
},
- {
- "spoolgetprinter",
- cmd_spoolss_getprinter,
- "Spool Printer Test",
- {COMPL_NONE, COMPL_NONE}
- },
-
/*
* server
*/