1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 3<html> 4 <head> 5 <meta name="generator" content="HTML Tidy, see www.w3.org"> 6 <title>SAMBA and LPRng</title> 7 <meta name="GENERATOR" content= 8 "Modular DocBook HTML Stylesheet Version 1.7"> 9 <link rel="HOME" title=" LPRng Reference Manual" href= 10 "index.htm"> 11 <link rel="UP" title="Installation" href="installation.htm"> 12 <link rel="PREVIOUS" title= 13 "Emulation for UNIX SystemV lp and lpstat " href= 14 "lpsimulation.htm"> 15 <link rel="NEXT" title="Security Concerns " href="setuid.htm"> 16 </head> 17 18 <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link= 19 "#0000FF" vlink="#840084" alink="#0000FF"> 20 <div class="NAVHEADER"> 21 <table summary="Header navigation table" width="100%" border= 22 "0" cellpadding="0" cellspacing="0"> 23 <tr> 24 <th colspan="3" align="center">LPRng Reference Manual: 5 25 Sep 2003 (For LPRng-3.8.22)</th> 26 </tr> 27 28 <tr> 29 <td width="10%" align="left" valign="bottom"><a href= 30 "lpsimulation.htm" accesskey="P">Prev</a></td> 31 32 <td width="80%" align="center" valign="bottom">Chapter 2. 33 Installation</td> 34 35 <td width="10%" align="right" valign="bottom"><a href= 36 "setuid.htm" accesskey="N">Next</a></td> 37 </tr> 38 </table> 39 <hr align="LEFT" width="100%"> 40 </div> 41 42 <div class="SECT1"> 43 <h1 class="SECT1"><a name="SMB">2.12. SAMBA and <b class= 44 "APPLICATION">LPRng</b></a></h1> 45 46 <p>The SMB network protocol is used by many Microsoft 47 Operating Systems to implement file and printer sharing. 48 SAMBA is a UNIX package that implements the SMB protocol and 49 provides a simple and easy way to import and export file 50 systems and printer facilities. The web site for SAMBA is <a 51 href="http://www.samba.org" target= 52 "_top">http://www.samba.org</a>. The SAMBA code is extremely 53 easy to install and the <acronym class= 54 "ACRONYM">SWAT</acronym> (Samba Web Administration Tool) 55 makes configuration almost trivial.</p> 56 57 <p>See the SAMBA <tt class= 58 "FILENAME">doc/text/Printing.txt</tt> and related 59 documentation for details on printing. In the <tt class= 60 "FILENAME">samba.conf</tt> file <var class= 61 "LITERAL">[global]</var> section or in the SWAT page for 62 printing configuration you need to specify the that you want 63 to have Samba handle printing, the <var class= 64 "LITERAL">print</var>, <b class="APPLICATION">lpq</b>, and <b 65 class="APPLICATION">lprm</b> commands to be used when a user 66 prints a job, asks for status, or removes a job, and a 67 temporary directory to hold print jobs when they are 68 submitted. The following is a simple example of to set up 69 printing for authenticated users.</p> 70 71 <div class="INFORMALEXAMPLE"> 72 <a name="AEN1384"></a> 73<pre class="SCREEN"> 74 [printers] 75 path = /var/spool/lpd/samba 76 # --- do not use the Samba default path = /tmp 77 print ok = yes 78 printing = lprng 79 load printers = yes 80 guest ok = no 81 printcap name = /etc/printcap 82 print command = /usr/bin/lpr -P%p -r %s 83 lpq command = /usr/bin/lpq -P%p 84 lprm command = /usr/bin/lprm -P%p %j 85 lppause command = /usr/sbin/lpc hold %p %j 86 lpresume command = /usr/sbin/lpc release %p %j 87 queuepause command = /usr/sbin/lpc stop %p 88 queueresume command = /usr/sbin/lpc start %p 89</pre> 90 </div> 91 <br> 92 <br> 93 94 <ol type="1"> 95 <li> 96 <p>Samba will make a copy of the files to be printed in 97 the directory specified by <var class= 98 "LITERAL">path</var>. If the print operation fails then 99 sometimes the print file is left in the directory.</p> 100 </li> 101 102 <li> 103 <p>The directory should have the same ownership and 104 permissions as <tt class="FILENAME">/tmp</tt>, i.e.- 105 owner and group <var class="LITERAL">root</var> and <var 106 class="LITERAL">bin</var>, with <var class= 107 "LITERAL">01777</var> permissions, where <var class= 108 "LITERAL">01000</var> is the sticky bit.</p> 109 110 <p>A directory whose `sticky bit' is set becomes an 111 append-only directory, or, more accurately, a directory 112 in which the deletion of files is re- stricted. A file in 113 a sticky directory may only be removed or renamed by a 114 user if the user has write permission for the directory 115 and the user is the owner of the file, the owner of the 116 directory, or the super-user. This feature is usefully 117 applied to directories such as /tmp which must be 118 publicly writable but should deny users the license to 119 arbitrarily delete or rename each others' files.</p> 120 </li> 121 122 <li> 123 <p>The directory should be examined periodically and 124 files older then a day should be removed. The following 125 command can be used to do this, and should be put in a 126 file that is periodically (one a day) executed by the <b 127 class="APPLICATION">cron</b> facility:</p> 128 129 <div class="INFORMALEXAMPLE"> 130 <a name="AEN1401"></a> 131<pre class="SCREEN"> 132 find /var/spool/lpd/samba -type f -mtime 2d -exec rm -f {} \; 133</pre> 134 </div> 135 <br> 136 <br> 137 </li> 138 139 <li> 140 <p>You must specify the print method as <var class= 141 "LITERAL">printing = lprng</var>. This will allow Samba 142 to parse the <b class="APPLICATION">LPRng</b> <b class= 143 "APPLICATION">lpq</b> status format correctly.</p> 144 </li> 145 146 <li> 147 <p>You must put all of the printers which Samba has 148 access to in the <tt class="FILENAME">printcap</tt> file. 149 Your Samba server may support reading the printcap file 150 by using a program. In this case the printcap file entry 151 can be one of the following:</p> 152 153 <div class="INFORMALEXAMPLE"> 154 <a name="AEN1411"></a> 155<pre class="SCREEN"> 156 [printers] 157 # 158 printcap name = |/usr/local/libexec/filters/getpc 159 # or 160 printcap name = |/usr/bin/lpc client all 161 162 #!/bin/sh 163 # getpc program 164 /usr/bin/lpq -as | /bin/sed -e 's/[@:].*//p' 165 166</pre> 167 </div> 168 <br> 169 <br> 170 171 <p>The <var class="LITERAL">lpc client all</var> command 172 will generate the printcap entries for all of the 173 printers. This was done to support Samba and other 174 printer gateway systems. You can also use a simple script 175 to modify the output of the printer status command as 176 shown in the example.</p> 177 </li> 178 179 <li> 180 <p>Samba can be configured to allow guests or 181 non-authenticated users to spool print jobs. 182 Unfortunately, by default <b class="APPLICATION">lpr</b> 183 will mark the jobs as submitted by the Samba server, not 184 the remote users. To solve this problem, the <tt class= 185 "COMMAND">lpr -U%U@%M</tt> option causes <b class= 186 "APPLICATION">lpr</b> to mark the jobs as submitted by 187 user <var class="LITERAL">%U</var> on host <var class= 188 "LITERAL">%M</var>, instead of the Samba server process. 189 The use of this option is restricted to root and a set of 190 userids listed in the <a href= 191 "allowusersetting.htm">allow_user_setting</a> 192 configuration option. If the userid of the submitter is 193 not in this list, then the option is quietly ignored. The 194 <tt class="COMMAND">-U%U@M</tt> can also be used with the 195 other LPRng commands as well. For example:</p> 196 197 <div class="INFORMALEXAMPLE"> 198 <a name="AEN1424"></a> 199<pre class="SCREEN"> 200 [printers] 201 guest ok = yes 202 print command = /usr/bin/lpr -U%U@%M -P%p -r %s 203 lpq command = /usr/bin/lpq -U%U@%M -P%p 204 lprm command = /usr/bin/lprm -U%U@%M -P%p %j 205 lppause command = /usr/sbin/lpc -U%U@%M hold %p %j 206 lpresume command = /usr/sbin/lpc -U%U@%M release %p %j 207 queuepause command = /usr/sbin/lpc -U%U@%M stop %p 208 queueresume command = /usr/sbin/lpc -U%U@%M start %p 209</pre> 210 </div> 211 <br> 212 <br> 213 </li> 214 </ol> 215 216 <p>When Samba gets a request for print queue status, it runs 217 the <var class="LITERAL">lpq command</var> program and then 218 parses the output of this command. Unfortunately, different 219 versions of Samba have different ways of parsing the output - 220 some are more flexible than others.</p> 221 222 <p>></p> 223 224 <p>One of the problems that might occur is when the <b class= 225 "APPLICATION">LPRng</b> <var class="LITERAL">done_jobs</var> 226 feature is enabled. This causes that status of the last few 227 jobs to be retained so that users can see what happened to 228 their jobs. For example:</p> 229 230 <div class="INFORMALEXAMPLE"> 231 <a name="AEN1432"></a> 232<pre class="SCREEN"> 233 h110: {588} % lpq 234 Printer: t1@h110 'Test Printer 1' 235 Queue: no printable jobs in queue 236 Server: no server active 237 Status: job 'papowell@h110+336' saved at 14:42:54.607 238 Filter_status: FILTER DONE 239 Rank Owner/ID Class Job Files Size Time 240 done papowell@h110+336 A 336 /tmp/hi 3 14:42:53 241</pre> 242 </div> 243 <br> 244 <br> 245 246 <p>In this example, the <var class="LITERAL">done</var> job 247 will have its status displayed by the lpq command. However, 248 this may confuse Samba, and it may report odd or unusual 249 status for your jobs. If the <b class="APPLICATION">lpq</b> 250 command reports that your job has completed but Samba reports 251 that it is printing or is stopped, then you should disable 252 the <var class="LITERAL">done_jobs</var> option in the 253 printcap entry:</p> 254 255 <div class="INFORMALEXAMPLE"> 256 <a name="AEN1438"></a> 257<pre class="SCREEN"> 258 lp: 259 :done_jobs=0 260 :... 261</pre> 262 </div> 263 <br> 264 <br> 265 </div> 266 267 <div class="NAVFOOTER"> 268 <hr align="LEFT" width="100%"> 269 270 <table summary="Footer navigation table" width="100%" border= 271 "0" cellpadding="0" cellspacing="0"> 272 <tr> 273 <td width="33%" align="left" valign="top"><a href= 274 "lpsimulation.htm" accesskey="P">Prev</a></td> 275 276 <td width="34%" align="center" valign="top"><a href= 277 "index.htm" accesskey="H">Home</a></td> 278 279 <td width="33%" align="right" valign="top"><a href= 280 "setuid.htm" accesskey="N">Next</a></td> 281 </tr> 282 283 <tr> 284 <td width="33%" align="left" valign="top">Emulation for 285 UNIX SystemV <b class="APPLICATION">lp</b> and <b class= 286 "APPLICATION">lpstat</b></td> 287 288 <td width="34%" align="center" valign="top"><a href= 289 "installation.htm" accesskey="U">Up</a></td> 290 291 <td width="33%" align="right" valign="top">Security 292 Concerns</td> 293 </tr> 294 </table> 295 </div> 296 </body> 297</html> 298 299