620aa5e8ba228668196d634b63079341392e39e0
[abartlet/samba.git/.git] / docs / htmldocs / printing.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 13. Printing Support</title><link rel="stylesheet" href="samba.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"><link rel="home" href="index.html" title="SAMBA Project Documentation"><link rel="up" href="optional.html" title="Part III. Advanced Configuration"><link rel="previous" href="groupmapping.html" title="Chapter 12. Configuring Group Mapping"><link rel="next" href="CUPS-printing.html" title="Chapter 14. CUPS Printing Support"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 13. Printing Support</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="groupmapping.html">Prev</a> </td><th width="60%" align="center">Part III. Advanced Configuration</th><td width="20%" align="right"> <a accesskey="n" href="CUPS-printing.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><h2 class="title"><a name="printing"></a>Chapter 13. Printing Support</h2></div><div><div class="author"><h3 class="author">Gerald (Jerry) Carter</h3><div class="affiliation"><span class="orgname">Samba Team<br></span><div class="address"><p><tt>&lt;<a href="mailto:jerry@samba.org">jerry@samba.org</a>&gt;</tt></p></div></div></div></div><div><div class="author"><h3 class="author">Patrick Powell</h3><div class="affiliation"><div class="address"><p><tt>&lt;<a href="mailto:papowell@lprng.org">papowell@lprng.org</a>&gt;</tt></p></div></div></div></div><div><p class="pubdate"> (3 May 2001) </p></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="printing.html#id2886394">Introduction</a></dt><dt><a href="printing.html#id2886510">Configuration</a></dt><dd><dl><dt><a href="printing.html#id2886557">Creating [print$]</a></dt><dt><a href="printing.html#id2886789">Setting Drivers for Existing Printers</a></dt><dt><a href="printing.html#id2886888">Support a large number of printers</a></dt><dt><a href="printing.html#id2886995">Adding New Printers via the Windows NT APW</a></dt><dt><a href="printing.html#id2887127">Samba and Printer Ports</a></dt></dl></dd><dt><a href="printing.html#id2886128">The Imprints Toolset</a></dt><dd><dl><dt><a href="printing.html#id2886155">What is Imprints?</a></dt><dt><a href="printing.html#id2887231">Creating Printer Driver Packages</a></dt><dt><a href="printing.html#id2887251">The Imprints server</a></dt><dt><a href="printing.html#id2887275">The Installation Client</a></dt></dl></dd><dt><a href="printing.html#id2886236">Diagnosis</a></dt><dd><dl><dt><a href="printing.html#id2886243">Introduction</a></dt><dt><a href="printing.html#id2887448">Debugging printer problems</a></dt><dt><a href="printing.html#id2887515">What printers do I have?</a></dt><dt><a href="printing.html#id2887557">Setting up printcap and print servers</a></dt><dt><a href="printing.html#id2887691">Job sent, no output</a></dt><dt><a href="printing.html#id2888240">Job sent, strange output</a></dt><dt><a href="printing.html#id2888316">Raw PostScript printed</a></dt><dt><a href="printing.html#id2888334">Advanced Printing</a></dt><dt><a href="printing.html#id2888360">Real debugging</a></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2886394"></a>Introduction</h2></div></div><p>Beginning with the 2.2.0 release, Samba supports 
3 the native Windows NT printing mechanisms implemented via 
4 MS-RPC (i.e. the SPOOLSS named pipe).  Previous versions of 
5 Samba only supported LanMan printing calls.</p><p>The additional functionality provided by the new 
6 SPOOLSS support includes:</p><div class="itemizedlist"><ul type="disc"><li><p>Support for downloading printer driver 
7         files to Windows 95/98/NT/2000 clients upon demand.
8         </p></li><li><p>Uploading of printer drivers via the 
9         Windows NT Add Printer Wizard (APW) or the 
10         Imprints tool set (refer to <a href="http://imprints.sourceforge.net" target="_top">http://imprints.sourceforge.net</a>). 
11         </p></li><li><p>Support for the native MS-RPC printing 
12         calls such as StartDocPrinter, EnumJobs(), etc...  (See 
13         the MSDN documentation at <a href="http://msdn.microsoft.com/" target="_top">http://msdn.microsoft.com/</a> 
14         for more information on the Win32 printing API)
15         </p></li><li><p>Support for NT Access Control Lists (ACL) 
16         on printer objects</p></li><li><p>Improved support for printer queue manipulation 
17         through the use of an internal databases for spooled job 
18         information</p></li></ul></div><p>
19 There has been some initial confusion about what all this means
20 and whether or not it is a requirement for printer drivers to be 
21 installed on a Samba host in order to support printing from Windows 
22 clients. As a side note, Samba does not use these drivers in any way to process 
23 spooled files.  They are utilized entirely by the clients.
24 </p><p>
25 The following MS KB article, may be of some help if you are dealing with
26 Windows 2000 clients:  <span class="emphasis"><em>How to Add Printers with No User 
27 Interaction in Windows 2000</em></span>
28 </p><p>
29 <a href="http://support.microsoft.com/support/kb/articles/Q189/1/05.ASP" target="_top">http://support.microsoft.com/support/kb/articles/Q189/1/05.ASP</a>
30 </p></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2886510"></a>Configuration</h2></div></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">[print$] vs. [printer$]</h3><p>
31 Previous versions of Samba recommended using a share named [printer$].  
32 This name was taken from the printer$ service created by Windows 9x 
33 clients when a printer was shared.  Windows 9x printer servers always have 
34 a printer$ service which provides read-only access via no 
35 password in order to support printer driver downloads.
36 </p><p>
37 However, the initial implementation allowed for a 
38 parameter named <i><tt>printer driver location</tt></i> 
39 to be used on a per share basis to specify the location of 
40 the driver files associated with that printer.  Another 
41 parameter named <i><tt>printer driver</tt></i> provided 
42 a means of defining the printer driver name to be sent to 
43 the client.
44 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886557"></a>Creating [print$]</h3></div></div><p>
45 In order to support the uploading of printer driver 
46 files, you must first configure a file share named [print$].  
47 The name of this share is hard coded in Samba's internals so 
48 the name is very important (print$ is the service used by 
49 Windows NT print servers to provide support for printer driver 
50 download).
51 </p><p>You should modify the server's smb.conf file to add the global
52 parameters and to create the 
53 following file share (of course, some of the parameter values,
54 such as 'path' are arbitrary and should be replaced with
55 appropriate values for your site):</p><pre class="programlisting">
56 [global]
57     ; members of the ntadmin group should be able
58     ; to add drivers and set printer properties
59     ; root is implicitly a 'printer admin'
60     printer admin = @ntadmin
61
62 [print$]
63     path = /usr/local/samba/printers
64     guest ok = yes
65     browseable = yes
66     read only = yes
67     ; since this share is configured as read only, then we need
68     ; a 'write list'.  Check the file system permissions to make
69     ; sure this account can copy files to the share.  If this
70     ; is setup to a non-root account, then it should also exist
71     ; as a 'printer admin'
72     write list = @ntadmin,root
73 </pre><p>The <a href="smb.conf.5.html#WRITELIST" target="_top"><i><tt>
74 write list</tt></i></a> is used to allow administrative 
75 level user accounts to have write access in order to update files 
76 on the share.  See the <a href="smb.conf.5.html" target="_top">smb.conf(5) 
77 man page</a> for more information on configuring file shares.</p><p>The requirement for <a href="smb.conf.5.html#GUESTOK" target="_top"><b>guest 
78 ok = yes</b></a> depends upon how your
79 site is configured.  If users will be guaranteed to have 
80 an account on the Samba host, then this is a non-issue.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Author's Note</h3><p>
81 The non-issue is that if all your Windows NT users are guaranteed to be 
82 authenticated by the Samba server (such as a domain member server and the NT 
83 user has already been validated by the Domain Controller in 
84 order to logon to the Windows NT console), then guest access 
85 is not necessary.  Of course, in a workgroup environment where 
86 you just want to be able to print without worrying about 
87 silly accounts and security, then configure the share for 
88 guest access.  You'll probably want to add <a href="smb.conf.5.html#MAPTOGUEST" target="_top"><b>map to guest = Bad User
89 </b></a> in the [global] section as well.  Make sure 
90 you understand what this parameter does before using it 
91 though. --jerry
92 </p></div><p>In order for a Windows NT print server to support 
93 the downloading of driver files by multiple client architectures,
94 it must create subdirectories within the [print$] service
95 which correspond to each of the supported client architectures.
96 Samba follows this model as well.</p><p>Next create the directory tree below the [print$] share 
97 for each architecture you wish to support.</p><p><tt>
98 [print$]-----
99         |-W32X86           ; &quot;Windows NT x86&quot;
100         |-WIN40            ; &quot;Windows 95/98&quot;
101         |-W32ALPHA         ; &quot;Windows NT Alpha_AXP&quot;
102         |-W32MIPS          ; &quot;Windows NT R4000&quot;
103         |-W32PPC           ; &quot;Windows NT PowerPC&quot;
104 </tt></p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">ATTENTION!  REQUIRED PERMISSIONS</h3><p>
105 In order to currently add a new driver to you Samba host, 
106 one of two conditions must hold true:
107 </p><div class="itemizedlist"><ul type="disc"><li><p>The account used to connect to the Samba host 
108         must have a uid of 0 (i.e. a root account)</p></li><li><p>The account used to connect to the Samba host
109         must be a member of the <a href="smb.conf.5.html#PRINTERADMIN" target="_top"><i><tt>printer 
110         admin</tt></i></a> list.</p></li></ul></div><p>
111 Of course, the connected account must still possess access
112 to add files to the subdirectories beneath [print$]. Remember
113 that all file shares are set to 'read only' by default.
114 </p></div><p>
115 Once you have created the required [print$] service and 
116 associated subdirectories, simply log onto the Samba server using 
117 a root (or <i><tt>printer admin</tt></i>) account
118 from a Windows NT 4.0/2k client.  Open &quot;Network Neighbourhood&quot; or
119 &quot;My Network Places&quot; and browse for the Samba host.  Once you have located
120 the server, navigate to the &quot;Printers...&quot; folder.
121 You should see an initial listing of printers
122 that matches the printer shares defined on your Samba host.
123 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886789"></a>Setting Drivers for Existing Printers</h3></div></div><p>The initial listing of printers in the Samba host's 
124 Printers folder will have no real printer driver assigned 
125 to them. This defaults to a NULL string to allow the use
126 of the local Add Printer Wizard on NT/2000 clients.
127 Attempting to view the printer properties for a printer
128 which has this default driver assigned will result in 
129 the error message:</p><p>
130 <span class="emphasis"><em>Device settings cannot be displayed.  The driver 
131 for the specified printer is not installed, only spooler 
132 properties will be displayed.  Do you want to install the 
133 driver now?</em></span>
134 </p><p>
135 Click &quot;No&quot; in the error dialog and you will be presented with
136 the printer properties window.  The way to assign a driver to a 
137 printer is to either
138 </p><div class="itemizedlist"><ul type="disc"><li><p>Use the &quot;New Driver...&quot; button to install 
139         a new printer driver, or</p></li><li><p>Select a driver from the popup list of 
140         installed drivers.  Initially this list will be empty.</p></li></ul></div><p>If you wish to install printer drivers for client 
141 operating systems other than &quot;Windows NT x86&quot;, you will need 
142 to use the &quot;Sharing&quot; tab of the printer properties dialog.</p><p>Assuming you have connected with a root account, you 
143 will also be able modify other printer properties such as 
144 ACLs and device settings using this dialog box.</p><p>A few closing comments for this section, it is possible 
145 on a Windows NT print server to have printers
146 listed in the Printers folder which are not shared.  Samba does
147 not make this distinction.  By definition, the only printers of
148 which Samba is aware are those which are specified as shares in
149 <tt>smb.conf</tt>.</p><p>Another interesting side note is that Windows NT clients do
150 not use the SMB printer share, but rather can print directly 
151 to any printer on another Windows NT host using MS-RPC.  This
152 of course assumes that the printing client has the necessary
153 privileges on the remote host serving the printer.  The default
154 permissions assigned by Windows NT to a printer gives the &quot;Print&quot;
155 permissions to the &quot;Everyone&quot; well-known group.
156 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886888"></a>Support a large number of printers</h3></div></div><p>One issue that has arisen during the development
157 phase of Samba 2.2 is the need to support driver downloads for
158 100's of printers.  Using the Windows NT APW is somewhat 
159 awkward to say the list.  If more than one printer are using the 
160 same driver, the <a href="rpcclient.1.html" target="_top"><b>rpcclient's
161 setdriver command</b></a> can be used to set the driver
162 associated with an installed driver.  The following is example
163 of how this could be accomplished:</p><p>
164 <tt>$ </tt><b><tt>rpcclient pogo -U root%secret -c &quot;enumdrivers&quot;</tt></b>
165 </p><pre class="programlisting"> 
166 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
167  
168 [Windows NT x86]
169 Printer Driver Info 1:
170      Driver Name: [HP LaserJet 4000 Series PS]
171  
172 Printer Driver Info 1:
173      Driver Name: [HP LaserJet 2100 Series PS]
174  
175 Printer Driver Info 1:
176      Driver Name: [HP LaserJet 4Si/4SiMX PS]
177 </pre><p>                                 
178 <tt>$ </tt><b><tt>rpcclient pogo -U root%secret -c &quot;enumprinters&quot;</tt></b>
179 </p><pre class="programlisting">
180 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
181      flags:[0x800000]
182      name:[\\POGO\hp-print]
183      description:[POGO\\POGO\hp-print,NO DRIVER AVAILABLE FOR THIS PRINTER,]
184      comment:[]
185                                   
186 </pre><p>
187 <tt>$ </tt><b><tt>rpcclient pogo -U root%secret -c &quot;setdriver hp-print \&quot;HP LaserJet 4000 Series PS\&quot;&quot;</tt></b>
188 </p><pre class="programlisting">
189 Domain=[NARNIA] OS=[Unix] Server=[Samba 2.2.0-alpha3]
190 Successfully set hp-print to driver HP LaserJet 4000 Series PS.
191 </pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886995"></a>Adding New Printers via the Windows NT APW</h3></div></div><p>
192 By default, Samba offers all printer shares defined in <tt>smb.conf</tt>
193 in the &quot;Printers...&quot; folder.  Also existing in this folder is the Windows NT 
194 Add Printer Wizard icon.  The APW will be show only if
195 </p><div class="itemizedlist"><ul type="disc"><li><p>The connected user is able to successfully
196         execute an OpenPrinterEx(\\server) with administrative
197         privileges (i.e. root or <i><tt>printer admin</tt></i>).
198         </p></li><li><p><a href="smb.conf.5.html#SHOWADDPRINTERWIZARD" target="_top"><i><tt>show 
199         add printer wizard = yes</tt></i></a> (the default).
200         </p></li></ul></div><p>
201 In order to be able to use the APW to successfully add a printer to a Samba 
202 server, the <a href="smb.conf.5.html#ADDPRINTERCOMMAND" target="_top"><i><tt>add 
203 printer command</tt></i></a> must have a defined value.  The program
204 hook must successfully add the printer to the system (i.e. 
205 <tt>/etc/printcap</tt> or appropriate files) and 
206 <tt>smb.conf</tt> if necessary.
207 </p><p>
208 When using the APW from a client, if the named printer share does 
209 not exist, <b>smbd</b> will execute the <i><tt>add printer 
210 command</tt></i> and reparse to the <tt>smb.conf</tt>
211 to attempt to locate the new printer share.  If the share is still not defined,
212 an error of &quot;Access Denied&quot; is returned to the client.  Note that the 
213 <i><tt>add printer program</tt></i> is executed under the context
214 of the connected user, not necessarily a root account.
215 </p><p>
216 There is a complementary <a href="smb.conf.5.html#DELETEPRINTERCOMMAND" target="_top"><i><tt>delete
217 printer command</tt></i></a> for removing entries from the &quot;Printers...&quot;
218 folder.
219 </p><p>
220 The following is an example <a href="smb.conf.5.html#ADDPRINTERCOMMAN" target="_top"><i><tt>add printer command</tt></i></a> script. It adds the appropriate entries to <tt>/etc/printcap.local</tt> (change that to what you need) and returns a line of 'Done' which is needed for the whole process to work.
221 </p><pre class="programlisting">
222 #!/bin/sh
223
224 # Script to insert a new printer entry into printcap.local
225 #
226 # $1, printer name, used as the descriptive name
227 # $2, share name, used as the printer name for Linux
228 # $3, port name
229 # $4, driver name
230 # $5, location, used for the device file of the printer
231 # $6, win9x location
232
233 #
234 # Make sure we use the location that RedHat uses for local printer defs
235 PRINTCAP=/etc/printcap.local
236 DATE=`date +%Y%m%d-%H%M%S`
237 LP=lp
238 RESTART=&quot;service lpd restart&quot;
239
240 # Keep a copy
241 cp $PRINTCAP $PRINTCAP.$DATE
242 # Add the printer to $PRINTCAP
243 echo &quot;&quot;                                                       &gt;&gt; $PRINTCAP
244 echo &quot;$2|$1:\\&quot;                                       &gt;&gt; $PRINTCAP
245 echo &quot;  :sd=/var/spool/lpd/$2:\\&quot;                     &gt;&gt; $PRINTCAP
246 echo &quot;  :mx=0:ml=0:sh:\\&quot;                             &gt;&gt; $PRINTCAP
247 echo &quot;  :lp=/usr/local/samba/var/print/$5.prn:&quot;       &gt;&gt; $PRINTCAP
248
249 touch &quot;/usr/local/samba/var/print/$5.prn&quot; &gt;&gt; /tmp/printadd.$$ 2&gt;&amp;1
250 chown $LP &quot;/usr/local/samba/var/print/$5.prn&quot; &gt;&gt; /tmp/printadd.$$ 2&gt;&amp;1
251
252 mkdir /var/spool/lpd/$2
253 chmod 700 /var/spool/lpd/$2
254 chown $LP /var/spool/lpd/$2
255 #echo $1 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
256 #echo $2 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
257 #echo $3 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
258 #echo $4 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
259 #echo $5 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
260 #echo $6 &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
261 $RESTART &gt;&gt; &quot;/usr/local/samba/var/print/$5.prn&quot;
262 # Not sure if this is needed
263 touch /usr/local/samba/lib/smb.conf
264 #
265 # You need to return a value, but I am not sure what it means.
266 #
267 echo &quot;Done&quot;
268 exit 0
269 </pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887127"></a>Samba and Printer Ports</h3></div></div><p>
270 Windows NT/2000 print servers associate a port with each printer.  These normally
271 take the form of LPT1:, COM1:, FILE:, etc...  Samba must also support the
272 concept of ports associated with a printer.  By default, only one printer port,
273 named &quot;Samba Printer Port&quot;, exists on a system.  Samba does not really a port in
274 order to print, rather it is a requirement of Windows clients.  
275 </p><p>
276 Note that Samba does not support the concept of &quot;Printer Pooling&quot; internally 
277 either.  This is when a logical printer is assigned to multiple ports as 
278 a form of load balancing or fail over.
279 </p><p>
280 If you require that multiple ports be defined for some reason,
281 <tt>smb.conf</tt> possesses a <a href="smb.conf.5.html#ENUMPORTSCOMMAND" target="_top"><i><tt>enumports 
282 command</tt></i></a> which can be used to define an external program 
283 that generates a listing of ports on a system.
284 </p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2886128"></a>The Imprints Toolset</h2></div></div><p>The Imprints tool set provides a UNIX equivalent of the 
285         Windows NT Add Printer Wizard.  For complete information, please 
286         refer to the Imprints web site at <a href="http://imprints.sourceforge.net/" target="_top">
287         http://imprints.sourceforge.net/</a> as well as the documentation 
288         included with the imprints source distribution.  This section will 
289         only provide a brief introduction to the features of Imprints.</p><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886155"></a>What is Imprints?</h3></div></div><p>Imprints is a collection of tools for supporting the goals 
290                 of</p><div class="itemizedlist"><ul type="disc"><li><p>Providing a central repository information 
291                         regarding Windows NT and 95/98 printer driver packages</p></li><li><p>Providing the tools necessary for creating 
292                         the Imprints printer driver packages.</p></li><li><p>Providing an installation client which 
293                         will obtain and install printer drivers on remote Samba 
294                         and Windows NT 4 print servers.</p></li></ul></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887231"></a>Creating Printer Driver Packages</h3></div></div><p>The process of creating printer driver packages is beyond
295                 the scope of this document (refer to Imprints.txt also included
296                 with the Samba distribution for more information).  In short,
297                 an Imprints driver package is a gzipped tarball containing the
298                 driver files, related INF files, and a control file needed by the
299                 installation client.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887251"></a>The Imprints server</h3></div></div><p>The Imprints server is really a database server that 
300                 may be queried via standard HTTP mechanisms.  Each printer 
301                 entry in the database has an associated URL for the actual
302                 downloading of the package.  Each package is digitally signed
303                 via GnuPG which can be used to verify that package downloaded
304                 is actually the one referred in the Imprints database.  It is 
305                 <span class="emphasis"><em>not</em></span> recommended that this security check 
306                 be disabled.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887275"></a>The Installation Client</h3></div></div><p>More information regarding the Imprints installation client 
307                 is available in the <tt>Imprints-Client-HOWTO.ps</tt> 
308                 file included with the imprints source package.</p><p>The Imprints installation client comes in two forms.</p><div class="itemizedlist"><ul type="disc"><li><p>a set of command line Perl scripts</p></li><li><p>a GTK+ based graphical interface to 
309                         the command line perl scripts</p></li></ul></div><p>The installation client (in both forms) provides a means
310                 of querying the Imprints database server for a matching
311                 list of known printer model names as well as a means to 
312                 download and install the drivers on remote Samba and Windows
313                 NT print servers.</p><p>The basic installation process is in four steps and 
314                 perl code is wrapped around <b>smbclient</b> 
315                 and <b>rpcclient</b>.</p><pre class="programlisting">   
316 foreach (supported architecture for a given driver)
317 {
318      1.  rpcclient: Get the appropriate upload directory 
319          on the remote server
320      2.  smbclient: Upload the driver files
321      3.  rpcclient: Issues an AddPrinterDriver() MS-RPC
322 }
323         
324 4.  rpcclient: Issue an AddPrinterEx() MS-RPC to actually
325     create the printer
326 </pre><p>One of the problems encountered when implementing 
327                 the Imprints tool set was the name space issues between 
328                 various supported client architectures.  For example, Windows 
329                 NT includes a driver named &quot;Apple LaserWriter II NTX v51.8&quot; 
330                 and Windows 95 calls its version of this driver &quot;Apple 
331                 LaserWriter II NTX&quot;</p><p>The problem is how to know what client drivers have 
332                 been uploaded for a printer.  As astute reader will remember 
333                 that the Windows NT Printer Properties dialog only includes 
334                 space for one printer driver name.  A quick look in the 
335                 Windows NT 4.0 system registry at</p><p><tt>HKLM\System\CurrentControlSet\Control\Print\Environment
336                 </tt></p><p>will reveal that Windows NT always uses the NT driver 
337                 name.  This is ok as Windows NT always requires that at least 
338                 the Windows NT version of the printer driver is present.  
339                 However, Samba does not have the requirement internally.  
340                 Therefore, how can you use the NT driver name if is has not 
341                 already been installed?</p><p>The way of sidestepping this limitation is to require 
342                 that all Imprints printer driver packages include both the Intel 
343                 Windows NT and 95/98 printer drivers and that NT driver is 
344                 installed first.</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2886236"></a>Diagnosis</h2></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2886243"></a>Introduction</h3></div></div><p>
345 This is a short description of how to debug printing problems with
346 Samba. This describes how to debug problems with printing from a SMB
347 client to a Samba server, not the other way around. For the reverse
348 see the examples/printing directory.
349 </p><p>
350 Ok, so you want to print to a Samba server from your PC. The first
351 thing you need to understand is that Samba does not actually do any
352 printing itself, it just acts as a middleman between your PC client
353 and your Unix printing subsystem. Samba receives the file from the PC
354 then passes the file to a external &quot;print command&quot;. What print command
355 you use is up to you.
356 </p><p>
357 The whole things is controlled using options in smb.conf. The most
358 relevant options (which you should look up in the smb.conf man page)
359 are:
360 </p><pre class="programlisting">
361       [global]
362         print command     - send a file to a spooler
363         lpq command       - get spool queue status
364         lprm command      - remove a job
365       [printers]
366         path = /var/spool/lpd/samba
367 </pre><p>
368 The following are nice to know about:
369 </p><pre class="programlisting">
370         queuepause command   - stop a printer or print queue
371         queueresume command  - start a printer or print queue
372 </pre><p>
373 Example:
374 </p><pre class="programlisting">
375         print command = /usr/bin/lpr -r -P%p %s
376         lpq command   = /usr/bin/lpq    -P%p %s
377         lprm command  = /usr/bin/lprm   -P%p %j
378         queuepause command = /usr/sbin/lpc -P%p stop
379         queuepause command = /usr/sbin/lpc -P%p start
380 </pre><p>
381 Samba should set reasonable defaults for these depending on your
382 system type, but it isn't clairvoyant. It is not uncommon that you
383 have to tweak these for local conditions.  The commands should
384 always have fully specified pathnames,  as the smdb may not have
385 the correct PATH values.
386 </p><p>
387 When you send a job to Samba to be printed,  it will make a temporary
388 copy of it in the directory specified in the [printers] section.
389 and it should be periodically cleaned out.  The lpr -r option
390 requests that the temporary copy be removed after printing; If
391 printing fails then you might find leftover files in this directory,
392 and it should be periodically cleaned out.  Samba used the lpq
393 command to determine the &quot;job number&quot; assigned to your print job
394 by the spooler.
395 </p><p>
396 The %&gt;letter&lt; are &quot;macros&quot; that get dynamically replaced with appropriate
397 values when they are used. The %s gets replaced with the name of the spool
398 file that Samba creates and the %p gets replaced with the name of the
399 printer. The %j gets replaced with the &quot;job number&quot; which comes from
400 the lpq output.
401 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887448"></a>Debugging printer problems</h3></div></div><p>
402 One way to debug printing problems is to start by replacing these
403 command with shell scripts that record the arguments and the contents
404 of the print file. A simple example of this kind of things might
405 be:
406 </p><pre class="programlisting">
407         print command = /tmp/saveprint %p %s
408
409     #!/bin/saveprint
410     # we make sure that we are the right user
411     /usr/bin/id -p &gt;/tmp/tmp.print
412     # we run the command and save the error messages
413     # replace the command with the one appropriate for your system
414     /usr/bin/lpr -r -P$1 $2 2&gt;&gt;&amp;/tmp/tmp.print
415 </pre><p>
416 Then you print a file and try removing it.  You may find that the
417 print queue needs to be stopped in order to see the queue status
418 and remove the job:
419 </p><pre class="programlisting">
420
421 h4: {42} % echo hi &gt;/tmp/hi
422 h4: {43} % smbclient //localhost/lw4
423 added interface ip=10.0.0.4 bcast=10.0.0.255 nmask=255.255.255.0
424 Password: 
425 Domain=[ASTART] OS=[Unix] Server=[Samba 2.0.7]
426 smb: \&gt; print /tmp/hi
427 putting file /tmp/hi as hi-17534 (0.0 kb/s) (average 0.0 kb/s)
428 smb: \&gt; queue
429 1049     3            hi-17534
430 smb: \&gt; cancel 1049
431 Error cancelling job 1049 : code 0
432 smb: \&gt; cancel 1049
433 Job 1049 cancelled
434 smb: \&gt; queue
435 smb: \&gt; exit
436 </pre><p>
437 The 'code 0' indicates that the job was removed.  The comment
438 by the  smbclient is a bit misleading on this.
439 You can observe the command output and then and look at the
440 /tmp/tmp.print file to see what the results are.  You can quickly
441 find out if the problem is with your printing system.  Often people
442 have problems with their /etc/printcap file or permissions on
443 various print queues.
444 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887515"></a>What printers do I have?</h3></div></div><p>
445 You can use the 'testprns' program to check to see if the printer
446 name you are using is recognized by Samba.  For example,  you can
447 use:
448 </p><pre class="programlisting">
449     testprns printer /etc/printcap
450 </pre><p>
451 Samba can get its printcap information from a file or from a program.
452 You can try the following to see the format of the extracted
453 information:
454 </p><pre class="programlisting">
455     testprns -a printer /etc/printcap
456
457     testprns -a printer '|/bin/cat printcap'
458 </pre></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887557"></a>Setting up printcap and print servers</h3></div></div><p>
459 You may need to set up some printcaps for your Samba system to use.
460 It is strongly recommended that you use the facilities provided by
461 the print spooler to set up queues and printcap information.
462 </p><p>
463 Samba requires either a printcap or program to deliver printcap
464 information.  This printcap information has the format:
465 </p><pre class="programlisting">
466   name|alias1|alias2...:option=value:...
467 </pre><p>
468 For almost all printing systems, the printer 'name' must be composed
469 only of alphanumeric or underscore '_' characters.  Some systems also
470 allow hyphens ('-') as well.  An alias is an alternative name for the
471 printer,  and an alias with a space in it is used as a 'comment'
472 about the printer.  The printcap format optionally uses a \ at the end of lines
473 to extend the printcap to multiple lines.
474 </p><p>
475 Here are some examples of printcap files:
476 </p><p>
477 </p><div class="orderedlist"><ol type="1"><li><p>
478 pr              just printer name
479 </p></li><li><p>
480 pr|alias        printer name and alias
481 </p></li><li><p>
482 pr|My Printer   printer name, alias used as comment
483 </p></li><li><p>
484 pr:sh:\        Same as pr:sh:cm= testing
485   :cm= \ 
486   testing
487 </p></li><li><p>
488 pr:sh           Same as pr:sh:cm= testing
489   :cm= testing
490 </p></li></ol></div><p>
491 </p><p>
492 Samba reads the printcap information when first started.  If you make
493 changes in the printcap information, then you must do the following:
494 </p><div class="orderedlist"><ol type="1"><li><p>
495 make sure that the print spooler is aware of these changes.
496 The LPRng system uses the 'lpc reread' command to do this.
497 </p></li><li><p>
498 make sure that the spool queues, etc., exist and have the
499 correct permissions.  The LPRng system uses the 'checkpc -f'
500 command to do this.
501 </p></li><li><p>
502 You now should send a SIGHUP signal to the smbd server to have
503 it reread the printcap information.
504 </p></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2887691"></a>Job sent, no output</h3></div></div><p>
505 This is the most frustrating part of printing.  You may have sent the
506 job,  verified that the job was forwarded,  set up a wrapper around
507 the command to send the file,  but there was no output from the printer.
508 </p><p>
509 First,  check to make sure that the job REALLY is getting to the
510 right print queue.  If you are using a BSD or LPRng print spooler,
511 you can temporarily stop the printing of jobs.  Jobs can still be
512 submitted, but they will not be printed.  Use:
513 </p><pre class="programlisting">
514   lpc -Pprinter stop
515 </pre><p>
516 Now submit a print job and then use 'lpq -Pprinter' to see if the
517 job is in the print queue.  If it is not in the print queue then
518 you will have to find out why it is not being accepted for printing.
519 </p><p>
520 Next, you may want to check to see what the format of the job really
521 was.  With the assistance of the system administrator you can view
522 the submitted jobs files.  You may be surprised to find that these
523 are not in what you would expect to call a printable format.
524 You can use the UNIX 'file' utitily to determine what the job
525 format actually is:
526 </p><pre class="programlisting">
527     cd /var/spool/lpd/printer   # spool directory of print jobs
528     ls                          # find job files
529     file dfA001myhost
530 </pre><p>
531 You should make sure that your printer supports this format OR that
532 your system administrator has installed a 'print filter' that will
533 convert the file to a format appropriate for your printer.
534 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2888240"></a>Job sent, strange output</h3></div></div><p>
535 Once you have the job printing, you can then start worrying about
536 making it print nicely.
537 </p><p>
538 The most common problem is extra pages of output: banner pages
539 OR blank pages at the end.
540 </p><p>
541 If you are getting banner pages,  check and make sure that the
542 printcap option or printer option is configured for no banners.
543 If you have a printcap,  this is the :sh (suppress header or banner
544 page) option.  You should have the following in your printer.
545 </p><pre class="programlisting">
546    printer: ... :sh
547 </pre><p>
548 If you have this option and are still getting banner pages,  there
549 is a strong chance that your printer is generating them for you
550 automatically.  You should make sure that banner printing is disabled
551 for the printer.  This usually requires using the printer setup software
552 or procedures supplied by the printer manufacturer.
553 </p><p>
554 If you get an extra page of output,  this could be due to problems
555 with your job format,  or if you are generating PostScript jobs,
556 incorrect setting on your printer driver on the MicroSoft client.
557 For example, under Win95 there is a option:
558 </p><pre class="programlisting">
559   Printers|Printer Name|(Right Click)Properties|Postscript|Advanced|
560 </pre><p>
561 that allows you to choose if a Ctrl-D is appended to all jobs.
562 This is a very bad thing to do, as most spooling systems will
563 automatically add a ^D to the end of the job if it is detected as
564 PostScript.  The multiple ^D may cause an additional page of output.
565 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2888316"></a>Raw PostScript printed</h3></div></div><p>
566 This is a problem that is usually caused by either the print spooling
567 system putting information at the start of the print job that makes
568 the printer think the job is a text file, or your printer simply
569 does not support PostScript.  You may need to enable 'Automatic
570 Format Detection' on your printer.
571 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2888334"></a>Advanced Printing</h3></div></div><p>
572 Note that you can do some pretty magic things by using your
573 imagination with the &quot;print command&quot; option and some shell scripts.
574 Doing print accounting is easy by passing the %U option to a print
575 command shell script. You could even make the print command detect
576 the type of output and its size and send it to an appropriate
577 printer.
578 </p></div><div class="sect2" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2888360"></a>Real debugging</h3></div></div><p>
579 If the above debug tips don't help, then maybe you need to bring in
580 the bug guns, system tracing. See Tracing.txt in this directory.
581 </p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="groupmapping.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="optional.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="CUPS-printing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 12. Configuring Group Mapping </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 14. CUPS Printing Support</td></tr></table></div></body></html>