mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
added support for deleting printers into the spoolss system
(This used to be commit e72a571853
)
This commit is contained in:
@ -1600,6 +1600,7 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count);
|
||||
void update_a_form(nt_forms_struct **list, const FORM *form, int count);
|
||||
int get_ntdrivers(fstring **list, char *architecture);
|
||||
void get_short_archi(char *short_archi, char *long_archi);
|
||||
uint32 del_a_printer(char *portname);
|
||||
void dump_a_param(NT_PRINTER_PARAM *param);
|
||||
BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
||||
BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);
|
||||
@ -2434,6 +2435,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_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);
|
||||
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);
|
||||
@ -2732,6 +2735,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_deleteprinter(POLICY_HND *handle);
|
||||
uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
|
||||
uint32 in_size,
|
||||
uint32 *type,
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
/* spoolss pipe: this are the calls which are not implemented ...
|
||||
#define SPOOLSS_OPENPRINTER 0x01
|
||||
#define SPOOLSS_DELETEPRINTER 0x06
|
||||
#define SPOOLSS_GETPRINTERDRIVER 0x0b
|
||||
#define SPOOLSS_DELETEPRINTERDRIVER 0x0d
|
||||
#define SPOOLSS_ADDPRINTPROCESSOR 0x0e
|
||||
@ -73,6 +72,7 @@
|
||||
#define SPOOLSS_GETJOB 0x03
|
||||
#define SPOOLSS_ENUMJOBS 0x04
|
||||
#define SPOOLSS_ADDPRINTER 0x05
|
||||
#define SPOOLSS_DELETEPRINTER 0x06
|
||||
#define SPOOLSS_SETPRINTER 0x07
|
||||
#define SPOOLSS_GETPRINTER 0x08
|
||||
#define SPOOLSS_ADDPRINTERDRIVER 0x09
|
||||
@ -1350,6 +1350,19 @@ typedef struct spool_r_addprinter
|
||||
}
|
||||
SPOOL_R_ADDPRINTER;
|
||||
|
||||
typedef struct spool_q_deleteprinter
|
||||
{
|
||||
POLICY_HND handle;
|
||||
}
|
||||
SPOOL_Q_DELETEPRINTER;
|
||||
|
||||
typedef struct spool_r_deleteprinter
|
||||
{
|
||||
POLICY_HND handle;
|
||||
uint32 status;
|
||||
}
|
||||
SPOOL_R_DELETEPRINTER;
|
||||
|
||||
|
||||
typedef struct spool_q_addprinterex
|
||||
{
|
||||
|
@ -614,6 +614,21 @@ static void save_specifics(NT_PRINTER_PARAM *param, int fd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
delete a printer - this just deletes the printer info file, any open
|
||||
handles are not affected
|
||||
****************************************************************************/
|
||||
uint32 del_a_printer(char *portname)
|
||||
{
|
||||
pstring file;
|
||||
|
||||
slprintf(file, sizeof(file), "%s/NTprinter_%s",
|
||||
lp_nt_drivers_file(), portname);
|
||||
if (unlink(file) != 0) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
|
||||
|
@ -864,6 +864,49 @@ BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* read a structure.
|
||||
* called from static spoolss_q_deleteprinter (srv_spoolss.c)
|
||||
* called from spoolss_deleteprinter (cli_spoolss.c)
|
||||
********************************************************************/
|
||||
BOOL spoolss_io_q_deleteprinter(char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_u == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter");
|
||||
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 static spoolss_r_deleteprinter (srv_spoolss.c)
|
||||
* called from spoolss_deleteprinter (cli_spoolss.c)
|
||||
********************************************************************/
|
||||
BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth)
|
||||
{
|
||||
prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter");
|
||||
depth++;
|
||||
|
||||
if (!prs_align(ps))
|
||||
return False;
|
||||
|
||||
if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
|
||||
return False;
|
||||
if (!prs_uint32("status", ps, depth, &r_u->status))
|
||||
return False;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* read a structure.
|
||||
* called from static spoolss_q_closeprinter (srv_spoolss.c)
|
||||
|
@ -123,6 +123,36 @@ static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata)
|
||||
return True;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* api_spoolss_deleteprinter
|
||||
*
|
||||
* called from the spoolss dispatcher
|
||||
********************************************************************/
|
||||
static BOOL api_spoolss_deleteprinter(prs_struct *data, prs_struct *rdata)
|
||||
{
|
||||
SPOOL_Q_DELETEPRINTER q_u;
|
||||
SPOOL_R_DELETEPRINTER r_u;
|
||||
|
||||
ZERO_STRUCT(q_u);
|
||||
ZERO_STRUCT(r_u);
|
||||
|
||||
if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) {
|
||||
DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
r_u.status = _spoolss_deleteprinter(&q_u.handle);
|
||||
memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle));
|
||||
|
||||
if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) {
|
||||
DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* api_spoolss_rffpcnex
|
||||
* ReplyFindFirstPrinterChangeNotifyEx
|
||||
@ -1104,6 +1134,7 @@ struct api_struct api_spoolss_cmds[] =
|
||||
{"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex },
|
||||
{"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata },
|
||||
{"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter },
|
||||
{"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter },
|
||||
{"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex },
|
||||
{"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex },
|
||||
{"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters },
|
||||
|
@ -200,6 +200,27 @@ static BOOL close_printer_handle(POLICY_HND *hnd)
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
delete a printer given a handle
|
||||
****************************************************************************/
|
||||
static BOOL delete_printer_handle(POLICY_HND *hnd)
|
||||
{
|
||||
Printer_entry *Printer = find_printer_index_by_hnd(hnd);
|
||||
|
||||
if (!OPEN_HANDLE(Printer))
|
||||
{
|
||||
DEBUG(3,("Error closing printer handle\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (del_a_printer(Printer->dev.printername) != 0) {
|
||||
DEBUG(3,("Error deleting printer %s\n", Printer->dev.printername));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
return the snum of a printer corresponding to an handle
|
||||
****************************************************************************/
|
||||
@ -622,6 +643,17 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle)
|
||||
return NT_STATUS_NO_PROBLEMO;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* api_spoolss_deleteprinter
|
||||
********************************************************************/
|
||||
uint32 _spoolss_deleteprinter(POLICY_HND *handle)
|
||||
{
|
||||
if (!delete_printer_handle(handle))
|
||||
return ERROR_INVALID_HANDLE;
|
||||
|
||||
return NT_STATUS_NO_PROBLEMO;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
GetPrinterData on a printer server Handle.
|
||||
********************************************************************/
|
||||
|
Reference in New Issue
Block a user