Bug 4942 - DeletePrinterDriverEx deletes files in use
Summary: DeletePrinterDriverEx deletes files in use
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: Printing (show other bugs)
Version: unspecified
Hardware: All Linux
: P3 normal
Target Milestone: ---
Assignee: David Disseldorp
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on: 8697
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-30 05:29 UTC by Martin Zielinski
Modified: 2012-01-23 21:32 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Zielinski 2007-08-30 05:29:21 UTC
When a printer driver is deleted with the flag DPD_DELETE_UNUSED_FILES
All files, that are used by other installed drivers must not be removed.

nt_printing.c - printer_driver_files_in_use (...)

calls "trim_overlap_drv_files(info, driver.info_3)"  to modify the driver info.
But the function returns immediately, if an overlapped file is found:

if ( trim_overlap_drv_files(info, driver.info_3) ) {
		free_a_printer_driver(driver, 3);
		SAFE_FREE( list );
		return True;
}

This might leave out lots of drivers and the info struct is not trimmed correctly. So files, that are in use by other drivers might be accidentally 
deleted.
Comment 1 Andreas Schneider 2012-01-09 11:07:39 UTC
Dave, could you please just verify that this doesn't happen in 3.6 and close the bug. Thanks!
Comment 2 David Disseldorp 2012-01-09 14:18:00 UTC
(In reply to comment #1)
> Dave, could you please just verify that this doesn't happen in 3.6 and close
> the bug. Thanks!

Looks like this bug was fixed by Martin in commit 205c352caeb32693a02fcfaeb3f18515719ac373, I'll do some quick testing.
Comment 3 David Disseldorp 2012-01-10 23:25:51 UTC
This specific bug is no longer a problem in my 3.6.1 test environment. I would still like to propose one patch in the error path to bring behaviour closer to Windows (Server 2k8):

The following changes since commit 7fb82a5a247b95bcd981574d6c0db013c954e026:

  krb5: Require gss_get_name_attribute or Heimdal's PAC parsing to build with krb5 (2012-01-10 23:23:07 +0100)

are available in the git repository at:
  git://git.samba.org/ddiss/samba.git bso4942_deldriver_err_status

David Disseldorp (1):
      spoolss: fix DPD_DELETE_ALL_FILES error return

 source3/rpc_server/spoolss/srv_spoolss_nt.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Comment 4 David Disseldorp 2012-01-11 15:19:24 UTC
(In reply to comment #3)
>   git://git.samba.org/ddiss/samba.git bso4942_deldriver_err_status
> 
> David Disseldorp (1):
>       spoolss: fix DPD_DELETE_ALL_FILES error return
> 

This change is now in the upstream master branch, along with
  s3-rpcclient: add deldriverex flags argument

Both are not required as a fix for this specific bug.
Comment 5 David Disseldorp 2012-01-18 11:19:00 UTC
With a fix for bug#8697 this bug remains a problem. The issue is in the conditions around the printer_driver_files_in_use() call - it is not called when DPD_DELETE_UNUSED_FILES is set.

 2266         delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
 2267 
 2268         /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
 2269 
 2270         if (delete_files &&
 2271             (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
 2272             printer_driver_files_in_use(tmp_ctx,
 2273                                         b,
 2274                                         info)) {
 2275                 status = WERR_PRINTER_DRIVER_IN_USE;
 2276                 goto done;
 2277         }

printer_driver_files_in_use() must be called when DPD_DELETE_UNUSED_FILES is set, as it is responsible for trimming overlapping files from the info structure.
Comment 6 David Disseldorp 2012-01-23 09:52:59 UTC
The fix for this bug has been commited to master. A check-in for 3.6.x is pending.
Comment 7 Karolin Seeger 2012-01-23 19:56:59 UTC
Patches for bug #8697 have been pushed to v3-6-test.

David, this one can be closed also, right?
Comment 8 David Disseldorp 2012-01-23 21:32:57 UTC
(In reply to comment #7)
> Patches for bug #8697 have been pushed to v3-6-test.
> 
> David, this one can be closed also, right?

Sure can, thanks Karolin!