Bug 10770 - Renaming a printer fails in Printer Management Console
Summary: Renaming a printer fails in Printer Management Console
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Printing (show other bugs)
Version: 4.1.11
Hardware: x64 Windows 7
: P5 minor (vote)
Target Milestone: ---
Assignee: printing-maintainers
QA Contact: Samba QA Contact
Depends on:
Reported: 2014-08-16 18:29 UTC by Marc Muehlfeld
Modified: 2015-11-19 03:18 UTC (History)
4 users (show)

See Also:

Level 10 debug log of the try renaming a printer (1.25 MB, text/x-log)
2014-08-16 18:29 UTC, Marc Muehlfeld
no flags Details
Error Screenshot (87.16 KB, image/png)
2014-08-16 18:30 UTC, Marc Muehlfeld
no flags Details
Simple fix for set info level 4 (2.70 KB, patch)
2014-12-23 03:19 UTC, Garming Sam
no flags Details
Adds some allocation checks (2.97 KB, patch)
2015-08-28 01:53 UTC, Garming Sam
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Muehlfeld 2014-08-16 18:29:48 UTC
Created attachment 10200 [details]
Level 10 debug log of the try renaming a printer

I wanted to change the Wiki Printer Howto, so that it describes the better way to manage the print server via the Printer Management Console. But there renaming of a printer fails.

Steps to reproduce (done on W7 64Bit):
- Open printermanagement.msc
- Go to Printers
- Expand your print server 
- Click Printers
- Try renaming a printer via [F2]
-> Fails with "The selected printer cannot be renamed. Operation could not be completed (error 0x0000007c).

Renaming via the following still works:
- Go to \\servername
- Click button "view remote printers"
- Rename printer via [F2]
But this way is not available on Win8 any more! That's why I wanted to change the HowTo, to provide the official way, that is usable on all supported Windows version.

What made this bug annoying is, that when you associate the first time a driver with a printer, then Windows renames the printer to the name of the driver. And in a corporate environment you typically have multiple of the same printers and want the to have the name you choosed and configured in your smb.conf. So it's neccessary to rename the printer after the driver association.
Comment 1 Marc Muehlfeld 2014-08-16 18:30:09 UTC
Created attachment 10201 [details]
Error Screenshot
Comment 2 Marc Muehlfeld 2014-08-16 19:17:22 UTC
It's possible to rename the printer via the Printer Management Console, too, if you do it by opening the printers properties and edit the name there.

It's only not possible in the Printer Management Console, if done via [F2].

Reducing the importance of this bug report to minor.
Comment 3 Garming Sam 2014-11-17 22:00:40 UTC
It looks like _spoolss_SetPrinter simply doesn't handle info level 4 which is what the F2 is sending, as opposed to info level 2 which is implemented and occurs with the properties dialog. I'll try to write up a patch I guess.
Comment 4 Garming Sam 2014-12-23 03:19:02 UTC
Created attachment 10557 [details]
Simple fix for set info level 4

Basically everything down below below the update_printer call takes struct info level 2, which has a lot more information. Instead of rewriting it entirely and likely getting it wrong, the old printer is retrieved and just filled in. 

There's some code that could probably be factored out, but the simple fix seems to work. I made some attempt to prevent as many duplications of memory, but got into too much trouble with talloc and some parts apparently freeing unexpectedly.
Comment 5 Marc Muehlfeld 2014-12-23 12:52:56 UTC
Thanks Garming for looking at this issue.

Your _patch works_ with 4.1.13 and 4.2rc3.

But I could not try it with master, because with and without your patch, "Printers" stay empty in the printmanagment.msc. But this seems to be a different issue. Should I open a new bug report for that?
Comment 6 David Disseldorp 2015-04-10 17:02:42 UTC
(In reply to Marc Muehlfeld from comment #5)
Please raise a new bug for the issue you encountered in master.

@Garming, please add memory allocation failure checks to your patch and send it to samba-technical for review.
Comment 7 Garming Sam 2015-08-28 01:53:13 UTC
Created attachment 11373 [details]
Adds some allocation checks

Apparently I wasn't CC'd on this. Adds the missing allocation checks.
Comment 8 Marc Muehlfeld 2015-11-02 14:57:21 UTC
(In reply to Garming Sam from comment #7)
Garming, can you please send your patch to samba-technical for review, with link to this bug report, to get this in fixed in the next release? Thanks.
Comment 9 Garming Sam 2015-11-19 03:18:18 UTC
(In reply to Marc Muehlfeld from comment #8)
Hi Marc. It went into master in September, with the link to the bugzilla (although the patch was tweaked from the one attached here).