Printing/CUPS/Quotas

Jump to: navigation, search

Quotas

By Kurt Pfeifle, author of KDEPrint handbook.

Unfortunately, the "quota" feature is not very well documented in the CUPS man pages nor the CUPS manuals or other documents. This is also true for other "official" IPP-defined options or print parameters (see RFC 2910 and 2911 for those). CUPS supports all of the required IPP-parameters plus most of the optional ones plus a few "CUPS-only" extensions.

At the present time, the described features are only supported when using the commandline with "lpadmin". You'll find some hints in the document "CUPS Implementation of IPP" (http://www.cups.org/ipp.html).

From what I read in the IPP-documents and what I thereafter found out in "trial'n'error" experiments, plus what I snatched by following the CUPS mailing list, here is what you need to know:

Setting up Quotas for certain printers

Quotas can be set with the "-o" (option) parameter when installing a printer with the "lpadmin"-command, or afterwards for an already existing printer (see also "man lpadmin").

  • With CUPS you may have pagecount- and filesize-based quotas for individual printers.
  • Quotas are calculated for each user individually. (Thus a single set of limits applies to all users for the printer concerned).
  • Quotas include banner pages (if those are used).
  • This means: you can limit every user to 20 pages per day on an expensive printer, but you cannot limit every user except Kurt or Chris or Michael or root.
  • There are "job-k-limit", "job-page-limit", and "job-quota-period" options to give when setting up a printer.
  • "job-quota-period" sets a time interval for quota computing (intervals are determined in seconds; so a day is 60x60x24=86.400, a week is 60x60x24x7=604.800, and a month is 60x60x24x30=2.592.000 seconds.)
  • For quotas to be enforced, the period *AND ADDITIONALLY* at least one limit must be set to non-zero.
  • The default value of 0 for "job-k-limit" specifies that there is no limit.
  • The default value of 0 for "job-page-limit" specifies that there is no limit.
  • The default (?) value of 0 for "job-quota-period" specifies that the limits apply to all jobs that have been printed by a user that are still known to the system.

Working Examples

The following examples are working, because both, time-period *AND* one or both limits are defined.

 lpadmin -p danka_infotec -o job-quota-period=604800 -o job-k-limit=1024 

This sets a limit of a file size of 1 MB (added-up) for each user on the existing printer "danka_infotec" during one week.

 lpadmin -p danka_infotec -o job-quota-period=604800 -o job-page-limit=100 

This sets a limit of 100 pages (added-up) for each user on the existing printer "danka_infotec" during one week.

 lpadmin -p danka_infotec -o job-quota-period=604800 -o job-k-limit=1024 -o job-page-limit=100 

This sets a combined limit of 1 MB (added-up) and 100 pages (added-up) for each user of existing printer "danka_infotec" during one week. Whichever limit is reached first will take effect.

Non-Working Examples

The following examples *NOT* working, as only *ONE*, time-period *OR* limit is specfied in any of these.

 lpadmin -p danka_infotec -o job-quota-period=604800 
 lpadmin -p danka_infotec -o job-page-limit=100 
 lpadmin -p danka_infotec -o job-k-limit=1024 

Error messages

Once a user reaches his quota limit, he'll get a "client-error-not-possible" message, if he wants to print.

Where is the Quota configuration stored?

The quotas and also the "-u allow:user1,user2..." as well as the "-u deny:user1,user2..." (see other article) stuff goes into the entries of the printers.conf file. See the following example (command should be given in one long line, not using the backslashes "\"):

 lpadmin -p quota_printer1 \ 
   -o job-quota-period=604800 \ 
     -o job-k-limit=1024 \ 
       -o job-page-limit=100 \ 
         -v file:/dev/null \ 
           -u deny:root,kurt,michael,chris \ 
             -E \ 
               -L "Dustbin or Black Hole" \ 
                 -D "This is to show how quotas and per-user-ACLs are supposed to work" \ 
                   -P /etc/cups/ppd/P450.ppd 

This command uses different parameters (see "man lpadmin" for details):

-p

specifies the user-defined printername

-o

specifies a user-selected (legal) option

-v

specifies the CUPS "device URI"

-E

"enables" the printer on the spot

-L

describes a location (free-form strings allowed)

-D

specifies a description of the printer (free-form strings allowed)

-P

specifies an absolute /path/to/an/available/PPD-file

The given command writes the following entry into the /etc/cups/printers.conf:

<Printer quota_printer1> 
  Info This is to show how quotas and per-user-ACLs are supposed to work 
  Location Dustbin or Black Hole 
  DeviceURI file:/dev/null 
  State Idle 
  Accepting Yes 
  JobSheets none none 
  QuotaPeriod 604800 
  PageLimit 100 
  KLimit 1024 
  DenyUser root 
  DenyUser kurt 
  DenyUser michael 
  DenyUser chris 
</Printer> 

To wrongly give both, the -u allow:... AND the -u deny:... within the same commandline (which is "illegal") seems to be "safe" in the sense that only the last given option will actually be used; it overrides the first one (command should be given in one long line, not using the backslashes "\"):

 lpadmin -p quota_printer2 \ 
   -o job-quota-period=604800 \ 
     -o job-k-limit=1024 \ 
       -o job-page-limit=100 \ 
         -v file:/dev/null \ 
           -u deny:root,kurt,michael \ 
             -u allow:kdh,waba \ 
               -E \ 
                 -L "Dustbin or Black Hole" \ 
                   -D "This is to show how quotas and per-user-ACLs are supposed to work" \ 
                     -P /etc/cups/ppd/P450.ppd 

Hence this writes the following entry into the /etc/cups/printers.conf:

<Printer quota_printer2> 
  Info This is to show how quotas and per-user-ACLs are supposed to work 
  Location Dustbin or Black Hole 
  DeviceURI file:/dev/null 
  State Idle 
  Accepting Yes 
  JobSheets none none 
  QuotaPeriod 604800 
  PageLimit 100 
  KLimit 1024 
  AllowUser kdh 
  AllowUser waba 
</Printer> 

To turn off all quotas again for a given printer, use the job-k-limit of 0 and a job-page-limit of 0 (i.e. issue the following command):

 lpadmin -p quota_printer \ 
   -o job-k-limit=0 \ 
     -o job-page-limit=0 \

This page was last edited on 26 May 2011, at 18:43. Content is available under Creative Commons License SA 4.0 unless otherwise noted.