CUPS is an unusually flexible printing system for UNIX and Linux computers. Rather than a re-implementation of the BSD LPD package (which is what LPRng is), CUPS is a new framework around which printing on Linux can work. Part of this framework is a compatibility layer, so that applications and users can use familiar printing commands, and so that CUPS clients can use LPD print servers, and vice versa. Major additional features include support for a new network printing protocol, IPP, which is based on the Hypertext Transfer Protocol (HTTP) used by Web servers and browsers; the ability to pass file type information with files to simplify the selection of print filters on the print server; the use of PostScript Printer Description (PPD) files to define printer capabilities; and "printer browsing," a feature that allows a client to search for printers on the network without having to explicitly configure the client to use a specific printer. If CUPS is widely adopted, these features will greatly simplify printer configuration, both for non-networked and networked use. One major hurdle faced by CUPS is the fact that it doesn't use the same types of configuration files that BSD LPD or LPRng use. Therefore, if you're already familiar with these systems, you'll have to learn to configure your printers in an entirely new way. If you like to work with GUI tools, you may want to look into a GUI front-end to CUPS for general configuration, such as KUPS (http://cups. sourceforge .net/kups/) or ESP Print Pro (http://www.easysw.com/printpro/). CUPS also comes with a Web-based tool, as described shortly; you can point your Web browser at http://localhost:631 to configure the computer on which the Web browser is running. NOTE
Configuring /etc/cups/cupsd.confThe CUPS server is controlled through the /etc/cups/cupsd.conf file. This file is modeled after the Apache configuration file (discussed in Chapter 20, Running Web Servers), as CUPS borrows many HTTP server features. CUPS also uses several other configuration files, such as /etc/cups/printers.conf and /etc/cups/classes.conf , which define specific printers and groups of printers, respectively. Both these files are normally edited via the lpadmin configuration tool or a GUI front-end, but the CUPS documentation recommends editing cupsd.conf manually. The cupsd.conf file consists of a series of directives that set specific features of the server's function, such as the server's name or where logs are stored. Directives that are particularly important for network print server functions include the following:
The default /etc/cups/cupsd.conf file provided with most CUPS packages leaves the server fairly open to access from outsiders. You should probably tighten access by applying CUPS configuration rules to restrict access to the server. For instance, the following directives block access to anything but the server computer itself and systems on the 172.22.0.0/16 network: <Location /printers> BrowseAllow from 127.0.0.1 BrowseAllow from 172.22.0.0/16 Allow from 127.0.0.1 Allow from 172.22.0.0/16 </Location> Because it applies to the /printers location, the preceding example does not completely close off access to the server. For instance, administrative tasks (via the /admin location) and access to specific print job information (via the /jobs location) is still available to other systems. You should probably restrict access to these locations as well, and apply packet filter firewall rules (as discussed in Chapter 25). The latter will completely block access to systems you don't authorize, assuming no bugs or misconfiguration. Accepting Jobs from BSD LPD or LPRng ClientsThe preceding discussion of /etc/cups/cupsd.conf directives applies most directly to clients that support IPP. Neither BSD LPD nor LPRng uses IPP, though; they use the older LPD protocol. (Work is underway for adding IPP support to LPRng, though.) Therefore, if your CUPS print server must accept print jobs from clients that use the LPD protocol, CUPS needs a helper program to let it do the job. This program is called cups-lpd , and it comes with CUPS. To use cups-lpd , you must configure it to work via a super server such as inetd or xinetd , as discussed in Chapter 4; the package doesn't work as a standalone server. It's normally located in the /usr/lib/cups/daemon directory. An appropriate /etc/inetd.conf file entry is as follows : printer stream tcp nowait lp /usr/lib/cups/daemon/cups-lpd cups-lpd Chapter 4 covers the differences between inetd and xinetd , should you need to configure cups-lpd to work with xinetd . Some distributions ship preconfigured to work correctly with BSD LPD clients, so you may not need to make such a modification. WARNING
Specifying the Server on a CUPS ClientYou can add printers to CUPS by using the command-line lpadmin utility, by using a GUI front-end to lpadmin , or by entering http://localhost:631 in a Web browser running on the computer (or the hostname and :631 on another computer that's allowed administrative access). Each of these methods of administration allows you to add or delete printers accessible from the computer in question, or to perform various other administrative tasks. To add a network printer, you could use lpadmin to enter a command like the following: # lpadmin -p PrinterName -E -v lpd:// server.name / queuname -m \ ppdfile.ppd In this example, PrinterName is the name of the printer queue to be used locally, server.name is the hostname of the print server, and queuename is the name of the print queue on that server. This example shows access to a print queue that uses the BSD LPD protocol, as indicated by the lpd that precedes the server and queue names . To use another CUPS server, you might prefer using ipp in place of lpd . This tells CUPS to use IPP rather than the BSD LPD protocol. (You can create a local queue in much the same way, but the parameter to -v would be parallel:/dev/lp0 or some other local device identifier.) Finally, the -m parameter identifies the PPD file for the printer, so that CUPS can pass information on the printer's capabilities back to CUPS-aware applications. On most installations, you can find a collection of PPD files in the /usr/share/cups/model directory tree. Many PostScript printers also ship with their own PPD files, which you can use. You can also attempt to use the driver listings at the Linux Printing Web site, http://www.linuxprinting.org/driver_list.cgi. Click on a Ghostscript driver name, then select your printer model in the CUPS-O-Matic area and click Generate CUPS PPD. After a brief delay, the result should be a PPD file that describes your printer's capabilities. As the comments in the generated file note, though, this machine-generated PPD file might have quirks , or it might not even work at all. For this reason, you're better off using a PPD file that's provided by your printer's manufacturer, if possible. TIP
If you want to modify an existing print queue, you may do so with the lpadmin tool just as if you were adding a new queue. Specify the original name and any other options you include override the originals . For instance, you can change a local queue to a network queue by using the -v option and specifying the new location. If you prefer to use a GUI tool, the Web interface (shown in Figure 9.1) is supported by default on a standard installation. After you enter the URL to your computer (including the port 631 specification), CUPS prompts you for an administrative username and password. You can then select from several options, such as Do Administration Tasks and Manage Printers. Figure 9.1 shows the latter, in which you can create, delete, and administer printers. Figure 9.1 shows two defined printers. The first, hp4000 , is the default and is an LPD printer. The second, lexmark , is connected to the parallel port. You can click Modify Printer to modify the basic settings, such as the server name, or you can adjust printer-specific settings such as page size and printer memory by clicking Configure Printer. Figure 9.1. The CUPS Web-based interface simplifies configuration of both local and network printers.
|