1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 7] Printing and Name Resolution</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:34:47Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch06_06.html" TITLE="6.6 Logon Scripts"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 6.6 Logon Scripts" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38Chapter 7</font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 39<A CLASS="sect1" HREF="ch07_02.html" TITLE="7.2 Printing to Windows Client Printers"> 40<IMG SRC="gifs/txtnexta.gif" ALT="Next: 7.2 Printing to Windows Client Printers" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 41</div> 42<blockquote> 43<div class="samplechapter"> 44<H1 CLASS="chapter"> 45<A CLASS="title" NAME="ch07-98459"> 467. Printing and Name Resolution</a></h1><DIV CLASS="htmltoc"> 47<P> 48<B> 49Contents:</b><br> 50<A CLASS="sect1" HREF="#ch07-61388" TITLE="7.1 Sending Print Jobs to Samba"> 51Sending Print Jobs to Samba</a><br> 52<A CLASS="sect1" HREF="ch07_02.html" TITLE="7.2 Printing to Windows Client Printers"> 53Printing to Windows Client Printers</a><br> 54<A CLASS="sect1" HREF="ch07_03.html" TITLE="7.3 Name Resolution with Samba"> 55Name Resolution with Samba</a></p><P> 56</p></div><P CLASS="para">This chapter tackles two Samba topics: setting up printers for use with a Samba server and configuring Samba to use or become a Windows Internet Name Service (WINS) server. Samba allows client machines to send documents to printers connected to the Samba server. In addition, Samba can also assist you with printing Unix documents to a printer on a Windows machine. In the first part of this chapter, we will discuss how to get printers configured to work on either side.</p><P CLASS="para"> 57In the second half of the chapter, we will introduce the Windows Internet Name Service, Microsoft's implementation of a NetBIOS Name Server (NBNS). As mentioned in <a href="ch01_01.html"><b>Chapter 1, <CITE CLASS="chapter">Learning the Samba</cite></b></a>, an NBNS allows machines to perform name resolution on a NetBIOS network without having to rely on broadcasts. Instead, each machine knows exactly where the WINS server is and can query it for the IP addresses of other machines on the network.</p><DIV CLASS="sect1"> 58<H2 CLASS="sect1"> 59<A CLASS="title" NAME="s1"></a> 60<A CLASS="title" NAME="ch07-61388"> 617.1 Sending Print Jobs to Samba</a></h2><P CLASS="para">A printer attached to the Samba server shows up in the list of shares offered in the Network Neighborhood. If the printer is registered on the client machine and the client has the correct printer driver installed, the client can effortlessly send print jobs to a printer attached to a Samba server. <A CLASS="xref" HREF="ch07_01.html#ch07-35075"> 62Figure 7.1</a> shows a Samba printer as it appears in the Network Neighborhood of a Windows client. </p><P CLASS="para">To administer printers with Samba, you should understand the basic process by which printing takes place on a network. Sending a print job to a printer on a Samba server involves four steps:</p><OL CLASS="orderedlist"> 63<LI CLASS="listitem"> 64<P CLASS="para"> 65<A CLASS="listitem" NAME="ch07-pgfId-948964"> 66</a>Opening and authenticating a connection to the printer share</p></li><LI CLASS="listitem"> 67<P CLASS="para"> 68<A CLASS="listitem" NAME="ch07-pgfId-948965"> 69</a>Copying the file over the network</p></li><LI CLASS="listitem"> 70<P CLASS="para"> 71<A CLASS="listitem" NAME="ch07-pgfId-948966"> 72</a>Closing the connection</p></li><LI CLASS="listitem"> 73<P CLASS="para"> 74<A CLASS="listitem" NAME="ch07-pgfId-948967"> 75</a>Printing and deleting the copy of the file </p><H4 CLASS="figure"> 76<A CLASS="title" NAME="ch07-35075"> 77Figure 7.1: A Samba printer in the Network Neighborhood</a></h4><IMG CLASS="graphic" SRC="figs/sam.0701.gif" ALT="Figure 7.1"></li></ol><P CLASS="para"> 78When a print job arrives at a Samba server, the print data is temporarily written to disk in the directory specified by the <CODE CLASS="literal"> 79path</code> option of the printer share. Samba then executes a Unix print command to send that data file to the printer. The job is printed as the authenticated user of the share. Note that this may be the guest user, depending on how the share is configured.</p><DIV CLASS="sect2"> 80<H3 CLASS="sect2"> 81<A CLASS="title" NAME="ch07-pgfId-951370"> 827.1.1 Print Commands</a></h3><P CLASS="para">In order to print the document, you'll need to tell Samba what the command is to print and delete a file. On Linux, such a command is:</p><PRE CLASS="programlisting"> 83lpr -r -P<CODE CLASS="replaceable"><I>printer</i></code> <CODE CLASS="replaceable"><I>file</i></code></pre><P CLASS="para"> 84This tells <CODE CLASS="literal"> 85lpr</code> to copy the document to a spool area, usually <I CLASS="filename"> 86/var/spool</i>, retrieve the name of the printer in the system configuration file (<I CLASS="filename">/etc/printcap</i>), and interpret the rules it finds there to decide how to process the data and which physical device to send it to. Note that because the <CODE CLASS="literal"> 87-r</code> option has been listed, the file specified on the command line will be deleted after it has been printed. Of course, the file removed is just a copy stored on the Samba server; the original file on the client is unaffected.</p><P CLASS="para"> 88Linux uses a Berkeley (BSD) style of printing. However, the process is similar on System V Unix. Here, printing and deleting becomes a compound command:</p><PRE CLASS="programlisting">lp -d<CODE CLASS="replaceable"><I>printer</i></code> -s <CODE CLASS="replaceable"><I>file</i></code>; rm <CODE CLASS="replaceable"> <I>file</i></code></pre><P CLASS="para"> 89With System V, the <I CLASS="filename"> 90/etc/printcap</i> file is replaced with different set of configuration files hiding in <I CLASS="filename"> 91/usr/spool/lp</i>, and there is no option to delete the file. You have to do it yourself, which is why we have added the <CODE CLASS="literal"> 92rm</code> command afterward.</p></div><DIV CLASS="sect2"> 93<H3 CLASS="sect2"> 94<A CLASS="title" NAME="ch07-pgfId-951469"> 957.1.2 Printing Variables</a></h3><P CLASS="para">Samba provides four variables specifically for use with printing configuration options. They are shown in <A CLASS="xref" HREF="ch07_01.html#ch07-29758"> 96Table 7.1</a>. </p><br> 97<TABLE CLASS="table" BORDER="1" CELLPADDING="3"> 98<CAPTION CLASS="table"> 99<A CLASS="title" NAME="ch07-29758"> 100Table 7.1: Printing Variables </a></caption><THEAD CLASS="thead"> 101<TR CLASS="row" VALIGN="TOP"> 102<TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 103<P CLASS="para"> 104Variable</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 105<P CLASS="para"> 106Definition</p></th></tr></thead><TBODY CLASS="tbody"> 107<TR CLASS="row" VALIGN="TOP"> 108<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 109<P CLASS="para"> 110<CODE CLASS="literal"> 111%s</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 112<P CLASS="para"> 113The full pathname of the file on the Samba server to be printed</p></td></tr><TR CLASS="row" VALIGN="TOP"> 114<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 115<P CLASS="para"> 116<CODE CLASS="literal"> 117%f</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 118<P CLASS="para"> 119The name of the file itself (without the preceding path) on the Samba server to be printed</p></td></tr><TR CLASS="row" VALIGN="TOP"> 120<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 121<P CLASS="para"> 122<CODE CLASS="literal"> 123%p</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 124<P CLASS="para"> 125The name of the Unix printer to use</p></td></tr><TR CLASS="row" VALIGN="TOP"> 126<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 127<P CLASS="para"> 128<CODE CLASS="literal"> 129%j</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 130<P CLASS="para"> 131The number of the print job (for use with <CODE CLASS="literal"> 132lprm</code>, <CODE CLASS="literal"> 133lppause</code>, and <CODE CLASS="literal"> 134lpresume</code>)</p></td></tr></tbody></table></div><DIV CLASS="sect2"> 135<H3 CLASS="sect2"> 136<A CLASS="title" NAME="ch07-pgfId-943749"> 1377.1.3 A Minimal Printing Setup</a></h3><P CLASS="para">Let's start with a simple but illustrative printing share. Assuming that you're on a Linux system and you have a printer called <CODE CLASS="literal"> 138lp</code> listed in the printer capabilities file, the following addition to your <I CLASS="filename"> 139smb.conf</i> file will make the printer accessible through the network:</p><PRE CLASS="programlisting"> 140[printer1] 141 printable = yes 142 print command = /usr/bin/lpr -r %s 143 printer = lp 144 printing = BSD 145 read only = yes 146 guest ok = yes</pre><P CLASS="para"> 147This configuration allows anyone to send data to the printer, something we may want to change later. For the moment, what's important to understand is that the variable <CODE CLASS="literal"> 148%s</code> in the <CODE CLASS="literal"> 149print</code> <CODE CLASS="literal"> 150command</code> option will be replaced with the name of the file to be printed when Samba executes the command. Changing the <CODE CLASS="literal"> 151print command</code> to reflect a different style of Unix machine typically involves only replacing the right side of the <CODE CLASS="literal"> 152print</code> <CODE CLASS="literal"> 153command</code> option with whatever command you need for your system and changing the target of the <CODE CLASS="literal"> 154printing</code> option.</p><P CLASS="para"> 155Let's look at the commands for a System V Unix. With variable substitution, the System V Unix command becomes:</p><PRE CLASS="programlisting"> 156print command = lp -d%p -s %s; rm %s</pre><P CLASS="para"> 157As mentioned earlier, the <CODE CLASS="literal"> 158%p</code> variable resolves to the name of the printer, while the <CODE CLASS="literal"> 159%s</code> variable resolves to the name of the file. After that, you can change the <CODE CLASS="literal"> 160printing</code> option to reflect that you're using a System V architecture:</p><PRE CLASS="programlisting"> 161printing = SYSV</pre><P CLASS="para"> 162If you are using share-level security, pay special attention to the guest account used by Samba. The typical setting, <CODE CLASS="literal"> 163nobody</code>, may not be allowed to print by the operating system. If that's true for your operating system, you should place a <CODE CLASS="literal"> 164guest</code> <CODE CLASS="literal"> 165account</code> option under the printing share (or even perhaps the global share) specifying an account that can. A popular candidate with the Samba authors is the <CODE CLASS="literal"> 166ftp</code> account, which is often preconfigured to be safe for untrusted guest users. You can set it with the following command:</p><PRE CLASS="programlisting"> 167guest account = ftp</pre><P CLASS="para"> 168Another common printing issue is that clients may need to request the status of a print job sent to the Samba server. Samba will not reject a document from being sent to an already busy printer share. Consequently, Samba needs the ability to communicate not only the status of the current printing job to the client, but also which documents are currently waiting to be printed on that printer. Samba also has to provide the client the ability to pause print jobs, resume print jobs, and remove print jobs from the printing queue. Samba provides options for each of these tasks. As you might expect, they borrow functionality from existing Unix commands. The options are: </p><UL CLASS="itemizedlist"> 169<LI CLASS="listitem"> 170<P CLASS="para"> 171<A CLASS="listitem" NAME="ch07-pgfId-956989"> 172</a><CODE CLASS="literal"> 173lpq command</code></p></li><LI CLASS="listitem"> 174<P CLASS="para"> 175<A CLASS="listitem" NAME="ch07-pgfId-956990"> 176</a><CODE CLASS="literal"> 177lprm command</code></p></li><LI CLASS="listitem"> 178<P CLASS="para"> 179<A CLASS="listitem" NAME="ch07-pgfId-956991"> 180</a><CODE CLASS="literal"> 181lppause command</code></p></li><LI CLASS="listitem"> 182<P CLASS="para"> 183<A CLASS="listitem" NAME="ch07-pgfId-956992"> 184</a><CODE CLASS="literal"> 185lpresume command</code></p></li></ul><P CLASS="para"> 186We will cover these options in more detail below. For the most part, however, the value of the <CODE CLASS="literal"> 187printing</code> configuration option will determine their values, and you should not need to alter the default values of these options.</p><P CLASS="para"> 188Here are a few important items to remember about printing shares:</p><UL CLASS="itemizedlist"> 189<LI CLASS="listitem"> 190<P CLASS="para"> 191<A CLASS="listitem" NAME="ch07-pgfId-951650"> 192</a>You must put <CODE CLASS="literal"> 193printable</code> <CODE CLASS="literal"> 194=</code> <CODE CLASS="literal"> 195yes</code> in all printer shares (even <CODE CLASS="literal"> 196[printers]</code>), so that Samba will know that they are printer shares. If you forget, the shares will not be usable for printing and will instead be treated as disk shares.</p></li><LI CLASS="listitem"> 197<P CLASS="para"> 198<A CLASS="listitem" NAME="ch07-pgfId-951651"> 199</a>If you set the <CODE CLASS="literal"> 200path</code> configuration option in the printer section, any files sent to the printer(s) will be copied to the directory you specify instead of to the default location of <I CLASS="filename"> 201/tmp</i>. As the amount of disk space allocated to <I CLASS="filename"> 202/tmp</i> can be relatively small in some Unix operating systems, many administrators opt to use <I CLASS="filename"> 203/var/spool</i> or some other directory instead.</p></li><LI CLASS="listitem"> 204<P CLASS="para"> 205<A CLASS="listitem" NAME="ch07-pgfId-951652"> 206</a>The <CODE CLASS="literal"> 207read only</code> option is ignored for printer shares.</p></li><LI CLASS="listitem"> 208<P CLASS="para"> 209<A CLASS="listitem" NAME="ch07-pgfId-951648"> 210</a>If you set <CODE CLASS="literal"> 211guest</code> <CODE CLASS="literal"> 212ok</code> <CODE CLASS="literal"> 213=</code> <CODE CLASS="literal"> 214yes</code> in a printer share and Samba is configured for share-level security, it will allow anyone to send data to the printer as the <CODE CLASS="literal"> 215guest</code> <CODE CLASS="literal"> 216account</code> user. </p></li></ul><P CLASS="para"> 217Using one or more Samba machines as a print server gives you a great deal of flexibility on your LAN. You can easily partition your available printers, restricting some to members of one department, or you can maintain a bank of printers available to all. In addition, you can restrict a printer to a selected few by adding the trusty <CODE CLASS="literal"> 218valid</code> <CODE CLASS="literal"> 219users</code> option to its share definition:</p><PRE CLASS="programlisting"> 220[deskjet] 221 printable = yes 222 path = /var/spool/samba/print 223 valid users = gail sam</pre><P CLASS="para"> 224All of the other share accessibility options defined in the previous chapter should work for printing shares as well. Since the printers themselves are accessed through Samba by name, it's also simple to delegate print services among several servers using familiar Unix commands for tasks such as load balancing or maintenance. </p></div><DIV CLASS="sect2"> 225<H3 CLASS="sect2"> 226<A CLASS="title" NAME="ch07-pgfId-951458"> 2277.1.4 The [printers] Share</a></h3><P CLASS="para"> 228<a href="ch04_01.html"><b>Chapter 4, <CITE CLASS="chapter">Disk Shares </cite></b></a>, briefly introduced <CODE CLASS="literal"> 229[printers]</code>, a special share for automatically creating printing services. Let's review how it works: if you create a share named <CODE CLASS="literal"> 230[printers]</code> in the configuration file, Samba will automatically read in your printer capabilities file and create a printing share for each printer that appears in the file. For example, if the Samba server had <CODE CLASS="literal"> 231lp</code>, <CODE CLASS="literal"> 232pcl</code> and <CODE CLASS="literal"> 233ps</code> printers in its printer capabilities file, Samba would provide three printer shares with those names, each configured with the options in the <CODE CLASS="literal"> 234[printers]</code> share.</p><P CLASS="para">Recall that Samba obeys following rules when a client requests a share that has not been created through the <I CLASS="filename"> 235smb.conf</i> file:</p><UL CLASS="itemizedlist"> 236<LI CLASS="listitem"> 237<P CLASS="para"> 238<A CLASS="listitem" NAME="ch07-pgfId-949501"> 239</a>If the share name matches a username in the system password file and a <CODE CLASS="literal"> 240[homes]</code> share exists, a new share is created with the name of the user and is initialized using the values given in the <CODE CLASS="literal"> 241[homes]</code> and <CODE CLASS="literal"> 242[global]</code> sections.</p></li><LI CLASS="listitem"> 243<P CLASS="para"> 244<A CLASS="listitem" NAME="ch07-pgfId-949506"> 245</a>Otherwise, if the name matches a printer in the system printer capabilities file, and a <CODE CLASS="literal"> 246[printers]</code> share exists, a new share is created with the name of the printer and initialized using the values given in the <CODE CLASS="literal"> 247[printers]</code> section. (Variables in the <CODE CLASS="literal"> 248[global]</code> section do not apply here.) </p></li><LI CLASS="listitem"> 249<P CLASS="para"> 250<A CLASS="listitem" NAME="ch07-pgfId-949507"> 251</a>If neither of those succeed, Samba looks for a <CODE CLASS="literal"> 252default</code> <CODE CLASS="literal"> 253service</code> share. If none is found, it returns an error.</p></li></ul><P CLASS="para"> 254This brings to light an important point: be careful that you do not give a printer the same name as a user. Otherwise, you will end up connecting to a disk share when you may have wanted a printer share instead.</p><P CLASS="para"> 255Here is an example <CODE CLASS="literal"> 256[printers]</code> share for a Linux (BSD) system. Some of these options are already defaults; however, we have listed them anyway for illustrative purposes:</p><PRE CLASS="programlisting"> 257[global] 258 printing = BSD 259 print command = /usr/bin/lpr -P%p -r %s 260 printcap file = /etc/printcap 261 min print space = 2000 262 263[printers] 264 path = /usr/spool/public 265 printable = true 266 guest ok = true 267 guest account = pcguest </pre><P CLASS="para"> 268Here, we've given Samba global options that specify the printing type (BSD), a print command to send data to the printer and remove a temporary file, our default printer capabilities file, and a minimum printing space of 2 megabytes.</p><P CLASS="para"> 269In addition, we've created a <CODE CLASS="literal"> 270[printers]</code> share for each of the system printers. Our temporary spooling directory is specified by the <CODE CLASS="literal"> 271path</code> option: <I CLASS="filename"> 272/usr/spool/public</i>. Each of the shares is marked as printable - this is necessary, even in the <CODE CLASS="literal"> 273[printers]</code> section. The two <CODE CLASS="literal"> 274guest</code> options are useful in the event that Samba is using share-level security: we allow guest access to the printer and we specify the guest user that Samba should use to execute print commands. </p></div><DIV CLASS="sect2"> 275<H3 CLASS="sect2"> 276<A CLASS="title" NAME="ch07-pgfId-943839"> 2777.1.5 Test Printing</a></h3><P CLASS="para">Here is how you can test printing from the Samba server. Let's assume the most complex case and use a guest account. First, run the Samba <EM CLASS="emphasis"> 278testparm</em> command on your configuration file that contains the print shares, as we did in <a href="ch02_01.html"><b>Chapter 2, <CITE CLASS="chapter">Installing Samba on a Unix System</cite></b></a>. This will tell you if there are any syntactical problems with the configuration file. For example, here is what you would see if you left out the <CODE CLASS="literal"> 279path</code> configuration option in the previous example:</p><PRE CLASS="programlisting"> 280# testparm 281Load smb config files from /usr/local/samba/lib/smb.conf 282Processing configuration file "/usr/local/samba/lib/smb.conf" 283Processing section "[global]" 284Processing section "[homes]" 285Processing section "[data]" 286Processing section "[printers]" 287No path in service printers - using /tmp 288Loaded services file OK. 289Press enter to see a dump of your service definitions 290Global parameters: 291 load printers: Yes 292 printcap name: /etc/printcap 293Default service parameters: 294 guest account: ftp 295 min print space: 0 296 print command: lpr -r -P%p %s 297 lpq command: lpq -P%p 298 lprm command: lprm -P%p %j 299lppause command: 300 lpresume command: 301 Service parameters [printers]: 302 path: /tmp 303 print ok: Yes 304 read only: true 305 public: true </pre><P CLASS="para"> 306Second, try the command <CODE CLASS="literal"> 307testprns</code> <CODE CLASS="replaceable"> 308<I> 309printername</i></code>. This is a simple program that verifies that the specified printer is available in your <EM CLASS="emphasis"> 310printcap</em> file. If your <EM CLASS="emphasis"> 311printcap</em> file is not in the usual place, you can specify its full pathname as the second argument to the <EM CLASS="emphasis"> 312testprns</em> command:</p><PRE CLASS="programlisting"> 313# testprns lp /etc/printcap 314Looking for printer lp in printcap file /etc/printcap 315Printer name lp is valid.</pre><P CLASS="para"> 316Next, log on as the guest user, go to the spooling directory, and ensure that you can print using the same command that <EM CLASS="emphasis"> 317testparm</em> says Samba will use. As mentioned before, this will tell you if you need to change the guest account, as the default account may not be allowed to print.</p><P CLASS="para"> 318Finally, print something to the Samba server via <CODE CLASS="literal"> 319smbclient</code>, and see if the following actions occur:</p><UL CLASS="itemizedlist"> 320<LI CLASS="listitem"> 321<P CLASS="para"> 322<A CLASS="listitem" NAME="ch07-pgfId-943874"> 323</a>The job appears (briefly) in the Samba spool directory specified by the path.</p></li><LI CLASS="listitem"> 324<P CLASS="para"> 325<A CLASS="listitem" NAME="ch07-pgfId-943875"> 326</a>The job shows up in your print systems spool directory.</p></li><LI CLASS="listitem"> 327<P CLASS="para"> 328<A CLASS="listitem" NAME="ch07-pgfId-943876"> 329</a>The job disappears from the spool directory that Samba used.</p></li></ul><P CLASS="para"> 330If <EM CLASS="emphasis"> 331smbclient</em> cannot print, you can reset the <CODE CLASS="literal"> 332print</code> <CODE CLASS="literal"> 333command</code> option to collect debugging information:</p><PRE CLASS="programlisting"> 334print command = /bin/cat %s >>/tmp/printlog; rm %s</pre><P CLASS="para"> 335or:</p><PRE CLASS="programlisting"> 336print command = echo "printed %s on %p" >>/tmp/printlog</pre><P CLASS="para"> 337A common problem with Samba printer configuration is forgetting to use the full pathnames for commands; simple commands often don't work because the guest account's PATH doesn't include them. Another frequent problem is not having the correct permissions on the spooling directory. </p><P CLASS="para">There is more information on debugging printers in the Samba documentation (<I CLASS="filename">Printing.txt</i>). In addition, the Unix print systems are covered in detail in AEleen Frisch's <EM CLASS="emphasis"> 338Essential Systems Administration</em> (published by O'Reilly).</p></div><DIV CLASS="sect2"> 339<H3 CLASS="sect2"> 340<A CLASS="title" NAME="ch07-pgfId-943883"> 3417.1.6 Setting Up and Testing a Windows Client</a></h3><P CLASS="para">Now that Samba is offering a workable printer, you need to set it up on a Windows client. Look at the Samba server in the Network Neighborhood. It should now show each of the printers that are available. For example, in <A CLASS="xref" HREF="ch07_01.html#ch07-35075"> 342Figure 7.1</a>, we saw a printer called <CODE CLASS="literal"> 343lp</code>.</p><P CLASS="para"> 344Next, you need to have the Windows client recognize the printer. Double-click on the printer icon to get started. If you try to select an uninstalled printer (as you just did), Windows will ask you if it should help configure it for the Windows system. Respond "Yes," which will open the Printer Wizard. </p><P CLASS="para"> 345The first thing the wizard will ask is whether you need to print from DOS. Let's assume you don't, so choose No and press the Next button to get to the manufacturer/model window as shown in <A CLASS="xref" HREF="ch07_01.html#ch07-60084"> 346Figure 7.2</a>. </p><H4 CLASS="figure"> 347<A CLASS="title" NAME="ch07-60084"> 348Figure 7.2: A printer in the Network Neighborhood</a></h4><IMG CLASS="graphic" SRC="figs/sam.0702.gif" ALT="Figure 7.2"><P CLASS="para"> 349In this dialog box, you should see a large list of manufacturers and models for almost every printer imaginable. If you don't see your printer on the list, but you know it's a PostScript printer, select Apple as the manufacturer and Apple LaserWriter as the model. This will give you the most basic Postscript printer setup, and arguably one of the most reliable. If you already have any Postscript printers attached, you will be asked about replacing or reusing the existing driver. Be aware that if you replace it with a new one, you may make your other printers fail. Therefore, we recommend you keep using your existing printer drivers as long as they're working properly.</p><P CLASS="para"> 350Following that, the Printer Wizard will ask you to name the printer. <A CLASS="xref" HREF="ch07_01.html#ch07-69466"> 351Figure 7.3</a> shows this example, where the name has defaulted to our second laserwriter. Here, you rename it from Apple Laserwriter (Copy 2) to "ps on Samba server," so you know where to look for the printouts. In reality, you can name the printer anything you want. </p><H4 CLASS="figure"> 352<A CLASS="title" NAME="ch07-69466"> 353Figure 7.3: Printer manufacturers and models</a></h4><IMG CLASS="graphic" SRC="figs/sam.0703.gif" ALT="Figure 7.3"><P CLASS="para"> 354Finally, the Printing Wizard asks if it should print a test page. Click on Yes, and you should be presented with the dialog in <A CLASS="xref" HREF="ch07_01.html#ch07-43374"> 355Figure 7.4</a>. </p><H4 CLASS="figure"> 356<A CLASS="title" NAME="ch07-43374"> 357Figure 7.4: Printing successfully completed</a></h4><IMG CLASS="graphic" SRC="figs/sam.0704.gif" ALT="Figure 7.4"><P CLASS="para"> 358If the test printing was unsuccessful, press the No button in <A CLASS="xref" HREF="ch07_01.html#ch07-43374"> 359Figure 7.4</a> and the Printing Wizard will walk you through some debugging steps for the client side of the process. If the test printing does work, congratulations! The remote printer will now be available to all your PC applications through the File and Print menu items.</p></div><DIV CLASS="sect2"> 360<H3 CLASS="sect2"> 361<A CLASS="title" NAME="ch07-30008"> 3627.1.7 Automatically Setting Up Printer Drivers</a></h3><P CLASS="para">The previous section described how to manually configure a printer driver for your Windows system. As a system administrator, however, you can't always guarantee that users can perform such a process without making mistakes. Luckily, however, you can ask Samba to automatically set up the printer drivers for a specific printer.</p><P CLASS="para"> 363Samba has three options that can be used to automatically set up printer drivers for clients who are connecting for the first time. These options are <CODE CLASS="literal"> 364printer</code> <CODE CLASS="literal"> 365driver</code>, <CODE CLASS="literal"> 366printer</code> <CODE CLASS="literal"> 367driver</code> <CODE CLASS="literal"> 368file</code>, and <CODE CLASS="literal"> 369printer</code> <CODE CLASS="literal"> 370driver</code> <CODE CLASS="literal"> 371location</code>. This section explains how to use these options to allow users to skip over the Manufacturer dialog in the Add Printer Wizard above.</p><P CLASS="para"> 372For more information on how to do this, see the <I CLASS="filename"> 373PRINTER_DRIVER.TXT</i> file in the Samba distribution documentation.</p><P CLASS="para"> 374There are four major steps:</p><OL CLASS="orderedlist"> 375<LI CLASS="listitem"> 376<P CLASS="para"> 377<A CLASS="listitem" NAME="ch07-pgfId-949602"> 378</a>Install the drivers for the printer on a Windows client (the printer need not be attached).</p></li><LI CLASS="listitem"> 379<P CLASS="para"> 380<A CLASS="listitem" NAME="ch07-pgfId-949746"> 381</a>Create a printer definition file from the information on a Windows machine.</p></li><LI CLASS="listitem"> 382<P CLASS="para"> 383<A CLASS="listitem" NAME="ch07-pgfId-949600"> 384</a>Create a <CODE CLASS="literal"> 385PRINTER$</code> share where the resulting driver files can be placed.</p></li><LI CLASS="listitem"> 386<P CLASS="para"> 387<A CLASS="listitem" NAME="ch07-pgfId-949601"> 388</a>Modify the Samba configuration file accordingly.</p></li></ol><P CLASS="para"> 389Let's go over each of the four steps in greater detail.</p><DIV CLASS="sect3"> 390<H4 CLASS="sect3"> 391<A CLASS="title" NAME="ch07-pgfId-949749"> 3927.1.7.1 Install the drivers on a windows client</a></h4><P CLASS="para"> 393Use Windows 95/98 for this step. It doesn't matter which client you choose, as long as it has the ability to load the appropriate drivers for the printer. In fact, you don't even need to have the printer attached to the machine. All you're interested in here is getting the appropriate driver files into the Windows directory. First, go to the Printers window of My Computer and double-click on the Add Printer icon, as shown in <A CLASS="xref" HREF="ch07_01.html#ch07-52397"> 394Figure 7.5</a>. </p><H4 CLASS="figure"> 395<A CLASS="title" NAME="ch07-52397"> 396Figure 7.5: The Printers window</a></h4><IMG CLASS="graphic" SRC="figs/sam.0705.gif" ALT="Figure 7.5"><P CLASS="para"> 397At this point, you can follow the Add Printer Wizard dialogs through to select the manufacturer and model of the printer in question. If it asks you if you want to print from MS-DOS, answer No. Windows should load the appropriate driver resources from its CD-ROM and ask you if you want to print a test page. Again, respond No and close the Add Printer Wizard dialog.</p></div><DIV CLASS="sect3"> 398<H4 CLASS="sect3"> 399<A CLASS="title" NAME="ch07-pgfId-949606"> 4007.1.7.2 Create a printer definition file</a></h4><P CLASS="para"> 401You can create a printer definition file by using the <I CLASS="filename"> 402make_ printerdef</i> script in the <I CLASS="filename"> 403/usr/local/samba/bin</i> directory. In order to use this script, you need to copy over the following four files from a Windows client:[<A CLASS="footnote" HREF="#ch07-pgfId-951615">1</a>]</p><BLOCKQUOTE CLASS="footnote"> 404<DIV CLASS="footnote"> 405<P CLASS="para"> 406<A CLASS="footnote" NAME="ch07-pgfId-951615">[1]</a> Older Windows 95 clients may have only the first two files.</p></div></blockquote><TABLE CLASS="simplelist" BORDER="0"> 407<TR> 408<TD CLASS="member"> 409<EM CLASS="emphasis"> 410C:\WINDOWS\INF\MSPRINT.INF</em></td></tr><TR> 411<TD CLASS="member"> 412<EM CLASS="emphasis"> 413C:\WINDOWS\INF\MSPRINT2.INF</em></td></tr><TR> 414<TD CLASS="member"> 415<EM CLASS="emphasis"> 416C:\WINDOWS\INF\MSPRINT3.INF</em></td></tr><TR> 417<TD CLASS="member"> 418<EM CLASS="emphasis"> 419C:\WINDOWS\INF\MSPRINT4.INF</em></td></tr></table><P CLASS="para"> 420Once you have the four files, you can create a printer definition file using the appropriate printer driver and its .INF file. If the printer driver starts with the letters A-K, use either the <EM CLASS="emphasis"> 421MSPRINT.INF</em> file or the <EM CLASS="emphasis"> 422MSPRINT3.INF</em> file. If it begins with the letters L-Z, use the <EM CLASS="emphasis"> 423MSPRINT2.INF</em> file or the <EM CLASS="emphasis"> 424MSPRINT4.INF</em> file. You may need to <EM CLASS="emphasis"> 425grep</em> through each of the files to see where your specific driver is. For the following example, we have located our driver in <EM CLASS="emphasis"> 426MSPRINT3.INF</em> and created a printer definition file for a HP DeskJet 560C printer:</p><PRE CLASS="programlisting"> 427$grep "HP DeskJet 560C Printer" MSPRINT.INF MSPRINT3.INF 428MSPRINT3.INF: "HP DeskJet 560C Printer"=DESKJETC.DRV,HP_DeskJet_ ... 429 430$make_printerdef MSPRINT3.INF "HP DeskJet 560C Printer" >printers.def 431FOUND:DESKJETC.DRV 432End of section found 433CopyFiles: DESKJETC,COLOR_DESKJETC 434Datasection: (null) 435Datafile: DESKJETC.DRV 436Driverfile: DESKJETC.DRV 437Helpfile: HPVDJC.HLP 438LanguageMonitor: (null) 439 440Copy the following files to your printer$ share location: 441DESKJETC.DRV 442HPVCM.HPM 443HPVIOL.DLL 444HPVMON.DLL 445HPVRES.DLL 446HPCOLOR.DLL 447HPVUI.DLL 448HPVDJCC.HLP 449color\HPDESK.ICM</pre><P CLASS="para"> 450Note the files that the script asks you to copy. You'll need those for the next step.</p></div><DIV CLASS="sect3"> 451<H4 CLASS="sect3"> 452<A CLASS="title" NAME="ch07-pgfId-949683"> 4537.1.7.3 Create a PRINTER$ share</a></h4><P CLASS="para">This part is relatively easy. Create a share called <CODE CLASS="literal"> 454[PRINTER$]</code> in your <I CLASS="filename"> 455smb.conf</i> that points to an empty directory on the Samba server. Once that is done, copy over the files that the <I CLASS="filename"> 456make_ printerdef</i> script requested of you into the location of the <CODE CLASS="literal"> 457path</code> configuration option for the <CODE CLASS="literal"> 458[PRINTER$]</code> share. For example, you can put the following in your configuration file:</p><PRE CLASS="programlisting"> 459[PRINTER$] 460 path = /usr/local/samba/print 461 read only = yes 462 browsable = no 463 guest ok = yes</pre><P CLASS="para"> 464The files requested by the <I CLASS="filename"> 465make_ printerdef</i> script are typically located in the <EM CLASS="emphasis"> 466C:\WINDOWS\SYSTEM</em> directory, although you can use the following commands to find out exactly where they are:</p><PRE CLASS="programlisting"> 467cd C:\WINDOWS 468dir <CODE CLASS="replaceable"> 469<I> 470filename</i></code> /s</pre><P CLASS="para"> 471In this case, each of the files needs to be copied to the <I CLASS="filename"> 472/usr/local/samba/print</i> directory on the Samba server. In addition, copy the <I CLASS="filename"> 473printers.def</i> file that you created over to that share as well. Once you've done that, you're almost ready to go. </p></div><DIV CLASS="sect3"> 474<H4 CLASS="sect3"> 475<A CLASS="title" NAME="ch07-pgfId-949694"> 4767.1.7.4 Modify the Samba configuration file</a></h4><P CLASS="para"> 477<I CLASS="filename"> 478</i>The last step is to modify the Samba configuration file by adding the following three options: </p><UL CLASS="itemizedlist"> 479<LI CLASS="listitem"> 480<P CLASS="para"> 481<A CLASS="listitem" NAME="ch07-pgfId-956995"> 482</a><CODE CLASS="literal"> 483printer</code> <CODE CLASS="literal"> 484driver</code></p></li><LI CLASS="listitem"> 485<P CLASS="para"> 486<A CLASS="listitem" NAME="ch07-pgfId-956996"> 487</a><CODE CLASS="literal"> 488printer</code> <CODE CLASS="literal"> 489driver</code> <CODE CLASS="literal"> 490file</code></p></li><LI CLASS="listitem"> 491<P CLASS="para"> 492<A CLASS="listitem" NAME="ch07-pgfId-956997"> 493</a><CODE CLASS="literal"> 494printer</code> <CODE CLASS="literal"> 495driver</code> <CODE CLASS="literal"> 496location</code></p></li></ul><P CLASS="para"> 497The <CODE CLASS="literal"> 498printer</code> <CODE CLASS="literal"> 499driver</code> <CODE CLASS="literal"> 500file</code> is a global option that points to the <I CLASS="filename"> 501printers.def</i> file; place that option in your <CODE CLASS="literal"> 502[global]</code> section. The other options should be set in the printer share for which you wish to automatically configure the drivers. The value for <CODE CLASS="literal"> 503printer</code> <CODE CLASS="literal"> 504driver</code> should match the string that shows up in the Printer Wizard on the Windows system. The value of the <CODE CLASS="literal"> 505printer</code> <CODE CLASS="literal"> 506driver</code> <CODE CLASS="literal"> 507location</code> is the pathname of the PRINTER$ share you set up, not the Unix pathname on the server. Thus, you could use the following:</p><PRE CLASS="programlisting"> 508[global] 509 printer driver file = /usr/local/samba/print/printers.def 510[hpdeskjet] 511 path = /var/spool/samba/printers 512 printable = yes 513 514 printer driver = HP DeskJet 560C Printer 515 printer driver location = \\%L\PRINTER$</pre><P CLASS="para"> 516Now you're ready to test it out. At this point, remove the Windows printer that you "set up" in the first step from the list of printers in the Printers window of My Computer. If Samba asks you to delete unneeded files, do so. These files will be replaced shortly on the client, as they now exist on the Samba server.</p></div><DIV CLASS="sect3"> 517<H4 CLASS="sect3"> 518<A CLASS="title" NAME="ch07-pgfId-949710"> 5197.1.7.5 Testing the configuration</a></h4><P CLASS="para"> 520Restart the Samba daemons and look for the <CODE CLASS="literal"> 521[hpdeskjet]</code> share under the machine name in the Network Neighborhood. At this point, if you click on the printer icon, you should begin the printer setup process and come to the dialog shown in <A CLASS="xref" HREF="ch07_01.html#ch07-60108"> 522Figure 7.6</a>.</p><P CLASS="para"> 523This is different from the dialog you saw earlier when setting up a printer. Essentially, the dialog is asking if you wish to accept the driver that is "already installed" - in other words, offered by Samba. Go ahead and keep the existing driver, and press the Next button. At this point, you can give the printer a name and print out a test page. If it works, the setup should be complete. You should be able to repeat the process now from any Windows client. </p><H4 CLASS="figure"> 524<A CLASS="title" NAME="ch07-60108"> 525Figure 7.6: Automatically configuring the printer driver</a></h4><IMG CLASS="graphic" SRC="figs/sam.0706.gif" ALT="Figure 7.6"></div></div></div></div></blockquote> 526<div> 527<center> 528<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 529<TR> 530<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 531<A CLASS="sect1" HREF="ch06_06.html" TITLE="6.6 Logon Scripts"> 532<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 6.6 Logon Scripts" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 533<A CLASS="book" HREF="index.html" TITLE=""> 534<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 535<A CLASS="sect1" HREF="ch07_02.html" TITLE="7.2 Printing to Windows Client Printers"> 536<IMG SRC="gifs/txtnexta.gif" ALT="Next: 7.2 Printing to Windows Client Printers" BORDER="0"></a></td></tr><TR> 537<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 5386.6 Logon Scripts</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 539<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 540<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 5417.2 Printing to Windows Client Printers</td></tr></table><hr noshade size=1></center> 542</div> 543 544<!-- End of sample chapter --> 545<CENTER> 546<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 547<A HREF="http://www.oreilly.com/"> 548<B>O'Reilly Home</B></A> <B> | </B> 549<A HREF="http://www.oreilly.com/sales/bookstores"> 550<B>O'Reilly Bookstores</B></A> <B> | </B> 551<A HREF="http://www.oreilly.com/order_new/"> 552<B>How to Order</B></A> <B> | </B> 553<A HREF="http://www.oreilly.com/oreilly/contact.html"> 554<B>O'Reilly Contacts<BR></B></A> 555<A HREF="http://www.oreilly.com/international/"> 556<B>International</B></A> <B> | </B> 557<A HREF="http://www.oreilly.com/oreilly/about.html"> 558<B>About O'Reilly</B></A> <B> | </B> 559<A HREF="http://www.oreilly.com/affiliates.html"> 560<B>Affiliated Companies</B></A><p> 561<EM>© 1999, O'Reilly & Associates, Inc.</EM> 562</FONT> 563</CENTER> 564</BODY> 565</html> 566