The SMB network protocol is used by many Microsoft Operating Systems to implement file and printer sharing. SAMBA is a UNIX package that implements the SMB protocol and provides a simple and easy way to import and export file systems and printer facilities. The web site for SAMBA is http://www.samba.org. The SAMBA code is extremely easy to install and the SWAT (Samba Web Administration Tool) makes configuration almost trivial.
The See the SAMBA doc/text/Printing.txt and related documentation for details on printing. In the samba.conf file [global] section or in the SWAT page for printing configuration you need to specify the that you want to have Samba handle printing, the print, lpq, and lprm commands to be used when a user prints a job, asks for status, or removes a job, and a temporary directory to hold print jobs when they are submitted. The following is a simple example of to set up printing for authenticated users.
[printers] path = /var/spool/lpd/samba # --- do not use the Samba default path = /tmp print ok = yes printing = lprng load printers = yes guest ok = no printcap file = /etc/printcap print command = /usr/bin/lpr -P%p -r %s lpq command = /usr/bin/lpq -P%p lprm command = /usr/bin/lprm -P%p %j lppause command = /usr/sbin/lpc hold %p %j lpresume command = /usr/sbin/lpc release %p %j queuepause command = /usr/sbin/lpc -P%p stop queueresume command = /usr/sbin/lpc -P%p start
Samba will make a copy of the files to be printed in the directory specified by path. If the print operation fails then sometimes the print file is left in the directory. The directory should be examined periodically and files older then a day should be removed. The following command can be used to do this, and should be put in a file that is periodically (one a day) executed by the cron facility:
find /var/spool/lpd/samba -type f -mtime 2d -exec rm -f {} \;
You must specify the print method as printing = lprng. This will allow Samba to parse the LPRng lpq status format correctly.
You must put all of the printers which Samba has access to in the printcap file. Your Samba server may support reading the printcap file by using a program. In this case the printcap file entry can be one of the following:
[printers] # printcap file = |/usr/local/libexec/filters/getpc # or printcap file = |/usr/bin/lpc client all #!/bin/sh # getpc program /usr/bin/lpq -as | /bin/sed -e 's/[@:].*//p'
The lpc client all command will generate the printcap entries for all of the printers. This was done to support Samba and other printer gateway systems. You can also use a simple script to modify the output of the printer status command as shown in the example.
If you want to allow all users to print without using authentication, then lpr -U%U@%M causes lpr to act as though user %U on host %M was the originator of the lpr request instead of the Samba server process. This makes jobs appear to be spooled by the user and commands appear to originate with the user. The use of this option is restricted; see the allow_user_setting configuration option for details. The option can also be used with the other LPRng commands as well.
[printers] guest ok = yes print command = /usr/bin/lpr -U%U@%H -P%p -r %s lpq command = /usr/bin/lpq -U%U@%H -P%p lprm command = /usr/bin/lprm -U%U@%H -P%p %j lppause command = /usr/sbin/lpc -U%U@%H hold %p %j lpresume command = /usr/sbin/lpc -U%U@%H release %p %j queuepause command = /usr/sbin/lpc -U%U@%H -P%p stop queueresume command = /usr/sbin/lpc -U%U@%H -P%p start