CUPS


CUPS is a modular printing system for Unix-like computer operating systems which allows a computer to act as a print server. A computer running CUPS is a host that can accept print jobs from client computers, process them, and send them to the appropriate printer.
CUPS consists of a print spooler and scheduler, a filter system that converts the print data to a format that the printer will understand, and a [|backend] system that sends this data to the print device. CUPS uses the Internet Printing Protocol as the basis for managing print jobs and queues. It also provides the traditional command line interfaces for the System V and Berkeley print systems, and provides support for the Berkeley print system's Line Printer Daemon protocol and limited support for the Server Message Block protocol. System administrators can configure the device drivers which CUPS supplies by editing text files in Adobe's PostScript Printer Description format. There are a number of user interfaces for different platforms that can configure CUPS, and it has a built-in web-based interface. CUPS is free software, provided under the Apache License.

History

, who owned Easy Software Products, started developing CUPS in 1997 and the first public betas appeared in 1999. The original design of CUPS used the Line Printer Daemon protocol, but due to limitations in LPD and vendor incompatibilities, the Internet Printing Protocol was chosen instead. CUPS was initially called "The Common UNIX Printing System". This name was shortened to just "CUPS" beginning with CUPS 1.4 due to legal concerns with the UNIX trademark. CUPS was quickly adopted as the default printing system for most Linux distributions. In March 2002, Apple Inc. adopted CUPS as the printing system for Mac OS X 10.2. In February 2007, Apple Inc. hired chief developer Michael Sweet and purchased the CUPS source code. On December 20, 2019, Michael Sweet announced on his blog that he had left Apple. In 2020, the OpenPrinting organization forked the project, with Michael Sweet continuing work on it. Apple retained the builds for macOS, iOS, and iPadOS with latest release of Apple CUPS being version 2.3.6 on May 25, 2022. In 2024, a critical vulnerability involving remote code execution in CUPS was found impacting all GNU/Linux systems.

Overview

CUPS provides a mechanism that allows print jobs to be sent to printers in a standard fashion. The print data goes to a scheduler which sends jobs to a filter system that converts the print job into a format the printer will understand. The filter system then passes the data on to a backend—a special filter that sends print data to a device or network connection. The system makes extensive use of PostScript and rasterization of data to convert the data into a format suitable for the destination printer.
CUPS offers a standard and modularised printing system that can process numerous data formats on the print server. Before CUPS, it was difficult to find a standard printer management system that would accommodate the very wide variety of printers on the market using their own printer languages and formats. For instance, the System V and Berkeley printing systems were largely incompatible with each other, and they required complicated scripts and workarounds to convert the program's data format to a printable format. They often could not detect the file format that was being sent to the printer and thus could not automatically and correctly convert the data stream. Additionally, data conversion was performed on individual workstations rather than a central server.
CUPS allows printer manufacturers and printer-driver developers to create drivers more easily that work natively on the print server. Processing occurs on the server, allowing for easier network-based printing than with other Unix printing systems. With Samba installed, users can address printers on remote Windows computers, and generic PostScript drivers can be used for printing across the network.

Scheduler

The CUPS scheduler implements Internet Printing Protocol over HTTP/1.1. A helper application converts Line Printer Daemon protocol requests to IPP. The scheduler also provides a web-based interface for managing print jobs, the configuration of the server, and for documentation about CUPS itself.
An authorization module controls which IPP and HTTP messages can pass through the system. Once the IPP/HTTP packets are authorized they are sent to the client module, which listens for and processes incoming connections. The client module is also responsible for executing external CGI programs as needed to support web-based printers, classes, and job status monitoring and administration. Once this module has processed its requests, it sends them to the IPP module which performs Uniform Resource Identifier validation to prevent a client from sidestepping any access controls or authentication on the HTTP server. The URI is a text string that indicates a name or address that can be used to refer to an abstract or physical resource on a network.
The scheduler allows for classes of printers. Applications can send requests to groups of printers in a class, allowing the scheduler to direct the job to the first available printer in that class. A jobs module manages print jobs, sending them to the filter and backend processes for final conversion and printing, and monitoring the status messages from those processes.
The CUPS scheduler utilizes a configuration module, which parses configuration files, initializes CUPS data structures, and starts and stops the CUPS program. The configuration module will stop CUPS services during configuration file processing and then restart the service when processing is complete.
A logging module handles the logging of scheduler events for access, error, and page log files. The main module handles timeouts and dispatch of I/O requests for client connections, watching for signals, handling child process errors and exits, and reloading the server configuration files as needed.
Other modules used by the scheduler include:
  • the MIME module, which handles a Multipurpose Internet Mail Extensions type and conversion database used in the filtering process that converts print data to a format suitable for a print device;
  • a PPD module that handles a list of Postscript Printer Description files;
  • a devices module that manages a list of devices that are available in the system;
  • a printers module that handles printers and PPDs within CUPS.

    Filter system

CUPS can process a variety of data formats on the print server. It converts the print-job data into the final language/format of the printer via a series of filters. It uses MIME types for identifying file formats.

MIME databases

After the CUPS system has assigned the print job to the scheduler, it is passed to the CUPS filter system. This converts the data to a format suitable for the printer. During start-up, the CUPS daemon loads two MIME databases: mime.types that defines the known file types that CUPS can accept data for, and mime.convs that defines the programs that process each particular MIME type.
The mime.types file has the syntax:
mimetype
For example, to detect an HTML file, the following entry would be applicable:
text/html html htm \

The second line matches the file contents to the specified MIME type by determining that the first kilobyte of text in the file holds printable characters and that those characters include HTML markup. If the pattern above matches, then the filter system would mark the file as the MIME type text/html.
The mime.convs file has the syntax:
source destination cost program
The source field designates the MIME type that is determined by looking up the mime.types file, while the destination field lists the type of output requested and determines what program should be used. This is also retrieved from mime.types. The cost field assists in the selection of sets of filters when converting a file. The last field, program, determines which filter program to use to perform the data conversion.
Some examples:
text/plain application/postscript 50 texttops
application/vnd.cups-postscript application/vnd.cups-raster 50 pstoraster
image/* application/vnd.cups-postscript 50 imagetops
image/* application/vnd.cups-raster 50 imagetoraster

Filtering process

The filtering process works by taking input data pre-formatted with six arguments:
  1. the job ID of the print job
  2. the user name
  3. the job name
  4. the number of copies to print
  5. any print options
  6. the filename.
It then determines the type of data that is being input and the filter to be used through the use of the MIME databases; for instance, image data will be detected and processed through a particular filter, and HTML data detected and processed through another filter.
CUPS can convert supplied data either into PostScript data or directly into raster data. If it is converted into PostScript data an additional filter is applied called a prefilter, which runs the PostScript data through another PostScript converter so that it can add printer-specific options like selecting page ranges to print, setting n-up mode and other device-specific things. After the pre-filtering is done, the data can either be sent directly to a CUPS backend if using a PostScript printer, or it can be passed to another filter like Foomatic by linuxprinting.org. Alternatively, it can be passed to Ghostscript, which converts the PostScript into an intermediary CUPS-raster format. The intermediary raster format is then passed onto a final filter which converts the raster data to a printer-specific format. The default filters included with CUPS include:
other proprietary languages like GDI or SPL are supported by Splix, a raster to SPL translator.
However, several other alternatives can integrate with CUPS. HPLIP provides Linux+CUPS drivers for HP printers, Gutenprint is a range of high-quality printer drivers for inkjet printers, and TurboPrint for Linux has another range of quality printer drivers for a wide range of printers.