mirror of
https://github.com/samba-team/samba.git
synced 2025-08-21 09:49:28 +03:00
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
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user