1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-10 12:58:35 +03:00

Added PRINTER_ALREADY_EXISTS error check from Gerry.

Jeremy
(This used to be commit c7f1d3d6f776da8619f1221d38619d084ffb990b)
This commit is contained in:
Jeremy Allison 2001-11-27 20:01:23 +00:00
parent ff033d062d
commit d919314390
2 changed files with 18 additions and 3 deletions

View File

@ -83,6 +83,7 @@
#define ERRunknownprinterdriver 1797 /* ERROR_UNKNOWN_PRINTER_DRIVER */
#define ERRinvalidprintername 1801 /* ERROR_INVALID_PRINTER_NAME */
#define ERRprinteralreadyexists 1802 /* ERROR_PRINTER_ALREADY_EXISTS */
#define ERRinvaliddatatype 1804 /* ERROR_INVALID_DATATYPE */
#define ERRinvalidenvironment 1805 /* ERROR_INVALID_ENVIRONMENT */
#define ERRprinterdriverinuse 3001 /* ERROR_PRINTER_DRIVER_IN_USE */
@ -161,6 +162,7 @@
#define WERR_MORE_DATA W_ERROR(234)
#define WERR_UNKNOWN_PRINTER_DRIVER W_ERROR(1797)
#define WERR_INVALID_PRINTER_NAME W_ERROR(1801)
#define WERR_PRINTER_ALREADY_EXISTS W_ERROR(1802)
#define WERR_INVALID_DATATYPE W_ERROR(1804)
#define WERR_INVALID_ENVIRONMENT W_ERROR(1805)
#define WERR_BUF_TOO_SMALL W_ERROR(2123)

View File

@ -5740,9 +5740,10 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
POLICY_HND *handle)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR err;
fstring name;
int snum;
NT_PRINTER_INFO_LEVEL *old_printer = NULL;
fstring name;
int snum;
WERROR err = WERR_OK;
if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) {
DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n"));
@ -5754,6 +5755,18 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
/* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/
convert_printer_info(info, printer, 2);
/* check to see if the printer already exists */
err = get_a_printer(&old_printer, 2, printer->info_2->sharename);
/* did we find a printer? */
if (W_ERROR_IS_OK(err)) {
DEBUG(5, ("_spoolss_addprinterex: Attempted to add a printer named [%s] when one already existed!\n",
printer->info_2->sharename));
free_a_printer(&old_printer, 2);
return WERR_PRINTER_ALREADY_EXISTS;
}
if (*lp_addprinter_cmd() )
if ( !add_printer_hook(printer) ) {
free_a_printer(&printer,2);