summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-08-30 00:45:59 +0000
committerJeremy Allison <jra@samba.org>2000-08-30 00:45:59 +0000
commitd407579b94ee2647d1e51c536534024e5c4c51ad (patch)
treec4a3ae28143ea3bfc4fe11022455b3d85f94c321
parent3b33053b886b88bb7546f77dcdb038fcdc501c6c (diff)
downloadsamba-d407579b94ee2647d1e51c536534024e5c4c51ad.tar.gz
samba-d407579b94ee2647d1e51c536534024e5c4c51ad.tar.bz2
samba-d407579b94ee2647d1e51c536534024e5c4c51ad.zip
Implemented AbortPrinter() from Gerald's Win32 test code. Just purge all
possible printjobs from that printer (I think this is correct). Added error code returns for print_queue_XXX() functions. Jeremy. (This used to be commit 6d081a9017f87f59b7189ba507e211db01c40af5)
-rw-r--r--source3/include/proto.h9
-rwxr-xr-xsource3/include/rpc_spoolss.h14
-rw-r--r--source3/lib/cmd_interp.c2
-rw-r--r--source3/printing/printing.c9
-rw-r--r--source3/rpc_parse/parse_spoolss.c35
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c31
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c19
-rw-r--r--source3/smbd/lanman.c6
8 files changed, 112 insertions, 13 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9b948bb8b9..22788e6581 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1755,9 +1755,9 @@ int print_queue_status(int snum,
print_queue_struct **queue,
print_status_struct *status);
int print_queue_snum(char *qname);
-BOOL print_queue_pause(struct current_user *user, int snum);
-BOOL print_queue_resume(struct current_user *user, int snum);
-BOOL print_queue_purge(struct current_user *user, int snum);
+BOOL print_queue_pause(struct current_user *user, int snum, int *errcode);
+BOOL print_queue_resume(struct current_user *user, int snum, int *errcode);
+BOOL print_queue_purge(struct current_user *user, int snum, int *errcode);
#endif
/*The following definitions come from profile/profile.c */
@@ -2723,6 +2723,8 @@ BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
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, POLICY_HND *hnd);
+BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth);
+BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth);
@@ -3093,6 +3095,7 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
uint32 user_switch, SPOOL_USER_CTR user_ctr,
POLICY_HND *handle);
uint32 _spoolss_closeprinter(POLICY_HND *handle);
+uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p);
uint32 _spoolss_deleteprinter(POLICY_HND *handle);
uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
uint32 in_size,
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 64047a1afc..7b3ee354ed 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -33,7 +33,6 @@
#define SPOOLSS_DELETEPRINTERDRIVER 0x0d
#define SPOOLSS_ADDPRINTPROCESSOR 0x0e
#define SPOOLSS_GETPRINTPROCESSORDIRECTORY 0x10
-#define SPOOLSS_ABORTPRINTER 0x15
#define SPOOLSS_READPRINTER 0x16
#define SPOOLSS_WAITFORPRINTERCHANGE 0x1c
#define SPOOLSS_DELETEFORM 0x1f
@@ -84,6 +83,7 @@
#define SPOOLSS_STARTPAGEPRINTER 0x12
#define SPOOLSS_WRITEPRINTER 0x13
#define SPOOLSS_ENDPAGEPRINTER 0x14
+#define SPOOLSS_ABORTPRINTER 0x15
#define SPOOLSS_ENDDOCPRINTER 0x17
#define SPOOLSS_ADDJOB 0x18
#define SPOOLSS_SCHEDULEJOB 0x19
@@ -1425,6 +1425,18 @@ typedef struct spool_r_deleteprinter
}
SPOOL_R_DELETEPRINTER;
+typedef struct spool_q_abortprinter
+{
+ POLICY_HND handle;
+}
+SPOOL_Q_ABORTPRINTER;
+
+typedef struct spool_r_abortprinter
+{
+ uint32 status;
+}
+SPOOL_R_ABORTPRINTER;
+
typedef struct spool_q_addprinterex
{
diff --git a/source3/lib/cmd_interp.c b/source3/lib/cmd_interp.c
index 0030710052..d2aafa8b5d 100644
--- a/source3/lib/cmd_interp.c
+++ b/source3/lib/cmd_interp.c
@@ -214,6 +214,8 @@ static uint32 cmd_quit(struct client_info *info, int argc, char *argv[])
free_connections();
exit(0);
+ /* NOTREACHED */
+ return 0;
}
/****************************************************************************
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index f5f40d8b9c..cf3748ed16 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -890,13 +890,14 @@ int print_queue_snum(char *qname)
/****************************************************************************
pause a queue
****************************************************************************/
-BOOL print_queue_pause(struct current_user *user, int snum)
+BOOL print_queue_pause(struct current_user *user, int snum, int *errcode)
{
int ret;
if (!user) return False;
if (!print_access_check(user, snum, PRINTER_ACE_MANAGE_DOCUMENTS)) {
+ *errcode = ERROR_ACCESS_DENIED;
return False;
}
@@ -912,11 +913,12 @@ BOOL print_queue_pause(struct current_user *user, int snum)
/****************************************************************************
resume a queue
****************************************************************************/
-BOOL print_queue_resume(struct current_user *user, int snum)
+BOOL print_queue_resume(struct current_user *user, int snum, int *errcode)
{
int ret;
if (!print_access_check(user, snum, PRINTER_ACE_MANAGE_DOCUMENTS)) {
+ *errcode = ERROR_ACCESS_DENIED;
return False;
}
@@ -932,13 +934,14 @@ BOOL print_queue_resume(struct current_user *user, int snum)
/****************************************************************************
purge a queue - implemented by deleting all jobs that we can delete
****************************************************************************/
-BOOL print_queue_purge(struct current_user *user, int snum)
+BOOL print_queue_purge(struct current_user *user, int snum, int *errcode)
{
print_queue_struct *queue;
print_status_struct status;
int njobs, i;
if (!print_access_check(user, snum, PRINTER_ACE_MANAGE_DOCUMENTS)) {
+ *errcode = ERROR_ACCESS_DENIED;
return False;
}
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 54794a7343..60b6eed0c9 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -1024,6 +1024,41 @@ BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
/*******************************************************************
* read a structure.
+ * called from static spoolss_q_abortprinter (srv_spoolss.c)
+ * called from spoolss_abortprinter (cli_spoolss.c)
+ ********************************************************************/
+BOOL spoolss_io_q_abortprinter(char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth)
+{
+ if (q_u == NULL) return False;
+
+ prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * write a structure.
+ * called from spoolss_r_abortprinter (srv_spoolss.c)
+ ********************************************************************/
+BOOL spoolss_io_r_abortprinter(char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter");
+ depth++;
+ if(!prs_uint32("status", ps, depth, &r_u->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ * read a structure.
* called from static spoolss_q_deleteprinter (srv_spoolss.c)
* called from spoolss_deleteprinter (cli_spoolss.c)
********************************************************************/
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 5a1592e4fb..e6a0f3ae6d 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -131,6 +131,36 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p)
}
/********************************************************************
+ * api_spoolss_abortprinter
+ *
+ * called from the spoolss dispatcher
+ ********************************************************************/
+static BOOL api_spoolss_abortprinter(pipes_struct *p)
+{
+ SPOOL_Q_ABORTPRINTER q_u;
+ SPOOL_R_ABORTPRINTER r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ if (!spoolss_io_q_abortprinter("", &q_u, data, 0)) {
+ DEBUG(0,("spoolss_io_q_abortprinter: unable to unmarshall SPOOL_Q_ABORTPRINTER.\n"));
+ return False;
+ }
+
+ r_u.status = _spoolss_abortprinter(&q_u.handle, p);
+
+ if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) {
+ DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/********************************************************************
* api_spoolss_deleteprinter
*
* called from the spoolss dispatcher
@@ -1209,6 +1239,7 @@ struct api_struct api_spoolss_cmds[] =
{"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
{"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
{"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
+ {"SPOOLSS_ABORTPRINTER", SPOOLSS_ABORTPRINTER, api_spoolss_abortprinter },
{"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
{"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
{"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index b118b7c933..b9266c7ee1 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -2999,6 +2999,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command,
{
struct current_user user;
int snum;
+ int errcode = 0;
Printer_entry *Printer = find_printer_index_by_hnd(handle);
if (p->ntlmssp_auth_validated) {
@@ -3018,27 +3019,39 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command,
switch (command) {
case PRINTER_CONTROL_PAUSE:
- if (print_queue_pause(&user, snum)) {
+ if (print_queue_pause(&user, snum, &errcode)) {
return 0;
}
break;
case PRINTER_CONTROL_RESUME:
case PRINTER_CONTROL_UNPAUSE:
- if (print_queue_resume(&user, snum)) {
+ if (print_queue_resume(&user, snum, &errcode)) {
return 0;
}
break;
case PRINTER_CONTROL_PURGE:
- if (print_queue_purge(&user, snum)) {
+ if (print_queue_purge(&user, snum, &errcode)) {
return 0;
}
break;
}
+ if (errcode)
+ return (uint32)errcode;
+
return ERROR_INVALID_FUNCTION;
}
/********************************************************************
+ * api_spoolss_abortprinter
+ ********************************************************************/
+
+uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p)
+{
+ return control_printer(handle, PRINTER_CONTROL_PURGE, p);
+}
+
+/********************************************************************
* called by spoolss_api_setprinter
* when updating a printer description
********************************************************************/
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 170bb9e6bd..82ab5f4d3c 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1940,13 +1940,13 @@ static BOOL api_WPrintQueuePurge(connection_struct *conn,uint16 vuid, char *para
switch (function) {
case 74: /* Pause queue */
- if (print_queue_pause(NULL, snum)) errcode = NERR_Success;
+ if (print_queue_pause(NULL, snum, &errcode)) errcode = NERR_Success;
break;
case 75: /* Resume queue */
- if (print_queue_resume(NULL, snum)) errcode = NERR_Success;
+ if (print_queue_resume(NULL, snum, &errcode)) errcode = NERR_Success;
break;
case 103: /* Purge */
- if (print_queue_purge(NULL, snum)) errcode = NERR_Success;
+ if (print_queue_purge(NULL, snum, &errcode)) errcode = NERR_Success;
break;
}