summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-11-27 20:01:23 +0000
committerJeremy Allison <jra@samba.org>2001-11-27 20:01:23 +0000
commitd919314390ad51384146797de5268b5c842f039b (patch)
treedde762ded5f462615df7f65e1d0a753006149133 /source3/rpc_server
parentff033d062d883e5f9e9fb08d4dbfcc1443491c21 (diff)
downloadsamba-d919314390ad51384146797de5268b5c842f039b.tar.gz
samba-d919314390ad51384146797de5268b5c842f039b.tar.bz2
samba-d919314390ad51384146797de5268b5c842f039b.zip
Added PRINTER_ALREADY_EXISTS error check from Gerry.
Jeremy (This used to be commit c7f1d3d6f776da8619f1221d38619d084ffb990b)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 2b8ae2de0b..71b776f80a 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -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);