1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

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 commit is contained in:
Jeremy Allison -
parent d09d8a3f4b
commit 6d081a9017
8 changed files with 112 additions and 13 deletions

View File

@ -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,

View File

@ -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
{

View File

@ -214,6 +214,8 @@ static uint32 cmd_quit(struct client_info *info, int argc, char *argv[])
free_connections();
exit(0);
/* NOTREACHED */
return 0;
}
/****************************************************************************

View File

@ -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;
}

View File

@ -1022,6 +1022,41 @@ BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
return True;
}
/*******************************************************************
* 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)

View File

@ -130,6 +130,36 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p)
return True;
}
/********************************************************************
* 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
*
@ -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 },

View File

@ -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,26 +3019,38 @@ 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

View File

@ -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;
}