Linux Setup Notes

name and address
created oct 07, 2009; updated nov 3, 2010

Windows Printing problems

This page describes common problems printing from Windows using Samba. We also describe common Windows printing problems and their solutions.

Windows users unable to print in Samba: Invalid handle

An apparent bug in some recent versions of Samba prevents printing from Windows clients. This pertains to Samba version 3.2.0rc1-22.1-1795-SUSE-SL11.0, which is the default in Suse 11, on an x86_64 (64-bit) system.

  1. Printing gets an hourglass and a box saying "Printing Document on the \\amnesia\cp4005 on \\amnesia\cp4005" (or whatever the printer is called). If the user clicks Cancel, Windows sometimes hangs, the screen turns blue, which means the desktop has crashed, and the user must power-cycle to recover. (This is not a bluescreen, just a blank desktop.) Otherwise, after several minutes, a message pops up saying "Could not start print job".
  2. The following error messages turn up in the Samba logs:
    [2009/10/07 10:03:19, 2] rpc_server/srv_spoolss_nt.c:find_printer_index_by_hnd(261) find_printer_index_by_hnd: Printer handle not found: _spoolss_abortprinter: Invalid handle (OTHER:15153:15205)

    [2009/10/07 10:04:21, 2] rpc_server/srv_spoolss_nt.c:find_printer_index_by_hnd(261) find_printer_index_by_hnd: Printer handle not found: find_printer_index_by_hnd: Printer handle not found: close_printer_handle: Invalid handle (OTHER:15153:15205)
    In the samba source code, this error message means that the printer name became null for some reason. This is similar to the errors that occur when a Windows client tries to print to a Samba share printer that is listed in smb.conf but no longer exists.
  3. No other error messages in /var/log/messages or anywhere else.
  4. Deleting and re-installing the printer in Windows, or changing the driver in Windows from PostScript to PCL6 does not help.
  5. Changing properties in Windows (e.g., Share this printer) has no effect.
  6. Both Windows and the server can print directly to the printer with no errors.

Changing to the latest version (3.4.2 at the time of this writing) did not work; nmbd failed to start, giving the following error:
/usr/sbin/nmbd: symbol lookup error: /usr/sbin/nmbd: undefined symbol: _talloc_get_type_abort
This is caused by Samba linking to the wrong library during compilation. Samba installs its own libtalloc library in /usr/lib, but the binary links to /usr/lib64/ It might be possible to circumvent this by setting environment variables, but I did not try this.

Changing to version 3.0.27a solved the problem. This is tricky because smbpasswd, log.smb, and smb.conf are all in different locations in various versions of samba. You need to run strings against the daemon binary to find the location of smbpasswd and smb.conf, and make the appropriate soft links to make sure the smbd that's running is using the correct files (don't rely on /etc/init.d/smb to do this, because you never know when you may have to bypass it). Run updatedb (from the findutils package) and locate log.smbd to find all the locations of the log files, which can be in up to three different places. Then monitor whichever log is most recent.

ps ax | grep smbd
17835 ?        Ss     0:00 /usr/sbin/smbd -D -s /etc/samba/smb.conf
strings  /usr/sbin/smbd  | grep smb.conf
strings  /usr/sbin/smbd  | grep smbpasswd

It is also necessary to type killall smbd and killall nmbd if any users currently have an open connection; typing smb restart in /etc/rc.d is not sufficient.

Changing to an earlier version is obviously not a good solution, but if you're behind an adequate firewall it should be relatively safe. Finding an alternative to samba will be difficult, as there are few good non-commercial alternatives at the moment.

Update (Nov 3, 2010)

We found that a misconfiguration or virus on one of the Windows clients can also cause a similar problem. One computer on our network suddenly started trying to make hundreds of connections to a non-existent printer. The Samba logs contained thousands of lines like this:

[2010/11/03 14:21:42, 2] lib/access.c:check_access(323)
  Allowed connection from  (
[2010/11/03 14:21:42, 2] rpc_server/srv_spoolss_nt.c:find_printer_index_by_hnd(259)
  find_printer_index_by_hnd: Printer handle not found: find_printer_index_by_hnd: 
Printer handle not found: close_printer_handle: Invalid handle (OURS:28815:28815)

This caused printing for other users to become extremely slow. We are investigating whether the Windows computer has a virus or what.

Samba Crashing

Update (6/25/2010) The latest Samba version 3.5.4 crashes (panics) at startup on our i86_64 machine, giving an "internal error" along with a core dump. This doesn't happen on 32-bit systems. This appears to be the long-standing libtalloc problem that has still not been fixed. Samba compiles a version 2 of the library, but links to version 1. Suggested fixes included installing libwbclient, recompiling with --disable-shared-libs, and compiling without the --prefix=user option. None of these had any effect.

Here is the relevant section of the log file. It shows that the crash occurs when smbd calls the function talloc_free().

[2010/06/28 15:25:47.878364,  2] lib/interface.c:478(interpret_interface)
  interpret_interface: Adding interface
[2010/06/28 15:25:47.880699,  0] lib/fault.c:46(fault_report)
[2010/06/28 15:25:47.880736,  0] lib/fault.c:47(fault_report)
  INTERNAL ERROR: Signal 6 in pid 10241 (3.5.4)
  Please read the Trouble-Shooting section of the Samba3-HOWTO
[2010/06/28 15:25:47.880760,  0] lib/fault.c:49(fault_report)
[2010/06/28 15:25:47.880803,  0] lib/fault.c:50(fault_report)
[2010/06/28 15:25:47.880820,  0] lib/util.c:1465(smb_panic)
  PANIC (pid 10241): internal error
[2010/06/28 16:32:46.321125,  0] lib/util.c:1569(log_stack_trace)
  BACKTRACE: 19 stack frames:
   #0 /usr/sbin/smbd(log_stack_trace+0x1c) [0x7f69154b7365]
   #1 /usr/sbin/smbd(smb_panic+0x55) [0x7f69154b7467]
   #2 /usr/sbin/smbd [0x7f69154a7f81]
   #3 /lib64/ [0x7f6912800660]
   #4 /lib64/ [0x7f69128005c5]
   #5 /lib64/ [0x7f6912801bb3]
   #6 /usr/lib64/ [0x7f6910ecfba2]
   #7 /usr/lib64/ [0x7f6910ed3b4d]

Solution: Download and install an older libtalloc package (called libtalloc1-3.2.4-devel in Suse). In Suse, this can be done using yast2, which installs a number of files and libraries, including libsmbclient, libtalloc, and several others. One of these critical files is either missing from the samba-3.5.4 tar.gz or not installed by the scripts, causing smbd to crash. Unfortunately it is not clear which file is the culprit.

Another gotcha is that the password database format has changed. The users' passwords are now stored in tdb format (/usr/local/samba/private/passdb.tdb) and must be converted from smbpasswd format before any users can log in. According to the manual, the only way to do this is by specifying encrypt passwords=no or by having all your users re-enter their passwords so they're encrypted in the new format. Fun!

... Oh yes, the log files are now located in /usr/local/samba/var. But that should not be a problem, because Samba administrators are used to finding the logfiles in a different place with each new version of Samba anyway.

Other Windows Printing Problems:

Problem: Error from GetPrinter:122
Solution: This message is spurious and users can still print. It is not a Samba or Windows problem, but is caused by third-party software, such as Lexmark or Dell Network Printer Support. The important message here is the title bar, not the error message itself. (The error message is a Windows message, and doesn't appear in the Samba source code.) In our case, the title bar said Lexmark NetPnP Shell Extensions. Uninstalling Lexmark Network Support from "Add or Remove Programs" in the Control Panel of the Windows computer eliminates the error message, and also changes the status message under each printer from "Access Denied" to "Ready". (Do not uninstall the printer driver.)

Problem: Access Denied, Unable to Connect
Solution: This message is also spurious and users can still print. Uninstalling the network support portion of the third-party network printing software changes the status message under each printer from "Unable to connect" to "Ready". However, when you click on the printer icon, the menu bar still says "Access denied, unable to connect."

Adding the line "use client driver = yes" to smb.conf makes the phony error message go away.

Problem: no errors but nothing coming from printer

  1. Remove the "filter" line from /etc/printcap entry if present
  2. Set smb.conf global section to contain the line print command = /usr/bin/lpr -h -r -P%p %s
  3. chmod a+rwx /var/spool/lpd
    chmod a+rwx /var/spool/lpd/*
  4. Re-start samba and lpd

Problem: Windows printing is slow
Solution: This is almost always one of three problems: a DNS failure, Windows searching the network for printers that don't exist, or third-party security software like McAfee.

  1. If there is a fixed time delay (such as 5 minutes) before printing, it is most likely a DNS problem. Make sure your DHCP server is giving the Windows users the IP of a valid name server.
  2. If the Print dialog box takes a long time, the most likely cause is that Windows is searching for printers that no longer exist. I once removed several defunct printers from Samba's smb.conf, and within hours I was bombarded with complaints about printing being slow. The symptom is that the print dialog box hangs for a couple of minutes. The users needed to delete any unused printer or fax icons. Windows is also a lot slower if the subnet mask is too big, e.g. on a 10.x.x.x network, because it has to scan a great many addresses to find a particular computer. In this case, searching the "Network Neighborhood" takes a very long time.
  3. Antivirus or firewall software like McAfee can also cause the same problem. This software might be fighting with Windows Firewall or checking the system for viruses when you try to print, It's not clear what it's doing, but disabling McAfee often makes printer and network delay problems go away.
  4. Another factor reported by someone else is the 15-second printing delay that Microsoft added sometime in 2002. This can be changed in Regedit by going to HKLM-System-CurrentControlSet-Control-WOW and changing LPT_timeout to a smaller number. Normally, there should only be a delay of 3-4 seconds when printing through Samba, assuming the printer is already warmed up. In my experience, this change usually makes things only slightly faster or else has no effect.

    If your Windows users do not have a DHCP server, they should always activate NetBios over TCP to avoid delays in searching for the names of other Windows computers.
  5. Another trick has been reported by others is to trick Vista into thinking you have a local printer. Go to Control Panel, choose printer, Add Printer. Choose Add a local printer. In the drop down box, select Local Port. Click Next. A dialog box will appear asking for you to enter a port name. Type in the Windows address (\\myservername\cp4005) or whatever. If you already have a printer using that Windows address, you will have to delete it first. This trick works by stopping Windows from searching on the network when you open the print dialog.
  6. Reset the word data key in the Windows registry as shown here: