2 <!-- SECTION: Getting Started -->
4 <TITLE>Managing Operation Policies
</TITLE>
5 <LINK REL=
"STYLESHEET" TYPE=
"text/css" HREF=
"../cups-printable.css">
9 <H1 CLASS=
"title">Managing Operation Policies
</H1>
11 <P>Operation policies are the rules used for each IPP operation in CUPS. These rules include things like
"user must provide a password",
"user must be in the system group",
"allow only from the local system", and so forth. Until CUPS
1.2, these rules were largely hardcoded and could only be customized at a very basic level.
</P>
13 <P>CUPS
1.2 and later provides a fine-grained policy layer which allows you to completely redefine the rules for each operation and/or printer. Each policy is named and defines access control rules for each IPP operation. This document describes how to manage policies and their rules.
</P>
15 <H2 CLASS=
"title"><A NAME=
"BASICS">The Basics
</A></H2>
17 <P>Operation policies are used for all IPP requests sent to the scheduler and are evaluated
<em>after
</em> the
<A HREF=
"ref-cupsd-conf.html#Location"><TT>Location
</TT></A> based access control rules. This means that operation policies can only add additional security restrictions to a request, never relax them. Use
<TT>Location
</TT> based access control rules for server-wide limits and operation policies for limits on individual printers, tasks, or services.
</P>
19 <P>Policies are stored in the
<VAR>cupsd.conf
</VAR> file in
<A HREF=
"ref-cupsd-conf.html#Policy"><TT>Policy
</TT></A> sections. Each policy has an alphanumeric name that is used to select it. Inside the policy section are one or more
<A
20 HREF=
"ref-cupsd-conf.html#LimitIPP"><TT>Limit
</TT></A> subsections which list the operations that are affected by the rules inside it.
<A HREF=
"#LISTING01">Listing
1</A> shows the default operation policy, appropriately called
"default", that is shipped with CUPS.
</P>
22 <P>The easiest way to add a policy to the
<VAR>cupsd.conf
</VAR> file is to use the web interface. Click on the
<VAR>Administration
</VAR> tab and then the
<VAR>Edit Configuration File
</VAR> button to edit the current
<VAR>cupsd.conf
</VAR> file. Click on the
<VAR>Save Changes
</VAR> button to save the changes and restart the scheduler. If you edit the
<VAR>cupsd.conf
</VAR> file from the console, make sure to
<A HREF=
"ref-cupsd-conf.html">restart the cupsd process
</A> before trying to use the new policy.
</P>
25 <EM>Listing
1:
<A NAME=
"LISTING01">Default Operation Policy
</A></EM>
28 2 # Job-related operations must be done by the owner or an
30 3 <Limit Send-Document Send-URI Hold-Job Release-Job
31 Restart-Job Purge-Jobs Set-Job-Attributes
32 Create-Job-Subscription Renew-Subscription
33 Cancel-Subscription Get-Notifications Reprocess-Job
34 Cancel-Current-Job Suspend-Current-Job Resume-Job
35 CUPS-Move-Job CUPS-Get-Document
>
36 4 Require user @OWNER @SYSTEM
40 8 # All administration operations require an administrator
42 9 <Limit CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class
43 CUPS-Delete-Class CUPS-Set-Default
>
45 11 Require user @SYSTEM
49 15 # All printer operations require a printer operator
51 16 <Limit Pause-Printer Resume-Printer
52 Set-Printer-Attributes Enable-Printer Disable-Printer
53 Pause-Printer-After-Current-Job Hold-New-Jobs
54 Release-Held-New-Jobs Deactivate-Printer Activate-Printer
55 Restart-Printer Shutdown-Printer Startup-Printer
56 Promote-Job Schedule-Job-After CUPS-Accept-Jobs
59 18 Require user
<em>varies by OS
</em>
63 22 # Only the owner or an administrator can cancel or
65 23 <Limit Cancel-Job CUPS-Authenticate-Job
>
66 24 Require user @OWNER @SYSTEM
76 <H3>The Default CUPS Operation Policy
</H3>
78 <P>The policy definition starts with an opening
<TT>Policy
</TT> directive:
</P>
84 <P>The first
<TT>Limit
</TT> subsection defines the rules for IPP job operations:
</P>
87 3 <Limit Send-Document Send-URI Hold-Job Release-Job
88 Restart-Job Purge-Jobs Set-Job-Attributes
89 Create-Job-Subscription Renew-Subscription
90 Cancel-Subscription Get-Notifications Reprocess-Job
91 Cancel-Current-Job Suspend-Current-Job Resume-Job
92 CUPS-Move-Job CUPS-Get-Document
>
93 4 Require user @OWNER @SYSTEM
98 <P>The operation names are listed on a single line with spaces separating them. Each name corresponds to the IPP operation described in any of the IETF or PWG standards documents for the Internet Printing Protocol.
<A HREF=
"#TABLE01">Table
1</A> lists all of the operations that have been defined along with their usage in CUPS.
</P>
100 <P>The access control rules are listed after the
<TT>Limit
</TT> line and are the same as those used for
<A HREF=
"ref-cupsd-conf.html#Location"><TT>Location
</TT></A> sections. In this case, we require the owner of the job (
"@OWNER") or a member of the
<A HREF=
"ref-cupsd-conf.html#SystemGroup"><TT>SystemGroup
</TT></A> (
"@SYSTEM") to do the operation. Because we do not include an
<A HREF=
"ref-cupsd-conf.html#AuthType"><TT>AuthType
</TT></A> directive here, the user information can come from the IPP request itself or the authenticated username from the HTTP request. The administrative operations starting on line
9, however,
<em>do
</em> use the
<TT>AuthType
</TT> directive, and so administrative operations need to be authenticated:
</P>
102 <PRE CLASS=
"example">
103 9 <Limit CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class
104 CUPS-Delete-Class CUPS-Set-Default
>
106 11 Require user @SYSTEM
110 15 # All printer operations require a printer operator
112 16 <Limit Pause-Printer Resume-Printer
113 Set-Printer-Attributes Enable-Printer Disable-Printer
114 Pause-Printer-After-Current-Job Hold-New-Jobs
115 Release-Held-New-Jobs Deactivate-Printer Activate-Printer
116 Restart-Printer Shutdown-Printer Startup-Printer
117 Promote-Job Schedule-Job-After CUPS-Accept-Jobs
120 18 Require user
<em>varies by OS
</em>
125 <P>The
"Order deny,allow" line at the end of both
<TT>Limit
</TT> subsections allows the request to come from any system allowed by the
<TT>Location
</TT> sections elsewhere in the
<VAR>cupsd.conf
</VAR> file.
</P>
127 <P>The
<TT>Cancel-Job
</TT> and
<TT>CUPS-Authenticate-Job
</TT> operations are listed separately to allow the web interface to more easily edit their policy without disturbing the rest. Like the rest of the job operations, we want the job's owner (
"@OWNER") or an administrator (
"@SYSTEM") to do it:
</P>
129 <PRE CLASS=
"example">
130 16 <Limit Cancel-Job CUPS-Authenticate-Job
>
131 17 Require user @OWNER @SYSTEM
136 <P>The last
<TT>Limit
</TT> subsection in any policy uses the special operation name
<TT>All
</TT>. CUPS will use the rules in this subsection for any operation you don't list specifically in the policy. In this case, all other operations are allowed without a username or authentication:
</P>
138 <PRE CLASS=
"example">
146 <DIV CLASS=
"table"><TABLE WIDTH=
"80%" SUMMARY=
"IPP Operation Names">
147 <CAPTION>Table
1:
<A NAME=
"TABLE01">IPP Operation Names
</A></CAPTION>
151 <TH>Used by CUPS?
</TH>
157 <TD NOWRAP
><TT>Print-Job
</TT></TD>
159 <TD>Creates a print job with a single file.
</TD>
162 <TD NOWRAP
><TT>Print-URI
</TT></TD>
164 <TD>Create a print job with a single URI.
</TD>
167 <TD NOWRAP
><TT>Validate-Job
</TT></TD>
169 <TD>Validates a print request before printing.
</TD>
172 <TD NOWRAP
><TT>Create-Job
</TT></TD>
174 <TD>Creates a print job with no files or URIs.
</TD>
177 <TD NOWRAP
><TT>Send-Document
</TT></TD>
179 <TD>Adds a file to a print job.
</TD>
182 <TD NOWRAP
><TT>Send-URI
</TT></TD>
184 <TD>Adds a URI to a print job.
</TD>
187 <TD NOWRAP
><TT>Cancel-Job
</TT></TD>
189 <TD>Cancels a print job.
</TD>
192 <TD NOWRAP
><TT>Get-Job-Attributes
</TT></TD>
194 <TD>Gets information and options associated with a job.
</TD>
197 <TD NOWRAP
><TT>Get-Jobs
</TT></TD>
199 <TD>Gets a list of jobs.
</TD>
202 <TD NOWRAP
><TT>Get-Printer-Attributes
</TT></TD>
204 <TD>Gets information and options associated with a printer or class.
</TD>
207 <TD NOWRAP
><TT>Hold-Job
</TT></TD>
209 <TD>Holds a print job for printing.
</TD>
212 <TD NOWRAP
><TT>Release-Job
</TT></TD>
214 <TD>Releases a print job for printing.
</TD>
217 <TD NOWRAP
><TT>Restart-Job
</TT></TD>
219 <TD>Reprints a print job.
</TD>
222 <TD NOWRAP
><TT>Pause-Printer
</TT></TD>
224 <TD>Stops a printer or class.
</TD>
227 <TD NOWRAP
><TT>Resume-Printer
</TT></TD>
229 <TD>Starts a printer or class.
</TD>
232 <TD NOWRAP
><TT>Purge-Jobs
</TT></TD>
234 <TD>Cancels all jobs on the server or a printer or class
235 and removes the job history information.
</TD>
238 <TD NOWRAP
><TT>Set-Printer-Attributes
</TT></TD>
240 <TD>Sets printer or class information; CUPS uses
241 CUPS-Add-Modify-Printer and CUPS-Add-Modify-Class
245 <TD NOWRAP
><TT>Set-Job-Attributes
</TT></TD>
247 <TD>Changes job options.
</TD>
250 <TD NOWRAP
><TT>Get-Printer-Supported-Values
</TT></TD>
252 <TD>Gets -supported attributes for a printer based on job
256 <TD NOWRAP
><TT>Create-Printer-Subscription
</TT></TD>
258 <TD>Creates an event subscription for a printer or the server.
</TD>
261 <TD NOWRAP
><TT>Create-Job-Subscription
</TT></TD>
263 <TD>Creates an event subscription for a job.
</TD>
266 <TD NOWRAP
><TT>Get-Subscription-Attributes
</TT></TD>
268 <TD>Gets information for an event subscription.
</TD>
271 <TD NOWRAP
><TT>Get-Subscriptions
</TT></TD>
273 <TD>Gets a list of event subscriptions.
</TD>
276 <TD NOWRAP
><TT>Renew-Subscription
</TT></TD>
278 <TD>Renews an event subscription that is about to expire.
</TD>
281 <TD NOWRAP
><TT>Cancel-Subscription
</TT></TD>
283 <TD>Cancels an event subscription.
</TD>
286 <TD NOWRAP
><TT>Get-Notifications
</TT></TD>
288 <TD>Gets (pending) events for an event subscription.
</TD>
291 <TD NOWRAP
><TT>Send-Notifications
</TT></TD>
293 <TD>Sends events for an event subscription.
</TD>
296 <TD NOWRAP
><TT>Get-Printer-Support-Files
</TT></TD>
298 <TD>Gets printer driver files for a Novell client.
</TD>
301 <TD NOWRAP
><TT>Enable-Printer
</TT></TD>
303 <TD>Starts a printer or class.
</TD>
306 <TD NOWRAP
><TT>Disable-Printer
</TT></TD>
308 <TD>Stops a printer or class.
</TD>
311 <TD NOWRAP
><TT>Pause-Printer-After-Current-Job
</TT></TD>
313 <TD>Stops a printer or class after the current job is finished.
</TD>
316 <TD NOWRAP
><TT>Hold-New-Jobs
</TT></TD>
318 <TD>Holds new jobs submitted to a printer or class.
</TD>
321 <TD NOWRAP
><TT>Release-Held-New-Jobs
</TT></TD>
323 <TD>Releases jobs that were held because of the
324 Hold-New-Jobs operation.
</TD>
327 <TD NOWRAP
><TT>Deactivate-Printer
</TT></TD>
329 <TD>Deactivates a printer or class.
</TD>
332 <TD NOWRAP
><TT>Activate-Printer
</TT></TD>
334 <TD>Activates a printer or class.
</TD>
337 <TD NOWRAP
><TT>Restart-Printer
</TT></TD>
339 <TD>Restarts a printer or class, resuming print jobs as needed.
</TD>
342 <TD NOWRAP
><TT>Shutdown-Printer
</TT></TD>
344 <TD>Powers a printer or class off.
</TD>
347 <TD NOWRAP
><TT>Startup-Printer
</TT></TD>
349 <TD>Powers a printer or class on.
</TD>
352 <TD NOWRAP
><TT>Reprocess-Job
</TT></TD>
354 <TD>Reprints a job on a different printer or class; CUPS has the
355 CUPS-Move-Job operation instead.
</TD>
358 <TD NOWRAP
><TT>Cancel-Current-Job
</TT></TD>
360 <TD>Cancels the current job on a printer or class.
</TD>
363 <TD NOWRAP
><TT>Suspend-Current-Job
</TT></TD>
365 <TD>Stops the current job on a printer or class.
</TD>
368 <TD NOWRAP
><TT>Resume-Job
</TT></TD>
370 <TD>Resumes printing of a stopped job.
</TD>
373 <TD NOWRAP
><TT>Promote-Job
</TT></TD>
375 <TD>Prints a job before others.
</TD>
378 <TD NOWRAP
><TT>Schedule-Job-After
</TT></TD>
380 <TD>Prints a job after others.
</TD>
383 <TD NOWRAP
><TT>CUPS-Get-Default
</TT> *
</TD>
385 <TD>Gets the server/network default printer or class.
</TD>
388 <TD NOWRAP
><TT>CUPS-Get-Printers
</TT> *
</TD>
390 <TD>Gets a list of printers and/or classes.
</TD>
393 <TD NOWRAP
><TT>CUPS-Add-Modify-Printer
</TT></TD>
395 <TD>Adds or modifies a printer.
</TD>
398 <TD NOWRAP
><TT>CUPS-Delete-Printer
</TT> *
</TD>
400 <TD>Removes a printer.
</TD>
403 <TD NOWRAP
><TT>CUPS-Get-Classes
</TT> *
</TD>
405 <TD>Gets a list of classes.
</TD>
408 <TD NOWRAP
><TT>CUPS-Add-Modify-Class
</TT></TD>
410 <TD>Adds or modifies a class.
</TD>
413 <TD NOWRAP
><TT>CUPS-Delete-Class
</TT> *
</TD>
415 <TD>Removes a class.
</TD>
418 <TD NOWRAP
><TT>CUPS-Accept-Jobs
</TT></TD>
420 <TD>Sets a printer's or class' printer-is-accepting-jobs
421 attribute to true.
</TD>
424 <TD NOWRAP
><TT>CUPS-Reject-Jobs
</TT></TD>
426 <TD>Sets a printer's or class' printer-is-accepting-jobs
427 attribute to false.
</TD>
430 <TD NOWRAP
><TT>CUPS-Set-Default
</TT> *
</TD>
432 <TD>Sets the server/network default printer or class.
</TD>
435 <TD NOWRAP
><TT>CUPS-Get-Devices
</TT> *
</TD>
437 <TD>Gets a list of printer devices.
</TD>
440 <TD NOWRAP
><TT>CUPS-Get-PPDs
</TT> *
</TD>
442 <TD>Gets a list of printer drivers or manufacturers.
</TD>
445 <TD NOWRAP
><TT>CUPS-Move-Job
</TT></TD>
447 <TD>Moves a job to a different printer or class.
</TD>
450 <TD NOWRAP
><TT>CUPS-Authenticate-Job
</TT></TD>
452 <TD>Authenticates a job for printing.
</TD>
455 <TD NOWRAP
><TT>CUPS-Get-Document
</TT></TD>
457 <TD>Retrieves a document file from a job.
</TD>
462 <P>* = These operations only apply to the default policy.
</P>
464 <H2 CLASS=
"title"><A NAME=
"CREATING">Creating Your Own Policies
</A></H2>
466 <P>The easiest way to create a new policy is to start with the default policy and then make changes to the copy. The first change you'll make is to give the policy a new name. Policy names can use the same characters as a printer name, specifically all printable characters except space, slash (/), and pound (#):
</P>
468 <PRE CLASS=
"example">
472 <P>Then you need to decide exactly what limits you want for the policy. For example, if you want to allow any user to cancel any other users' jobs, you can change the
<TT>Cancel-Job
</TT> limits to:
</P>
474 <PRE CLASS=
"example">
475 <Limit Cancel-Job
>
480 <P>The directives inside the
<TT>Limit
</TT> subsection can use any of the normal limiting directives:
<A HREF=
"ref-cupsd-conf.html#Allow"><TT>Allow
</TT></A>,
<A HREF=
"ref-cupsd-conf.html#AuthType"><TT>AuthType
</TT></A>,
<A HREF=
"ref-cupsd-conf.html#Deny"><TT>Deny
</TT></A>,
<A HREF=
"ref-cupsd-conf.html#Encryption"><TT>Encryption
</TT></A>,
<A HREF=
"ref-cupsd-conf.html#Require"><TT>Require
</TT></A>, and
<A HREF=
"ref-cupsd-conf.html#Satisfy"><TT>Satisfy
</TT></A>.
<A HREF=
"#TABLE02">Table
2</A> lists some basic
"recipes" for different access control rules.
</P>
482 <DIV CLASS=
"table"><TABLE WIDTH=
"80%" SUMMARY=
"Access Control Recipes">
483 <CAPTION>Table
2:
<A NAME=
"TABLE02">Access Control Recipes
</A></CAPTION>
486 <TH>Access Level
</TH>
487 <TH>Directives to Use
</TH>
492 <TD>Allow Everyone
</TD>
493 <TD><PRE>Order deny,allow
494 Allow from all
</PRE></TD>
497 <TD>Allow Everyone on the Local Network
</TD>
498 <TD><PRE>Order deny,allow
499 Allow from @LOCAL
</PRE></TD>
502 <TD>Deny Everyone/Disable Operation(s)
</TD>
503 <TD><PRE>Order deny,allow
</PRE></TD>
506 <TD>Require Login (System) Password
</TD>
507 <TD><PRE>AuthType Basic
</PRE></TD>
510 <TD>Require CUPS (lppasswd) Password
</TD>
511 <TD><PRE>AuthType BasicDigest
</PRE></TD>
514 <TD>Require Kerberos
</TD>
515 <TD><PRE>AuthType Negotiate
</PRE></TD>
518 <TD>Require the Owner of a Job or Subscription
</TD>
519 <TD><PRE>Require user @OWNER
</PRE></TD>
522 <TD>Require an Administrative User
</TD>
523 <TD><PRE>Require user @SYSTEM
</PRE></TD>
526 <TD>Require Member of Group
"foogroup"</TD>
527 <TD><PRE>Require user @foogroup
</PRE></TD>
530 <TD>Require
"john" or
"mary"</TD>
531 <TD><PRE>Require user john mary
</PRE></TD>
534 <TD>Require Encryption
</TD>
535 <TD><PRE>Encryption Required
</PRE></TD>
540 <H3>Creating a Policy for a Computer Lab
</H3>
542 <P>One common operating scenario is a computer lab. The lab is managed by one or more technicians that assist the users of the lab and handle the basic administration tasks.
<A HREF=
"#LISTING02">Listing
2</A> shows an operation policy that only allows access from the lab's subnet,
10.0.2.x, and allows the lab technicians, who are members of a special UNIX group for that lab called
"lab999", to do job, printer, and subscription management operations.
</P>
544 <PRE CLASS=
"example">
545 <EM>Listing
2:
<A NAME=
"LISTING02">Operation Policy for a Lab
</A></EM>
548 2 # Job- and subscription-related operations must be done
549 by the owner, a lab technician, or an administrator...
550 3 <Limit Send-Document Send-URI Hold-Job Release-Job
551 Restart-Job Purge-Jobs Set-Job-Attributes
552 Create-Job-Subscription Renew-Subscription
553 Cancel-Subscription Get-Notifications Reprocess-Job
554 Cancel-Current-Job Suspend-Current-Job Resume-Job
555 CUPS-Move-Job Cancel-Job CUPS-Authenticate-Job CUPS-Get-Document
>
556 4 Require user @OWNER @lab999 @SYSTEM
558 6 Allow from
10.0.2.0/
24
561 9 # All administration operations require a lab technician
562 or an administrator to authenticate...
563 10 <Limit Pause-Printer Resume-Printer
564 Set-Printer-Attributes Enable-Printer Disable-Printer
565 Pause-Printer-After-Current-Job Hold-New-Jobs
566 Release-Held-New-Jobs Deactivate-Printer Activate-Printer
567 Restart-Printer Shutdown-Printer Startup-Printer
568 Promote-Job Schedule-Job-After CUPS-Accept-Jobs
569 CUPS-Reject-Jobs CUPS-Set-Default
>
571 12 Require user @lab999 @SYSTEM
573 14 Allow from
10.0.2.0/
24
576 17 # All other operations are allowed from the lab network...
579 20 Allow from
10.0.2.0/
24
585 <H2 CLASS=
"title"><A NAME=
"SELECT">Using Policies
</A></H2>
587 <P>Once you have created a policy, you can use it in two ways. The first way is to assign it as the default policy for the system using the
<A HREF=
"ref-cupsd-conf.html#DefaultPolicy"><TT>DefaultPolicy
</TT></A> directive in the
<VAR>cupsd.conf
</VAR> file. For example, add the following line to the
<VAR>cupsd.conf
</VAR> file to use the
"lab999" policy from the previous section:
</P>
589 <PRE CLASS=
"example">
593 <P>To associate the policy with one or more printers, use either the
<A HREF=
"man-lpadmin.html">lpadmin(
8)
</A> command or the web interface to change the operation policy for each printer. When using the
<B>lpadmin
</B> command, the
<TT>-o printer-op-policy=name
</TT> option sets the operation policy for a printer. For example, enter the following command to use the
"lab999" policy from the previous section with a printer named
"LaserJet4000":
</P>
595 <PRE CLASS=
"command">
596 lpadmin -p LaserJet4000 -o printer-op-policy=lab999
599 <P>To make the same change in the web interface, go to the printer's web page, for example
"http://localhost:631/printers/LaserJet4000", and choose
<VAR>Set Default Options
</VAR> from the
<VAR>Administration
</VAR> menu button. Click on the
<VAR>Policies
</VAR> link and choose the desired policy from the pull-down list. Click on
<VAR>Set Default Options
</VAR> to change the policy for the printer.
</P>