Starting from possibly 3.0.7 Samba no longer resolves printer names successfully. Here's is the username map: !smbop = christophk zbenutzer = * The smb.conf entry: [hp43dpc] path = /tmp printable = Yes printer name = FWI-HP4300D cups options = "raw" and the rpcclient output rpcclient $> getprinter hp43dpc 2 servername:[\\127.0.0.1] printername:[\\127.0.0.1\CIP-Service D] sharename:[hp43dpc] portname:[FWI-HP4300D] drivername:[HP LaserJet 4300 PCL 6] comment:[0,05 Euro pro Seite] location:[Servicebüro] sepfile:[] printprocessor:[winprint] datatype:[RAW] parameters:[] attributes:[0x3048] priority:[0x1] defaultpriority:[0x1] starttime:[0x0] untiltime:[0x0] status:[0x0] cjobs:[0x0] averageppm:[0x0] and the log: [2005/10/11 11:03:37, 3] rpc_server/srv_spoolss_nt.c:set_printer_hnd_printertype(471) Setting printer type=\\fwi-fortuna\CIP-Service A Farbe Printer is a printer [2005/10/11 11:03:37, 4] rpc_server/srv_spoolss_nt.c:set_printer_hnd_name(507) Setting printer name=\\fwi-fortuna\CIP-Service A Farbe (len=33) searching for [CIP-Service A Farbe] [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_alloc(313) Finding user CIP-Service A Farbe [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(262) Trying _Get_Pwnam(), username as lowercase is cip-service a farbe [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(269) Trying _Get_Pwnam(), username as given is CIP-Service A Farbe [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(278) Trying _Get_Pwnam(), username as uppercase is CIP-SERVICE A FARBE [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(286) Checking combinations of 0 uppercase letters in cip-service a farbe [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(290) Get_Pwnam_internals didn't find user [CIP-Service A Farbe]! [2005/10/11 11:03:37, 4] lib/username.c:map_username(171) Scanning username map /etc/samba/usermap [2005/10/11 11:03:37, 5] lib/username.c:user_in_netgroup_list(369) Unable to get default yp domain [2005/10/11 11:03:37, 3] lib/username.c:map_username(212) Mapped user CIP-Service A Farbe to zbenutzer [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_alloc(313) Finding user zbenutzer [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(262) Trying _Get_Pwnam(), username as lowercase is zbenutzer [2005/10/11 11:03:37, 5] lib/username.c:Get_Pwnam_internals(290) Get_Pwnam_internals did find user [zbenutzer]! [2005/10/11 11:03:37, 3] smbd/service.c:find_service(151) checking for home directory zbenutzer gave [2005/10/11 11:03:37, 3] smbd/service.c:find_service(161) checking whether zbenutzer is a valid printer name... [2005/10/11 11:03:37, 3] smbd/service.c:find_service(171) zbenutzer is not a valid printer name [2005/10/11 11:03:37, 3] smbd/service.c:find_service(208) find_service() failed to find service zbenutzer ... yes i know its for a different printer, but they are all configured the same way and all dont work with >3.0.7 To me it seems that find_service called by set_printer_hnd_name doenst find a share with the printername (due to the long printername) and then looks if the servicename is a username and the share a homeshare. map_username called by find_service changes the printername to a username, and then all subsequent tries to map the long printer name to a share name in set_rpinter_hnd_name fail, because the servicename was changed.
*** Bug 3158 has been marked as a duplicate of this bug. ***
here is a UNTESTED patch, mainly to show you again what seems to be problem: --- service.c 2005-11-13 23:29:23.000000000 +0100 +++ service.c.old 2005-11-13 18:40:51.000000000 +0100 @@ -143,29 +143,14 @@ * Try mapping the servicename, it may * be a Windows to unix mapped user name. */ - /* but dont modify the servicename if mapping - * doesnt return sth. useful - * christophk@cip.wiwi.uni-karlsruhe.de 14.11.05 - */ - fstring mapped_username; - fstrcpy(mapped_username,service); - - if(map_username(mapped_username)) { - phome_dir = get_user_home_dir(mapped_username); - DEBUG(3,("checking for home directory %s gave %s\n",service, - phome_dir?phome_dir:"(NULL)")); - iService = add_home_service(mapped_username,mapped_username /* 'username' */, phome_dir); - if (iService >= 0) - fstrcpy(service, mapped_username); - } - - } else { + if(map_username(service)) + phome_dir = get_user_home_dir(service); + } - DEBUG(3,("checking for home directory %s gave %s\n",service, - phome_dir?phome_dir:"(NULL)")); + DEBUG(3,("checking for home directory %s gave %s\n",service, + phome_dir?phome_dir:"(NULL)")); - iService = add_home_service(service,service /* 'username' */, phome_dir); - } + iService = add_home_service(service,service /* 'username' */, phome_dir); } /* If we still don't have a service, attempt to add it as a printer. */ calling map_username in find_service changes the servicename. find_service is called by set_printer_hnd_name, which then can't find any printer with the changed servicename. After reading through the code, i had the impression that dynamically genereted printer shres (i.e. "load printers = yes") can't be found if using a username map, too!
Good catch. Not the patch I would do. I'll attach a fix shortly.
Created attachment 1588 [details] remove use of find_service when looking for a printername specifically
should be fixed by the attached patch. Does in my testing at least. Thanks for teh bug report.
Created attachment 1589 [details] too much in the last patch. This is only the necessary changes