System Software Installation Notes

CUPS Networked Printer Setup

The Common Unix Printing System (CUPS) can be installed or in many cases comes preinstalled on Unix/Linux systems. It provides printer support that is much better than the traditional Unix BSD printer support, with drivers for many printers, the ability to print everything as postscript (through automatic conversion), and Web-based configuration and adminstration of the printers. As Ina would say, "What's not to like?"

Additionally, CUPS can access networked printers that are shared through network print servers (such as Lantronix or Netprint) and can make any of its printers available to Windows/SMB clients via Samba shares. These notes describe how we set up CUPS to access networked printers and how we go about sharing them to Windows. Printers may also be locally attached to the CUPS server and shared in a similar manner via Samba.

Configuring Networked Printers

Once you've either installed and configured CUPS, or configured the pre-installed version of CUPS that came with your OS, launch the CUPS UI via your Web browser. The first time around, you will need to do this directly from a Web browser on the machine where CUPS is installed, and use the hostname localhost:

http://localhost:631

When you have the UI up and running, you can allow other machines to remotely administer CUPS by clicking the Administration tab and checking the "Allow remote administration" check box. Otherwise, you will always have to administer CUPS from localhost.

All of the administration functions, such as adding printers, are carried out from the Administration page so begin by picking the "Administration" tab.

The next step is to tell CUPS about your printers so that it can manage printing on them. The best way to show how this is done is to proceed with a few examples. In our first example, we'll add a networked postscript printer that is connected to the network via a print server that uses the LPD protocol. We'll begin by clicking the "Add Printer" button and then filling in the form that follows.

On earlier versions of CUPS, the printer information was filled out first and then the device type and connection information was supplied. The latest versions of CUPS (e.g. 6.x and 7.x) do it the other way around so we start by picking the device type. Since we wish to set up the printer on a print server that uses the LPD protocol to print Postscript jobs, we'll proceed as follows:

Other Network Printers: LPD/LPR Host or Printer from dropdown list

After selecting "LPD/LPR Host or Printer" and clicking the "Continue" button:

Connection: lpd://kinkos/Laser Note: this example is for a Lantronix EPS-2 which has a queue called "Laser" on Port_2. You get the IP number and queue name from the server's setup but you should always use the prefix "lpd://".

After clicking the "Continue" button a second time on later versions of CUPS or immediately after adding the new printer on earlier versions, we fill out the form with the printer's information:

Printer Name: Laser

Location: Office

Description: NEC Silentwriter 95 LASER printer

Sharing: Share this printer Note: if this option is available, you'll probably want to check it so that CUPS can share the printer via SMB.

On earlier versions of CUPS, we now click "Continue" and then pick the device type as follows:

Device: LPD/LPR server from dropdown list

URI: lpd://kinkos/Laser Note: this example is for a Lantronix EPS-2 which has a queue called "Laser" on Port_2. You get the IP number and queue name from the server's setup but you should always use the prefix "lpd://".

Make: Postscript

Model: Generic postscript printer

After all of the information is filled in, one way or another, click "Continue" to set up the printer.

In our second example, we'll set up a line printer that uses the Raw protocol to print ASCII text, without modification (e.g. Genicom, DataProducts). We'll begin by clicking the "Add Printer" button and then filling in the relevant data, as described in the first example:

Printer Name: Line Printer

Location: Data Processing

Description: DataProducts high speed line printer

Device: AppSocet/JetDirect from dropdown list

URI: socket://10.100.0.20:10001/PORT1 Note: this example is for a NetPrint 500/100 which uses port 10001 (by default) and has a queue name of PORT1 (by default) You get the IP number, port number and queue name from the server's setup but you should always use the prefix "socket://".

Make: Raw

Model: Raw queue

For each printer, you may want to test its printing capabilities after it is set up, by clicking the "Printers" tab and then clicking its "Print Test Page" button or selecting "Print Test Page" from the dropdown list (as appropriate for your version of CUPS).

Once you have set up all your printers, you should select one of them as the default, by clicking the "Printers" tab and then clicking the "Set As Default" button or selecting "Set As Server Default" from the dropdown list for the printer that you wish to be the default. You can test the default print setting by using the lpr command from the command prompt to print a small text file:

lpr conf/cupsd.conf

By the way, if the print job doesn't immediately appear on the printer but is queued instead, you might want to go to the Web UI and, under the "Printers" tab, click "Resume Printer" or selct "Resume Printer" from the dropdown list. For some reason, CUPS seems to want to gratuitously pause printers on its own.

CUPS Under Samba

Samba can be used to make all of the printers, that are configured under CUPS, available to Windows/SMB clients. If the printer is a postscript printer, it simply needs to be shared by Samba, at which point it can be easily utilized by any Windows/SMB clients using the regular driver for that printer.

If your printer requires some kind of special driver (e.g. one of those cheap ink-dispensers, ooops, we meant inkjet printers, like the Canon printers), you will need to set up a generic postscript driver that can be used by any printer client to create the output that is to be spooled to CUPS. Once that is done and the printer is defined under Samba, it can be likewise utilized by any Windows/SMB client that wishes to use it.

Postscript Printers

If it wasn't obvious from the above preamble, most of the printer setup involves dealing with the device drivers needed to produce postscript output that can be printed by CUPS. In the old days, we used to begin this little odyssey by getting the generic CUPS postscript drivers from the CUPS Web site (under the "Download" tab, you'd see the "Windows Driver" downloads, which include the "cups-windows-6.0" tarball). Although it wss billed as source, the tarball also included precompiled DLLs. Once you'd downloaded it, you could untar the files and extract the CUPS postscript drivers:

tar -xvzf cups-windows-6.0-source.tar.gz

Since the Fruit Company has taken over development of CUPS, the "Windows Driver" downloads have disappeared. We leave speculation as to why this is to you conspiracy theorists and the lawyers in the Justice Department Antitrust Division. Suffice to say, "They're gone baby."

Fortunately, there are still copies of the drivers available on the Web, including our copy right here: cups-windows-drivers-6.0.tar.gz.

Once you'd downloaded our drivers file, you can untar the drivers themselves like this:

tar -xvzf cups-windows-drivers-6.0.tar.gz

Incidentally, if you download our drivers file, you'll also get the patches to the cups6.ppd files that change the driver name to something a little better suited to general use and make them work on 64-bit machines.

An alternative to downloading our CUPS drivers file is: http://www.helixstorm.com/sambacifsadcupsx86x64-windows-drivers/. If you choose to download this file, you'll also get the appropriate Windows postscript drivers (so you can skip the "get them from Windows" steps below) but you might still want to get our drivers file and substitute the cups6.ppd files therein.

Create a drivers directory (under your CUPS install directory — note that this is a different directory than the "driver" directory that is found in the CUPS library path) for the driver files and copy them into it:

cd cups-windows-drivers-6.0 or cups-windows-6.0
su
mkdir /usr/share/cups/drivers
cp i386/* /usr/share/cups/drivers
mkdir /usr/share/cups/drivers/x64
cp x64/* /usr/share/cups/drivers/x64

Now, the CUPS postscript drivers also depend on the Windows postscript drivers and the cupsaddsmb command on some versions of CUPS has a bug in it whereby it loops endlessly if the Windows postscript drivers cannot be found. To get them, you must go to a version of Windows 2000, XP, 2003 Server, Vista, 2008 Server or 7 and copy the required files. If you are using Samba, this should be a snap for the 32-bit drivers. The directory to look in is:

C:\WINNT\system32\spool\drivers\w32x86\3 for Windows 2000
C:\WINDOWS\system32\spool\drivers\w32x86\3 for Windows XP
C:\WINDOWS\system32\spool\drivers\w32x86\3 for 32-bit Windows Vista

Under Windows 7, the 64-bit postscript drivers are locked up in a cabinet file and need to be extracted before they can be used. To extract them, you need to actually be on the Windows 7 machine where you do the following:

Launch a command window with "Run as administrator" checked. You should be able to do this by right clicking on the "Command Window" icon in the "Start" menu or from the "All Programs" menu. When the dropdown list pops up, you'll set the adminstrator choice there.

expand C:\Windows\System32\spool\drivers\x64\PCC\ntprint.inf* -f:* destdir

Copy the extracted drivers from destdir.

Windows 2003 Server or 2008 Server are left as an exercise to the reader (you're supposed to be a sysadmin, aren't you?) but they should be pretty similar to Windows XP or 7.

The four files that you want for both 32-bit and 64-bit are:

ps5ui.dll
pscript.hlp
pscript.ntf
pscript5.dll

Also, the same buggy cupsaddsmb wants to use lowercase names for these drivers but some of the files may have uppercase names. Windoze doesn't care but Unix/Linux sure does. So, lowercase all the names before proceeding, if necessary.

Once you have these four (or eight, if you also went for the 64-bit) files with lowercase names, copy them to the drivers directory that you created above:

su
cd WindowsPSDrivers/i386
cp ps5ui.dll pscript.hlp pscript.ntf pscript5.dll /usr/share/cups/drivers
cd WindowsPSDrivers/x64
cp ps5ui.dll pscript.hlp pscript.ntf pscript5.dll /usr/share/cups/drivers/x64
chmod u-x /usr/share/cups/drivers/*
chmod u-x /usr/share/cups/drivers/x64/*

Add the printers definition information to the Samba config file. You'll have to figure out where to actually put the information but it should look something like this:

[global]   load printers = yes   ; cups options = raw   printing = cups   printcap name = /etc/printcap

[printers]   comment = All Printers   path = /var/spool/samba   browseable = no   public = yes   guest ok = yes   writable = no   printable = yes   printer admin = root

[print$]   comment = Printer Drivers   path = /etc/samba/drivers   browseable = yes   guest ok = no   read only = yes   write list = root

Be sure to check that the "cups options = raw" parameter is not present in the global options section of the config file or, if it is, it is commented out. Some of the later default Samba config files have this parameter set.

If the installed version of Samba, on your system, wasn't compiled against a version of libcups.so that will enumerate the printers for it, or if you didn't compile Samba against such a version of libcups.so (this could happen if CUPS wasn't installed on your system when you built Samba, for example), the supposedly-preferred "printcap name = cups" thing won't work. However, since CUPS exports all of its printer definitions to printcap automagically, you should be able to use "printcap name = /etc/printcap". In this case, be sure that the cupsd.conf configuration file has these two directives set:

Printcap /etc/printcap
PrintcapFormat BSD

Also, there's a bug in some versions of Samba that causes printers not to be handled properly if the permissions of the user looking at the printer are not those of the printer administrator. The upshot of this is that the printer will appear to Winduhs as "permission denied", although the user will be able to print to the printer. Unfortunately, this precludes the user from setting up the printer, since Windoze will not proceed past the first step, once the printer is selected. The kludge is to add all of the users who will be setting up a printer to the following line for the "[printers]" or individual printer definiton:

printer admin = root, user1, user2, ...

Once the printer has been set up, the user names can be removed from the list. The users will get the annoying "permission denied" message but will still be able to print.

Be aware that, under versions of Samba from 3.x and above, "printer admin" is deprecated and probably should be left out of the configuration file (allthough we've been leaving it in with no adverse consequences so far). If the above problem still exists in your version of Samba 3.x, the following "[global]" option is reported to fix things:

use client driver = Yes

Finally, run the cupsaddsmb command to export the postscript printer drivers and the printer PPDs for all of the installed printers to Samba:

su
mkdir /etc/samba/drivers
/usr/sbin/cupsaddsmb -H localhost -U root -a -v

Or, if you prefer, you can run this cupsaddsmb command to export the postscript printer drivers and the printer PPD for an individual printer:

su
mkdir /etc/samba/drivers
/usr/sbin/cupsaddsmb -H localhost -U root -v Photo

Note that you must supply the name of the Samba server (despite what the man page for cubsaddsmb says) or the command seems to fail. Also, you will be prompted for the root password under Samba (this may be different than your system's root password). Don't even think of running this command without the "-v" option. Under some Samba versions, it is so buggy and it loops endlessly if there's any error from Samba, that you'll want to see exactly what is going on.

Even more fun is that, under some versions of Samba, this command bombs out while doing rpcclient. We suspect it is a problem with rpcclient, whereby it does not properly handle logins using a username file, supplied via the "-A" option in the cupsaddsmb code. Anyway, if cubsaddsmb gets an NT_STATUS_LOGON_FAILURE while trying to run rpcclient to register the newly-added driver (and loops endlessly), you can run the rpcclient command yourself. Simply cut and paste the failed command from the error message and run it directly, after removing the "-N" and "-A" options and substituting "-U root". It should look something like:

rpcclient localhost -U root -c 'adddriver "Windows NT x86" \   "Photo:pscript5.dll:Photo.ppd:ps5ui.dll:pscript.hlp:NULL:RAW:\   pscript5.dll,Photo.ppd,ps5ui.dll,pscript.hlp,pscript.ntf,\   cups6.ini,cupsps6.dll,cupsui6.dll"'

Then, you will need to manually connect the driver to the printer by running the setdriver command, which will look something like this:

rpcclient localhost -U root -c 'setdriver Photo Photo'

In the setdriver command, the first name is the printer name and the second is the driver name (as registered by adddriver). In this example they are both the same but they can be different, if you want.

You can verify that the drivers are installed correctly and that they are associated with the printer by doing something like this:

rpcclient localhost -U root -c 'enumdrivers 3'
rpcclient localhost -U root -c 'getprinter Photo 2'

Note that on at least one version of Samba, the enumdrivers command segfaulted but the driver was still installed correctly. The ultimate test is if the getprinter command shows the driver listed under "drivername:". You may also be able to see what's going on with the drivers by trying enumdrivers at a less detailed level. For example:

rpcclient localhost -U root -c 'enumdrivers 2'

For a more comprehensive description of how this works, you can surf over to this URL:

http://www.linuxtopia.org/online_books/network_administration_guides/
  samba_reference_guide/29_CUPS-printing_105.html

To utilize the printer from Windows 2000, XP, 2003 Server, 2008 Server or 7, follow the SMB Print Server Setup instructions in the Accessing a Print Server notes. These notes show all of the steps that must be taken to get the shared printer working from the Windows client side.

Meanwhile, if you find all of the tap dancing described above, needed to use the proper driver for your particular printer, not to your liking, and you just want simple, straightforward postscript printing, you can define your printer something like this in your Samba configuration file:

[Laser]   printable = yes   print command = /usr/bin/lpr -P%p -r %s   printer = Laser   printing = BSD   path = /var/tmp   browseable = no   public = yes   writable = no   printable = yes   printer admin = root

Note that you may have to figure out the appropriate print command for printing on your system. The example above uses one of the Berkeley lpr-type commands to print on the default printer. The Samba docs are helpful.

If the printer requires any kind of driver, you will have to either install it on each client machine that uses the printer or mark the printer as a raw device on each client. Simple printing of straight text files should work but getting printing of any kind of postscript documents working may be more fun than it is worth. CUPS will probably try to monkey with the output, since it thinks it knows how the device should work, based on its installation on the CUPS server, and it may even double convert the document to postscript/postscript. Setting up a separate raw printer on the CUPS server, which will just spool the output formatted by the drivers on the client systems, without modification, straight to the printer, may prove the best method.

Once the printer is set up how you like it, add the printer (as described in the SMB Print Server Setup instructions in the Accessing a Print Server notes). If your printer requires postscript, pick a standard driver file from the list of already-supported drivers for any postscript printer such as the HP LaserJet 5P/5MP PostScript printer. All postscript printers use the same Microsoft postscript engine so anything that you choose should work.

Raw Printers

If you have a printer that is a total pain in the butt (like the Canon BubbleJet series printers), but you none-the-less have a non-postscript Windows driver for it, you can set up a RAW printer queue under CUPS and use it to send output to the printer. To do this, make the following choices when setting up the printer:

Make: Raw

Model: Raw queue

Then, on Windows, install the printer as described in the SMB Print Server Setup instructions in the Accessing a Print Server notes but, when it comes time to install the drivers, pick the proper driver from the list of standard drivers or install the one supplied by the manufacturer. You should be able to print to the printer but all bets are off as to whether CUPS will correctly handle the interaction between the two printer queues, if simultaneous print requests from the Unix/Linix side and the Winddoze side are received at once.