printer_driver_files_in_use() performs two tasks: it returns whether any
of the files in the to-be-deleted driver overlap with other drivers, it
also trims such files from the info structure passed in.
In processing a DeletePrinterDataEx request with DPD_DELETE_UNUSED_FILES
set, printer_driver_files_in_use() must be called to ensure files in
use by other drivers are not removed.
https://bugzilla.samba.org/show_bug.cgi?id=4942
Signed-off-by: Andreas Schneider <asn@samba.org>
delete_files = r->in.delete_flags
& (DPD_DELETE_ALL_FILES | DPD_DELETE_UNUSED_FILES);
- /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
- if (delete_files &&
- (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
- printer_driver_files_in_use(mem_ctx,
- b,
- info)) {
- status = WERR_PRINTER_DRIVER_IN_USE;
- goto done;
+ if (delete_files) {
+ bool in_use = printer_driver_files_in_use(mem_ctx, b, info);
+ if (in_use && (r->in.delete_flags & DPD_DELETE_ALL_FILES)) {
+ status = WERR_PRINTER_DRIVER_IN_USE;
+ goto done;
+ }
+ /*
+ * printer_driver_files_in_use() has trimmed overlapping files
+ * from info so they are not removed on DPD_DELETE_UNUSED_FILES
+ */
}