Integrating CUPS with Samba

In addition to files, you can share printers with Samba. To do this, you first need to set up your Linux printing environment. In Chapter 14 you can read how to do this with CUPS. After setting up the CUPS environment, Samba will share all CUPS printers automatically. Note that this may be convenient in a home network but probably isn't a good idea to do in a professional network environment. In Listing 15-5 you can see the parameters from the default Samba configuration file that enable printer sharing with Samba.

Listing 15-5. The Default Samba Configuration File [global]

printing = cups printcap name = cups printcap cache time = 750 cups options = raw [printers]

comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No

comment = Printer Drivers path = /var/lib/samba/drivers write list = @ntadmin root force group = ntadmin create mask = 0664 directory mask = 0775

As you can see, the Samba printing environment consists of three parts. First, the section [global] uses four parameters to determine how printing should be handled:

printing = cups: With this option, CUPS is defined as the default printing system. Alternatively, you could use the legacy LPD print system. CUPS, however, is so much more advanced that modern Linux systems don't use LPD anymore. Therefore, printing = cups is a good default value.

printcap name = cups: This parameter indicates that the file containing printer definitions is not the legacy /etc/printcap file but the CUPS subsystem. You need this line if you are using CUPS for printing.

printcap cache time = 750: This option specifies the number of seconds before Samba checks the CUPS configuration again to see whether any new printers were defined. This is a reasonable setting that makes sure new printers are automatically integrated in your Samba environment every 12.5 minutes.

cups options = raw: With this option, you specify how print jobs offered to the CUPS server are handled. Since CUPS can't understand the data format generated by the Samba server, you should set this option to raw. Since interpreting print jobs is the job of the CUPS subsystem, you should leave this setting like this.

After the generic options in the [global] section, you must define two shares for the printers. The share [printers] sets up an environment where all printers can store their temporary print jobs. The [print$] share stores printer drivers. Just keep them at their default values; they'll work fine that way.

In the previous example, all printers on the server are shared. It is possible to share just one printer as well. Listing 15-6 shows an example of this.

Listing 15-6. Sharing One Printer Only

[laserprinter]

printable = yes printer = hv1430 path = /var/tmp

In this example, a share with the name laserprinter is defined. This share just needs three options. The first option, printable = yes, indicates that this is a printer and not a shared directory. The most important line is printer = hv1430; this line refers to the queue as it is defined in the CUPS subsystem. Lastly, the option path = /var/tmp indicates what directory should be used for the temporary spooling of printer jobs.

When sharing printers with your Samba server, you have to take care of the drivers as well. You could choose to install the drivers at the Windows workstation locally. This, however, would force you to maintain them on each individual workstation, which is not an ideal situation. Therefore, it is easier to install printer drivers on the Samba server. To do this, you need the share [print$]. Listing 15-7 shows the default values of this share.

Listing 15-7. The [print$] Share Allows for Storage of Printer Drivers at the Samba Server [print$]

comment = Printer Drivers path = /var/lib/samba/drivers write list = @ntadmin root force group = ntadmin create mask = 0664 directory mask = 0775

This example uses some important options. First, this is the name of the directory where the printer drivers are stored. Next, the write list option specifies what users are allowed to write to this directory; it should be write-accessible for root and members of the group ntadmin only. With these settings in place, you can set up the printer in your Windows environment. The following steps show how to do this:

1. On Windows, start the Add Printer Wizard.

2. Indicate that you want to add a network printer and then browse to the shared printer. Tell the wizard you want to install a new printer driver.

3. Now select the printer model for which you want to install the drivers. This will install the drivers to the /var/lib/samba/drivers directory automatically.

Tip Make sure you are installing the printer drivers from your Windows workstation as a user with sufficient permissions to the printer. By default, only the user root and members of the Linux group ntadmin have permissions to write new printer drivers to the directory /var/lib/samba/drivers.

Was this article helpful?

0 0

Post a comment