Printing with Samba

Some builds of Puppy do not have the 'smbspool' utility (type "which smbspool" in a terminal to find out). There is a special CUPS driver script named 'smbw' which in turn uses the 'smbclient' utility to print. This is a valuable contribution from rcrsn51.

PART 1: smbspool drop-in replacement

The device URI (Uniform Resource Identifier) format for smbspool is defined as:

smb://[username[:password]@][workgroup/]server[:port]/printer

Please take note of the compulsory minimum in bold: smb:// [username[:password]@] [workgroup/] server [:port] /printer

Examples:

  1. smb://PRINTSERVER/HP4V (minimum parameter smb://server/printer)
  2. smb://192.168.1.2/ML1200 (same as #1 but using IP address)
  3. smb://zigbert:ladiesman217@/192.168.2.22:9191/MP250 (extended parameters with username, password and server port)
  4. smb://dogbert:majesty@SYHDP/DILBERT/LEDCOPIER (extended parameters with username, password and domain name)

Features:

  • Fully supports smb URI format. This allows the authentication details to be embedded within the URI.
  • Allows printing to multiple authenticated servers without mucking with separate authentication files.
  • Supports print copies option, if required.
  • Supports smbclient from both samba and samba-tng.

PART 2: Getting CUPS to work with Windows print servers

Extract from: http://willem.engen.nl/projects/cupssmb/
by Willem van Engen

CUPS uses smbspool(8) to print pages to windows servers. This did not appear to work, whereas printing with smbclient(1) did (some relief). Wanting to get it working, I created a custom CUPS backend that uses the latter instead of the former. This also allowed me to solve the problem of the windows password being visible in the device uri (which is shown in the web interface). Note that this still is a work in progress: it is being used with success, but now and then I encounter issues. This page will be updated accordingly.

Following are sections for using the aforementioned programs. The final section gives a possible solution for using windows print servers with CUPS when smbspool(8) isn't working.

Printing with smbspool

A CUPS backend(7) is a program, usually located in /usr/lib/cups/backend/, that sends a job to a printer or print server. CUPS uses smbspool(8), which is part of samba, to spool jobs to windows servers. To this end, there is a symbolic link from /usr/lib/cups/backend/smb to /usr/bin/smbspool.

To test the backend, it is possible to invoke smbspool(8) by hand. For example: DEVICE_URI="smb://server/printer" smbspool 1234 me sometitle 1 <test.ps

Printing with smbclient

It is also possible to use smbclient(1) to print. When logging into a printer share on a windows server, one can issue the print command to print a file. For example:

smbclient -W Domain -U me //server/printer
Added interface ip=xxx.xxx.xxx.xxx bcast=xxx.xxx.xxx.xxx nmask=xxx.xxx.xxx.xxx
Password: password
Domain=[Domain] OS=[Windows Server 2003 3790 Service Pack 2] Server=[Windows Server 2003 5.2]
smb: \> print test.ps
printing file test.ps as test.ps
xxxxx bytes printed

smb: \> quit

A CUPS backend using smbclient

When smbspool(8) doesn't work, it may be possible to get printing working with smbclient(1).

You should still create the file /etc/samba/printing.auth containing your windows credentials, like this:

  • username = s123456
  • password = mypassword
  • domain = TUE
To protect it from prying eyes, make it owned by user cupsys (or whatever CUPS backends are run by on your system) and make it readable for that user only. For Ubuntu users: this user is cupsys on Feisty, but lp on Gutsy.

Remains to setup CUPS. I recommend to add a printer using the web interface with a device uri with protocol smbw, like smbw://physfp.phys.tue.nl/n-IS2060PS

If you happen to use AppArmor in enforcing mode, you'll need to add #include <abstractions/samba> to the cupsd profile.