The Common UNIX Printing System (CUPS) is a software providing a portable printing layer for UNIX-based operating systems. It will allow us to turn the system into a printer server and share printers with Samba; though this is not a particularly difficult task, please be sure to closely follow this procedure to successfully export the printer(s) to Samba through the cupsaddsmb(8) command.
You should already have installed CUPS as a dependency when adding the Samba package. CUPS configuration goes beyond the scope of this document, so please refer to the documentation for a detailed description of its features and options. The following configuration will refer to my own printer (a Dell 1600n Laser printer), so make sure to correctly configure your own printer(s) before proceeding to Samba configuration. The printers are defined in the /etc/cups/printers.conf(5) configuration file:
<DefaultPrinter dp1600n> Info Dell Laser Printer 1600n Location Room 123 DeviceURI ipp://prn1.lan.kernel-panic.it/ State Idle StateMessage Printer is idle Accepting Yes </Printer>
Now we have to retrieve the correct driver files. First, we need the Universal PostScript printer drivers for Windows from the Adobe website. You can download them here: select the installer for your language and install the drivers on a Windows machine. At the end of the installation, you should find the following files in the C:\WINDOWS\system32\spool\drivers\w32x86\3 folder:
Now create the /usr/local/share/cups/drivers directory on the file server:
# mkdir /usr/local/share/cups/drivers/
and copy the above files into it (warning: on the file server, driver file names must be lowercase!).
Next, we need to download the Windows CUPS drivers and extract and copy them to the drivers directory:
# tar -zxvf cups-windows-6.0-source.tar.gz [ ... ] # cd cups-windows-6.0/i386 # cp cups6.ini cupsui6.dll cupsps6.dll /usr/local/share/cups/drivers/
The last file you need to retrieve is the PPD file appropriate to your printer. Fortunately, if you can't find the file on the printer driver CD, Easy Software Products provides a huge collection of PPD files which includes support for the most common printers. Download the Linux file (portable format), extract it, look for the PPD file appopriate to your printer and copy it to /etc/cups/ppd/; for example:
# tar -zxvf printpro-4.5.12-linux-intel.tar.gz [ ... ] # tar -zxvf printpro-dell.ss [ ... ] # gunzip -o /etc/cups/ppd/dp1600n.ppd usr/share/cups/model/en/dp1600n.ppd.gz
Please note that the PPD file has exactly the same name ("dp1600n") as the printer defined in /etc/cups/printers.conf(5) (plus the ".ppd" extension). If the two names differ, you may encounter problems when running the cupsaddsmb(8) command later.
Now we can proceed to update Samba configuration by adding a few options to the [global] section and by defining a couple of additional sections:
[global] [ ... ] load printers = yes printing = cups printcap name = cups show add printer wizard = Yes use client driver = No [dp1600n] comment = Dell Laser MFP 1600n # Users must have write access to the spool directory valid users = root @DomainUsers path = /var/spool/samba/printing printer = dp1600n public = no writable = no printable = yes [print$] comment = Printer Drivers path = /etc/samba/drivers browseable = no guest ok = no read only = yes write list = root
The spool directory must be writeable by the users authorized to print and have the sticky-bit set; for example:
# chgrp 513 /var/spool/samba/printing # chmod 1770 /var/spool/samba/printing
Now we can start the cupsd(8) daemon and reload Samba configuration:
# /usr/local/sbin/cupsd # pkill -HUP smbd
Well, so we're finally ready to issue the cupsaddsmb(8) command, which will actually export printers to samba:
# mkdir /etc/samba/drivers # cupsaddsmb -H localhost -U root -v -a [ ... ] Printer Driver dp1600n successfully installed. [ ... ] Succesfully set dp1600n to driver dp1600n. #
If everything went fine, now you should find the PostScript drivers and the PPD file(s) in the fresh new /etc/samba/drivers/W32X86/3 directory:
# ls -l /etc/samba/drivers/W32X86/3/ total 2884 -rwxr--r-- 1 root wheel 25729 Feb 28 01:55 dp1600n.ppd -rwxr--r-- 1 root wheel 129024 Feb 28 01:49 ps5ui.dll -rwxr--r-- 1 root wheel 26038 Feb 28 01:55 pscript.hlp -rwxr--r-- 1 root wheel 792644 Feb 28 01:55 pscript.ntf -rwxr--r-- 1 root wheel 455168 Feb 28 01:49 pscript5.dll #
The last step is configuring the system to run cupsd(8) on boot, by adding the following lines to the /etc/rc.local file, before the start of Samba:
if [ -x /usr/local/sbin/cupsd ]; then echo -n ' cupsd' /usr/local/sbin/cupsd fi