From: David Disseldorp Date: Tue, 17 Jan 2012 16:06:38 +0000 (+0100) Subject: s3-spoolss: fix printer_driver_files_in_use() call ordering X-Git-Tag: tevent-0.9.15~298 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=7123b592fe10f879d4e62ca25a35eefe82b02652;p=ddiss%2Fsamba.git s3-spoolss: fix printer_driver_files_in_use() call ordering 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 --- diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 07a9f826208..c691b4a1f5a 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -2173,15 +2173,17 @@ static WERROR spoolss_dpd_version(TALLOC_CTX *mem_ctx, 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 + */ }