Bug 8554 - New cups printer not added to registry
New cups printer not added to registry
Product: Samba 3.6
Classification: Unclassified
Component: Printing
All All
: P5 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
: 8612 (view as bug list)
Depends on: 8921
Blocks: 8595
  Show dependency treegraph
Reported: 2011-10-28 11:08 UTC by Björn Baumbach
Modified: 2012-07-12 15:05 UTC (History)
5 users (show)

See Also:

proposed fix for bug 8554 (3.36 KB, patch)
2011-11-03 14:29 UTC, Björn Baumbach
asn: review-
proposed fix for bug 8554 and 8612 (4.18 KB, patch)
2011-12-07 12:50 UTC, Björn Baumbach
no flags Details
Level 10 Debug Log (2.49 MB, application/octet-stream)
2011-12-07 14:53 UTC, Marc Muehlfeld
no flags Details
new proposed fix for bug 8554 and 8612 (4.20 KB, patch)
2011-12-16 17:10 UTC, Björn Baumbach
asn: review+
smb.conf, level 10 debug logs and network trace (2.97 MB, application/octet-stream)
2011-12-18 14:42 UTC, Marc Muehlfeld
no flags Details
Samba config files (2.05 KB, application/octet-stream)
2012-02-06 11:44 UTC, Marc Muehlfeld
no flags Details
fix like v2, but with additional debug message (4.31 KB, patch)
2012-02-07 15:15 UTC, Björn Baumbach
no flags Details
v3-6-test patch (4.35 KB, patch)
2012-02-08 10:41 UTC, Andreas Schneider
gd: review+
fixed v3-6-test patch (4.42 KB, patch)
2012-02-08 13:04 UTC, Andreas Schneider
gd: review+
v3-6-test patch3 (4.57 KB, patch)
2012-02-09 09:39 UTC, Andreas Schneider
gd: review+

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Baumbach 2011-10-28 11:08:07 UTC
Samba does not write newly added cups printers into the registry.

After adding a new cups printer you can run
rpcclient -c "enumprinters"
Comment 1 Guenther Deschner 2011-11-01 16:39:40 UTC
A hotfix is the following, the final patch should add it into the load_printers path where already deleted printers are handled:

 source3/rpc_server/spoolss/srv_spoolss_nt.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 3405566..0174851 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -3622,6 +3622,11 @@ static WERROR printserver_notify_info(struct pipes_struct *p,
                                continue; /* skip */
+                       winreg_create_printer_internal(mem_ctx,
+                               get_session_info_system(),
+                               p->msg_ctx,
+                               lp_servicename(snum));
                        /* Maybe we should use the SYSTEM session_info here... */
                        result = winreg_get_printer_internal(mem_ctx,
Comment 2 Björn Baumbach 2011-11-03 14:29:35 UTC
Created attachment 7059 [details]
proposed fix for bug 8554
Comment 3 Björn Baumbach 2011-11-16 09:01:44 UTC
*** Bug 8612 has been marked as a duplicate of this bug. ***
Comment 4 Marc Muehlfeld 2011-11-16 09:47:27 UTC
The attached Björn attached doesn't fix the problem here. Maybe my reported bug (Bug #8612), that was marked as duplicated of this one, isn't exactly the same?!

If I add a new printer section to my smb.conf and restart the services the new printer still isn't shown in "\\server\Drucker und Faxgeräte".

The workaround to run
# rpcclient -c "enumprinters"
doesn't work here also. This just show me the help of the rpcclient command.
Comment 5 Andreas Schneider 2011-11-16 09:56:17 UTC

could you please try the patch from comment #1?
Comment 6 Marc Muehlfeld 2011-11-16 10:18:55 UTC
When I try the fix from comment #1, I get:

patching file source3/rpc_server/spoolss/srv_spoolss_nt.c
Hunk #1 FAILED at 3622.
1 out of 1 hunk FAILED -- saving rejects to file source3/rpc_server/spoolss/srv_spoolss_nt.c.rej

I guess it's a formating problem when I copy/paste the code (I'm not very conversant with patching).
Comment 7 Arvid Requate 2011-11-23 13:37:00 UTC
We needed to replace "auth_serversupplied_info" by "auth_session_info" to make Björns patch apply to a non-recent git snapshot.

Björns patch fixes a related problem of the smbd build from a samba4 git snapshot, where a newly created CUPS printer would be loaded into smbd with a broken "printername" of '//LOCALHOST/', i.e. missing the actual share name (empty in the outgoing spoolss_GetPrinter structure after the initial OpenPrinterEx rpc command). Maybe this is also the case in 3.6.0. Without Björns patch this happened whenever the first connect to the new printer share would be initiated by a non-privileged user logged on to a Windows client (XP or 7).
Comment 8 Andreas Schneider 2011-11-23 14:40:08 UTC
Comment on attachment 7059 [details]
proposed fix for bug 8554

This is only a partial fix. We need to fix this  in lp_add_printer(). To be more precise, there needs to be a function creating the defaults in the registry before we call lp_add_printer() or lp_add_one_printer().
Comment 9 Marc Muehlfeld 2011-11-24 15:27:58 UTC
For my tests I haven't added a new printer to my LPRng printcap. I just copied a printer section and gave it a new name. The parameter "printer name" points to an already existing printcap entry.

I applied the partial-patch to 3.6.1, added a new printer section to smb.conf and restarted the services. Nothing appears in \\server\Drucker und Faxgeräte.

Also one more information:
If I run the "rpcclient" workaround, the printer is there, but when I try to assign a driver, XP freezes for several minutes and the driver isn't applied. See the comment from my other bug:
(I don't know if it's something related with the bug I reported, or with this one here, too.)
Comment 10 Björn Baumbach 2011-12-07 12:50:56 UTC
Created attachment 7163 [details]
proposed fix for bug 8554 and 8612

Marc Muehlfeld, could you verify that this patch fix it?
Comment 11 Marc Muehlfeld 2011-12-07 14:49:47 UTC
I applied the patch. But: If I add a new printer section to smb.conf and restart the services, the new printer still don't appear. I still have to run the "rpcclient" workaround to make it visible.

- right-click to new printer / properties
- Message "no driver assigned. would you upload one?" -> no
- Go to "extended" tab and choose a driver that is already on the servers print$. -> click "ok"
- No crash/hang now. But after 20-30 seconds I get "no driver assigned. would you upload one?" again.
- The "model" column shows the name of the assigned driver now.
- right-click to the new printer again / properties
- Message "no driver assigned. would you upload one?" comes up -> no
- "extended"-tab shows the assigned driver now. but something still is wrong, because windows still thinks no driver is assigned and asks everytime for one when I go to the printers properties.
Comment 12 Marc Muehlfeld 2011-12-07 14:53:03 UTC
Created attachment 7164 [details]
Level 10 Debug Log

The attached logfile contains a level 10 debug log of the steps I described in my previous post (on 3.6.1 with your patch).
Comment 13 Marc Muehlfeld 2011-12-07 15:06:30 UTC
Problem is also there, if I assign the driver with
rpcclient -U administrator -c 'setdriver HPCP1515-9 "HP Color LaserJet CP1510 Series PS"'
Comment 14 Björn Baumbach 2011-12-16 17:10:37 UTC
Created attachment 7195 [details]
new proposed fix for bug 8554 and 8612

Okay, I think I've fixed it.
Could you try this, please?

notice: After adding a new printer to the smb.conf, we'll have to wait until the parent smbd reread the smb.conf. Then we have to wait for the printcap-cache timeout. After the timeout the printers should be available.
Comment 15 Marc Muehlfeld 2011-12-18 14:42:19 UTC
Created attachment 7203 [details]
smb.conf, level 10 debug logs and network trace

I applied your patch to the fresh 3.6.1 sources, compiled and installed it. Then I duplicated a printer entry and gave it a new name (the copy still points to the same "printer name =" value like the one I copied it from). Then I restart (not reload) smbd and nmbd.

I wait for about 5 mins and could see some "Printcap cache time expired" and "reloading printcap cache" in the smbd.log (I have the cache timeout at 60 seconds). But the printer doesn't appear in windows \\server\drucker und faxgeräte.

I run the rpcclient -c "enumprinters" workaround to make it appear.

In windows I see the printer in \\server\drucker und faxgeräte now. I right-click to it -> properties -> extended tab and assigend a driver to it. Then I click "OK" and the dialoge hangs for about 20 seconds. And after that the "Driver .. not installed on the server. ... Would you like to install a driver?" window was shown on top of the printer properties window.

Find attached my smb.conf, level 10 debug logs and a network trace of all the steps I had done.

If I can help you by providing more debug logs or network traces, please let me know, which steps I should include. Then I'll quickly provide you the required information. I meanwhile have a complete test environment (PDC, Member, XP Client) here. :-)
Comment 16 Marc Muehlfeld 2011-12-18 14:52:47 UTC
I also saw, that when I had applied your patch, and start the samba services while using my old lock-directory from 3.5.12 (like what is the situation when I upgrade from 3.5.12 to 3.6.1), none of my old existing and working printers are migrated. \\server\drucker und faxgeräte shows abolutely nothing now (until I do the rpcclient workaround).

Would it help, if I attach my 3.5.12-lock-directory or some files from there? If yes, is there anything security related (cache passwords,...), I should better not upload here, in these files?
Comment 17 Wilco Baan Hofman 2012-01-25 16:32:32 UTC
I'm hitting this as well. Confirming that the workaround works.
Comment 18 Björn Baumbach 2012-01-25 16:39:29 UTC
Sorry, didn't have the time to check the issue again.
But I'm nearly sure, that the patch fixed the issue on my machine.

Wilco, if you have some free time, could you check if the patch 7195 fix the issue?
It's important that you have to wait until the parent smbd reread the smb.conf. Then you have to wait for the printcap-cache timeout. After the timeout the printers should be available.
Comment 19 Wilco Baan Hofman 2012-01-25 18:30:55 UTC
Yes, checking the patch is on my todo list for tomorrow. Not sure if the patch 's supposed to catch renames, haven't looked at the code yet.
Comment 20 Wilco Baan Hofman 2012-01-26 12:16:05 UTC
Attachment #7195 [details] ("new proposed fix for bug 8554 and 8612") fixes it for me. Printers get added just the way I'm used to.
Comment 21 Marc Muehlfeld 2012-01-26 14:14:30 UTC
I can't confirm that the patch is working!

I retried the same steps today as I did in Comment 15 + 16. And the result is still the same. I attached debug logs and network traces in Comment 15 + 16. Maybe you can have a look at it (an on this comment).

I also tried 3.6.2 today (without the patch), which is also having the same issues.
Comment 22 Wilco Baan Hofman 2012-01-27 23:19:02 UTC
Marc, does it work for you if you reload samba?
Comment 23 Marc Muehlfeld 2012-01-30 08:15:11 UTC
I retried 3.6.1 with the patch today with a reload (instead of restart) - doesn't work also. Even 30 mins later, the new printer doesn't appear.

The affected version of the bugreport can be set to 3.6.3 (I tried that version today, too - same problem).

Could I provide more debugs or traces than in Comment 12 to help fixing this issue soon?
Comment 24 Andreas Schneider 2012-02-06 10:00:59 UTC
Marc, which distribution are you running and how did you do the reload?
Comment 25 Marc Muehlfeld 2012-02-06 10:49:11 UTC
Im running samba on Scientific Linux 6.1 (RHEL 6.1 clone like CentOS) on x86_64 architecture.

I did the reload by
# kill -HUP $(cat /var/run/samba/smbd.pid)
# kill -HUP $(cat /var/run/samba/nmbd.pid)
Comment 26 Andreas Schneider 2012-02-06 11:21:31 UTC
I have to dig into the code and check if there is a difference, but normally you do:

smbcontrol smbd reload-config
Comment 27 Andreas Schneider 2012-02-06 11:29:58 UTC
Marc: Could you please attach your smb.conf file and describe the steps you did to try to reproduce it. I would like to redo it here.
Comment 28 Marc Muehlfeld 2012-02-06 11:44:03 UTC
Created attachment 7297 [details]
Samba config files
Comment 29 Marc Muehlfeld 2012-02-06 12:00:42 UTC
I tried "smbcontrol smbd reload-config", but doesn't help (but restarting the services also doesn't work to make new added printers appear).

Here are the steps I do:

- Copy/paste an existing printersection from printer.conf (I'd splitted the configs, but I attached both) and change the copys name to a not existing one.
- Reload/restart samba processes (smbd/nmbd)
- Wait for 5 mins to be sure that the printcap-cache timeout is over (cache timeout is set in smb.conf to 60 seconds).
- All other steps: See Comment 11
Comment 30 Marc Muehlfeld 2012-02-06 12:02:02 UTC
If you want, I can provide a team viewer session to my computer, if you want to have a look in my test environment and try some things.
Comment 31 Björn Baumbach 2012-02-07 15:15:26 UTC
Created attachment 7300 [details]
fix like v2, but with additional debug message
Comment 32 Andreas Schneider 2012-02-07 15:17:52 UTC
Marc: Could you please reproduce it and provide logs, I'm not able to reproduce it here.

Providing Samba log files

Provide all log files from '/var/log/samba/' directory and the tdb files from
'/var/lib/samba' and the configuration file '/etc/samba/smb.conf'. Post the
output of 'rpm -qi samba' or 'rpm -qi samba-<subpackage>' too. We need that
information to reconstruct what happened.

If winbind for logging in is part of the problem please provide
'/etc/security/pam_winbind.conf' and if you have enabled debug in
'pam_winbind.conf' Ä/var/log/messages' is requried too.

More detailed description about different Samba components can be found blow
this section.

Testing daemons (winbind, smb, nmb)

1. Stop all running Samba processes (winbind, smb, nmb)

2. Remove all log files from /var/log/samba/

    With this approach we ensure to have the start date of the testing in the
    log files.

3. Edit /etc/samba/smb.conf and set the following variables in the in the
   [general] section of the config:

     debug level = 10
     debug pid = Yes
     max log size = 0

    Instead of setting a global debug level in smb.conf it's also visible to

     smbcontrol <damon_name> debug 10

    to increase the debug level of the Samba daemon in question to 10 at run

    If winbind is part of the scenario please set

     debug = yes

    in /etc/security/pam_winbind.conf

4. Start the processes again (winbind, smb, nmb)

5. Reproduce the error and note the time when you start any test. If a problem
   occurs while testing note the time (use date on the system you perform the
   tests on to get a time fitting to the log files).

Attach the log files from '/var/log/samba/' and the tdb files from
'/var/lib/samba/' to the bug. If possible, remove the tdb files and provide clean
files. Therefore it's best to bond them to one compressed tar archive. The
relevant parts of '/var/log/messages' could be interesting too.
Comment 33 Andreas Schneider 2012-02-07 15:18:27 UTC
With the patch from comment #31 :)
Comment 34 Marc Muehlfeld 2012-02-07 16:15:58 UTC
First of all: We are running the printing services on our PDC, not on a member. So no winbind is installed.

- I reset my environment to 3.5.12 and replaced the tdb files in the locks directory with the ones which were never used on 3.6 before (I took them from my 3.5.12 live environment). All services are stopped and the log directory ist empty.

- I compiled 3.6.3 including your patch with the configure-options you find in the file "USED-COMPILE-OPTIONS".

- I installed the patched 3.6.3 version.

- I start smbd and nmbd 

- On a XP Sp3 (vm-02) machiene I go to \\genome\Drucker und Faxgeräte. I see all my printers.

- I copy the [HPCP1515-1] section in printers.conf (an file I include in my smb.conf) to [HPCP1515-2] (everything stays the same, except the []-name

- Reload smbd and nmbd using smbcontrol (Di 7. Feb 16:48:22 CET 2012). The output I redirected to smbd.smbcontrol.log and nmbd.smbcontrol.log

- Refreshing on XP with [F5]: The new HPCP1515-2 printer isn't there.

- Waiting for 2 Minutes

- Refreshing on XP with [F5] (Di 7. Feb 16:50:27 CET 2012): The new HPCP1515-2 printer still isn't there.

- Running the rpcclient workaround (Di 7. Feb 16:51:01 CET 2012).

- Refreshing on XP with [F5] (Di 7. Feb 16:51:11 CET 2012): The new HPCP1515-2 printer is now shown.

- Right-click to the printer / properties (Di 7. Feb 16:51:42 CET 2012)

- Choose "no" on the question that no driver is installed and if I want to install one.

- Go to the "extended" tab an assign an existing driver to the printer (HP Color LaserJet CP1510 Series PS) and click OK (Di 7. Feb 16:54:37 CET 2012)

- Properties window closed automatially.

- Windows renamed the printer automatically to "HP Color LaserJet CP1510 Series PS"

- I rename it back to "HPCP1515-2" by [F2] (Di 7. Feb 16:56:03 CET 2012)

- Rightclick / properties on the new printer again. (Di 7. Feb 16:56:28 CET 2012)

- Window opens and the assigned driver is there this time. (Not like on my previous tries, where Windows tells me that there is no driver assigned like in Comment 11).

- Shutting down smbd/nmbd (Di 7. Feb 16:59:23 CET 2012)

- Copying logs and 3.6.3-lock directory to the archive for you

I uploaded the archive to: http://www.medizinische-genetik.de/samba.tar.bz2, because it is to big (12M) for attaching it to the bugreport. I'll delete the file in 1 week.

Additional Information:
- Find in the archive:
  - usr/var/locks.used_only_on_3.5.12_yet = tdb files which have only be used on 3.5.12 yet.
  - usr/var/locks is the lock directory after the above steps

- There are no samba packages installed on the system ("rpm -aq | grep samba" outputs nothing).
Comment 35 Andreas Schneider 2012-02-07 19:10:16 UTC
So you copied the first printer to 'HPCP1515-2' and didn't change the 'printer name' from 'HPCP1515-1' to 'HPCP1515-2'?

I've used your printing setting:

        load printers = no
        printing = lprng
        printcap name = /etc/printcap

and created a printers.conf file. Everytime it works just fine for me. Well the log always says 'HPCP1515-1' cause I didn't change the printer name, but the printer shows up if I simply browse to my machine \\magrathea with the Explorer here on Windows 7.
Comment 36 Andreas Schneider 2012-02-07 19:13:09 UTC
I've tested with Windows XP too.

If I go to \\magrathea\Printers and Faxes add the printer and hit reload in that Window it doesn't appear.

If I change the 'printer name' to be a different one than the printer I just copied, it works.
Comment 37 Marc Muehlfeld 2012-02-07 19:22:14 UTC
So it's an issue just on XP?

I'll try it tomorrow with a different printer name, too, when im back in the office.

I haven't changed the printer name, because I have some other printers with the same schema already (Two virtual printers on windows with different settings but with the same printer backend in lprng pointing to one physical device).
Comment 38 Marc Muehlfeld 2012-02-08 07:54:02 UTC
You are right. This bug only appears, if the 'printer name' is the same and only the [] name differs (tried only on XP. I don't have 7 here).
Comment 39 Andreas Schneider 2012-02-08 10:21:56 UTC
It looks like WinXP can't deal with duplicate printer names. I consider the initial bug as fixed.
Comment 40 Marc Muehlfeld 2012-02-08 10:34:32 UTC
We use this procedure without any problems since about 8 years on XP now.

For one printer we have several names [], but they all use the same "printer name" parameter for sending the data to the lprng backend.

We use this to provide different "virtual" printers to the users. E. g. we have
SHMX2600-1_SW with default black/white settings and SHMX2600-1_F with default color setting. Both printers have the same "printer name" parameter in samba, because it is the same device, but different names in Windows (the ones set in []).

        path = /var/spool/lpd/samba
        browseable = yes
        writeable = no
        printable = yes
        guest ok = yes
        printer name = SHMX2600-1

        path = /var/spool/lpd/samba
        browseable = yes
        writeable = no
        printable = yes
        guest ok = yes
        printer name = SHMX2600-1
Comment 41 Andreas Schneider 2012-02-08 10:41:19 UTC
Created attachment 7301 [details]
v3-6-test patch
Comment 42 Guenther Deschner 2012-02-08 10:52:59 UTC
Comment on attachment 7301 [details]
v3-6-test patch

looks good
Comment 43 Andreas Schneider 2012-02-08 10:54:31 UTC
Karolin, could you please apply the attached patch to 3.6? Thanks!
Comment 44 Andreas Schneider 2012-02-08 10:59:57 UTC
Karolin, if you close this bug you can also close bug #8612.
Comment 45 Marc Muehlfeld 2012-02-08 11:10:42 UTC
I checked the last patch. It's working. Only the described good feature, samba had for many years, got lost. :-(
Comment 46 Marc Muehlfeld 2012-02-08 11:17:47 UTC
One more comment:

If you drop this feature, then the manpage shows wrong information yet:

printer name (S)
   If specified in the [global] section, the printer name given will be used for any printable service that does not have its own printer name specified.

If you add the 'printer name' parameter in the [global] section and add a printer without that parameter, the issue is the same like I described in my situation with my virtual printers: The printer don't appear, except you run the rpcclient workaround.

According to the man page I did:

   printer name = SHMX2600-1

        path = /var/spool/lpd/samba
        browseable = yes
        writeable = no
        printable = yes
        guest ok = yes

So I still think it is a not fixed bug!
Comment 47 Andreas Schneider 2012-02-08 11:54:05 UTC
The patch attached to this bug fixes the bug described. The patch fixes this bug and several people, including you have confirmed that the registry entries are correctly created now.

If you think that there is a regression with 'printer name' between 3.5 and 3.6 then please open a *new* bug for this.
Comment 48 Andreas Schneider 2012-02-08 13:04:55 UTC
Created attachment 7303 [details]
fixed v3-6-test patch

Printers need to be added by the sname to be unique.
Comment 49 Guenther Deschner 2012-02-08 13:47:47 UTC
Comment on attachment 7303 [details]
fixed v3-6-test patch

looks good
Comment 50 Andreas Schneider 2012-02-08 16:16:17 UTC
Marc, the new updated patch should also address your problem. Even if printer names should be unique like in the spoolss spec.
Comment 51 Marc Muehlfeld 2012-02-08 16:27:25 UTC
I retried with the new patch.
I can confirm that it fixes the problem in the other two situations, too.
So you can close Bug #8748, too.

Many thanks.
Comment 52 Andreas Schneider 2012-02-09 09:39:36 UTC
Created attachment 7311 [details]
v3-6-test patch3

I've found another bug in the patch. Deleted printers were still present. Here is an updated version.
Comment 53 Marc Muehlfeld 2012-02-09 10:13:57 UTC
I checked v3-6-test patch3. Everything, including deletion, worked.
Comment 54 Andreas Schneider 2012-02-10 14:33:58 UTC
The patch doesn't work as expected. We need more changes.
Comment 55 Marc Muehlfeld 2012-03-26 13:26:22 UTC
Is there anything we can help to get this 5 month old issue fixed in the next samba version, that prevents users like us from switching to 3.6? It already seems to be half done.
Comment 56 Andreas Schneider 2012-03-30 15:44:17 UTC
We are still working on it. There are some race conditions which are hard to find. This patch triggers it more often. I don't want to make it worse for 3.6 so we need to fix this race condition first. I've worked on Thursday together with Michael on it. We found 2 bugs but not the root cause yet. Sorry for the delay.
Comment 57 Marc Muehlfeld 2012-04-01 11:15:41 UTC
Thanks for the information. I hope you'll find the remaining problems.
Just let me know if I can help by testing or providing logs.
Comment 58 Andreas Schneider 2012-04-17 13:07:42 UTC
We found quite some bugs in the registry code which will be fixed soon. After this we can push this patch.
Comment 59 Marc Muehlfeld 2012-04-17 13:26:33 UTC
Just add the patch if it's ready and a short note of the changed parts and I'll test.
Comment 60 Guenther Deschner 2012-05-09 09:21:50 UTC
Comment on attachment 7311 [details]
v3-6-test patch3

looks good
Comment 61 Andreas Schneider 2012-05-09 09:31:26 UTC
Karolin, please pick the patch for 3.6 as soon as the registry bugs are fixed.
Comment 62 Karolin Seeger 2012-05-10 13:28:30 UTC
Pushed to v3-6-test.
Closing out bug report.

Comment 63 Björn Jacke 2012-07-12 15:05:35 UTC
*** Bug 8612 has been marked as a duplicate of this bug. ***