IMPORTANT: Per accedir als fitxer de subversion: http://acacha.org/svn (sense password). Poc a poc s'aniran migrant els enllaços. Encara però funciona el subversion de la farga però no se sap fins quan... (usuari: prova i la paraula de pas 123456)

Alert.png Aquesta wiki forma part dels materials d'un curs
Curs: SambasobreLDAP
Fitxers: https://svn.projectes.lafarga.cat/svn/iceupc/SambaSobreLDAP/cups,
Repositori SVN: https://anonymous@svn.projectes.lafarga.cat/svn/iceupc/SambaSobreLDAP
Usuari: anonymous
Paraula de pas: sense paraula de pas
Autors: Lluís Pérez Vidal Sergi Tur Badenas

El sistema CUPS Common Unix Sistem Printing és una aplicació que permet a una màquina funcionar com un potent servidor d'impressores. Es basa en el protocol IPP que permet compartir impressores a través de xarxes TCP/IP.

Història

TODO:

La primera versión de producción de CUPS (basada en IPP/1.0) fue liberada en octubre de 1999. Desde entonces, se han publicado bastantes actualizaciones para la versión 1.0, destinadas a corregir los errores encontrados, así como añadir seguridad y portabilidad a la versión existente; se ha de notar que no se han añadido nuevas funcionalidades para mejorar la estabilidad del código de CUPS. CUPS 1.1 está basado en IPP/1.1 y se han añadido las funcionalidades pedidas por sus usuarios. Al igual que con la versión 1.0, CUPS 1.1 disfrutará de las actualizaciones necesarias para corregir cualquier problema encontrado en el software, pero no se añadirán nuevas características.

Conceptes i sigles

Consulteu Printing

IPP. Internet Printing Protocol

IPP defineix un protocol d'impressió i gestió de treballs d'impressió.

És un protocol basat en IP i pot ser usat localment o a través d'Internet per tal de comunicar-se tant amb impressores remotes com locals. IPP suporta control d'accés, autenticació i xifratge.

IPP està basat en el protocol HTTP 1.1.

PPD. PostScript Printer Description

PostScript Printer Description (PPD) Specification

PostScript és en essència un PDL que permet mostrar pàgines d'impressió en un format independent de dispositiu, però a l'hora de la veritat, cada dispositiu té capacitat i opcions diferents (doble pàgina, grapes, color, etc.).

Adobe va crear un format anomenat PostScript Printer Description que s'emmagatzema normalment el fitxers amb l'extensió PPD. Cada impressora PostScript ve amb un fitxer d'aquest tipus.

El PPD conté la informació sobre les capacitats especials de la impressora, com per exemple:

  • Resol·lucions acceptades
  • Unitats duplex
  • Safates

Per cada característica també especifica quin ordre s'ha d'executar per activar aquesta característica. Això és el permet que a l'hora d'imprimir un document per aquella impressora puguem especificar aquestes característiques especials.

NOTA: Un fitxer poscript que contingui comandes especifiques per a una impressora pot ser no portable a altres impressores

CUPS pot gestionar qualsevol fitxer PPD que compleixi amb les especificacions. Inclús si el venedor d'una impressora no especifica que la impressora suporti Linux o altres SO, podeu estar segurs que si disposeu del PPD per a Windows NT (Windows XP inclòs), podeu utilitzar aquest fitxer sense cap mena de canvi per a CUPS i així disposar de totes les funcionalitat per aquella impressora.

Diversos trucs que poden ser útils:

Comprovar un fitxer PPD

Per comprovar si un fitxers PPD compleix les especificacions podeu utilitzar:

http://www.cups.org/testppd.php 

Pugeu el PPD i us comprovarà el fitxer.

Foomatic or cupsomatic PPDs

Son PPDs generats a la pàgina http://linuxprinting.org. Si teniu els PPD del fabricant, utilitzeu aquestos primer.

On trobar els PPD de les impressores

Per xarxa podeu fer-ho accedint a una màquina que disposi dels PPD:

$ smbclient //NT4-box/print\$ -U username 

Primer busqueu a la carpeta: W32X86/2

També podeu utilitzar l'ordre locate a un sistema Linux:

$ locate ppd | grep 1018
/etc/cups/ppd/HP-LaserJet-1018.ppd
...

Llocs on trobar ppds:

/etc/cups/ppd
/usr/share/ppd

Consulteu també PostScript

Tipus de sistemes d'impressió

Consulteu Printing#Model_client-servidor._Sistema_centralitzat_.28Central_Spooling.29

Arquitectura CUPS

ArquitecturaCUPS.png

Sistema de filtratge

http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/CUPS-printing.html#overridesettings

TODO:

The core of the CUPS filtering system is based on Ghostscript. In addition to Ghostscript, CUPS uses some other filters of its own. You (or your OS vendor) may have plugged in even more filters. CUPS handles all data file formats under the label of various MIME types. Every incoming print file is subjected to an initial autotyping. The autotyping determines its given MIME type. A given MIME type implies zero or more possible filtering chains relevant to the selected target printer. This section discusses how MIME types recognition and conversion rules interact. They are used by CUPS to automatically set up a working filtering chain for any given input data format.

If CUPS rasterizes a PostScript file natively to a bitmap, this is done in two stages:

   *
     The first stage uses a Ghostscript device named “cups” (this is since version 1.1.15) and produces a generic raster format called “CUPS raster”.
   *
     The second stage uses a “raster driver” that converts the generic CUPS raster to a device-specific raster. 

Make sure your Ghostscript version has the “cups” device compiled in (check with gs -h | grep cups). Otherwise you may encounter the dreaded Unable to convert file 0 in your CUPS error_log file. To have “cups” as a device in your Ghostscript, you either need to patch GNU Ghostscript and recompile or use ESP Ghostscript. The superior alternative is ESP Ghostscript. It supports not just CUPS, but 300 other devices (while GNU Ghostscript supports only about 180). Because of this broad output device support, ESP Ghostscript is the first choice for non-CUPS spoolers, too. It is now recommended by Linuxprinting.org for all spoolers.

CUPS printers may be set up to use external rendering paths. One of the most common is provided by the Foomatic/cupsomatic concept from Linuxprinting.org. This uses the classical Ghostscript approach, doing everything in one step. It does not use the “cups” device, but one of the many others. However, even for Foomatic/cupsomatic usage, best results and broadest printer model support is provided by ESP Ghostscript (more about Foomatic/cupsomatic, particularly the new version called now foomatic-rip, follows). MIME Types and CUPS Filters

CUPS reads the file /etc/cups/mime.types (and all other files carrying a *.types suffix in the same directory) upon startup. These files contain the MIME type recognition rules that are applied when CUPS runs its autotyping routines. The rule syntax is explained in the man page for mime.types and in the comments section of the mime.types file itself. A simple rule reads like this:

application/pdf pdf string(0,%PDF)

This means if a filename has a .pdf suffix or if the magic string %PDF is right at the beginning of the file itself (offset 0 from the start), then it is a PDF file (application/pdf). Another rule is this:

application/postscript ai eps ps string(0,%!) string(0,<04>%!)

If the filename has one of the suffixes .ai, .eps, .ps, or if the file itself starts with one of the strings %! or <04>%!, it is a generic PostScript file (application/postscript). Warning

Don't confuse the other mime.types files your system might be using with the one in the /etc/cups/ directory. Note

There is an important difference between two similar MIME types in CUPS: one is application/postscript, the other is application/vnd.cups-postscript. While application/postscript is meant to be device-independent, job options for the file are still outside the PS file content, embedded in command line or environment variables by CUPS, application/vnd.cups-postscript may have the job options inserted into the PostScript data itself (where applicable). The transformation of the generic PostScript (application/postscript) to the device-specific version (application/vnd.cups-postscript) is the responsibility of the CUPS pstops filter. pstops uses information contained in the PPD to do the transformation.

CUPS can handle ASCII text, HP-GL, PDF, PostScript, DVI, and many image formats (GIF, PNG, TIFF, JPEG, Photo-CD, SUN-Raster, PNM, PBM, SGI-RGB, and more) and their associated MIME types with its filters. MIME Type Conversion Rules

CUPS reads the file /etc/cups/mime.convs (and all other files named with a *.convs suffix in the same directory) upon startup. These files contain lines naming an input MIME type, an output MIME type, a format conversion filter that can produce the output from the input type, and virtual costs associated with this conversion. One example line reads like this:

application/pdf application/postscript 33 pdftops

This means that the pdftops filter will take application/pdf as input and produce application/postscript as output; the virtual cost of this operation is 33 CUPS-$. The next filter is more expensive, costing 66 CUPS-$:

application/vnd.hp-HPGL application/postscript 66 hpgltops

This is the hpgltops, which processes HP-GL plotter files to PostScript.

application/octet-stream

Here are two more examples:

application/x-shell application/postscript 33 texttops text/plain application/postscript 33 texttops

The last two examples name the texttops filter to work on text/plain as well as on application/x-shell. (Hint: This differentiation is needed for the syntax highlighting feature of texttops). Filtering Overview

There are many more combinations named in mime.convs. However, you are not limited to use the ones predefined there. You can plug in any filter you like to the CUPS framework. It must meet, or must be made to meet, some minimal requirements. If you find (or write) a cool conversion filter of some kind, make sure it complies with what CUPS needs and put in the right lines in mime.types and mime.convs; then it will work seamlessly inside CUPS. Filter Requirements

The “CUPS requirements” for filters are simple. Take filenames or stdin as input and write to stdout. They should take these arguments:

printer

   The name of the printer queue (normally this is the name of the filter being run). 

job

   The numeric job ID for the job being printed. 

user

   The string from the originating-user-name attribute. 

title

   The string from the job-name attribute. 

copies

   The numeric value from the number-copies attribute. 

options

   The job options. 

filename

   (optionally) The print request file (if missing, filters expect data fed through stdin). In most cases, it is easy to write a simple wrapper script around existing filters to make them work with CUPS. 

Prefilters

As previously stated, PostScript is the central file format to any UNIX-based printing system. From PostScript, CUPS generates raster data to feed non-PostScript printers.

But what happens if you send one of the supported non-PS formats to print? Then CUPS runs “prefilters” on these input formats to generate PostScript first. There are prefilters to create PostScript from ASCII text, PDF, DVI, or HP-GL. The outcome of these filters is always of MIME type application/postscript (meaning that any device-specific print options are not yet embedded into the PostScript by CUPS and that the next filter to be called is pstops). Another prefilter is running on all supported image formats, the imagetops filter. Its outcome is always of MIME type application/vnd.cups-postscript (not application/postscript), meaning it has the print options already embedded into the file. This is shown in Prefiltering in CUPS to Form PostScript.

Figure 22.4. Prefiltering in CUPS to Form PostScript. Prefiltering in CUPS to Form PostScript.

pstops

pstops is a filter that is used to convert application/postscript to application/vnd.cups-postscript. As stated earlier, this filter inserts all device-specific print options (commands to the printer to ask for the duplexing of output, or stapling and punching it, and so on) into the PostScript file. An example is illustrated in Adding Device-Specific Print Options.

Figure 22.5. Adding Device-Specific Print Options. Adding Device-Specific Print Options.

This is not all. Other tasks performed by it are:

   *
     Selecting the range of pages to be printed (e.g., you can choose to print only pages “3, 6, 8-11, 16, and 19-21”, or only odd-numbered pages).
   *
     Putting two or more logical pages on one sheet of paper (the so-called “number-up” function).
   *
     Counting the pages of the job to insert the accounting information into the /var/log/cups/page_log. 

pstoraster

pstoraster is at the core of the CUPS filtering system. It is responsible for the first stage of the rasterization process. Its input is of MIME type application/vnd.cups-postscript; its output is application/vnd.cups-raster. This output format is not yet meant to be printable. Its aim is to serve as a general-purpose input format for more specialized raster drivers that are able to generate device-specific printer data. This is shown in the PostScript to Intermediate Raster Format diagram.

Figure 22.6. PostScript to Intermediate Raster Format. PostScript to Intermediate Raster Format.

CUPS raster is a generic raster format with powerful features. It is able to include per-page information, color profiles, and more, to be used by the downstream raster drivers. Its MIME type is registered with IANA and its specification is, of course, completely open. It is designed to make it quite easy and inexpensive for manufacturers to develop Linux and UNIX raster drivers for their printer models should they choose to do so. CUPS always takes care of the first stage of rasterization so these vendors do not need to care about Ghostscript complications (in fact, there are currently more than one vendor financing the development of CUPS raster drivers). This is illustrated in the CUPS-Raster Production Using Ghostscript illustration.

Figure 22.7. CUPS-Raster Production Using Ghostscript. CUPS-Raster Production Using Ghostscript.

CUPS versions before version 1.1.15 shipped a binary (or source code) standalone filter, named pstoraster. pstoraster, which was derived from GNU Ghostscript 5.50 and could be installed instead of and in addition to any GNU or AFPL Ghostscript package without conflicting.

Since version 1.1.15, this feature has changed. The functions for this filter have been integrated back into Ghostscript (now based on GNU Ghostscript version 7.05). The pstoraster filter is now a simple shell script calling gs with the -sDEVICE=cups parameter. If your Ghostscript fails when this command is executed: gs -h |grep cups, you might not be able to print, update your Ghostscript. imagetops and imagetoraster

In the section about prefilters, we mentioned the prefilter that generates PostScript from image formats. The imagetoraster filter is used to convert directly from image to raster, without the intermediate PostScript stage. It is used more often than the previously mentioned prefilters. We summarize in a flowchart the image file filtering in the Image Format to CUPS-Raster Format Conversion illustration.

Figure 22.8. Image Format to CUPS-Raster Format Conversion. Image Format to CUPS-Raster Format Conversion.

rasterto [printers specific]

CUPS ships with quite a variety of raster drivers for processing CUPS raster. On my system, I find in /usr/lib/cups/filter/ the following: rastertoalps, rastertobj, rastertoepson, rastertoescp, rastertopcl, rastertoturboprint, rastertoapdk, rastertodymo, rastertoescp, rastertohp, and rastertoprinter. Don't worry if you have fewer drivers than this; some of these are installed by commercial add-ons to CUPS (like rastertoturboprint), and others (like rastertoprinter) by third-party driver development projects (such as Gutenprint) wanting to cooperate as closely as possible with CUPS. See the Raster to Printer-Specific Formats illustration.

Figure 22.9. Raster to Printer-Specific Formats. Raster to Printer-Specific Formats.

Backends

The last part of any CUPS filtering chain is a backend. Backends are special programs that send the print-ready file to the final device. There is a separate backend program for any transfer protocol for sending print jobs over the network, and one for every local interface. Every CUPS print queue needs to have a CUPS “device-URI” associated with it. The device URI is the way to encode the backend used to send the job to its destination. Network device-URIs use two slashes in their syntax, local device URIs only one, as you can see from the following list. Keep in mind that local interface names may vary greatly from my examples, if your OS is not Linux:

usb

   This backend sends print files to USB-connected printers. An example for the CUPS device-URI to use is usb:/dev/usb/lp0. 

serial

   This backend sends print files to serially connected printers. An example for the CUPS device-URI to use is serial:/dev/ttyS0?baud=11500. 

parallel

   This backend sends print files to printers connected to the parallel port. An example for the CUPS device-URI to use is parallel:/dev/lp0. 

SCSI

   This backend sends print files to printers attached to the SCSI interface. An example for the CUPS device-URI to use is scsi:/dev/sr1. 

lpd

   This backend sends print files to LPR/LPD-connected network printers. An example for the CUPS device-URI to use is lpd://remote_host_name/remote_queue_name. 

AppSocket/HP JetDirect

   This backend sends print files to AppSocket (a.k.a., HP JetDirect) connected network printers. An example for the CUPS device-URI to use is socket://10.11.12.13:9100. 

ipp

   This backend sends print files to IPP-connected network printers (or to other CUPS servers). Examples for CUPS device-URIs to use are ipp:://192.193.194.195/ipp (for many HP printers) and ipp://remote_cups_server/printers/remote_printer_name. 

http

   This backend sends print files to HTTP-connected printers. (The http:// CUPS backend is only a symlink to the ipp:// backend.) Examples for the CUPS device-URIs to use are http:://192.193.194.195:631/ipp (for many HP printers) and http://remote_cups_server:631/printers/remote_printer_name. 

smb

   This backend sends print files to printers shared by a Windows host. Examples of CUPS device-URIs that may be used includes:
   smb://workgroup/server/printersharename
   smb://server/printersharename
   smb://username:password@workgroup/server/printersharename
   smb://username:password@server/printersharename
   The smb:// backend is a symlink to the Samba utility smbspool (does not ship with CUPS). If the symlink is not present in your CUPS backend directory, have your root user create it: ln -s `which smbspool' /usr/lib/cups/backend/smb. 

It is easy to write your own backends as shell or Perl scripts if you need any modification or extension to the CUPS print system. One reason could be that you want to create “special” printers that send the print jobs as email (through a “mailto:/” backend), convert them to PDF (through a “pdfgen:/” backend) or dump them to “/dev/null”. (In fact, I have the systemwide default printer set up to be connected to a devnull:/ backend: there are just too many people sending jobs without specifying a printer, and scripts and programs that do not name a printer. The systemwide default deletes the job and sends a polite email back to the $USER asking him or her to always specify the correct printer name.)

Not all of the mentioned backends may be present on your system or usable (depending on your hardware configuration). One test for all available CUPS backends is provided by the lpinfo utility. Used with the -v parameter, it lists all available backends:

$ lpinfo -v

Sistema client servidor

El sistema o host que funcionar com a servidors d'impressores posa a disposició del sistemes o hosts clients les seves impressores. Això permet centralitzar la gestió de les impressores.

CUPS utilitza el port per defecte del protocol IPP (Internet Printing Protocol), tal i com podeu veure al fitxer /etc/services:

$ cat /etc/services | grep ipp
ipp		631/tcp				# Internet Printing Protocol
ipp		631/udp

El port és el 631. Podeu utilitzar nmap per tal de comprovar si un servidor remot (o local posant localhost) té el port obert:

$ sudo nmap localhost -p 631

Starting Nmap 5.00 ( http://nmap.org ) at 2010-10-12 11:26 CEST
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Interesting ports on localhost (127.0.0.1):
PORT    STATE SERVICE
631/tcp open  ipp

Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds

NOTA: Compte que el port 631 no és un dels ports que nmap escannegi per defecte! Cal indicar-lo

És condició necessària (però no suficient) que el port estigui obert per tal de poder utilitzar un servidor CUPS. Per accedir a la interfície web cal posar:

http://localhost:631

IMPORTANT: La configuració per defecte de CUPS no permet accedir al servidor CUPS via web, veureu que el port està tancat:

$  sudo nmap 192.168.0.8 -p 631

Starting Nmap 5.00 ( http://nmap.org ) at 2010-10-12 11:27 CEST
Interesting ports on 192.168.0.8:
PORT    STATE  SERVICE
631/tcp closed ipp

Cal canviar la configuració o també podeu utilitzar un túnel SSH per fer la connexió:

$ ssh -L 6666:localhost:631 192.168.0.8

I connectar-vos al servidor amb:

http://localhost:6666


NOTA: En el cas d'skolelinux el servidor principal(tjener.intern 10.0.2.2) és el servidor d'impressores. Les estacions de treball skolelinux ja estan configurades per ser clients del servidor principal. Si el que tenim son altres distribuciones a les estacions de treball podem configurar-les com a clients seguint les passes de l'apartat següent

Configuració del servidor

El principal fitxer de configuració del servidor és /etc/cups/cupsd.conf:

Es pot consultar el manual:

$ man cupsd.conf

o a l'adreça

http://www.cups.org/documentation.php/man-cupsd.conf.html

Aplicar els canvis (reiniciar o recarregar el servidor)

Podeu utilitzar l'script:

/etc/init.d/cups

Si no indiqueu cap paràmetre us dirà les opcions possibles:

$ sudo /etc/init.d/cups
Usage: /etc/init.d/cups {start|stop|restart|force-reload|status}

Afegir impressores

A la web http://www.skolelinux.no/~klaus/sarge/x3819.html podreu trobar una guia de com afegir impressores al servidor principal d'skolelinux mitjançant kde o el konqueror.

Els passos son molt similars si es té Ggnome i s'utilitza gnome cups-manager.

Establir usuari i password dels usuaris administradors

L'accés als apartats administració (de fet es pot controlar de forma granular els accessos a les diferents seccions de CUPS) es fa normalment a través de Autentificació Digest (típus el que fa Apache).Podeu trobar més info i exemples a http://www.cups.org/doc-1.1/sam.html#7_11_3.

Els usuaris i passwords s'estableixen amb la comanda lppasswd:

$ lppasswd -a admin
Password: 
Password again: 

NOTA: el paràmetre -a indica que voleu afegir un usuari. L'ordre té certes similituds amb l'ordre htpasswd. Per modificar la paraula de pas d'un usuari ja existent no poseu aquest paràmetre!

Evidentment es pot consultar el man:

$ man lpppasswd

CUPS determina una mida mínima per al password i que contingui tant caràcters simples com al menys un numèric.

El fitxer on es guarden els usuaris i contrasenyes és /etc/cups/passwd.md5.

Al fitxer de configuració del dimoni CUPS (/etc/cups/cupsd.conf) s'ha d'establir l'opció:

AuthType Default

NOTA: també hi ha l'opció digest o none per no posar aunteticació

Un extracte del fitxer:

#<Location /classes/name>
#
# You may wish to limit access to printers and classes, either with Allow
# and Deny lines, or by requiring a username and password.
#
#</Location>

#<Location /printers>
#
# You may wish to limit access to printers and classes, either with Allow
# and Deny lines, or by requiring a username and password.
#
#</Location>

#<Location /printers/name>
#
# You may wish to limit access to printers and classes, either with Allow
# and Deny lines, or by requiring a username and password.
#

## Anonymous access (default)
#AuthType None

## Require a username and password (Basic authentication)
#AuthType Basic
#AuthClass User

## Require a username and password (Digest/MD5 authentication)
AuthType Digest
AuthClass User

Com podeu veure es poden establir limitacions per seccions...

NOTA: També cal que tingueu en compte que a l'hora de posar la paraula de pas i usuari, CUPS us canviarà el protocol de http a https i les noves versions de Firefox us donaran un error ja que el certificat és autosignat

Per defecte lppasswd no permet als usuaris que es canviïn la seva pròpia paraula de pas. Per que puguin cal establir el bit setuid:

$ sudo chmod u+s /usr/bin/lppasswd

Els usuaris que poden administrar són aquells que formen part del group especificat a la directiva:

$ cat /etc/cups/cupsd.conf| grep Group
SystemGroup lpadmin

és a dir ldpadmin a l'exemple. Podeu consultar els groups als que pertanyeu amb:

$ groups
sergi adm dialout cdrom plugdev lpadmin sambashare admin

Accedir en mode administrador

Configuració dels clients

La configuració dels clients es realitza amb el fitxer /etc/cups/client.conf. Aquest fitxer conté una serie de directives que configuren el client. La directiva més important és:

ServerName nom_o_ip_del_servidor_cups

El sistema que utilitzem a l'etic no és a nivell de client sino que es pot fer a nivell d'usuari mitjancant el fitxer ~/.cupsrc que es torba a la home de l'usuari.Exemple:

$ cat .cupsrc
ServerName tjener.intern

També es pot utilitzar DNS i així si canviessim el servidor d'impressores de màquina només caldria reconfigurar DNS:

$ cat .cupsrc
ServerName ipp.intern

La configuració de DNS és al fitxer /etc/bind/debian-edu/db.intern:

$cat /etc/bind/debian-edu/db.intern
;; -*- zone -*-
$TTL 1H
@                       IN      SOA     domain.intern. hostmaster.intern. (
                                2004070101      ; serial
                                8H              ; refresh for slaves
                                3H              ; retry
                                4W              ; expire time at slaves
                                1H              ; negative TTL
                                )

                                IN      NS      domain.intern.
                                IN      MX      10 postoffice.intern.
;;;;;;;;;;;;;;;;;;;;;;
; Server with aliases
;;;;;;;;;;;;;;;;;;;;;;
tjener                          IN      A       10.0.2.2
                                IN      AFSDB   1 tjener.intern.
syslog                          IN      CNAME   tjener
bootps                          IN      CNAME   tjener
ntp                             IN      CNAME   tjener
homes                           IN      CNAME   tjener
www                             IN      CNAME   tjener
db                              IN      CNAME   tjener
backup                          IN      CNAME   tjener
webcache                        IN      CNAME   tjener
ipp                             IN      CNAME   tjener
ssh                             IN      CNAME   tjener
cfengine                        IN      CNAME   tjener
ltsp                            IN      CNAME   tjener
ldap                            IN      CNAME   tjener
kerberos                        IN      CNAME   tjener

Extret de http://www.cups.org/doc-1.1/sam.html#CLIENT_SETUP.

Es pot consultar el manual:

$man client.conf

o a l'adreça http://www.cups.org/documentation.php/man-client.conf.html.

Aplicació gnome-cups-manager

Aquí el tema és més sencill. Els usuaris que pertanyen al grup lpadmin i root poden executar l'aplicació gnome-cups-manager que està al menú:

Sistema > Administració > Impressores

També es pot accedir directament amb:

$ gnome-cups-manager

És una alternativa a l'accés per la Interfície web

Configuració

Raw printing server

TODO

     #application/octet-...
  • Do the same for the file /etc/cups/mime.convs.
  • Add a raw printer using the Web interface. Point your browser at http://localhost:631. Enter Administration, and add the printer following the prompts. Do not install any drivers for it. Choose Raw. Choose queue name Raw Queue.
  • In the smb.conf file [printers] section add use client driver = Yes, and in the [global] section add printing = CUPS, plus printcap = CUPS.
  • Install the printer as if it is a local printer, that is, Printing to LPT1:.
  • Edit the configuration under the Detail tab and create a local port that points to the raw printer queue that you have configured above. Example: \\server\raw_q. Here, the name raw_q is the name you gave the print queue in the CUPS environment.

Informació extreta de la secció:

Raw Print Serving: Vendor Drivers on Windows Clients

De:

http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/CUPS-printing.html

Afegir impressores

Fitxer /etc/cups/printers.conf

És el fitxer on el dimoni CUPSd guarda la informació de les impressores.

La documentació la podeu trobar al manual:

$ man printers.conf(5)       Apple  Inc.                                                  printers.conf(5)

NAME
       printers.conf - printer configuration file for cups 

DESCRIPTION
      The  printers.conf file defines the local printers that are available. It is normally located in the /etc/cups directory a
      and is generated automatically by the cupsd(8) program when printers
      are added or deleted.

      Each line in the file can be a configuration directive, a blank line, or a comment. Comment lines start with the # 
      character.

DIRECTIVES
      <Printer name> ... </Printer>
           Defines a specific printer.

      <DefaultPrinter name> ... </Printer>
           Defines a default printer.

      Accepting Yes

      Accepting No
           Specifies whether the printer is accepting new jobs.

      AllowUser [ user @group ... ]
           Allows specific users and groups to print to the printer.

      DenyUser [ user @group ... ]
           Prevents specific users and groups from printing to the printer.

      DeviceURI uri
           Specifies the device URI for a printer.

      ErrorPolicy abort-job

      ErrorPolicy retry-current-job

      ErrorPolicy retry-job

      ErrorPolicy stop-printer
           Specifies the error policy for the printer.

      Info text
           Specifies human-readable text describing the printer.

      JobSheets banner banner
           Specifies the banner pages to use for the printer.

      KLimit number
           Specifies the job-k-limit value for the printer.

      Location text
           Specifies human-readable text describing the location of the printer.

      OpPolicy name
           Specifies the operation policy for the printer.

      PageLimit number
           Specifies the job-page-limit value for the printer.

      PortMonitor monitor
           Specifies the port monitor for a printer.

      QuotaPeriod seconds
           Specifies the job-quota-period value for the printer.

      Shared Yes

      Shared No
           Specifies whether the printer is shared.

      State idle

      State stopped
           Specifies the initial state of the printer (Idle or Stopped)

      StateMessage text
           Specifies the message associated with the state.

      StateTime seconds
           Specifies the date/time associated with the state.

SEE ALSO
      classes.conf(5), cupsd(8), cupsd.conf(5), mime.convs(5), mime.types(5),
      http://localhost:631/help

COPYRIGHT
      Copyright 2007-2009 by Apple Inc.

29 April 2009                                                                                    
CUPS                                                                                printers.conf(5)

Un exemple de fitxer:

# Printer configuration file for CUPS v1.4.4
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
<DefaultPrinter HP-Deskjet-5800>
Info HP Deskjet 5800
MakeModel HP Deskjet 5800 hpijs, 3.10.6
DeviceURI hp:/net/deskjet_5800?ip=192.168.0.223
State Idle
StateTime 1315405289
Type 8425500
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 100 foomatic-rip
Filter application/vnd.cups-pdf 0 foomatic-rip
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
 ErrorPolicy retry-job
</Printer>
 <Printer HP-LaserJet-P2015>
Info HP LaserJet P2015
MakeModel HP LaserJet P2015 Series Postscript (recommended)
DeviceURI socket://192.168.20.201:9100
State Idle
StateTime 1306493881
Type 8425668
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-command 0 commandtops
Filter application/vnd.cups-postscript 0 -
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</Printer>
<Printer HP-LaserJet-P2055dn> 
Info HP LaserJet P2055dn
MakeModel HP LaserJet p2055dn hpijs pcl3, 3.10.6
DeviceURI hp:/net/HP_LaserJet_P2055dn?ip=192.168.0.221
State Idle
StateTime 1307440681
Type 8425500
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 100 foomatic-rip
Filter application/vnd.cups-pdf 0 foomatic-rip
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</Printer>
<Printer HP-Photosmart-C5100-series>
Info HP Photosmart C5100 series
MakeModel HP Photosmart c5100 Series hpijs, 3.10.6
DeviceURI hp:/net/Photosmart_C5100_series?zc=maninfo5180
State Stopped
StateMessage /usr/lib/cups/backend/hp failed
StateTime 1304673422
Reason paused
Reason marker-supply-low-warning
Type 8425500
Filter application/vnd.cups-raw 0 -
Filter application/vnd.cups-postscript 100 foomatic-rip
Filter application/vnd.cups-pdf 0 foomatic-rip
Filter application/vnd.cups-command 0 commandtops
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy retry-job
</Printer>

Interfície web

Per accedir a la interfície web cal posar la URL al navegador (p.ex. Firefox):

http://localhost:631

NOTA: Veureu que la interfície web, a l'instal·lació per defecte, només està disponible a localhost mitjançant l'interficie loopback (suposeu que la IP del servidor és 192.168.0.3):

$ nmap 192.168.0.3 -p 631
...
631/tcp closed ipp
Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

En canvi:

$ nmap localhost
...
631/tcp  open  ipp
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds

Com permetre la connexió a la interfície web des de màquines remotes

Al fitxer de configuració del servidor /etc/cups/cupsd.conf cal modificar les línies:

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock

Com podeu veure només utilitza la targeta de xarxa loopback. Si poseu (o afegiu si voleu mantenir la connexió per localhost):

Listen IP_SERVIDOR:631

o

Port 631
# Only listen for connections from the local machine.
#Listen localhost:631
Listen /var/run/cups/cups.sock

NOTA: Desconec si té alguna implicació terure'l, però per si de cas deixeu la connexió mitjançant socket Linux, fitxer /var/run/cups/cups.sock

Ara es podrà accedir a la interfície web posant la ip del servidor des d'una màquina remota. Si ho intenteu posant la següent URL al vostre navegador (Firefox):

http://IP_DEL_SERVIDOR:631

Us donarà l'error 403 Forbidden. Cal que doneu permisos per evitar els error 403 Acces Forbidden. Consulteu:

CUPS#403_Forbidden

I per tal de poder accedir a les seccions d'administració us caldrà crear un usuari amb lppasswd. Consulteu:

CUPS#Establir_usuari_i_password_dels_usuaris_administradors

Recordeu d'aplicar els canvis:

$ sudo /etc/init.d/cups reload

Interfície web (skolelinux)

L'adreça és http://tjener.intern:631/. El port típic de cups és 631 (IPP: Internet Printing Protocol):

# cat /etc/services | grep 631
ipp             631/tcp                         # Internet Printing Protocol
ipp             631/udp

La interfície web té parts que son públiques i altres que només son pels administradors. A més, hi ha la limitació que només es pugui accedri com a administrador desde local (servidor tjener).

Si intentem accedir desde una màquina remota a parts d'administració ens donara un error 403 Forbidden Acces:

Forbidden
You don't have permission to access the resource on this server. 

Per executar en local podem entrar amb freenx o utilitzar el X11Forwarding de SSH.

$ ssh -X sergi.tur@10.0.2.2
Password:
Warning: No xauth data; using fake authentication data for X11 forwarding.
Linux tjener.intern 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686 GNU/Linux

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

Last login: Tue Jul 25 14:21:51 2006 from etic1.intern
Bienvenido sergi.tur! tjener.intern está listo para t.
===============================================================
= OJO!!!! SERVER ETIC!!!!!!!!! =
===============================================================
$mozilla-firefox

Un cop ens surti la finestra de firefox demanem la pàgina http://localhost:631. El usuari i password seràn els que hem establert amb la comanda lppasswd.

Logging

Loglevel

En cas de tenir problemes amb CUPS, pot ser recomanable canviar el nivell de Log de:

LogLevel warn

a

LogLevel debug


Fitxers de log

El fitxer d'error de CUPS a Ubuntu el trobareu a /var/log/cups/error_log. El podeu consultar amb:

$ sudo tail -f /var/log/cups/error_log

També hi ha un fitxer de log que registra els accesos a la interfície web de CUPS:

$ sudo tail -f /var/log/cups/access_log
192.168.111.17 - - [16/Oct/2010:10:47:42 +0200] "POST /admin/ HTTP/1.1" 200 127 - -
localhost - - [16/Oct/2010:10:47:42 +0200] "POST /admin/ HTTP/1.1" 401 140 CUPS-Delete-Printer successful-ok
192.168.111.17 - - [16/Oct/2010:10:47:42 +0200] "POST /admin/ HTTP/1.1" 401 127 - -
192.168.111.17 - - [16/Oct/2010:10:47:42 +0200] "POST /admin/ HTTP/1.1" 200 127 - -
192.168.111.17 - - [16/Oct/2010:10:47:48 +0200] "POST /admin/ HTTP/1.1" 200 127 - -
localhost - - [16/Oct/2010:10:47:50 +0200] "POST /admin/ HTTP/1.1" 401 140 CUPS-Delete-Printer successful-ok
...

Ordres

El paquet client (cups-client) ofereix les següent ordres:

$ dpkg -L cups-client | grep bin
/usr/bin
/usr/bin/cancel
/usr/bin/cupstestppd
/usr/bin/cupstestdsc
/usr/bin/lp
/usr/bin/lpoptions
/usr/bin/lppasswd
/usr/bin/lpstat
/usr/sbin
/usr/sbin/cupsaddsmb
/usr/sbin/lpadmin
/usr/sbin/lpinfo
/usr/sbin/lpmove
/usr/sbin/cupsaccept
/usr/sbin/cupsctl
/usr/sbin/accept
/usr/sbin/reject
/usr/sbin/cupsreject
/usr/sbin/cupsdisable
/usr/sbin/cupsenable

lpadmin

Consulteu el manual:

$ man lpadmin

Exemple de com afegir una impressora:

$ lpadmin -p mysmbtstprn -v socket://10.160.51.131:9100 -E -P canonIR85.ppd

cupsaddsmb

Consulteu cupsaddsmb.

Cancel

Per cancel·lar tots els treballs pendents:

$ cancel -a

Consulteu:

$ man cancel

Cups pdf

Aquest paquet éens proporciona la opció d'imprimir documents en PDF. Cal instal·lar:

$ sudo apt-get install cups-pd

Ara ja podem afegir la impressora des de el menú Sistema/Administració/Impressores. Seleccionem impressora nova, i fem servir la impressora detectada com a PDF printer (Virtual Printer).

Seleccionem una impressora genèrica i postscript color.

El fitxer impresos com a PDF es guarden a la HOME en una carpeta anomenada PDF.

Pot ser que sigui necessari reiniciar Cups:

$ sudo /etc/init.d/cupsys restart

Recursos:

Samba i CUPS

Consulteu Samba i CUPS

Aplicacions

API de CUPS

Permet desenvolupar aplicacions que treballin amb CUPS. Per exemple és utilitzat per Samba (consulteu Samba i CUPS i altres eines d'impressió).

Impressores

HP 1018

hp-check -t

$ hp-check -t
Summary of needed commands to run to satisfy missing dependencies:
sudo aptitude install --assume-yes libcupsys2-dev cupsys-bsd
sudo aptitude install --assume-yes libdbus-1-dev
sudo aptitude install --assume-yes build-essential
sudo aptitude install --assume-yes openssl
sudo aptitude install --assume-yes libjpeg62-dev
sudo aptitude install --assume-yes libsnmp-dev
sudo aptitude install --assume-yes libtool
sudo aptitude install --assume-yes libusb-dev
sudo aptitude install --assume-yes python-qt4-dbus
sudo aptitude install --assume-yes python2.5-dev
sudo aptitude install --assume-yes python-reportlab
sudo aptitude install --assume-yes libsane-dev

Instal·lem doncs:

$ sudo aptitude install --assume-yes libcupsys2-dev cupsys-bsd libdbus-1-dev libdbus-1-dev build-essential openssl libjpeg62-dev libsnmp-dev libtool libusb-dev python-
qt4-dbus python2.5-dev python-reportlab libsane-dev

Ara podem utilitzar l'eina:

$ hp-tools

La impressora no funciona o es queda penjada després de falta de paper

Torneu-la a configurar amb:

$ sudo hp-setup

També per pujar el firmware a l'impresora:

$ sudo hp-firmware -i

HP Linux Imaging and Printing System (ver. 3.9.2)
Firmware Download Utility ver. 2.4  

Copyright (c) 2001-9 Hewlett-Packard Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

Using device: hp:/usb/HP_LaserJet_1018?serial=KP0CWLF

Passos a seguir abans de la versió 8.04?

A Ubuntu cal executar:

$ sudo apt-get install build-essential
$ wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz
$ tar zxf foo2zjs.tar.gz
$ cd foo2zjs
$ sudo make uninstall
$ make
$ ./getweb 1018
$ sudo make install install-hotplug cups

El hotplug s'encarrega de carregar el firware cada cop. Per comprovar que tot esta bé es pot utilitzar:

$ sudo usb_printerid /dev/usb/lp0
MFG:Hewlett-Packard;MDL:HP LaserJet 1018;CMD:ACL;CLS:PRINTER;DES:HP LaserJet 1018;FWVER:20051028;

o

 sudo usb_printerid /dev/usblp0 
GET_DEVICE_ID string:
MFG:Hewlett-Packard;MDL:HP LaserJet 1018;CMD:ACL;CLS:PRINTER;DES:HP LaserJet 1018;FWVER:20051028;

Impresora no habilitada

A vegades cal marcar la impressora com habilitada a la gestió d'impressores (a polítiques Estat).

Problemes amb Gutsy. Desaparició de /dev/usb/lp0

Sembla ser que hi ha un error a Hal que fa que la impressora es quedi fregida al tenir algun error (com per exemple quedar-se sense paper). El problema és que reiniciant la impresora això s'hauria de solucionar però res de res (només em funcionava al reiniciar amb Windows).

El problema és veu amb:

$ dmesg | grep usb
[ 2183.719640] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid  0x03F0 pid 0x4117

Quan dona aquest missatge tot esta bé. Quan es penja dona

$ dmesg | grep usb
[ 2250.324369] /build/buildd/linux-source-2.6.22-2.6.22/drivers/usb/class/usblp.c: usblp0: removed

Sembla que l'error esta solucionat a la versió Hardy. Jo encara no m'he atrevit a aventurar-me a una nova versió i he fet les següents passes per instal·lar la nova versió del paquet hal-cups-utils:

NOTA: Sembla que podeu saltar aquests passos...

$ cd
$ mkdir test
$ cd test
$ wget https://launchpad.net/ubuntu/hardy/+source/hal-cups-utils/0.6.13+svn86-0ubuntu1/+files/hal-cups-utils_0.6.13+svn86.orig.tar.gz
$ wget https://launchpad.net/ubuntu/hardy/+source/hal-cups-utils/0.6.13+svn86-0ubuntu1/+files/hal-cups-utils_0.6.13+svn86-0ubuntu1.diff.gz
$ wget https://launchpad.net/ubuntu/hardy/+source/hal-cups-utils/0.6.13+svn86-0ubuntu1/+files/hal-cups-utils_0.6.13+svn86-0ubuntu1.dsc
$ dpkg-source -x hal-cups-utils_0.6.13+svn86-0ubuntu1.dsc
$ cd hal-cups-utils-0.6.13+svn86
$ sudo apt-get install cdbs libcupsys2-dev
$ fakeroot
# dpkg-buildpackage
# exit
$ cd ..
$ sudo dpkg -i hal-cups-utils_0.6.13+svn86-0ubuntu1_i386.deb 

I també cal assegurar-se de tenir el firmware adequat a la carpeta adequada

$ cd /usr/share/foo2zjs/firmware
$ getweb 1018
$ sudo -i
# arm2hpdl sihp1018.img > sihp1018.dl
# rm sihp1018.img
# exit

Bugs Ubuntu:

Cups i Ldap

Resol·lució de problemes

403 Forbidden

Cal editar el fitxer /etc/cups/cupsd.conf:

$ sudo joe /etc/cups/cupsd.conf

i posar:

Allow all

a les seccions:

...
# Restrict access to the server...
<Location />
  Order allow
  Allow all
</Location>  

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow all
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow all
</Location>

I aplicar els canvis amb:

$ sudo /etc/init.d/cups reload

Vegeu també

Enllaços externs

Manuals,referències i pàgines web: