summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-02-18 01:58:56 +0100
committerGünther Deschner <gd@samba.org>2010-02-18 02:19:42 +0100
commit2d2db2a8226f6a3a8e114abc9a37aea66dba912e (patch)
tree95c2f963a6f2ff0be6961b39e8d93138da9c7811 /source3/rpc_server
parent5cff7e1692e4caa308271581f3df3f72c4f31261 (diff)
downloadsamba-2d2db2a8226f6a3a8e114abc9a37aea66dba912e.tar.gz
samba-2d2db2a8226f6a3a8e114abc9a37aea66dba912e.tar.bz2
samba-2d2db2a8226f6a3a8e114abc9a37aea66dba912e.zip
s3-spoolss: more AddPrinter{Ex} checks.
Windows will allow to add a non-shared printer that is returned by EnumPrinters. Samba has no notion of non-shared local printers yet, so just make sure to behave like we do elsewhere: a printer autoloaded by samba or added to samba is shared. Guenther
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 66eb59bd40..49ca8c2c2b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7136,6 +7136,15 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
return WERR_NOMEM;
}
+ /* samba does not have a concept of local, non-shared printers yet, so
+ * make sure we always setup sharename - gd */
+ if ((printer->info_2->sharename[0] == '\0') && (printer->info_2->printername != '\0')) {
+ DEBUG(5, ("spoolss_addprinterex_level_2: "
+ "no sharename has been set, setting printername %s as sharename\n",
+ printer->info_2->printername));
+ fstrcpy(printer->info_2->sharename, printer->info_2->printername);
+ }
+
/* check to see if the printer already exists */
if ((snum = print_queue_snum(printer->info_2->sharename)) != -1) {
@@ -7145,6 +7154,15 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
return WERR_PRINTER_ALREADY_EXISTS;
}
+ if (!lp_force_printername(GLOBAL_SECTION_SNUM)) {
+ if ((snum = print_queue_snum(printer->info_2->printername)) != -1) {
+ DEBUG(5, ("spoolss_addprinterex_level_2: Attempted to add a printer named [%s] when one already existed!\n",
+ printer->info_2->printername));
+ free_a_printer(&printer, 2);
+ return WERR_PRINTER_ALREADY_EXISTS;
+ }
+ }
+
/* validate printer info struct */
if (!info_ctr->info.info2->printername ||
strlen(info_ctr->info.info2->printername) == 0) {