Common UNIX Printing System MICHAEL R. SWEET 201 West 103rd Street,Indianapolis,Indiana 46290 ii Common UNIX Printing System Associate Publisher Jeff Koch Copyright © 2002 by Sams Publishing Acquisitions Editor All rights reserved.No part of this book shall be reproduced,stored in a Kathryn Purdum retrieval system,or transmitted by any means,electronic,mechanical, Development Editor photocopying,recording,or otherwise,without written permission from Mark Renfrow the publisher.No patent liability is assumed with respect to the use of the information contained herein.Although every precaution has been taken Managing Editor in the preparation of this book,the publisher and author assume no Matt Purcell responsibility for errors or omissions.Nor is any liability assumed for Project Editor damages resulting from the use of the information contained herein. George E.Nedeff International Standard Book Number:0-672-32196-3 Copy Editors Library of Congress Catalog Card Number:2001089505 Cynthia Fields Printed in the United States of America Margo Catts Second Printing:August 2001 Karen A.Gill 05 4 3 2 Indexer Larry Sweazy Trademarks Proofreader The UNIX trademark is also shown as Unix;both are registered trade- Teresa Stephens marks of the X Open Group,Inc.All other terms mentioned in this book that are known to be trademarks or service marks have been appropriately Technical Editor capitalized.Sams Publishing cannot attest to the accuracy of this informa- Tim Hicks tion.Use of a term in this book should not be regarded as affecting the Team Coordinator validity of any trademark or service mark. Vicki Harding Warning and Disclaimer Interior Designer Every effort has been made to make this book as complete and as accu- Gary Adair rate as possible,but no warranty or fitness is implied.The information Cover Designer provided is on an “as is”basis. Alan Clements Page Layout Lizbeth Patterson iii Contents at a Glance Introduction 1 Part I Using CUPS 1 Introduction to CUPS 9 2 Compiling and Installing CUPS 23 3 Setting Up Printers and Classes 37 4 Printing with CUPS 69 5 Server Configuration 91 6 Client Configuration 109 Part II The Internet Printing Protocol 7 Overview of IPP 121 8 Anatomy of an IPP Request 127 9 Printer Objects 141 10 Job Objects 167 11 Subscription Objects 189 12 CUPS Extensions to IPP 205 Part III Programming with CUPS 13 Overview of CUPS Programming 219 14 Using CUPS API Functions 231 15 Sending IPP Requests Using CUPS 267 16 Writing File Filters for CUPS 303 17 Writing Printer Drivers for CUPS 333 18 Writing Backends for CUPS 363 19 Writing Notifiers for CUPS 373 iv Part IV Appendices A Configuration File Directives 383 B IPP Reference 427 C CUPS Constants 435 D CUPS Structures 453 E CUPS Functions 463 F Common UNIX Printing System License Agreement 575 Index 591 Contents Introduction........................................................................................1 The History of Printing in Unix..............................................................................1 Printing from Personal Computers ..........................................................................2 The Evolution of CUPS..........................................................................................2 About This Book......................................................................................................5 Part 1 Using CUPS 1 Introduction to CUPS 9 The Printing Problem............................................................................................10 The Technology......................................................................................................10 Client and Server ........................................................................................11 Jobs..............................................................................................................12 Classes..........................................................................................................12 Filters ..........................................................................................................13 Printer Drivers ............................................................................................14 Backends......................................................................................................15 Networking..................................................................................................15 Graphical Interfaces................................................................................................16 ESP Print Pro..............................................................................................17 GtkLP..........................................................................................................17 KUPS..........................................................................................................17 QtCUPS......................................................................................................19 XPP ............................................................................................................19 Resources ..............................................................................................................20 The CUPS Mailing List ..............................................................................20 CUPS Newsgroups......................................................................................21 Web Sites ....................................................................................................22 Summary................................................................................................................22 2 Building and Installing CUPS 23 Installing a Source Distribution..............................................................................24 Getting the CUPS Source Code..................................................................24 Requirements..............................................................................................24 Configuring the CUPS Sources....................................................................25 Compiling CUPS........................................................................................29 Testing the Software ....................................................................................30 Installing the Software..................................................................................30 Upgrading the Software................................................................................31 Running the Software..................................................................................31 vi Installing a Binary Distribution ..............................................................................31 Getting a CUPS Binary Distribution............................................................31 Installing or Upgrading a Portable Distribution............................................32 Installing an RPM Distribution....................................................................33 Installing a Debian Distribution....................................................................34 Summary................................................................................................................35 3 Setting Up Printers and Classes 37 Basics of Printers....................................................................................................38 Printer Devices............................................................................................38 Printer Drivers ............................................................................................45 Adding Your First Printer........................................................................................47 Adding Your First Printer from the Command-Line ....................................47 Configuring Your Printer from the Command-Line ....................................48 Adding Your First Printer from the Web..................................................................49 Configuring Your Printer from the Web Interface ........................................51 Printing a Test Page................................................................................................54 Managing Printers from the Command-Line..........................................................55 Setting the Printer Description....................................................................56 Setting the Printer Location ........................................................................56 Changing the Printer Device........................................................................56 Changing the Printer Driver........................................................................57 Changing the Printer Configuration............................................................57 Setting Quotas on a Printer..........................................................................58 Restricting Access to a Printer......................................................................58 Deleting Printers..........................................................................................59 Setting the Default Printer ..........................................................................59 Starting and Stopping Printers......................................................................59 Accepting and Rejecting Print Jobs..............................................................60 Managing Printers from the Web Interface..............................................................60 Configuring Printers from the Web Interface................................................61 Modifying Printers ......................................................................................61 Deleting Printers..........................................................................................61 Starting Printers ..........................................................................................62 Stopping Printers..........................................................................................62 Accepting Print Jobs....................................................................................62 Rejecting Print Jobs ....................................................................................62 Printing a Test Page......................................................................................62 Basics of Classes......................................................................................................62 Managing Printer Classes from the Command-Line ..............................................63 Removing Printers from a Class ..................................................................63 Removing a Class Completely ....................................................................63 vii Adding Classes from the Web Interface ..................................................................64 Managing Classes from the Web Interface ..............................................................65 Modifying Classes........................................................................................65 Deleting Classes............................................................................................66 Starting Classes ............................................................................................66 Stopping Classes ..........................................................................................67 Accepting Print Jobs....................................................................................67 Rejecting Print Jobs ....................................................................................68 Printing a Test Page......................................................................................68 Implicit Classes ......................................................................................................68 Summary................................................................................................................68 4 Printing with CUPS 69 Printing Files..........................................................................................................70 Choosing a Printer ................................................................................................70 Printing Multiple Copies..............................................................................70 Encrypting Your Print Jobs ....................................................................................71 Setting Printer Options..........................................................................................71 Printing Collated Copies..............................................................................71 Printer-Specific Options ........................................................................................71 Standard Printer Options........................................................................................73 General Options ..........................................................................................73 Banner Options............................................................................................75 Document Options......................................................................................75 Text Options................................................................................................77 Image Options ............................................................................................78 HP-GL/2 Options ......................................................................................80 Raw or Unfiltered Output ..........................................................................81 Saving Printer Options ..........................................................................................82 Setting Options for a Specific Printer ..........................................................82 Viewing the Current Saved Options............................................................82 Setting the Default Printer ..........................................................................82 Printer Instances ..........................................................................................83 Checking the Printer Status from the Command Line............................................83 Checking the Printer Status from the Web..............................................................84 Canceling a Print Job from the Command-Line ....................................................84 Canceling a Print Job from the Web Interface........................................................84 Configuring Applications for CUPS ......................................................................84 GIMP..........................................................................................................85 Netscape......................................................................................................86 Star Office....................................................................................................86 Summary................................................................................................................90 viii 5 Server Configuration 91 The Basics..............................................................................................................92 Configuration Files......................................................................................92 Changing the Server Configuration..............................................................92 Server Directives..........................................................................................93 Restarting the CUPS Server........................................................................93 Basic Configuration Options..................................................................................93 Configuring CUPS as a Server ....................................................................93 Easy Web Browsing......................................................................................94 Enhanced Security ......................................................................................95 Encryption ..................................................................................................95 Enabling Encryption in Your Server..............................................................98 Advanced Access Control......................................................................................100 Basics of Access Control ............................................................................101 Authentication of Users..............................................................................101 Authentication of Groups ..........................................................................103 Address-Based Access Control....................................................................104 Name-Based Access Control ......................................................................104 Log Files ..............................................................................................................105 The Access Log File....................................................................................105 The Error Log File ....................................................................................106 The Page Log File......................................................................................107 Summary..............................................................................................................107 6 Client Configuration 109 The Basics............................................................................................................110 Manual Configuration of Print Queues......................................................110 Specifying a Single Server for Printing ......................................................111 Automatic Configuration of Print Queues..................................................111 Specifying Multiple Servers for Printing ....................................................112 Relaying Printers to Other Clients ............................................................112 Load Balancing and Failsafe Operation ................................................................113 Printing from LPD Clients ..................................................................................114 Printing from Mac OS Clients..............................................................................115 Columbia Appletalk Package (CAP) ..........................................................115 XINET KA/Spool ....................................................................................115 NetATalk....................................................................................................116 Printing from Windows Clients............................................................................116 Configuring SAMBA 2.0.x........................................................................116 Configuring SAMBA 2.2.x........................................................................116 Configuring Windows Clients with IPP ....................................................117 Summary..............................................................................................................117 ix Part II The Internet Printing Protocol 7 Introduction to the Internet Printing Protocol 121 History of IPP......................................................................................................122 The Line Printer Daemon Protocol............................................................122 Making a New Protocol ............................................................................123 Object Model ......................................................................................................124 Extensions............................................................................................................125 References............................................................................................................125 Summary..............................................................................................................126 8 Anatomy of an IPP Request 127 Dissecting an IPP Request....................................................................................128 The HTTP Request..................................................................................128 The Request Header..................................................................................129 Groups and Attributes................................................................................131 Groups ......................................................................................................132 Attributes ..................................................................................................133 Array (1setof) Values....................................................................................134 The Response......................................................................................................134 Status Codes ..............................................................................................135 Value Tags ..................................................................................................137 Responses Containing Multiple Objects ....................................................137 Summary..............................................................................................................139 9 Printer Objects 141 What Is a Printer Object? ....................................................................................142 Required Attributes....................................................................................142 The document-format-supported Attribute................................................146 Optional Attributes ..............................................................................................155 The color-supported Attribute....................................................................156 The job-impressions-supported Attribute....................................................156 The job-k-octets-supported Attribute ........................................................156 The job-media-sheets-supported Attribute..................................................156 The multiple-document-jobs-supported Attribute......................................157 The multiple-operation-time-out Attribute................................................157 The pages-per-minute Attribute ................................................................157 The pages-per-minute-color Attribute........................................................157 The print-quality-default Attribute ............................................................157 The print-quality-supported Attribute........................................................157 The printer-current-time Attribute............................................................158 The printer-driver-installer Attribute..........................................................158