Lecture 34

Printers and Spooling

Elements of a Spooling System

Any spooling system comprises the following parts:
Commands to initiate printing
The user decides what files to print, which printers to use, and other parameters of the printing process. BSD calls the spooled data jobs, Sys V refers to them as requests.
Queues
FIFO queues used store the print jobs/requests
Spooling directories
Under BSD, the file is copied to a spooling directory. Under System V, a request file is generated and the file is accessed in its original location at the time printing takes place.
Server process(es) (Spooling software)
Used to receive jobs, store them, and transfer a job/request from the spooling directories to the appropriate printing device
Administrative commands
Let the administrator start and stop the printing subsystem or specific printers, and manage individual print jobs

Types of Printers

BSD Printing

lpr
Adds a job to the print queue by copying the file into the spool directory. When submitted, a job ID (number) is associated with the file to be printed and is reported to the user, for future reference.

lpq
Lists jobs that reside in the print queues
lprm
Removes a job or jobs from print queues. Users can typically remove only those jobs they have spooled. Only root can delete someone else's job from a print queue.
lpd
The printer daemon. It sends data from the spool directories to the actual printer devices.
lpc
The printer control program. It allows root to enable and disable spooling, remove jobs from a queue, change the order of jobs in the queue, view printer status information, and start or stop the lpd process.
/etc/printcap
The printer configuration file. It contains entries describing the salient parameters of each printer device available to the system, whether local or remote.
Printcap file entries
The printcap file is like unto the termcap file in that it describes capabilities of a device as a collection of colon separated variable=value pairs. Here are a couple of sample entries (from Frisch):
lp|line printer:\
  :sd=/var/spool/lp:if=/usr/lib/lpf:lf=/var/adm/llpd-errs:\
  :lo=lp0LOCK:lp=/dev/lp:pl=66:pw=132:af=/var/adm/lpacct

ps|3rd Floor Laser Printer:\
  :sd=/var/spool/ps:br#9600:rw:sh:lo=lock:mx1000000:\
  :af=/var/adm/ps_acct/lp3:lf=/var/spool/ps/log:\
  :lp=/dev/ps:cf=/usr/lib/pscif:df=/usr/lib/psdvi:\
  :gf=/usr/lib/psgraph:if=/usr/lib/pspf:\
  :nf=/usr/lib/ips:rf=/usr/lib/psfort:\
  :tr=/usr/lib/pscat:vf=/usr/lib/ps:
Variables:
af
Account file path
br
baud rate
lf
Error log file path
lo
Lock file name
lp
Printer device file
mx
Max file size (0=unlimited)
pl
Page length (in lines)
sd
Spool directory
sh
Suppress headers/banners page
sb
Use a short (one-line) header/banner
df, gf, if, nf, rf, tf, vf
Filters (programs) to convert input from Tek dvi format, plot format, any arbitrary format, ditroff, fortran text format, troff format, and versatek format plot files
Each printer will have its own spool directory in /var/spool. The spool directories are owned by the daemon user and the group daemon with permissions 755. This forces users to employ lpr to insert files into the directory for printing. The spooling daemon lpd normally resides in /usr/lib.

System V Printing

System V printer control software is widely regarded as a piece of junk. It rated low marks after its introduction and has never been heralded as an icon of progress since that time.

One benefit of SysV printing is the use of printer classes. A user can queue a job to a printer class which is supported by a number of different devices. The specific device to receive the job can be dynamically determined to achieve a reasonable system load. This is primarily useful in settings where operators manage a number of similar print devices. You don't generally want the user to have no idea of the final destination of output.

SysV printing provides the following user commands:

lp
initiate print requests
cancel
remove a request
lpstat
list contents of a queue
The spooling daemon on SysV is lpsched. It can be administered with the following commands:
accept
Start accepting requests for a given printer.
reject
Stop accepting requests for a given printer.
enable
Allow jobs from the queue to be sent to the printer.
disable
Stop allowing jobs from the queue to be sent to the printer.
lpadmin
Configure the printing environment (lots of options).
lpmove
Transfer a job from one printer to another (usually a bad idea unless requested by the user).
lpshut
Turn off the lpsched daemon.
SysV uses the /etc/printers.conf file to serve the same much the same purpose as the printcap file of BSD.

LPRng (LPR: the Next Generation)

LPRng is maintained by Patrick Powell at http://www.lprng.com/. It is a complete printing system that provides all the common BSD printing commands and the most important SysV commands (i.e. those employed by users).

LPRng offers several security benefits. It eliminates the BSD requirement that the system run as root. This is a significant benefit since the lpr client and the lpd filters are potential security holes when executed as root. LPRng stops the effect of any compromise of the printing system to the printing system alone. LPRng supports Kerberos 5, SSL, and PGP authentication for host authentication.

Finally, LPRng provides some of the beneficial queue management features that are provided by SysV.

Internet Printing Protocol

This is a relatively new (born in 1996) attempt to develop an Internet standard for printing that includes core functions for a user to : The Common Unix Print Server (CUPS) is a cross-platform implementation of IPP.

The CUPS scheduler is an HTTP/1.1 server application that takes HTTP requests vie IPP POST requests. It also provides a web server for documentation, status monitoring, and administration. The server is configured in a way similarly to Apache, but also includes MIME rules for converting files for printing and Postscript Printer Description (PPD) files for each printer.

The CUPS API provides functions for queueing jobs, getting printer status information, accessing resources with HPP and IPP, and manipulating PPD files.

CUPS provides both System V and Berkeley command-line interface programs for submitting jobs and checking on printer status.

CUPS providings an imaging library for managing large images.

CUPS backend programs support parallel, serial, USB, LPD, IPP, and AppSocket (JetDirect) connections.

CUPS is included in the Debian stable distribution and is available across the range of Unix/Linux platforms.