Initial import
[samba] / docs / htmldocs / using_samba / ch10.html
1 <html>
2 <body bgcolor="#ffffff">
3
4 <img src="samba2_xs.gif" border="0" alt=" " height="100" width="76"
5 hspace="10" align="left" />
6
7 <h1 class="head0">Chapter 10. Printing</h1>
8
9
10
11 <p><a name="INDEX-1"/>This
12 chapter tackles the topic of setting up printers for use with Samba.
13 Aside from the &quot;coolness factor&quot; of
14 seeing documents from Windows word processing and graphics
15 applications appearing in the output tray of the Unix printer, this
16 facility can greatly increase the usefulness of your Samba server. In
17 many organizations, using a Unix system as the print server has led
18 to happier system administrators and users alike, due to the reduced
19 frequency of problems.</p>
20
21 <p>Samba allows client machines to share printers connected to the Samba
22 host system, and Samba can also send Unix documents to printers
23 shared by Windows systems. In this chapter, we discuss how to get
24 printers configured to work in either direction.</p>
25
26 <p>We focus in this chapter on getting Samba to serve up printers that
27 are already functioning on the Unix host. We include just a few
28 basics about setting up printers on Unix. Good references for this
29 topic include <em class="citetitle">Network Printing</em>,
30 <em class="citetitle">Essential System Administration</em>, and
31 <em class="citetitle">Running Linux</em>, all by
32 O'Reilly and Associates.</p>
33
34
35
36 <div class="sect1"><a name="samba2-CHP-10-SECT-1"/>
37
38 <h2 class="head1">Sending Print Jobs to Samba</h2>
39
40 <p><a name="INDEX-2"/>A
41 printer shared by the Samba server shows up in the list of shares
42 offered in the Network Neighborhood. If the printer is registered on
43 the client machine and the client has the correct printer driver
44 installed, the client can effortlessly send print jobs to a printer
45 attached to a Samba server. <a href="ch10.html#samba2-CHP-10-FIG-1">Figure 10-1</a> shows a
46 Samba printer as it appears in the Network Neighborhood of a Windows
47 client.</p>
48
49 <div class="figure"><a name="samba2-CHP-10-FIG-1"/><img src="figs/sam2_1001.gif"/></div><h4 class="head4">Figure 10-1. A Samba printer in the Network Neighborhood</h4>
50
51 <p>To administer printers with Samba, you should understand the basic
52 process by which
53 <a name="INDEX-3"/>printing
54 takes place on a network. On the client system, the application
55 software prints by utilizing the system's printer
56 driver for the printer that will be creating the actual output. It is
57 the printer driver software running on the client system that
58 translates the application's high-level calls into a
59 stream of binary data specific to the model of printer in use. In the
60 case of a serial, parallel, or USB printer, the data is stored in a
61 temporary file in the local system's printer queue
62 and then sent through the respective port directly to the printer.
63 For a network printer, the file is sent over the network.</p>
64
65 <a name="samba2-CHP-10-NOTE-150"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
66 <p>Because the data has already been processed through a printer driver
67 by the time it reaches the Samba host, make sure the printer on the
68 Unix system is configured without any printer driver and that it will
69 print whatever data it receives in raw form. If you already have the
70 printer configured for use by Unix applications, you might need to
71 set up another queue for it to print documents received from Windows
72 clients correctly.</p>
73 </blockquote>
74
75 <p>Sending a <a name="INDEX-4"/>print job to a printer on a
76 <a name="INDEX-5"/>Samba server involves four steps:</p>
77
78 <ol><li>
79 <p>Opening and authenticating a connection to the printer share</p>
80 </li><li>
81 <p>Copying the file over the network</p>
82 </li><li>
83 <p>Closing the connection</p>
84 </li><li>
85 <p>Printing and deleting the copy of the file</p>
86 </li></ol>
87 <p>When a print job arrives at a Samba server, the print data is
88 temporarily written to disk in the directory specified by the
89 <tt class="literal">path</tt> option of the printer share. Samba then
90 executes a Unix print command to send that datafile to the printer.
91 The job is then printed as the authenticated user of the share. Note
92 that this can be the guest user, depending on how the share is
93 configured.</p>
94
95
96 <div class="sect2"><a name="samba2-CHP-10-SECT-1.1"/>
97
98 <h3 class="head2">Print Commands</h3>
99
100 <p><a name="INDEX-6"/>To print the
101 document, you'll need to inform Samba of the command
102 used to print and delete a file. On Linux, which uses a BSD-style
103 printing system, a command that does this is:</p>
104
105 <blockquote><pre class="code">lpr -r -P<em class="replaceable">printer</em> <em class="replaceable">file</em></pre></blockquote>
106
107 <p>This command tells <a name="INDEX-7"/><em class="emphasis">lpr</em> to retrieve the
108 name of the printer in the system configuration file
109 (<em class="filename">/etc/printcap</em>) and interpret the rules it finds
110 there to decide how to process the data and which physical device to
111 send it to. Note that because the <em class="emphasis">-r</em> option has
112 been specified, the file will be deleted after it has been printed.
113 Of course, the file removed is just a copy stored on the Samba
114 server; the original document on the client is unaffected.</p>
115
116 <p>The process is similar on System V Unix. Here, printing and deleting
117 become a compound command:</p>
118
119 <blockquote><pre class="code">lp -d<em class="replaceable">printer</em> -s <em class="replaceable">file</em>; rm <em class="replaceable">file</em></pre></blockquote>
120
121 <p>In this case, the <em class="filename">/etc/printcap</em> file is replaced
122 with a different set of configuration files residing in
123 <em class="filename">/usr/spool/lp</em>. Because the
124 <em class="emphasis">lp</em> command has no option to delete the file
125 after it is printed, we have added the <em class="emphasis">rm</em>
126 command.</p>
127
128
129 </div>
130
131
132 <div class="sect2"><a name="samba2-CHP-10-SECT-1.2"/>
133
134 <h3 class="head2">A Minimal Printing Setup</h3>
135
136 <p>Let's start with a simple yet illustrative
137 <a name="INDEX-8"/>printing
138 share. Assuming that you're on a Linux system and
139 you have a printer called <tt class="literal">netprinter</tt> listed in the
140 printer capabilities file, the following addition to your
141 <em class="filename">smb.conf</em> file makes the printer accessible
142 through the network:</p>
143
144 <blockquote><pre class="code">[printer1]
145     printable = yes
146     print command = /usr/bin/lpr -P%p -r %s
147     printer = netprinter
148     printing = BSD
149     path = /var/tmp</pre></blockquote>
150
151 <p>The variable <tt class="literal">%s</tt> in the
152 <tt class="literal">print</tt><a name="INDEX-9"/> <tt class="literal">command</tt>
153 option is replaced with the name of the file to be printed when Samba
154 executes the command. There are four Samba configuration-file
155 variables specifically for use with
156 <a name="INDEX-10"/>printing
157 options. They are shown in <a href="ch10.html#samba2-CHP-10-TABLE-1">Table 10-1</a>.</p>
158
159 <a name="samba2-CHP-10-TABLE-1"/><h4 class="head4">Table 10-1. Printing variables</h4><table border="1">
160
161
162
163 <tr>
164 <th>
165 <p>Variable</p>
166 </th>
167 <th>
168 <p>Definition</p>
169 </th>
170 </tr>
171
172
173 <tr>
174 <td>
175 <p><tt class="literal">%s</tt></p>
176 </td>
177 <td>
178 <p>The full pathname of the file on the Samba server to be printed</p>
179 </td>
180 </tr>
181 <tr>
182 <td>
183 <p><tt class="literal">%f</tt></p>
184 </td>
185 <td>
186 <p>The name of the file itself (without the preceding path) on the Samba
187 server to be printed</p>
188 </td>
189 </tr>
190 <tr>
191 <td>
192 <p><tt class="literal">%p</tt></p>
193 </td>
194 <td>
195 <p>The name of the Unix printer to use</p>
196 </td>
197 </tr>
198 <tr>
199 <td>
200 <p><tt class="literal">%j</tt></p>
201 </td>
202 <td>
203 <p>The number of the print job (for use with <tt class="literal">lprm</tt>,
204 <tt class="literal">lppause</tt>, and <tt class="literal">lpresume</tt>)</p>
205 </td>
206 </tr>
207
208 </table>
209
210 <p>For other flavors of Unix, it is necessary to modify both the
211 <tt class="literal">printing</tt> and <tt class="literal">print</tt>
212 <tt class="literal">command</tt> options. For System V Unix, we would
213 specify:</p>
214
215 <blockquote><pre class="code">[printer1]
216     printing = SYSV
217     print command = lp -d%p -s %s; rm %s</pre></blockquote>
218
219 <p>With the <tt class="literal">printing</tt> <tt class="literal">=</tt>
220 <tt class="literal">SYSV</tt> parameter, we notify Samba that the local
221 printing system uses the System V Unix method. As mentioned earlier,
222 the <tt class="literal">%p</tt> variable resolves to the name of the
223 printer, while the <tt class="literal">%s</tt> variable resolves to the
224 name of the file.</p>
225
226 <p>Clients might need to request the status of a print job sent to the
227 Samba server. Because Samba sends print jobs to the Unix printing
228 system for spooling, there might be a number of jobs in the queue at
229 any given time. Consequently, Samba needs to communicate to the
230 client not only the status of the current printing job, but also
231 which documents are waiting to be printed on that printer. Samba also
232 has to provide the client the ability to pause print jobs, resume
233 print jobs, and remove print jobs from the printing queue. Samba
234 provides options for each of these tasks. As you might expect, they
235 borrow functionality from the following existing Unix commands:</p>
236
237 <ul><li>
238 <p><tt class="literal">lpq</tt><a name="INDEX-11"/></p>
239 </li><li>
240 <p><tt class="literal">lprm</tt><a name="INDEX-12"/></p>
241 </li><li>
242 <p><tt class="literal">lppause</tt><a name="INDEX-13"/></p>
243 </li><li>
244 <p><tt class="literal">lpresume</tt><a name="INDEX-14"/></p>
245 </li></ul>
246 <p>We cover these options in more detail later in this chapter. For the
247 most part, Samba provides reasonable default values for them based on
248 the value of the <tt class="literal">printing</tt> configuration option, so
249 you can probably get by without having to formulate your own commands
250 for them.</p>
251
252 <p>Here are a few important items to remember about
253 <a name="INDEX-15"/>printing shares:</p>
254
255 <ul><li>
256 <p>You must put
257 <tt class="literal">printable</tt><a name="INDEX-16"/> <tt class="literal">=</tt>
258 <tt class="literal">yes</tt> in all printer shares (even
259 <tt class="literal">[printers]</tt>) so that Samba knows they are printer
260 shares. If you forget, the shares will be unusable for printing and
261 will instead be treated as disk shares.</p>
262 </li><li>
263 <p>If you set the <tt class="literal">path</tt> configuration option in the
264 printer section, any files sent to the printer(s) will be copied to
265 the directory you specify instead of to the default location of
266 <em class="filename">/tmp</em>. Because the amount of disk space allocated
267 to <em class="filename">/tmp</em> can be relatively small in some Unix
268 operating systems, many administrators prefer to use
269 <em class="filename">/var/tmp, /var/spool/tmp</em>, or some other
270 directory instead.</p>
271 </li><li>
272 <p>If you set <tt class="literal">guest</tt> <tt class="literal">ok</tt>
273 <tt class="literal">=</tt> <tt class="literal">yes</tt> in a printer share and
274 Samba is configured for share-level security, anyone can send data to
275 the printer as the <tt class="literal">guest</tt>
276 <tt class="literal">account</tt> user.</p>
277 </li></ul>
278 <p>Using one or more Samba machines as a print server gives you a great
279 deal of flexibility on your LAN. You can easily partition your
280 available printers, restricting some to members of one department, or
281 you can maintain a bank of printers available to all. In addition,
282 you can restrict a printer to a select few by adding the
283 <tt class="literal">valid</tt> <tt class="literal">users</tt> option to its share
284 definition:</p>
285
286 <blockquote><pre class="code">[deskjet]
287     printable = yes
288     path = /var/spool/samba/print
289     valid users = elizabeth cozy jack heather alexander lina emerald</pre></blockquote>
290
291 <p>All the other share accessibility options work for printing shares as
292 well.</p>
293
294
295 </div>
296
297
298 <div class="sect2"><a name="samba2-CHP-10-SECT-1.3"/>
299
300 <h3 class="head2">The [printers] Share</h3>
301
302 <p>If a share named
303 <tt class="literal">[printers]</tt><a name="INDEX-17"/> is in the configuration file,
304 Samba will automatically read in your printer capabilities file and
305 create a printing share for each printer that appears in the file.
306 For example, if the Samba server had <tt class="literal">lp</tt>,
307 <tt class="literal">pcl</tt>, and <tt class="literal">ps</tt> printers in its
308 printer capabilities file, Samba would provide three printer shares
309 with those names, each configured with the options in the
310 <tt class="literal">[printers]</tt> share.</p>
311
312 <p>Recall that Samba obeys the following rules when a client requests a
313 share that has not been created with an explicit share definition in
314 the <em class="filename">smb.conf</em> file:</p>
315
316 <ul><li>
317 <p>If the share name matches a username in the system password file and
318 a <tt class="literal">[homes]</tt> share exists, a new share is created
319 with the name of the user and is initialized using the values given
320 in the <tt class="literal">[homes]</tt> and <tt class="literal">[global]</tt>
321 sections.</p>
322 </li><li>
323 <p>Otherwise, if the name matches a printer in the system printer
324 capabilities file and a <tt class="literal">[printers]</tt> share exists, a
325 new share is created with the name of the printer and initialized
326 using the values given in the <tt class="literal">[printers]</tt> section.
327 (Variables in the <tt class="literal">[global]</tt> section do not apply
328 here.)</p>
329 </li><li>
330 <p>If neither of those succeeds, Samba looks for a
331 <tt class="literal">default</tt> <tt class="literal">service</tt> share. If none
332 is found, it returns an error.</p>
333 </li></ul>
334 <p>This brings to light an important point: be careful that you do not
335 give a printer the same name as a user. Otherwise, users end up
336 connecting to a disk share when they might have wanted a printer
337 share instead.</p>
338
339 <p>Here is an example
340 <tt class="literal">[printers]</tt><a name="INDEX-18"/> share for a Linux system. Some of
341 these options are already defaults; however, we have listed them
342 anyway for illustrative purposes:</p>
343
344 <blockquote><pre class="code">[printers]
345     printable = yes
346     printing = BSD
347     printcap name = /etc/printcap
348     print command = /usr/bin/lpr -P%p -r %s
349     path = /var/spool/lpd/tmp
350     min print space = 2000</pre></blockquote>
351
352 <p>Here, we've given Samba global options that specify
353 the printing type (BSD), a print command to send data to the printer
354 and later remove the temporary file, the location of our printer
355 capabilities file, and a minimum disk space for printing of 2MB.</p>
356
357 <p>In addition, we've created a
358 <tt class="literal">[printers]</tt> share for each system printer. Our
359 temporary spooling directory is specified by the
360 <tt class="literal">path</tt> option:
361 <em class="filename">/var/spool/lpd/tmp</em>. Each share is marked as
362 printable&mdash;this is a necessary option, even in the
363 <tt class="literal">[printers]</tt> section.</p>
364
365
366 </div>
367
368
369 <div class="sect2"><a name="samba2-CHP-10-SECT-1.4"/>
370
371 <h3 class="head2">Testing the Configuration</h3>
372
373 <p><a name="INDEX-19"/>After running
374 <em class="emphasis">testparm</em> and restarting the Samba daemons, you
375 can check to make sure everything is set up correctly by using
376 <em class="emphasis">smbclient</em><a name="INDEX-20"/><a name="INDEX-21"/> to send a file to the printer.
377 Connect to the printer using the command:</p>
378
379 <blockquote><pre class="code"># <tt class="userinput"><b>smbclient /</b></tt><em class="replaceable">server</em><tt class="userinput"><b>/</b></tt><em class="replaceable">printshare</em></pre></blockquote>
380
381 <p>and then use the <em class="emphasis">print</em> command to print a file:</p>
382
383 <blockquote><pre class="code">smb: /&gt; <tt class="userinput"><b>print </b></tt><em class="replaceable">textfile</em></pre></blockquote>
384
385 <a name="samba2-CHP-10-NOTE-151"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
386 <p>If you connect to a print share served by a Windows 95/98/Me system
387 configured to use user-mode security and cannot authenticate using
388 what you know to be a correct username and password, try
389 reconfiguring the Windows system to use share-mode security.</p>
390 </blockquote>
391
392 <p>When you print something through the Samba server via
393 <em class="emphasis">smbclient</em>, the following actions should occur:</p>
394
395 <ul><li>
396 <p>The job appears (briefly) in the Samba spool directory specified by
397 the path.</p>
398 </li><li>
399 <p>The job shows up in your print system's spool
400 directory.</p>
401 </li><li>
402 <p>The job disappears from the spool directory that Samba used.</p>
403 </li></ul>
404 <p>If <em class="emphasis">smbclient</em> cannot print, you can reset the
405 <tt class="literal">print</tt> <tt class="literal">command</tt> option to collect
406 debugging information:</p>
407
408 <blockquote><pre class="code">print command = echo &quot;printed %s on %p&quot; &gt;&gt;/tmp/printlog</pre></blockquote>
409
410 <p>A <a name="INDEX-22"/>common
411 problem with Samba printer configuration is forgetting to use the
412 full pathnames for commands. Another frequent problem is not having
413 the correct permissions on the spooling directory.<a name="FNPTR-1"/><a href="#FOOTNOTE-1">[1]</a> As usual,
414 check your Samba log files and system log files for error messages.
415 If you use BSD printing, you can change the <tt class="literal">lp</tt>
416 keyword in the printer's printcap entry to something
417 other than <em class="filename">/dev/null</em>, allowing you to collect
418 error messages from the printing system.</p>
419
420 <a name="samba2-CHP-10-NOTE-152"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
421 <p>More information on
422 <a name="INDEX-23"/>debugging printers is in the file
423 <em class="filename">docs/textdocs/Printing.txt</em> in the Samba source
424 distribution. The Unix print systems are covered in detail in
425 <a name="INDEX-24"/>&AElig;leen
426 Frisch's <em class="emphasis">Essential Systems
427 Administration</em> (published by O'Reilly).</p>
428 </blockquote>
429
430
431 </div>
432
433
434 <div class="sect2"><a name="samba2-CHP-10-SECT-1.5"/>
435
436 <h3 class="head2">Enabling SMB Printer Sharing in Mac OS X</h3>
437
438 <p>With Samba preinstalled with
439 <a name="INDEX-25"/><a name="INDEX-26"/>Mac OS X, sharing access to a printer
440 among Windows clients is easy. First, of course, you should set up
441 local access using the Print Center application (located in
442 <em class="filename">/Applications/Utilities</em>). Under the Printers
443 menu, select Add Printer..., and make the appropriate selection from
444 the pop-up menu. For example, if the printer is directly attached,
445 select USB; if the printer is powered on, it should appear in the
446 list. Choose the printer, and press the Add button.</p>
447
448 <p>Edit <em class="filename">/etc/smb.conf</em>, uncommenting the
449 <tt class="literal">[printers]</tt> share and making any additional
450 configuration changes you feel are necessary. Finally, enable the
451 Samba startup item as described in <a href="ch02.html">Chapter 2</a>,
452 either by checking Windows File Sharing in Sharing Preferences or by
453 manually editing <em class="filename">/etc/hostconfig</em>. Now your
454 printer can be used by remote Windows clients.</p>
455
456 <p>On Mac OS X and some other BSD-based systems, you can test your
457 configuration using
458 <em class="emphasis">smbutil</em><a name="INDEX-27"/>. The following will send the
459 file named <em class="filename">print_test_file</em> to the printer named
460 <em class="filename">printshare</em> on the server
461 <em class="emphasis">bsdserver</em> :</p>
462
463 <blockquote><pre class="code">% <tt class="userinput"><b>smbutil print //bsdserver/printshare print_test_file</b></tt></pre></blockquote>
464
465 <p>See <a href="ch05.html">Chapter 5</a> for more information on using
466 <em class="emphasis">smbutil</em>.</p>
467
468
469 </div>
470
471
472 <div class="sect2"><a name="samba2-CHP-10-SECT-1.6"/>
473
474 <h3 class="head2">Setting Up and Testing a Windows Client</h3>
475
476 <p><a name="INDEX-28"/>Now that Samba is
477 offering a workable printer, you can set up your access to it on a
478 Windows client. Browse through the Samba server in the Network
479 Neighborhood. It should now show each printer that is available. For
480 example, in <a href="ch10.html#samba2-CHP-10-FIG-1">Figure 10-1</a>, we saw a printer called
481 <tt class="literal">lp</tt>.</p>
482
483 <p>Next, you need to have the Windows client recognize the printer.
484 Double-click the printer icon to get started. If you try to select an
485 uninstalled printer (as you just did), Windows will ask you if it
486 should help configure it for the Windows system. Click the Yes or OK
487 button, and the Printer Wizard will open.</p>
488
489 <p>If you are installing a printer on Windows 95/98/Me, the first thing
490 the wizard will ask is whether you need to print from DOS.
491 Let's assume you don't, so choose
492 the &quot;No&quot; radio button and press the
493 Next &gt; button to get to the manufacturer/model window, as shown in
494 <a href="ch10.html#samba2-CHP-10-FIG-2">Figure 10-2</a>.</p>
495
496 <div class="figure"><a name="samba2-CHP-10-FIG-2"/><img src="figs/sam2_1002.gif"/></div><h4 class="head4">Figure 10-2. Setting the manufacturer and model of the printer</h4>
497
498 <p>In this dialog box, you should see a large list of manufacturers and
499 models for a huge number of printers. Select the manufacturer of your
500 printer in the left side of the dialog box, and then the exact model
501 of the printer in the list on the right side.</p>
502
503 <p>In some cases, you might not find your printer in the list, or the
504 version of the printer driver included with Windows might be out of
505 date. In cases such as these, consult the printer
506 manufacturer's documentation on how to install the
507 driver. Typically, you will click the Have Disk... button to install
508 the driver from a CD-ROM or disk file.</p>
509
510 <p>If you don't see your printer on the list, but you
511 know it's a PostScript printer, select Apple as the
512 manufacturer and Apple LaserWriter as the model. This will give you
513 the most basic PostScript printer setup&mdash;and arguably one of the
514 most reliable. If you already have PostScript printers attached, you
515 will be asked about replacing or reusing the existing driver. Be
516 aware that if you replace it with a new one, you might make your
517 other printers fail. Therefore, we recommend you keep using your
518 existing printer drivers as long as they're working
519 properly.</p>
520
521 <p>Click the Next &gt; or OK button. On Windows 95/98/Me, the Printer
522 Wizard asks you to name the printer. On Windows NT/2000/XP, you need
523 to right-click the printer's icon and select
524 Properties to assign the printer a name. <a href="ch10.html#samba2-CHP-10-FIG-3">Figure 10-3</a>
525 shows how we've named our printer to show that
526 it's shared by the <tt class="literal">mixtec</tt> Samba
527 server.</p>
528
529 <div class="figure"><a name="samba2-CHP-10-FIG-3"/><img src="figs/sam2_1003.gif"/></div><h4 class="head4">Figure 10-3. Setting the printer name</h4>
530
531 <p>Finally, on Windows 95/98/Me the Printing Wizard asks if it should
532 print a test page. Click the &quot;Yes&quot;
533 radio button, then the Finish button, and you should be presented
534 with the dialog box shown in <a href="ch10.html#samba2-CHP-10-FIG-4">Figure 10-4</a>. On Windows
535 NT/2000/XP, the printer test function is also accessed through the
536 printer's Properties dialog box.</p>
537
538 <div class="figure"><a name="samba2-CHP-10-FIG-4"/><img src="figs/sam2_1004.gif"/></div><h4 class="head4">Figure 10-4. Sending a test page to the printer</h4>
539
540 <p>If the test printing was unsuccessful, click the No button and the
541 Printing Wizard will walk you through some debugging steps for the
542 client side of the process. If the test printing does work, the
543 remote printer will now be available to all Windows applications
544 through the File and Print menu items.</p>
545
546
547 </div>
548
549
550 </div>
551
552
553
554 <div class="sect1"><a name="samba2-CHP-10-SECT-2"/>
555
556 <h2 class="head1">Printing to Windows Printers</h2>
557
558 <p><a name="INDEX-29"/>If you have printers
559 connected to systems running Windows 95/98/Me or Windows NT/2000/XP,
560 the printers can also be accessed from your Unix system using tools
561 that are part of the Samba distribution. First, it is necessary to
562 create a printer share on the Windows system. Then set up the printer
563 on the Unix side by configuring a new printer and using a Samba
564 printing program as the printer's filter.</p>
565
566
567 <div class="sect2"><a name="samba2-CHP-10-SECT-2.1"/>
568
569 <h3 class="head2">Sharing Windows Printers</h3>
570
571 <p>Sharing printers on Windows is not unlike sharing files. In fact, it
572 is a little simpler. Open the Control Panel, then double-click the
573 Printers icon to open the Printers window. Right-click the icon for
574 the printer you want to share, and select Sharing.... This opens the
575 dialog box shown in <a href="ch10.html#samba2-CHP-10-FIG-5">Figure 10-5</a> for a Windows 98
576 system, or <a href="ch10.html#samba2-CHP-10-FIG-6">Figure 10-6</a> on a Windows 2000 system.
577 (The dialog box appears slightly different on other Windows versions,
578 but functions almost identically.)</p>
579
580 <a name="samba2-CHP-10-NOTE-153"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
581 <p>On Windows 95/98/Me systems, you may need to run file sharing in
582 share-level (rather than user-level) access control mode to access a
583 shared printer from Samba. To check or set this mode, go to Control
584 Panel, then double-click on Network, then click on the Access Control
585 tab. More detailed information on this can be found in <a href="ch05.html">Chapter 5</a>.</p>
586 </blockquote>
587
588 <div class="figure"><a name="samba2-CHP-10-FIG-5"/><img src="figs/sam2_1005.gif"/></div><h4 class="head4">Figure 10-5. Sharing printers on Windows 98</h4>
589
590 <div class="figure"><a name="samba2-CHP-10-FIG-6"/><img src="figs/sam2_1006.gif"/></div><h4 class="head4">Figure 10-6. Sharing printers on Windows 2000</h4>
591
592 <p>Click the &quot;Shared as&quot; radio button,
593 then click the OK button. The printer is now accessible by other
594 systems on the network.</p>
595
596
597 </div>
598
599
600 <div class="sect2"><a name="samba2-CHP-10-SECT-2.2"/>
601
602 <h3 class="head2">Adding a Unix Printer</h3>
603
604 <p><a name="INDEX-30"/>The Samba distribution comes with
605 three programs that assist with printing on shared printers. The
606 <em class="emphasis">smbprint</em><a name="INDEX-31"/> program works with systems that use the
607 BSD printing system,
608 <em class="emphasis">smbprint.sysv</em><a name="INDEX-32"/>
609 works with systems that use System V printing, and
610 <em class="emphasis">smbspool</em><a name="INDEX-33"/>
611 works with systems that use the Common Unix Printing System (CUPS).
612 In the following sections we show you how to install printers for
613 each system.</p>
614
615
616 <div class="sect3"><a name="samba2-CHP-10-SECT-2.2.1"/>
617
618 <h3 class="head3">BSD printers</h3>
619
620 <p><a name="INDEX-34"/><a name="INDEX-35"/>The
621 BSD printing system is used by many Unix variants, including Red Hat
622 Linux. With BSD printing, all the printers on the system have an
623 entry in the <em class="filename">/etc/printcap</em> file, which is the
624 database of printer capabilities used by the <em class="emphasis">lpd</em>
625 line printer daemon and other programs that assist with printing. The
626 Red Hat Linux implementation is a bit different in that
627 <em class="filename">/etc/printcap</em> is a machine-generated file, which
628 is re-created every time the <em class="emphasis">lpd</em> daemon is
629 restarted by the <em class="emphasis">/etc/rc.d/init.d/lpd</em> script.
630 Instead of editing <em class="filename">/etc/printcap</em>, we will add an
631 entry for our printer in <em class="filename">/etc/printcap.local</em>,
632 which the system automatically includes verbatim when creating
633 <em class="filename">/etc/printcap</em>.</p>
634
635 <a name="samba2-CHP-10-NOTE-154"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
636 <p>If you are using the version of Samba installed from an RPM file as
637 on Red Hat Linux, you might be able to skip these directions and use
638 the <em class="emphasis">printconf</em> tool, which has support for SMB
639 printers. Unfortunately, this tool might not work correctly if you
640 have installed Samba from the Samba source distribution.</p>
641 </blockquote>
642
643 <p>Here is the entry we added to our
644 <em class="filename">/etc/printcap.local</em><a name="INDEX-36"/><a name="INDEX-37"/> file to support our Hewlett-Packard
645 DeskJet 932C printer, which is shared by <tt class="literal">maya</tt>, a
646 Windows 98 system:</p>
647
648 <blockquote><pre class="code">lp|maya-hp932c:\
649     :cm=HP 932C on maya:\
650     :sd=/var/spool/lpd/maya:\
651     :af=/var/spool/lpd/maya/acct:\
652     :if=/usr/local/samba/bin/smbprint:\
653     :mx=0:\
654     :lp=/dev/null:</pre></blockquote>
655
656 <p>The first line creates names for the printer. We are calling it both
657 <tt class="literal">maya-hp932c</tt>, to describe its location on the
658 network and the type of printer, and <tt class="literal">lp</tt> so that
659 programs will use it as the default printer. The rest of the lines
660 specify keywords and values. The <tt class="literal">cm</tt> keyword allows
661 us to assign a comment string to the printer. The
662 <tt class="literal">sd</tt> and <tt class="literal">af</tt> keywords assign the
663 printer's spool directory and accounting files,
664 respectively. The <tt class="literal">if</tt> keyword assigns the print
665 filter. We are using the <em class="emphasis">smbprint</em> command to
666 send the output to the shared SMB printer. The <tt class="literal">mx</tt>
667 keyword is set to zero to allow any size file to be printed, and
668 <tt class="literal">lp</tt> is set to <em class="filename">/dev/null</em> to
669 discard error messages.</p>
670
671 <p>You can follow our model to create an entry for your own printer. If
672 you want to go beyond the capabilities we used, refer to your
673 system's <em class="emphasis">printcap(5)</em> manual
674 page for a complete listing of keywords.</p>
675
676 <p>Go to your Samba source distribution's root
677 directory, and install the <em class="emphasis">smbprint</em> program like
678 this:</p>
679
680 <blockquote><pre class="code"># <tt class="userinput"><b>cp examples/printing/smbprint /usr/local/samba/bin</b></tt></pre></blockquote>
681
682 <p>We next create the printer's spool directory:</p>
683
684 <blockquote><pre class="code"># <tt class="userinput"><b>cd /var/spool/lpd</b></tt>
685 # <tt class="userinput"><b>mkdir maya</b></tt>
686 # <tt class="userinput"><b>chown lp:lp maya</b></tt>
687 # <tt class="userinput"><b>chmod 700 maya</b></tt></pre></blockquote>
688
689 <p>The <em class="emphasis">smbprint</em> program looks for a file named
690 <em class="filename">.config</em> in the printer's spool
691 directory, which contains information on how to connect to the
692 printer share. We create this file and then fill in the required
693 information:</p>
694
695 <blockquote><pre class="code"># <tt class="userinput"><b>cd maya</b></tt>
696 # <tt class="userinput"><b>&gt;.config</b></tt>
697 # <tt class="userinput"><b>chown lp:lp .config</b></tt>
698 # <tt class="userinput"><b>chmod 600 .config</b></tt></pre></blockquote>
699
700 <p>Use your preferred text editor to edit the
701 <em class="filename">.config</em> file, and enter three lines, like this:</p>
702
703 <blockquote><pre class="code">server=maya
704 service=hp
705 password=&quot;&quot;</pre></blockquote>
706
707 <p>This is for our shared printer having a UNC of
708 <em class="filename">\\maya\hp</em>. When we created the printer share, we
709 did not give it a password, so we use a null password here. If your
710 printer share is on a Windows NT/2000/XP system, use your domain
711 password.</p>
712
713 <p>Finally, restart the printer daemon:</p>
714
715 <blockquote><pre class="code"># <tt class="userinput"><b>/etc/rc.d/init.d/lpd restart</b></tt></pre></blockquote>
716
717 <p>You can now try printing something. Run the following command:</p>
718
719 <blockquote><pre class="code">$ <tt class="userinput"><b>lpr textfile</b></tt></pre></blockquote>
720
721 <p>If you have everything set up correctly, the file prints on the
722 shared printer. If you get &quot;stair
723 stepping&quot; of text, caused by the printer not
724 returning to the left margin at the beginning of every line, modify
725 the <tt class="literal">if</tt> keyword in your printcap entry to run
726 <em class="emphasis">smbprint</em> with the <em class="emphasis">-t</em>
727 option. <a name="INDEX-38"/><a name="INDEX-39"/></p>
728
729
730 </div>
731
732
733
734 <div class="sect3"><a name="samba2-CHP-10-SECT-2.2.2"/>
735
736 <h3 class="head3">System V printers</h3>
737
738 <p><a name="INDEX-40"/><a name="INDEX-41"/>Sending print jobs from a System V Unix
739 system is a little easier than with the BSD system. Here, you need to
740 edit the <em class="filename">smbprint.sysv</em> script in the
741 <em class="filename">examples/printing</em> directory of the Samba
742 distribution and do the following:</p>
743
744 <ol><li>
745 <p>Change the <tt class="literal">server</tt>, <tt class="literal">service</tt>, and
746 <tt class="literal">password</tt> parameters in the script to match the
747 NetBIOS computer name, its shared printer service, and its password,
748 respectively. For example, the following entries would be correct for
749 the service in the previous example:</p>
750
751 <blockquote><pre class="code">server = maya
752 service = hp
753 password = &quot;&quot;</pre></blockquote>
754 </li>
755 <li>
756 <p>Run the following commands, which create a reference for the new
757 printer (which we are naming <tt class="literal">hp_printer</tt>) in the
758 printer capabilities file:</p>
759
760 <blockquote><pre class="code"># <tt class="userinput"><b>lpadmin -p hp_printer -v /dev/null -i./smbprint.sysv</b></tt>
761 # <tt class="userinput"><b>enable hp_printer</b></tt>
762 # <tt class="userinput"><b>accept hp_printer</b></tt></pre></blockquote>
763 </li></ol>
764 <p>After you've done that, restart the Samba daemons
765 and try printing to <tt class="literal">hp_printer</tt> using any standard
766 Unix program.</p>
767
768
769 </div>
770
771
772
773 <div class="sect3"><a name="samba2-CHP-10-SECT-2.2.3"/>
774
775 <h3 class="head3">CUPS printers</h3>
776
777 <p><a name="INDEX-42"/><a name="INDEX-43"/><a name="INDEX-44"/>CUPS<a name="FNPTR-2"/><a href="#FOOTNOTE-2">[2]</a> uses
778 a set of modules, called
779 <em class="firstterm">backends</em><a name="INDEX-45"/>, to send print jobs to various
780 destinations, such as local printers attached to parallel, serial, or
781 Universal Serial Bus (USB) ports, or over the network using Unix line
782 printer daemon (LPD) protocol, Internet Printing Protocol (IPP),
783 AppleTalk Printer Access Protocol (PAP), and so on. The software
784 package does not come with a backend for SMB; the Samba suite
785 includes the <em class="emphasis">smbspool</em>
786 <a name="INDEX-46"/>utility for this purpose.</p>
787
788 <p>To enable printing to remote SMB printers using CUPS, create a
789 symbolic link named <em class="filename">smb</em> in the CUPS backend
790 directory pointing to <em class="emphasis">smbspool</em>. Depending on
791 installation options, these could be in a number of places in the
792 directory hierarchy, so be sure to check your system. Using a common
793 default installation, the command would look like this:</p>
794
795 <blockquote><pre class="code"># <tt class="userinput"><b>ln -s /usr/local/samba/bin/smbspool /usr/lib/cups/backend/smb</b></tt></pre></blockquote>
796
797 <p>Issue a HUP signal to the CUPS daemon, <em class="emphasis">cupsd</em>,
798 and check for the existence of SMB support with the <em class="emphasis">lpinfo
799 -v</em> command. Its output should now include a line that says
800 <tt class="literal">network</tt> <tt class="literal">smb</tt>.</p>
801
802 <p>To add a printer, use the CUPS web interface, accessible on the local
803 system at <em class="emphasis">http://localhost:631/</em>,
804 or use the <em class="emphasis">lpadmin</em> command:</p>
805
806 <blockquote><pre class="code"># <tt class="userinput"><b>lpadmin -p hp932c -E -v smb://maya/hp932c -D &quot;HP 932C on maya&quot;</b></tt></pre></blockquote>
807
808 <p>This creates and enables the new print spool called
809 <tt class="literal">hp932c</tt>. The <em class="emphasis">-v</em> argument
810 specifies the printer device, which in this case is accessed over the
811 network using an SMB URI. If the printer is not guest-accessible,
812 you'll need to provide a username and password in
813 the URI. The full format is as follows:</p>
814
815 <blockquote><pre class="code">smb://[<em class="replaceable">username</em>[:<em class="replaceable">password</em>]@][<em class="replaceable">workgroup</em>/]<em class="replaceable">server</em>/<em class="replaceable">printshare</em></pre></blockquote>
816
817 <p>The <em class="emphasis">lpadmin</em><a name="INDEX-47"/> command makes changes to
818 <em class="filename">/etc/cups/printers.conf</em> and sends a HUP signal
819 to the <em class="emphasis">cupsd</em> daemon, resulting in the creation
820 of a local raw printer spool. In this example, print data is passed
821 in raw format to the Windows system, which has the necessary printer
822 drivers and printer description files to format the data
823 appropriately. The <em class="emphasis">-D</em> option is used to give the
824 printer a comment string.</p>
825
826 <p>Once you have the printer set up, it's time to test
827 it out. CUPS understands both BSD-style and System V-style printing
828 commands, so you can use whichever is more comfortable. Using the BSD
829 <em class="emphasis">lpr</em> command, try something like:</p>
830
831 <blockquote><pre class="code">$ <tt class="userinput"><b>lpr -P hp932c textfile</b></tt></pre></blockquote>
832
833 <p>You should now be set up to use the printer from any application on
834 the Unix system. <a name="INDEX-48"/></p>
835
836
837 </div>
838
839
840 </div>
841
842
843 <div class="sect2"><a name="samba2-CHP-10-SECT-2.3"/>
844
845 <h3 class="head2">Samba Printing Options</h3>
846
847 <p><a href="ch10.html#samba2-CHP-10-TABLE-2">Table 10-2</a> summarizes the Samba <a name="INDEX-49"/><a name="INDEX-50"/>printing
848 options.</p>
849
850 <a name="samba2-CHP-10-TABLE-2"/><h4 class="head4">Table 10-2. Printing configuration options</h4><table border="1">
851
852
853
854
855
856
857 <tr>
858 <th>
859 <p>Option</p>
860 </th>
861 <th>
862 <p>Parameters</p>
863 </th>
864 <th>
865 <p>Function</p>
866 </th>
867 <th>
868 <p>Default</p>
869 </th>
870 <th>
871 <p>Scope</p>
872 </th>
873 </tr>
874
875
876 <tr>
877 <td>
878 <p><tt class="literal">printing</tt></p>
879 </td>
880 <td>
881 <p><tt class="literal">bsd</tt>, <tt class="literal">sysv</tt>,
882 <tt class="literal">cups</tt>, <tt class="literal">hpux</tt>,
883 <tt class="literal">aix</tt>, <tt class="literal">qnx</tt>,
884 <tt class="literal">plp</tt>, <tt class="literal">softq</tt>, or
885 <tt class="literal">lprng</tt></p>
886 </td>
887 <td>
888 <p>Printing system type of the Samba host</p>
889 </td>
890 <td>
891 <p>System-dependent</p>
892 </td>
893 <td>
894 <p>Share</p>
895 </td>
896 </tr>
897 <tr>
898 <td>
899 <p><tt class="literal">printable</tt> <tt class="literal">(print ok)</tt></p>
900 </td>
901 <td>
902 <p>boolean</p>
903 </td>
904 <td>
905 <p>Marks a share as a printing share</p>
906 </td>
907 <td>
908 <p><tt class="literal">no</tt></p>
909 </td>
910 <td>
911 <p>Share</p>
912 </td>
913 </tr>
914 <tr>
915 <td>
916 <p><tt class="literal">printer</tt> <tt class="literal">(printer name)</tt></p>
917 </td>
918 <td>
919 <p>string (Unix printer name)</p>
920 </td>
921 <td>
922 <p>Name for the printer that is shown to clients</p>
923 </td>
924 <td>
925 <p>System-dependent</p>
926 </td>
927 <td>
928 <p>Share</p>
929 </td>
930 </tr>
931 <tr>
932 <td>
933 <p><tt class="literal">lpq cache time</tt></p>
934 </td>
935 <td>
936 <p>numeric (time in seconds)</p>
937 </td>
938 <td>
939 <p>Amount of time in seconds that Samba will cache the printer queue
940 status</p>
941 </td>
942 <td>
943 <p><tt class="literal">10</tt></p>
944 </td>
945 <td>
946 <p>Global</p>
947 </td>
948 </tr>
949 <tr>
950 <td>
951 <p><tt class="literal">postscript</tt></p>
952 </td>
953 <td>
954 <p>boolean</p>
955 </td>
956 <td>
957 <p>Treats all print jobs as PostScript by prefixing
958 <tt class="literal">%!</tt> at the beginning of each file</p>
959 </td>
960 <td>
961 <p><tt class="literal">no</tt></p>
962 </td>
963 <td>
964 <p>Share</p>
965 </td>
966 </tr>
967 <tr>
968 <td>
969 <p><tt class="literal">load printers</tt></p>
970 </td>
971 <td>
972 <p>boolean</p>
973 </td>
974 <td>
975 <p>If <tt class="literal">yes</tt>, automatically loads each printer in the
976 <em class="emphasis">printcap</em> file as printing shares</p>
977 </td>
978 <td>
979 <p><tt class="literal">yes</tt></p>
980 </td>
981 <td>
982 <p>Global</p>
983 </td>
984 </tr>
985 <tr>
986 <td>
987 <p><tt class="literal">print command</tt></p>
988 </td>
989 <td>
990 <p>string (shell command)</p>
991 </td>
992 <td>
993 <p>Unix command to perform printing</p>
994 </td>
995 <td>
996 <p>See below</p>
997 </td>
998 <td>
999 <p>Share</p>
1000 </td>
1001 </tr>
1002 <tr>
1003 <td>
1004 <p><tt class="literal">lpq command</tt></p>
1005 </td>
1006 <td>
1007 <p>string (shell command)</p>
1008 </td>
1009 <td>
1010 <p>Unix command to return the status of the printing queue</p>
1011 </td>
1012 <td>
1013 <p>See below</p>
1014 </td>
1015 <td>
1016 <p>Share</p>
1017 </td>
1018 </tr>
1019 <tr>
1020 <td>
1021 <p><tt class="literal">lprm command</tt></p>
1022 </td>
1023 <td>
1024 <p>string (shell command)</p>
1025 </td>
1026 <td>
1027 <p>Unix command to remove a job from the printing queue</p>
1028 </td>
1029 <td>
1030 <p>See below</p>
1031 </td>
1032 <td>
1033 <p>Share</p>
1034 </td>
1035 </tr>
1036 <tr>
1037 <td>
1038 <p><tt class="literal">lppause command</tt></p>
1039 </td>
1040 <td>
1041 <p>string (shell command)</p>
1042 </td>
1043 <td>
1044 <p>Unix command to pause a job on the printing queue</p>
1045 </td>
1046 <td>
1047 <p>See below</p>
1048 </td>
1049 <td>
1050 <p>Share</p>
1051 </td>
1052 </tr>
1053 <tr>
1054 <td>
1055 <p><tt class="literal">lpresume</tt> <tt class="literal">command</tt></p>
1056 </td>
1057 <td>
1058 <p>string (shell command)</p>
1059 </td>
1060 <td>
1061 <p>Unix command to resume a paused job on the printing queue</p>
1062 </td>
1063 <td>
1064 <p>See below</p>
1065 </td>
1066 <td>
1067 <p>Share</p>
1068 </td>
1069 </tr>
1070 <tr>
1071 <td>
1072 <p><tt class="literal">printcap name</tt></p>
1073
1074 <p><tt class="literal">(printcap)</tt></p>
1075 </td>
1076 <td>
1077 <p>string (filename)</p>
1078 </td>
1079 <td>
1080 <p>Location of the printer capabilities file</p>
1081 </td>
1082 <td>
1083 <p>System-dependent</p>
1084 </td>
1085 <td>
1086 <p>Global</p>
1087 </td>
1088 </tr>
1089 <tr>
1090 <td>
1091 <p><tt class="literal">min print space</tt></p>
1092 </td>
1093 <td>
1094 <p>numeric (size in kilobytes)</p>
1095 </td>
1096 <td>
1097 <p>Minimum amount of free disk space that must be present to print</p>
1098 </td>
1099 <td>
1100 <p><tt class="literal">0</tt></p>
1101 </td>
1102 <td>
1103 <p>Share</p>
1104 </td>
1105 </tr>
1106 <tr>
1107 <td>
1108 <p><tt class="literal">queuepause</tt> <tt class="literal">command</tt></p>
1109 </td>
1110 <td>
1111 <p>string (shell command)</p>
1112 </td>
1113 <td>
1114 <p>Unix command to pause a queue</p>
1115 </td>
1116 <td>
1117 <p>See below</p>
1118 </td>
1119 <td>
1120 <p>Share</p>
1121 </td>
1122 </tr>
1123 <tr>
1124 <td>
1125 <p><tt class="literal">queueresume</tt> <tt class="literal">command</tt></p>
1126 </td>
1127 <td>
1128 <p>string (shell command)</p>
1129 </td>
1130 <td>
1131 <p>Unix command to resume a queue</p>
1132 </td>
1133 <td>
1134 <p>See below</p>
1135 </td>
1136 <td>
1137 <p>Share</p>
1138 </td>
1139 </tr>
1140
1141 </table>
1142
1143
1144 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.1"/>
1145
1146 <h3 class="head3">printing</h3>
1147
1148 <p>The <tt class="literal">printing</tt><a name="INDEX-51"/> configuration option tells
1149 Samba which <a name="INDEX-52"/>printing system to use. There are
1150 several different families of commands to control printing and print
1151 statusing. Samba supports seven different types, as shown in <a href="ch10.html#samba2-CHP-10-TABLE-3">Table 10-3</a>.</p>
1152
1153 <a name="samba2-CHP-10-TABLE-3"/><h4 class="head4">Table 10-3. Printing system types</h4><table border="1">
1154
1155
1156
1157 <tr>
1158 <th>
1159 <p>Variable</p>
1160 </th>
1161 <th>
1162 <p>Definition</p>
1163 </th>
1164 </tr>
1165
1166
1167 <tr>
1168 <td>
1169 <p>BSD</p>
1170 </td>
1171 <td>
1172 <p>Berkeley Unix system</p>
1173 </td>
1174 </tr>
1175 <tr>
1176 <td>
1177 <p>SYSV</p>
1178 </td>
1179 <td>
1180 <p>System V</p>
1181 </td>
1182 </tr>
1183 <tr>
1184 <td>
1185 <p>CUPS</p>
1186 </td>
1187 <td>
1188 <p>Common Unix Printing System</p>
1189 </td>
1190 </tr>
1191 <tr>
1192 <td>
1193 <p>AIX</p>
1194 </td>
1195 <td>
1196 <p>IBM's AIX operating system</p>
1197 </td>
1198 </tr>
1199 <tr>
1200 <td>
1201 <p>HPUX</p>
1202 </td>
1203 <td>
1204 <p>Hewlett-Packard Unix</p>
1205 </td>
1206 </tr>
1207 <tr>
1208 <td>
1209 <p>QNX</p>
1210 </td>
1211 <td>
1212 <p>QNX Realtime Operating System</p>
1213 </td>
1214 </tr>
1215 <tr>
1216 <td>
1217 <p>LPRNG</p>
1218 </td>
1219 <td>
1220 <p>LPR Next Generation</p>
1221 </td>
1222 </tr>
1223 <tr>
1224 <td>
1225 <p>SOFTQ</p>
1226 </td>
1227 <td>
1228 <p>SOFTQ system</p>
1229 </td>
1230 </tr>
1231 <tr>
1232 <td>
1233 <p>PLP</p>
1234 </td>
1235 <td>
1236 <p>Portable Line Printer</p>
1237 </td>
1238 </tr>
1239
1240 </table>
1241
1242 <p>The value for this option must be one of these seven selections. For
1243 example:</p>
1244
1245 <blockquote><pre class="code">printing = SYSV</pre></blockquote>
1246
1247 <p>The default value of this option is system-dependent and is
1248 configured when Samba is first compiled. For most systems, the
1249 <em class="filename">configure</em> script automatically detects the
1250 printing system to be used and configures it properly in the Samba
1251 makefile. However, if your system is a PLP, LPRNG, or QNX printing
1252 system, you need to specify this explicitly in the makefile or the
1253 printing share.</p>
1254
1255 <p>The most common system types are BSD, SYSV, and CUPS. Each printer on
1256 a BSD Unix server is described in the printer capabilities
1257 file&mdash;normally <em class="filename">/etc/printcap</em>. See the
1258 section on the <tt class="literal">printcap</tt> <tt class="literal">file</tt>
1259 parameter for more information on this topic.</p>
1260
1261 <p>Setting the <tt class="literal">printing</tt> configuration option
1262 automatically sets at least three other printing options for the
1263 service in question: <tt class="literal">print</tt>
1264 <tt class="literal">command</tt>, <tt class="literal">lpq</tt>
1265 <tt class="literal">command</tt>, and <tt class="literal">lprm</tt>
1266 <tt class="literal">command</tt>. If you are running Samba on a system that
1267 doesn't support any of the printing styles listed in
1268 <a href="ch10.html#samba2-CHP-10-TABLE-3">Table 10-3</a>, simply set the commands for each of
1269 these manually.</p>
1270
1271
1272 </div>
1273
1274
1275
1276 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.2"/>
1277
1278 <h3 class="head3">printable</h3>
1279
1280 <p>The <tt class="literal">printable</tt><a name="INDEX-53"/> option must be set to
1281 <tt class="literal">yes</tt> to flag a share as a printing service. If this
1282 option is not set, the share will be treated as a disk share instead.
1283 You can set the option as follows:</p>
1284
1285 <blockquote><pre class="code">[printer1]
1286     printable = yes</pre></blockquote>
1287
1288
1289 </div>
1290
1291
1292
1293 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.3"/>
1294
1295 <a name="INDEX-54"/><h3 class="head3">printer</h3>
1296
1297 <p>The option, also called
1298 <tt class="literal">printer</tt><a name="INDEX-55"/> <tt class="literal">name</tt>,
1299 specifies the name of the printer on the server to which the share
1300 points. This option has no default and should be set explicitly in
1301 the configuration file, even though Unix systems themselves often
1302 recognize a default name such as <tt class="literal">lp</tt> for a printer.
1303 For example:</p>
1304
1305 <blockquote><pre class="code">[deskjet]
1306     printer = hpdkjet1</pre></blockquote>
1307
1308
1309 </div>
1310
1311
1312
1313 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.4"/>
1314
1315 <h3 class="head3">lpq cache time</h3>
1316
1317 <p>The global <tt class="literal">lpq</tt><a name="INDEX-56"/> <tt class="literal">cache</tt>
1318 <tt class="literal">time</tt> option allows you to set the number of
1319 seconds for which Samba will remember the current printer status.
1320 After this time elapses, Samba will issue an <em class="emphasis">lpq</em>
1321 command (or whatever command you specify with the
1322 <tt class="literal">lpq</tt> <tt class="literal">command</tt> option) to get a
1323 more up-to-date status that it can report to users. This defaults to
1324 10 seconds, but can be increased if your <tt class="literal">lpq</tt>
1325 <tt class="literal">command</tt> takes an unusually long time to run or you
1326 have lots of clients. A time setting of 0 disables caching of queue
1327 status. The following example resets the time to 30 seconds:</p>
1328
1329 <blockquote><pre class="code">[deskjet]
1330     lpq cache time = 30</pre></blockquote>
1331
1332
1333 </div>
1334
1335
1336
1337 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.5"/>
1338
1339 <h3 class="head3">postscript</h3>
1340
1341 <p>The <tt class="literal">postscript</tt><a name="INDEX-57"/> option forces the
1342 printer to treat all data sent to it as PostScript. It does this by
1343 prefixing the characters <tt class="literal">%!</tt> to the beginning of
1344 the first line of each job. It is normally used with PCs that insert
1345 a <tt class="literal">^D</tt> (control-D or
1346 &quot;end-of-file&quot; mark) in front of the
1347 first line of a PostScript file. It will not, obviously, turn a
1348 non-PostScript printer into a PostScript one. The default value of
1349 this options is <tt class="literal">no</tt>. You can override it as
1350 follows:</p>
1351
1352 <blockquote><pre class="code">[deskjet]
1353     postscript = yes</pre></blockquote>
1354
1355
1356 </div>
1357
1358
1359
1360 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.6"/>
1361
1362 <h3 class="head3">load printers</h3>
1363
1364 <p>The <tt class="literal">load</tt><a name="INDEX-58"/> <tt class="literal">printers</tt>
1365 option tells Samba to create shares for all known printer names and
1366 load those shares into the browse list. Samba will create and list a
1367 printer share for each printer name in
1368 <em class="filename">/etc/printcap</em> (or the system equivalent). For
1369 example, if your
1370 <em class="filename">printcap</em><a name="INDEX-59"/> file looks
1371 like this:<a name="FNPTR-3"/><a href="#FOOTNOTE-3">[3]</a></p>
1372
1373 <blockquote><pre class="code">lp:\
1374   :sd=/var/spool/lpd/lp:\            <i class="lineannotation">spool directory</i>
1375   :mx#0:\                            <i class="lineannotation">maximum file size (none)</i>
1376   :sh:\                              <i class="lineannotation">supress burst header (no)</i>
1377   :lp=/dev/lp1:\                     <i class="lineannotation">device name for output</i>
1378   :if=/var/spool/lpd/lp/filter:      <i class="lineannotation">text filter</i>
1379
1380 laser:\
1381   :sd=/var/spool/lpd/laser:\         <i class="lineannotation">spool directory</i>
1382   :mx#0:\                            <i class="lineannotation">maximum file size (none)</i>
1383   :sh:\                              <i class="lineannotation">supress burst header (no)</i>
1384   :lp=/dev/laser:\                   <i class="lineannotation">device name for output</i>
1385   :if=/var/spool/lpd/lp/filter:      <i class="lineannotation">text filter</i></pre></blockquote>
1386
1387 <p>the shares <tt class="literal">[lp]</tt> and <tt class="literal">[laser]</tt> are
1388 automatically created as valid print shares when Samba is started.
1389 Both shares borrow the configuration options specified in the
1390 <tt class="literal">[printers]</tt> section to configure themselves and are
1391 available in the browse list for the Samba server. The default value
1392 for this option is <tt class="literal">yes</tt>. If you prefer to specify
1393 each printer explicitly in your configuration file, use the
1394 following:</p>
1395
1396 <blockquote><pre class="code">[global]
1397     load printers = no</pre></blockquote>
1398
1399
1400 </div>
1401
1402
1403
1404 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.7"/>
1405
1406 <a name="INDEX-60"/><a name="INDEX-61"/><a name="INDEX-62"/><a name="INDEX-63"/><a name="INDEX-64"/><h3 class="head3">print command, lpq command, lprm command,lppause command, lpresume command</h3>
1407
1408 <p>These options tell Samba which Unix commands control and send data to
1409 the printer. The Unix commands involved are: <em class="emphasis">lpr</em>
1410 (send to Line PRinter), <em class="emphasis">lpq</em> (List Printer
1411 Queue), <em class="emphasis">lprm</em> (Line Printer ReMove), and
1412 optionally <em class="emphasis">lppause</em> and
1413 <em class="emphasis">lpresume</em>. Samba provides an option named after
1414 each command, in case you need to override any of the system
1415 defaults. For example, consider the following:</p>
1416
1417 <blockquote><pre class="code">lpq command = /usr/ucb/lpq %p</pre></blockquote>
1418
1419 <p>This would set <tt class="literal">lpq</tt> <tt class="literal">command</tt> to
1420 use <em class="filename">/usr/ucb/lpq</em>. Similarly:</p>
1421
1422 <blockquote><pre class="code">lprm command = /usr/local/bin/lprm -P%p %j</pre></blockquote>
1423
1424 <p>would set the Samba printer remove command to
1425 <em class="filename">/usr/local/bin/lprm</em> and provide it the print job
1426 number using the <tt class="literal">%j</tt> variable.</p>
1427
1428 <p>The default values for each option are dependent on the value of the
1429 <tt class="literal">printing</tt> option. <a href="ch10.html#samba2-CHP-10-TABLE-4">Table 10-4</a>
1430 shows the default commands for each printing option. The most popular
1431 printing system is BSD.</p>
1432
1433 <a name="samba2-CHP-10-TABLE-4"/><h4 class="head4">Table 10-4. Default commands for various printing options</h4><table border="1">
1434
1435
1436
1437
1438
1439
1440 <tr>
1441 <th>
1442 <p>Option</p>
1443 </th>
1444 <th>
1445 <p>BSD, AIX, PLP, LPRNG</p>
1446 </th>
1447 <th>
1448 <p>SYSV, HPUX</p>
1449 </th>
1450 <th>
1451 <p>QNX</p>
1452 </th>
1453 <th>
1454 <p>SOFTQ</p>
1455 </th>
1456 </tr>
1457
1458
1459 <tr>
1460 <td>
1461 <p><tt class="literal">print</tt> <tt class="literal">command</tt></p>
1462 </td>
1463 <td>
1464 <p><tt class="literal">lpr -r -P%p %s</tt></p>
1465 </td>
1466 <td>
1467 <p><tt class="literal">lp -c -d%p %s; rm</tt> <tt class="literal">%s</tt></p>
1468 </td>
1469 <td>
1470 <p><tt class="literal">lp -r -P%p %s</tt></p>
1471 </td>
1472 <td>
1473 <p><tt class="literal">lp -d%p -s %s; rm %s</tt></p>
1474 </td>
1475 </tr>
1476 <tr>
1477 <td>
1478 <p><tt class="literal">lpq</tt> <tt class="literal">command</tt></p>
1479 </td>
1480 <td>
1481 <p><tt class="literal">lpq -P%p</tt></p>
1482 </td>
1483 <td>
1484 <p><tt class="literal">lpstat -o%p</tt></p>
1485 </td>
1486 <td>
1487 <p><tt class="literal">lpq -P%p</tt></p>
1488 </td>
1489 <td>
1490 <p><tt class="literal">lpstat -o%p</tt></p>
1491 </td>
1492 </tr>
1493 <tr>
1494 <td>
1495 <p><tt class="literal">lprm</tt> <tt class="literal">command</tt></p>
1496 </td>
1497 <td>
1498 <p><tt class="literal">lprm -P%p %j</tt></p>
1499 </td>
1500 <td>
1501 <p><tt class="literal">cancel %p-%j</tt></p>
1502 </td>
1503 <td>
1504 <p><tt class="literal">cancel %p-%j</tt></p>
1505 </td>
1506 <td>
1507 <p><tt class="literal">cancel %p-%j</tt></p>
1508 </td>
1509 </tr>
1510 <tr>
1511 <td>
1512 <p><tt class="literal">lppause</tt> <tt class="literal">command</tt></p>
1513 </td>
1514 <td>
1515 <p><tt class="literal">lp -i %p-%j -H</tt> <tt class="literal">hold</tt></p>
1516
1517 <p>(SYSV only)</p>
1518 </td>
1519 <td>
1520 <p>None</p>
1521 </td>
1522 <td>
1523 <p>None</p>
1524 </td>
1525 <td>
1526 <p>None</p>
1527 </td>
1528 </tr>
1529 <tr>
1530 <td>
1531 <p><tt class="literal">lpresume</tt> <tt class="literal">command</tt></p>
1532 </td>
1533 <td>
1534 <p><tt class="literal">lp -i %p-%j -H</tt> <tt class="literal">resume</tt></p>
1535
1536 <p>(SYSV only)</p>
1537 </td>
1538 <td>
1539 <p>None</p>
1540 </td>
1541 <td>
1542 <p>None</p>
1543 </td>
1544 <td>
1545 <p><tt class="literal">qstat -s -j%j -r</tt></p>
1546 </td>
1547 </tr>
1548
1549 </table>
1550
1551 <p>It is usually unnecessary to reset these options in Samba, with the
1552 possible exception of the <tt class="literal">print</tt>
1553 <tt class="literal">command</tt>. This option might need to be set
1554 explicitly if your printing system doesn't have a
1555 <em class="emphasis">-r</em> (remove after printing) option on the
1556 printing command. For example:</p>
1557
1558 <blockquote><pre class="code">print command = /usr/local/lpr -P%p %s; /bin/rm %s</pre></blockquote>
1559
1560 <p>With a bit of judicious programming, these
1561 <em class="filename">smb.conf</em> options can also be used for debugging:</p>
1562
1563 <blockquote><pre class="code">print command = cat %s &gt;&gt;/tmp/printlog; lpr -r -P%p %s</pre></blockquote>
1564
1565 <p>Using the previous configuration, it is possible to verify that files
1566 are actually being delivered to the Samba server. If they are, their
1567 contents will show up in the file <em class="filename">/tmp/printlog</em>.</p>
1568
1569 <p>After BSD, the next most popular kind of printing system is SYSV (or
1570 System V) printing, plus some SYSV variants for
1571 IBM's AIX and Hewlett-Packard's
1572 HP-UX. These systems do not have an
1573 <em class="filename">/etc/printcap</em> file. Instead, the
1574 <tt class="literal">printcap</tt> <tt class="literal">file</tt> option can be set
1575 to an appropriate <em class="emphasis">lpstat</em> command for the system.
1576 This tells Samba to get a list of printers from the
1577 <em class="emphasis">lpstat</em> command. Alternatively, you can set the
1578 global configuration option <tt class="literal">printcap</tt>
1579 <tt class="literal">name</tt> to the name of a dummy
1580 <em class="filename">printcap</em> file you provide. In the latter case,
1581 the file must contain a series of lines such as:</p>
1582
1583 <blockquote><pre class="code">lp|print1|My Printer 1
1584 print2|My Printer 2
1585 print3|My Printer 3</pre></blockquote>
1586
1587 <p>Each line names a printer followed by aliases for it. In this
1588 example, the first printer is called <tt class="literal">lp</tt>,
1589 <tt class="literal">print1</tt>, or <tt class="literal">My</tt>
1590 <tt class="literal">Printer</tt> <tt class="literal">1</tt>, whichever the user
1591 prefers to use. The first name is used in place of
1592 <tt class="literal">%p</tt> in any command Samba executes for that printer.</p>
1593
1594 <p>Two additional printer types are also supported by Samba: LPRNG (LPR
1595 New Generation) and PLP (Public Line Printer). These are public
1596 domain and open source printing systems and are used by many sites to
1597 overcome problems with vendor-supplied software. Samba also supports
1598 the printing systems of the SOFTQ and QNX real-time operating
1599 systems.</p>
1600
1601
1602 </div>
1603
1604
1605
1606 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.8"/>
1607
1608 <h3 class="head3">printcap name</h3>
1609
1610 <p>If the <tt class="literal">printcap</tt><a name="INDEX-65"/><a name="INDEX-66"/>
1611 <tt class="literal">name</tt> option (also called
1612 <tt class="literal">printcap</tt>) appears in a printing share, Samba uses
1613 the file specified as the system printer capabilities file (normally
1614 <em class="filename">/etc/printcap</em>). However, you can reset it to a
1615 file consisting of only the printers you want to share over the
1616 network. The value must be the filename (with its complete path
1617 specified) of a printer capabilities file on the server:</p>
1618
1619 <blockquote><pre class="code">[deskjet]
1620     printcap name = /usr/local/samba/lib/printcap</pre></blockquote>
1621
1622 <p>The CUPS printing system uses its own method of determining printer
1623 capabilities, rather than the standard <em class="filename">printcap</em>
1624 file. In this case, set <tt class="literal">printcap</tt>
1625 <tt class="literal">name</tt> as follows:</p>
1626
1627 <blockquote><pre class="code">[global]
1628     printing = cups
1629     printcap name = cups</pre></blockquote>
1630
1631
1632 </div>
1633
1634
1635
1636 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.9"/>
1637
1638 <h3 class="head3">min print space</h3>
1639
1640 <p>The <tt class="literal">min</tt><a name="INDEX-67"/> <tt class="literal">print</tt>
1641 <tt class="literal">space</tt> option sets the amount of space that must be
1642 available on the disk that contains the spool directory if printing
1643 is to be allowed. Setting it to zero (the default) turns the check
1644 off; setting it to any other number sets the amount of free space in
1645 kilobytes required. This option helps to avoid having print jobs fill
1646 up the remaining disk space on the server, which can cause other
1647 processes to fail:</p>
1648
1649 <blockquote><pre class="code">[deskjet]
1650     min print space = 4000</pre></blockquote>
1651
1652
1653 </div>
1654
1655
1656
1657 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.10"/>
1658
1659 <a name="INDEX-68"/><h3 class="head3">queuepause command</h3>
1660
1661 <p>This configuration option specifies a command that tells Samba how to
1662 pause an entire print queue, as opposed to a single job on the queue.
1663 The default value depends on the printing type chosen. You should not
1664 need to alter this option.</p>
1665
1666
1667 </div>
1668
1669
1670
1671 <div class="sect3"><a name="samba2-CHP-10-SECT-2.3.11"/>
1672
1673 <a name="INDEX-69"/><h3 class="head3">queueresume command</h3>
1674
1675 <p>This configuration option specifies a command that tells Samba how to
1676 resume a paused print queue, as opposed to resuming a single job on
1677 the print queue. The default value depends on the printing type
1678 chosen. You should not need to alter this option. <a name="INDEX-70"/> <a name="INDEX-71"/> <a name="INDEX-72"/><a name="INDEX-73"/></p>
1679
1680
1681 </div>
1682
1683
1684 </div>
1685
1686
1687 </div>
1688
1689 <hr/><h4 class="head4">Footnotes</h4><blockquote><a name="FOOTNOTE-1"/> <p><a href="#FNPTR-1">[1]</a> If
1690 you are using Linux, you can use the <em class="emphasis">checkpc</em>
1691 command to check for this type of error.</p> <a name="FOOTNOTE-2"/>
1692 <p><a href="#FNPTR-2">[2]</a> CUPS is open source software (<a href="http://www.opensource.org">http://www.opensource.org</a>) developed by Easy
1693 Software Products. For more information, visit <a href="http://www.cups.org">http://www.cups.org</a>.</p> <a name="FOOTNOTE-3"/> <p><a href="#FNPTR-3">[3]</a> We have placed annotated comments off to
1694 the right in case you've never dealt with this file
1695 before.</p> </blockquote><hr/><h4 class="head4"><a href="toc.html">TOC</a></h4></body></html>