Section 7.2. A Usable Print Share

7.2. A Usable Print Share

When planning a new print share, you must know a few pieces of information. The values in parantheses are what we will use for this information in our example print share:

  • The name of the printer (hp2100)

  • The name of the print share (postscript)

  • The type of printing supported by the OS for this queue (BSD)

  • The directory that will be used to store jobs sent from clients (/var/spool/samba)

Using this information, we can create the following initial print share:

 [postscript]     print ok = yes     printing = bsd     path = /var/spool/samba     print command = /usr/bin/lpr -Php2100 %s; /bin/rm %s     lpq command   = /usr/bin/lpq -Php2100     lprm command  = /usr/bin/lprm -Php2100 %j     queue pause command  = /usr/sbin/lpc stop hp2100     queue resume command = /usr/sbin/lpc start hp2100 

To ensure that all users can send jobs to the printer, the /var/spool/samba directory has been assign world-writable permissions (chmod 1777 /var/spool/samba).

We could have defined printer name = hp2100 and replaced the string hp2100 with the %p variable. In the absence of the printer name option, the %p variable defaults to the name of the share itself. So if we rename the share to [hp2100], we can simplify the service definition to the following:

 [hp2100]     print ok = yes     printing = bsd     path = /var/spool/samba     print command = /usr/bin/lpr -P%p %s; /bin/rm %s     lpq command   = /usr/bin/lpq -P%p     lprm command  = /usr/bin/lprm -P%p %j     queue pause command  = /usr/sbin/lpc stop %p     queue resume command = /usr/sbin/lpc start %p 

It would be nice if there were a way to define aliased names for shares. The closest possibility is the copy parameter discussed in Chapter 4. However, creating a new share named [postscript] and setting it as a copy of the [hp2100] service would break the %p variable, because the printer name option would default to postscript rather than hp2100. A satisfactory solution entails creating a postscript alias for the hp2100 in /etc/printcap, which would appear as:

 hp2100|postscript:\     <remaining printcap options:....> 

One common problem that arises using any external commands in smb.conf occurs when Samba is unable to locate the program or script in the current PATH setting. This is why absolute paths to the BSD printing tools are used in these examples (and why we did not simply accept the default printing values).

If all the printers on your server use the same printing hooks, you can move most of these parameters to the [global] section. The path directive is still defined in the individual printer section, however, since you would not want /var/spool/samba to become to the default path for all file shares as well:

 [global]     ## set printing defaults for all queues     printing = bsd     print command = /usr/bin/lpr -P%p %s; /bin/rm %s     lpq command   = /usr/bin/lpq -P%p     lprm command  = /usr/bin/lprm -P%p %j     queue pause command  = /usr/sbin/lpc stop %p     queue resume command = /usr/sbin/lpc start %p [hp2100]     print ok = yes     path = /var/spool/samba 

File shares and print shares are very similar in both smb.conf and the CIFS protocol, so you can often reuse parameters discussed in the context of file shares for new printers. In our example, we can assign a comment to the print share by adding the following line to the [hp2100] share. Users will then be able to view the printer's description when browsing the share details:

     comment = Classroom laser printer in RM 114 

Some of the parameters, such as store dos attributes, are specific to file shares and make no sense for a printer, just as the print command is irrelevant for a file share. Such parameters are ignored when they are inapplicable to a given smb.conf service.

We can use smbclient to test our new example [hp2100] print share. In order to do so, we must have at least one valid user account on the Samba host. This example reuses the account named lizard defined in Chapter 2 and assumes an associated password of test. For the test, we use smbclient to print the local /etc/hosts file.

 $ smbclient //localhost/hp2100 -U lizard%test Domain=[VALE] OS=[Unix] Server=[Samba 3.0.22] smb: \> lcd /etc smb: \> print hosts putting file hosts as hosts (8.9 kb/s) (average 8.9 kb/s) smb: \> queue 1        1083         Remote Downlevel Document hosts 

If this command does not succeed, there are several places to start looking. First check the Samba logfiles for error messages returned by the print command option. Also ensure that the spool directory specified by the path parameter is writable by the connected user. If Samba appears to be functioning correctly but no paper appears at the printer, it is time to review Unix print system debugging techniques.

Using Samba
Using Samba: A File and Print Server for Linux, Unix & Mac OS X, 3rd Edition
ISBN: 0596007698
EAN: 2147483647
Year: 2004
Pages: 135 © 2008-2017.
If you may any questions please contact us: