LPRng Reference Manual: 5 Sep 2003 (For LPRng-3.8.22)
Prev | Chapter 2. Installation | Next

# 2.12. SAMBA and LPRng

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.

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 name = /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  stop %p
            queueresume command = /usr/sbin/lpc start %p

1. 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.

2. The directory should have the same ownership and permissions as `/tmp`, i.e.- owner and group root and bin, with 01777 permissions, where 01000 is the sticky bit.

   A directory whose `sticky bit' is set becomes an append-only directory, or, more accurately, a directory in which the deletion of files is re- stricted. A file in a sticky directory may only be removed or renamed by a user if the user has write permission for the directory and the user is the owner of the file, the owner of the directory, or the super-user. This feature is usefully applied to directories such as /tmp which must be publicly writable but should deny users the license to arbitrarily delete or rename each others' files.

3. 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 {} \;

4. You must specify the print method as printing = lprng. This will allow Samba to parse the LPRng lpq status format correctly.

5. 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 name = |/usr/local/libexec/filters/getpc
             # or
               printcap name = |/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.

6. Samba can be configured to allow guests or non-authenticated users to spool print jobs. Unfortunately, by default lpr will mark the jobs as submitted by the Samba server, not the remote users. To solve this problem, the `lpr -U%U@%M` option causes lpr to mark the jobs as submitted by user %U on host %M, instead of the Samba server process. The use of this option is restricted to root and a set of userids listed in the allow_user_setting configuration option. If the userid of the submitter is not in this list, then the option is quietly ignored. The `-U%U@M` can also be used with the other LPRng commands as well. For example:

           [printers]
               guest ok = yes
               print command =       /usr/bin/lpr  -U%U@%M -P%p -r %s
               lpq command   =       /usr/bin/lpq  -U%U@%M -P%p
               lprm command  =       /usr/bin/lprm -U%U@%M -P%p %j
               lppause command =     /usr/sbin/lpc -U%U@%M hold %p %j
               lpresume command =    /usr/sbin/lpc -U%U@%M release %p %j
               queuepause command =  /usr/sbin/lpc -U%U@%M stop %p
               queueresume command = /usr/sbin/lpc -U%U@%M start %p

When Samba gets a request for print queue status, it runs the lpq command program and then parses the output of this command. Unfortunately, different versions of Samba have different ways of parsing the output - some are more flexible than others.

>

One of the problems that might occur is when the LPRng done_jobs feature is enabled. This causes that status of the last few jobs to be retained so that users can see what happened to their jobs. For example:

        h110: {588} % lpq
        Printer: t1@h110 'Test Printer 1'
         Queue: no printable jobs in queue
         Server: no server active
         Status: job 'papowell@h110+336' saved at 14:42:54.607
         Filter_status: FILTER DONE
         Rank   Owner/ID         Class Job Files    Size Time
        done   papowell@h110+336   A   336 /tmp/hi     3 14:42:53

In this example, the done job will have its status displayed by the lpq command. However, this may confuse Samba, and it may report odd or unusual status for your jobs. If the lpq command reports that your job has completed but Samba reports that it is printing or is stopped, then you should disable the done_jobs option in the printcap entry:

        lp:
          :done_jobs=0
          :...

Prev | Home | Next
Emulation for UNIX SystemV lp and lpstat | Up | Security Concerns