<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <meta name="generator" content="HTML Tidy, see www.w3.org">
    <title>SAMBA and LPRng</title>
    <meta name="GENERATOR" content=
    "Modular DocBook HTML Stylesheet Version 1.7">
    <link rel="HOME" title=" LPRng Reference Manual" href=
    "index.htm">
    <link rel="UP" title="Installation" href="installation.htm">
    <link rel="PREVIOUS" title=
    "Emulation for UNIX SystemV lp and lpstat " href=
    "lpsimulation.htm">
    <link rel="NEXT" title="Security Concerns " href="setuid.htm">
  </head>

  <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link=
  "#0000FF" vlink="#840084" alink="#0000FF">
    <div class="NAVHEADER">
      <table summary="Header navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <th colspan="3" align="center">LPRng Reference Manual: 24
          Sep 2004 (For LPRng-3.8.28)</th>
        </tr>

        <tr>
          <td width="10%" align="left" valign="bottom"><a href=
          "lpsimulation.htm" accesskey="P">Prev</a></td>

          <td width="80%" align="center" valign="bottom">Chapter 2.
          Installation</td>

          <td width="10%" align="right" valign="bottom"><a href=
          "setuid.htm" accesskey="N">Next</a></td>
        </tr>
      </table>
      <hr align="LEFT" width="100%">
    </div>

    <div class="SECT1">
      <h1 class="SECT1"><a name="SMB">2.12. SAMBA and <b class=
      "APPLICATION">LPRng</b></a></h1>

      <p>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 <a
      href="http://www.samba.org" target=
      "_top">http://www.samba.org</a>. The SAMBA code is extremely
      easy to install and the <acronym class=
      "ACRONYM">SWAT</acronym> (Samba Web Administration Tool)
      makes configuration almost trivial.</p>

      <p>See the SAMBA <tt class=
      "FILENAME">doc/text/Printing.txt</tt> and related
      documentation for details on printing. In the <tt class=
      "FILENAME">samba.conf</tt> file <var class=
      "LITERAL">[global]</var> section or in the SWAT page for
      printing configuration you need to specify the that you want
      to have Samba handle printing, the <var class=
      "LITERAL">print</var>, <b class="APPLICATION">lpq</b>, and <b
      class="APPLICATION">lprm</b> 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.</p>

      <div class="INFORMALEXAMPLE">
        <a name="AEN1384"></a>
<pre class="SCREEN">
    [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
</pre>
      </div>
      <br>
      <br>

      <ol type="1">
        <li>
          <p>Samba will make a copy of the files to be printed in
          the directory specified by <var class=
          "LITERAL">path</var>. If the print operation fails then
          sometimes the print file is left in the directory.</p>
        </li>

        <li>
          <p>The directory should have the same ownership and
          permissions as <tt class="FILENAME">/tmp</tt>, i.e.-
          owner and group <var class="LITERAL">root</var> and <var
          class="LITERAL">bin</var>, with <var class=
          "LITERAL">01777</var> permissions, where <var class=
          "LITERAL">01000</var> is the sticky bit.</p>

          <p>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.</p>
        </li>

        <li>
          <p>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 <b
          class="APPLICATION">cron</b> facility:</p>

          <div class="INFORMALEXAMPLE">
            <a name="AEN1401"></a>
<pre class="SCREEN">
    find /var/spool/lpd/samba -type f -mtime 2d -exec rm -f {} \;
</pre>
          </div>
          <br>
          <br>
        </li>

        <li>
          <p>You must specify the print method as <var class=
          "LITERAL">printing = lprng</var>. This will allow Samba
          to parse the <b class="APPLICATION">LPRng</b> <b class=
          "APPLICATION">lpq</b> status format correctly.</p>
        </li>

        <li>
          <p>You must put all of the printers which Samba has
          access to in the <tt class="FILENAME">printcap</tt> 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:</p>

          <div class="INFORMALEXAMPLE">
            <a name="AEN1411"></a>
<pre class="SCREEN">
    [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'
   
</pre>
          </div>
          <br>
          <br>

          <p>The <var class="LITERAL">lpc client all</var> 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.</p>
        </li>

        <li>
          <p>Samba can be configured to allow guests or
          non-authenticated users to spool print jobs.
          Unfortunately, by default <b class="APPLICATION">lpr</b>
          will mark the jobs as submitted by the Samba server, not
          the remote users. To solve this problem, the <tt class=
          "COMMAND">lpr -U%U@%M</tt> option causes <b class=
          "APPLICATION">lpr</b> to mark the jobs as submitted by
          user <var class="LITERAL">%U</var> on host <var class=
          "LITERAL">%M</var>, instead of the Samba server process.
          The use of this option is restricted to root and a set of
          userids listed in the <a href=
          "allowusersetting.htm">allow_user_setting</a>
          configuration option. If the userid of the submitter is
          not in this list, then the option is quietly ignored. The
          <tt class="COMMAND">-U%U@M</tt> can also be used with the
          other LPRng commands as well. For example:</p>

          <div class="INFORMALEXAMPLE">
            <a name="AEN1424"></a>
<pre class="SCREEN">
    [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
</pre>
          </div>
          <br>
          <br>
        </li>
      </ol>

      <p>When Samba gets a request for print queue status, it runs
      the <var class="LITERAL">lpq command</var> 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.</p>

      <p>&gt;</p>

      <p>One of the problems that might occur is when the <b class=
      "APPLICATION">LPRng</b> <var class="LITERAL">done_jobs</var>
      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:</p>

      <div class="INFORMALEXAMPLE">
        <a name="AEN1432"></a>
<pre class="SCREEN">
    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
</pre>
      </div>
      <br>
      <br>

      <p>In this example, the <var class="LITERAL">done</var> 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 <b class="APPLICATION">lpq</b>
      command reports that your job has completed but Samba reports
      that it is printing or is stopped, then you should disable
      the <var class="LITERAL">done_jobs</var> option in the
      printcap entry:</p>

      <div class="INFORMALEXAMPLE">
        <a name="AEN1438"></a>
<pre class="SCREEN">
    lp:
      :done_jobs=0
      :...
</pre>
      </div>
      <br>
      <br>
    </div>

    <div class="NAVFOOTER">
      <hr align="LEFT" width="100%">

      <table summary="Footer navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="33%" align="left" valign="top"><a href=
          "lpsimulation.htm" accesskey="P">Prev</a></td>

          <td width="34%" align="center" valign="top"><a href=
          "index.htm" accesskey="H">Home</a></td>

          <td width="33%" align="right" valign="top"><a href=
          "setuid.htm" accesskey="N">Next</a></td>
        </tr>

        <tr>
          <td width="33%" align="left" valign="top">Emulation for
          UNIX SystemV <b class="APPLICATION">lp</b> and <b class=
          "APPLICATION">lpstat</b></td>

          <td width="34%" align="center" valign="top"><a href=
          "installation.htm" accesskey="U">Up</a></td>

          <td width="33%" align="right" valign="top">Security
          Concerns</td>
        </tr>
      </table>
    </div>
  </body>
</html>



syntax highlighted by Code2HTML, v. 0.9.1