Printing Support in SAMBA 3.0


0.97beta11, 01-06-2003. post-SambaXP
Kurt Pfeifle, Danka Deutschland GmbH
Freely distributable via digital media -- keep reference to original author -- commercial reprint requires written permission

Table of Contents


PART IV. PRINTING

Chapter 6. "Classical" Printing Support in Samba 3.0

6.1. Features and Benefits

6.2. Technical Introduction

6.3. A simple Configuration to print with Samba 3.0 6.4. Extended sample Configuration to print with Samba 3.0

6.5. Detailed Explanation of the Example's Settings 6.6. Innovations in Samba Printing since 2.2 6.7. Installing Drivers into [print$] 6.8. "The Proof for the Pudding lies in the Eating" (Client Driver Insta Procedure) 6.9. Other Gotchas 6.10. The Imprints Toolset 6.11. Add Network Printers at Logon without User Interaction

6.12. The "addprinter command"

6.13. Migration of "Classical" printing to Samba 3.0

6.14. Publishing Printer Information in Active Directory or LDAP

6.15. Common Errors and Problems

Chapter 7: CUPS Printing Support in Samba 3.0


7.1. Features and Benefits

7.2. Basic Configuration of CUPS support 7.3. Advanced Configuration 7.4. Using CUPS/Samba in an advanced Way -- intelligent printing with PostScript Driver Download 7.5. The CUPS Filtering Architecture 7.6. Network printing (purely Windows) 7.7. Network Printing (Windows clients -- UNIX/Samba Print Servers) 7.8. Network PostScript RIP: CUPS Filters on Server -- clients use PostScript Driver with CUPS-PPDs 7.9. Windows Terminal Servers (WTS) as CUPS Clients 7.10. Setting up CUPS for driver Download 7.11. Installing PostScript Driver Files manually (using rpcclient) 7.11.7. Troubleshooting revisited

7.12. The printing *.tdb Files 7.13. CUPS Print Drivers from Linuxprinting.org
7.14. Page Accounting with CUPS more collected material...

7.15. Auto-Deletion or Preservation of CUPS Spool Files 7.16. When not to use Samba to print to CUPS

7.17. In Case of Trouble..... Chapter 8: APPENDIX

8.1. Trouble Shooting Guidelines to fix typical Samba printing Problems

8.2. Printing from CUPS to Windows attached Printers

8.3. More CUPS filtering Chains

8.4. my TO-BO-DONE list...

8.5. Troubleshooting Tips


Changelog
01-05-2003: corrected typos
            add a very lean smb.conf example
            work on other smb.conf examples
            how to use "testparm" to discover "hidden" settings
            how to set default driver values for all clients
            sketch out a logon script to install printers without user interaction

02-05-2003: add paragraph about "tdbbackup"

03-05-2003: extended explanation for adding drivers remotely (APW + rpcclient)
            added info about how to find out which driver files are required
            added info about how to get hold of the driver files
            added info about running "rpcclient adddriver|setdriver" manually

04-05-2003: made a new structure of content, reorganized headings
            heavily extended manual installation of driver with the help of rpcclient,
                                                 (this is now a step-by-step tutorial)

06-05-2003: a lot of typos corrected -- most is spellchecked now
            checked some of my recipes (they still worked ;-)
            wrote a few sentences about printing *from* Samba *to* CUPS
            include more rundll32 examples (one using also "runas")

17-05-2003: integrated most of the feedback comments from various people
            A lot of feedback from Ken Sarkies -- thanks a lot!
            Ciprian Vizitiu crafted the PNG flowcharts from my original ASCII art. Wow!
                                        (a few bugs and typos in the PNGs need to be corrected.)

25-05-2003: don't confuse files with identical names from "version 2" and "version 3" drivers!
            (included an example)
            Many suggestions by Ken Sarkies made it into this draft

01-06-2003: *complete* overhaul for the foomatic-rip/Linuxprinting.org drivers' section; needs 
            to be further streamlined
            inclusion of a more complex example smb.conf for CUPS 
            re-create paragraphs about CUPS backends (had mysteriously disappeared sometime back)
            elaborated the example about "installing large numbers of printers"


================
  CONTRIBUTORS            
================
Special thanks go to Dragan Krnic, Ken Sarkies and Ciprian Vizitiu. Dragan provided some
very valuable feedback about the manual installation of drivers using rpcclient; Ken did
a meticulous review of the text with many suggestions for improvements; Ciprian converted
my initial ASCII-art flowcharts into the nice PNGs. 2 dozen more people contributed spelling
and translation fixes and other improvements. Thanks!
           

PART IV. PRINTING


Chapter 6. "Classical" Printing Support in Samba 3.0


Last Update : Sun Jun 01st 23:44:15 UTC 2003

Abstract

This is a part of the upcoming collection of HOWTOs added to Samba documentation in preparation of the 3.0 version release. I try to ensure that "everything printing" is current, but it seems a larger job than one person can maintain. Please send updates and corrections to kpfeifle@danka.de.

This documentation is distributed under the GNU General Public License (GPL) version 2. A copy of the license is included with the Samba source distribution. A copy can be found on-line at http://www.fsf.org/licenses/gpl.txt

Cheers, Kurt


6.1. Features and Benefits

Printing is often a mission-critical service for the users. Samba can provide this service reliably and seamlessly for a client network consisting of Windows workstations.

A Samba-3.0 print service may be run on a Standalone or a Domain member server, side by side with file serving functions, or on a dedicated print server. It can be made as tight or as loosely secured as needs dictate. Configurations may be simple or complex. Available authentication schemes are essentially the same as described for file services in previous chapters. Overall, Samba's printing support is now able to replace an NT or Windows 2000 print server full-square, with additional benefits in many cases. Clients may download and install drivers and printers through their familiar "Point'n'Print" mechanism. Printer installations executed by "Logon Scripts" are no problem. Administrators can upload and manage drivers to be used by clients through the familiar "Add Printer Wizard". As an additional benefit, driver and printer management may be run from the commandline or through scripts, making it more efficient in case of large numbers of printers. If a central accounting of print jobs (tracking every single page and supplying the raw data for all sorts of statistical reports) is required, this is best supported by CUPS as the print subsystem underneath the Samba hood.

This chapter deals with the foundations of Samba printing, as they implemented by the more traditional UNIX (BSD- and System V-style) printing systems. Many things apply to CUPS, the newer Common UNIX Printing System, too; so if you use CUPS, you might be tempted to jump to the next chapter -- but you will certainly miss a few things if you do so. Better read this chapter too.

Note, that the author verified most of the given examples on Windows XP Professional clients. If you encounter quotes describing the responses to commands given, bear in mind that Windows 2000 clients are very similar, but may differ in details. Windows NT is somewhat more different. Also, this was done on a German Win XP editon. Translating back to English may not be as accurate as desired. (If you want to help with future editions of this document, please send in correct transcripts of what you see on your screen for the English versions of the various clients).

6.2. Technical Introduction

Samba's printing support always relies on the installed print subsystem of the Unix OS it runs on. Samba is a "middleman". It takes printfiles from Windows (or other SMB) clients and passes them to the real printing system for further processing. Therefore it needs to "talk" to 2 sides: to the Windows print clients and to the Unix printing system. Hence we must differentiate between the various client OS types which behave differently as well as the various UNIX print subsystems, which have different features and are accessed differently. This part of the Samba HOWTO Collection deals with "the traditional" way of Unix printing first; the next chapter covers in great detail the more modern Common UNIX Printing System (CUPS). CUPS users, be warned: don't just jump on to the next chapter. You might miss important info contained only here!

We assume here that you have your printer(s) already configured to print from UNIX: At the very least they must be set up to print when you send pre-formatted printjobs to them. It is then Samba's job to "share" this service to Windows clients.

6.2.1. What happens if you send a Job from a Client

To successfully print a job from a Windows client via a Samba print server to a UNIX printer, there are 6 (potentially 7) stages:

6.2.2. Printing related Configuration Parameters

There are a number of configuration parameters in smb.conf controlling Samba's printing behaviour. Please do also turn to the man page for smb.conf to acquire an overview of these parameters. As with other parameters, there are Global (tagged with a "G" in the listings) and Service Level ("S") parameters.

6.2.3. Parameters recommended for Use

These configuration parameters are directly related to Samba-3.0 printing. Their meaning is explained further below.

LIST OF PRINTING RELATED PARMETERS IN SAMBA-3.0
The following smb.conf parameters directly related to printing are used in Samba 3.0. See also the smb.conf man page for detailed explanations:
    Global level parameters
    • addprinter command (G)
    • deleteprinter command (G)
    • disable spoolss (G)
    • enumports command (G)
    • load printers (G)
    • lpq cache time (G)
    • os2 driver map (G)
    • printcap name (G), printcap (G)
    • show add printer wizard (G)
    • total print jobs (G)
    • use client driver (G)
    Service level parameters
    • hosts allow (S)
    • hosts deny (S)
    • lppause command (S)
    • lpq command (S)
    • lpresume command (S
    • lprm command (S)
    • max print jobs (S)
    • min print space (S)
    • print command (S)
    • printable (S), print ok (S)
    • printer name (S), printer (S)
    • printer admin (S)
    • printing = [cups|bsd|lprng...] (S)
    • queuepause command (S)
    • queueresume command (S)
    • total print jobs (S)

Samba's printing support implements the Microsoft Remote Procedure Calls (MS-RPC) methods for printing. These are used by Windows NT (and later) print servers. The old "LanMan" protocol is still supported as a fallback resort, and for older clients to use. More details will follow further beneath.

6.2.4. Parameters for backwards Compatibility

There have been two new parameters added in Samba 2.2.2, still present in Samba-3.0:

Both of these options are described in the smb.conf(5) man page and are disabled by default. Use them with caution!

PARAMETERS "FOR BACKWARD COMPATIBILITY ONLY", USE WITH CAUTION
The following smb.conf parameters were already in Samba 2.2; they are only used for backward compatibility:
  • disable spoolss (G)
  • use client driver (S)

6.2.5. Parameters no longer in Use

Samba users upgrading from 2.2.x to 3.0 need to be aware, that some previously available settings are no longer supported (as was announced in time). Here is a list of them:

"OLD" PARAMETERS, REMOVED IN SAMBA-3.0
The following smb.conf parameters have been deprecated already in Samba 2.2 and are now completely removed from Samba 3.0. You can not use them in new 3.0 installations:
  • printer driver file (G)
  • total print jobs (G)
  • postscript (S)
  • printer driver (S)
  • printer driver location (S)

6.3. A simple Configuration to print with Samba 3.0

Here is a very simple example configuration for print related settings in the smb.conf file. If you compare it with your own system's smb.conf, you probably find some additional parameters included there (as pre-configured by your OS vendor). Further below is a discussion and explanation of the parameters. Note, that this example doesn't use many parameters. However, in many environments these are enough to provide a valid smb.conf which enables all clients to print.

 [global]
         printing = bsd
         load printers = yes

 [printers]
         path = /var/spool/samba
         printable = yes
         public = yes
         writable = no
        

This is only an example configuration. Many settings, if not explicitly set to a specific value, are used and set by Samba implicitly to its own default, because these have been compiled in. To see all settings, let root use the "testparm" utility. "testparm" also gives warnings if you have mis-configured certain things. Its complete output is easily 340 lines and more. You may want to pipe it through a pager program.

The syntax for the configuration file is easy to grasp. You should know that smb.conf is not very picky about its syntax. It has been explained elsewhere in this document. A short reminder: It even tolerates some spelling errors (like "browsable" instead of "browseable"). Most spelling is case-insensitive. Also, you can use "Yes|No" or "True|False" for boolean settings. Lists of names may be separated by commas, spaces or tabs.

6.3.1. Verification of "Settings in Use" with testparm

To see all (or at least most) printing related settings in Samba, including the implicitly used ones, try the command outlined below (hit "ENTER" twice!). It greps for all occurrences of "lp", "print", "spool", "driver", "ports" and "[" in testparm's output and gives you a nice overview about the running smbd's print configuration. (Note that this command does not show individually created printer shares, or the spooling paths in each case). Here is the output of my Samba, with exactly the same scarce settings in smb.conf as shown above:

 transmeta: # testparm -v | egrep "(lp|print|spool|driver|ports|\[)"
 
 Load smb config files from /etc/samba/smb.conf.simpleprinting
 Processing section "[homes]"
 Processing section "[printers]"
 
 [global]
        smb ports = 445 139
        lpq cache time = 10
        total print jobs = 0
        load printers = Yes
        printcap name = /etc/printcap
        disable spoolss = No
        enumports command =
        addprinter command = 
        deleteprinter command = 
        show add printer wizard = Yes
        os2 driver map =
        printer admin =
        min print space = 0
        max print jobs = 1000
        printable = No
        printing = bsd
        print command = lpr -r -P'%p' %s
        lpq command = lpq -P'%p'
        lprm command = lprm -P'%p' %j
        lppause command =
        lpresume command =
        printer name =
        use client driver = No

 [homes]

 [printers]
        path = /var/spool/samba
        printable = Yes
        

You can easily verify which settings were implicitly added by Samba's default behaviour. Don't forget about this point -- it may be important in you future dealings with Samba.

NOTE: testparm in Samba-3.0 behaves differently from 2.2.x: used without the "-v" switch it only shows you the settings actually written into smb.conf! To see the complete configuration used, add the "-v" parameter to testparm.

6.3.2. A little Experiment to warn you

Should you need to troubleshoot at one stage, please always go back to this point first and verify if "testparm" shows the parameters you expect! To give you an example from personal experience as a warning, try to just "comment out" the "load printers" parameter. If your 2.2.x system behaves like mine, you'll see this:

 kde-bitshop:/etc/samba # grep "load printers" smb.conf
 #      load printers = Yes    # This setting is commented ooouuuuut!!

 kde-bitshop:/etc/samba # testparm -v smb.conf | egrep "(load printers)"
        load printers = Yes
        

Despite of my imagination that the commenting out of this setting should prevent Samba from publishing my printers, it still did! Oh Boy -- it cost me quite some time to find out the reason. But I am not fooled any more... at least not by this ;-)

 kde-bitshop:/etc/samba # grep -A1 "load printers" smb.conf
        load printers = No
        # This setting is what I mean!!
 #      load printers = Yes
        # This setting is commented ooouuuuut!!

 kde-bitshop:/etc/samba # testparm -v smb.conf.simpleprinting | egrep "(load printers)"
        load printers = No
        

Only if setting the parameter explicitly to "load printers = No" would Samba recognize my intentions. So my strong advice is:

You can have a working Samba print configuration with this minimal smb.conf:

 kde-bitshop:/etc/samba # cat /etc/samba/smb.conf-minimal
        [printers]
        

This example should show you, that you can use testparm to test any filename for fitness as a Samba configuration. Actually, we want to encourage you to *not* change your smb.conf on a working system (unless you know exactly what you do)! Don't rely on an assumption that changes will only take effect after you re-start smbd! This is not the case. Samba re-reads its smb.conf every 60 seconds and on each new client connection. You might have to face changes for your productive clients you didn't mean to apply at this time! You will now note a few more interesting things. Just ask testparm what the Samba print configuration would be, if you used this minimalistic file as your real smb.conf:

 kde-bitshop:~ # testparm -v /etc/samba/smb.conf-minimal | egrep "(print|lpq|spool|driver|ports|[)"
 Processing section "[printers]"
 WARNING: [printers] service MUST be printable!
 No path in service printers - using /tmp

        lpq cache time = 10
        total print jobs = 0
        load printers = Yes
        printcap name = /etc/printcap
        disable spoolss = No
        enumports command =
        addprinter command =
        deleteprinter command =
        show add printer wizard = Yes
        os2 driver map =
        printer admin =
        min print space = 0
        max print jobs = 1000
        printable = No
        printing = bsd
        print command = lpr -r -P%p %s
        lpq command = lpq -P%p
        printer name =
        use client driver = No
 [printers]
        printable = Yes
        

testparm issued 2 warnings,

However, this was not fatal, and Samba-3.0 will default to values that will work here. But, please!, don't rely on this and don't use this! This example was only meant to make you carefully design and spell out your setup what you really want it to be. The outcome on your system may vary on some parameters, since you may have a Samba built with a different compile time configuration. [WARNING: Don't put a comment sign *at the end* of a valid smb.conf line. It will make it to be ignored (just as if you had put it on the front). This I at first regarded as a bug in my Samba version(s). But the man page says: "Internal whitespace in a parameter value is retained verbatim." - This means a line consisting of "printing =lpring #This defines LPRng as the printing system" will regard the whole of the string after the "=" sign as the value you want to define. And this is an invalid value that will be ignored, and a default value used instead.]

6.4. Extended sample Configuration to print with Samba 3.0

Here we show a more verbose example configuration for print related settings in an smb.conf. Below is a discussion and explanation of the various parameters. We chose to use BSD-style printing here, because we guess it is still the most commonly used system on legacy Linux installations. (New installs now predominantly have CUPS, which is discussed entirely in the next section of this document). Note, that this example specifically names many parameters which don't need to be -- because they would be used anyway "by default". You might be able to do with a leaner smb.conf. (Tip: if you read access it with "SWAT", and then write it to disk again, it will be optimized in a way such that it doesn't contain any superfluous parameters and comments. SWAT organizes the file for best performance. Remember, that each smbd re-reads the Samba configuration once a minute, and that each connection spawns an smbd process of its own -- so it is not a bad idea to optimize the smb.conf in environments with hundreds or thousands of clients...).

 [global]
         printing = bsd
         load printers = yes
         show add printer wizard = yes
         printcap name = /etc/printcap
         printer admin = @ntadmin, root
         total print jobs = 100
         lpq cache time = 20
         use client driver = no

 [printers]
         comment = All Printers
         printable = yes
         path = /var/spool/samba
         browseable = no
         guest ok = yes
         public = yes
         read only = yes
         writable = no       

 [my_printer_name]
         comment = Printer with Restricted Access
         path = /var/spool/samba_my_printer
         printer admin = kurt
         browseable = yes
         printable = yes
         writeable = no
         hosts allow = 0.0.0.0
         hosts deny = turbo_xp, 10.160.50.23, 10.160.51.60
         guest ok = no
        

This also is only an example configuration. For the [my_printer_name] service it defines a different "printer admin" than is defined in the [global] section, and a differfent spool path. Additionally, it includes a parameter which denies access to 3 hosts. You may not find all the settings in your own smb.conf (as pre-configured by your OS vendor). Many configuration parameters, if not explicitly set to a specific value, are used and set by Samba implicitly to its own default, because these have been compiled in. To see all settings, let root use the "testparm" utility. "testparm" also gives warnings if you have mis-configured certain things.

6.5. Detailed Explanation of the Example's Settings

Following is a discussion of the settings from above shown example.

6.5.1. The [global] Section

The [global] section is one of 4 special sections (along with [homes], [printers] and [print$]...) It contains all parameters which apply to the server as a whole. It is the place for parameters which have only a "global" meaning (G). It may also contain service level parameters (S) which then define settings for all other sections and shares. This way you can simplify the configuration and forego to set the same value repeatedly. (Within each individual section or share you may however override these globally set "share level" settings and specify other values).

printing = bsd
this sets Samba to use default print commands applicable for the BSD (a.k.a. RFC 1179 style or LPR/LPD) printing system. In general, the "printing" parameter informs Samba about the print subsystem it should expect. Samba supports CUPS, LPD, LPRNG, SYSV, HPUX, AIX, QNX and PLP. Each of these systems defaults to a different "print command" (and other queue control commands). (Note, that the "printing" parameter is normally a service level parameter. Since it is included here in the [global] section, it will take effect for all printer shares that are not defined differently). Samba-3.0 does no longer support the SOFTQ printing system.
load printers = yes
this tells Samba to create automatically all available printer shares. "Available" printer shares are discovered by scanning the printcap file. All created printer shares are also loaded for browsing. If you use this parameter, it is not required to specify separate shares for each printer. Each automatically created printer share will clone the configuration options found in the [printers] section. (A "load printers = no" setting will allow you to specify each UNIX printer you want to share separately, leaving out some you don't want to be publicly visible and available).
show add printer wizard = yes
this setting is normally enabled by default (even if the parameter is not written into the smb.conf). It makes the "Add Printer Wizard" icon show up in the "Printers" folder of the Samba host's share listing (as shown in "Network Neighbourhood" or by the "net view" command). To disable it, you need to explicitly set it to "no" (commenting it out will not suffice!). The Add Printer Wizard lets you upload printer drivers to the [print$] share and associate it with a printer (if the respective queue exists there before the action), or exchange a printer's driver against any other previously uploaded driver.
total print jobs = 100
this setting sets the upper limit to 100 print jobs being active on the Samba server at any one time. Should a client submit a job which exceeds this number, a "no more space available on server" type of error message will be returned by Samba to the client. A setting of "0" (the default) means there is *no* limit at all!
printcap name = /etc/printcap
this tells Samba where to look for a list of available printer names. (If you use CUPS, make sure that a printcap file is written: this is controled by the "Printcap" directive of cupsd.conf).
printer admin = @ntadmin
members of the ntadmin group should be able to add drivers and set printer properties ("ntadmin" is only an example name -- it needs to be a valid UNIX group name); root is implicitly always a 'printer admin'. The "@" sign preceeds group names in smb.conf. "printer admins" can do anything to printers via the remote administration interfaces offered by MS-RPC (see below). Note that the "printer admin" parameter is normally a share level parameter, so you may associate different groups to different printer shares in larger installations, if you use the "printer admin" parameter on the share levels).
lpq cache time = 20
this controls the cache time for the results of the lpq command. It prevents the lpq command to be called too often and takes load from a heavily frequented print server.
use client driver = no
if set to "yes", this setting only takes effect for Win NT/2k/XP clients (and not for Win 95/98/ME). Its default value is "No" (or "False"). It must NOT be enabled on print shares (with a "yes" or "true" setting) which have valid drivers installed on the Samba server! For more detailed explanations see the man page of smb.conf.

6.5.2. The [printers] Section

This is the second special section. If a section with this name appears it the smb.conf, users are able to connect to any printer specified in the Samba host's printcap file, because Samba on startup then creates a printer share for every printername it finds in the printcap file. You could regard this section as a general convenience shortcut to share all printers with minimal configuration. It is also a container for settings which should apply as default to all printers. (For more details see the smb.conf man page.) Settings inside this container must be share level parameters (S).

comment = All printers
the "comment" is shown next to the share if a client queries the server, either via "Network Neighbourhood" or with the "net view" command to list available shares.
printable = yes
please note well, that the [printers] service must be declared as printable. If you specify otherwise, smbd will refuse to load smb.conf at startup. This parameter allows connected clients to open, write to and submit spool files into the directory specified with the "path" parameter for this service. It is used by Samba to differentiate printer shares from file shares.
path = /var/spool/samba
this must point to a directory used by Samba to spool incoming print files. It must not be the same as the spool directory specified in the configuration of your UNIX print subsystem! The path would typically point to a directory which is world writeable, with the "sticky" bit set to it.
browseable = no
this is always set to "no" if "printable = yes". It makes the [printer] share itself invisible in the list of available shares in a "net view" command or in the Explorer browse list. (Note that you will of course see the individual printers).
guest ok = yes
if set to "yes", then no password is required to connect to the printers service. Access will be granted with the privileges of the "guest account". On many systems the guest account will map to a user named "nobody". This user is in the UNIX passwd file with an empty password, but with no valid UNIX login. (Note: on some systems the guest account might not have the privilege to be able to print. Test this by logging in as your guest user using "su - guest" and run a system print command like "lpr -P printername /etc/motd"....)
public = yes
this is a synonym for "guest ok = yes". Since we have "guest ok = yes", it really doesn't need to be here! (This leads to the interesting question: "What, if I by accident have to contradictory settings for the same share?" -- The answer is: "The last one encountered by Sambe wins:" The "winner" is shown by testparm. Testparm doesn't complain about different settings of the same parameter for the same share! You can test this by setting up mulitple lines for the "guest account" parameter with different usernames, and then run testparm to see which one is actually used by Samba.)
read only = yes
this normally (for other types of shares) prevents users to create or modify files in the service's directory. However, in a "printable" service, it is ALWAYS allowed to write to the directory (if user privileges allow connection), but only via print spooling operations. "Normal" write operations are not allowed.
writeable = no
synonym for "read only = yes"

6.5.3. Any [my_printer_name] Section

If a section appears in the smb.conf, which is tagged as "printable = yes", Samba presents it as a printer share to its clients. Note, that Win95/98/ME clients may have problems with connecting or loading printer drivers if the share name has more than 8 characters! Also be very carefull if you name a printer the same as an existing user or file share name: Upon a client's connection request to a certain sharename, Samba always tries to find file shares with that name first; if it finds one, it will connect to this and will never come round and attempt to connect to a printer with the same name!

comment = Printer with Restricted Access
the comment says it all.
path = /var/spool/samba_my_printer
here we did set the spooling area for this printer to another directory than the standard. It is not a requirement to set it differently, but an option.
printer admin = kurt
the printer admin definition is different for this explicitly defined printer share from the general convencience [printers] share. It is not a requirement; we did it to show that it is possible if you want it.
browseable = yes
we also made this printer browseable (for the clients' convenience to find it when browsing the Network Neighbourhood).
printable = yes
see explanation in last subsection.
writeable = no
see explanation in last subsection.
hosts allow = 10.160.50., 10.160.51.
here we exercise a certain degree of access control by using the "hosts allow" and "hosts deny" parameters. Note, that this is not by any means a safe bet. It is not a way to secure your printers. This line accepts all clients from a certain subnet in a first evaluation of access control
hosts deny = turbo_xp, 10.160.50.23, 10.160.51.60
all listed hosts are not allowed here (even if they belong to the "allowed subnets"). As you can see, you could name IP addresses as well as NetBIOS hostnames here.
guest ok = no
this printer is not open for the guest account!

6.5.4. Print Commands

In each section defining a printer (or in the [printers] section), a "print command" parameter may be defined. It sets a command to process the files which have been placed into the Samba print spool directory for that printer. (That spool directory was, remember?, set up with the "path" parameter). Typically, this command will submit the spool file to the Samba host's print subsystem, using the suitable system print command. But there is no requirement that this needs to be the case. For debugging purposes or some other reason you may want to do something completely different than "print" the file. An example is that your command just copies it to a save place for further investigation when you need to debug printing. If you craft your own print commands (or even print command shell scripts), make sure you pay attention to also remove the files from the Samba spool directory. Otherwise your hard disk may soon suffer from shortage of free space.

6.5.5. Default Print Commands for various Unix Print Subsystems

You learned earlier on, that Samba in most cases uses its built-in settings for many parameters if it can not find an explicitly stated one in its configuration file. The same is true for the "print command ". The default print command varies depending on the "printing =..." parameter setting. You will notice some funny "%<LETTER>" notions in all the commands beneath. These stand for "printername", "spoolfile" and "job ID". They are explained in more detail further below. Here is an overview (excluding the special case CUPS, which is discussed in the next chapter):

 If this setting is active...        ...this is used in lieu of an explicitly set command:
 ----------------------------        ------------------------------------------------------
 
 printing = bsd|aix|lprng|plp   -->  print command is "lpr -r -P%p %s"
 printing = sysv|hpux           -->  print command is "lp -c -P%p %s; rm %s"
 printing = qnx                 -->  print command is "lp -r -P%p -s %s"
 
 
 printing = bsd|aix|lprng|plp   -->  lpq command is "lpq -P%p"
 printing = sysv|hpux           -->  lpq command is "lpstat -o%p"
 printing = qnx                 -->  lpq command is "lpq -P%p"
 
 
 printing = bsd|aix|lprng|plp   -->  lprm command is "lprm -P%p %j"
 printing = sysv|hpux           -->  lprm command is "cancel %p-%j"
 printing = qnx                 -->  lprm command is "cancel %p-%j"
 
 
 printing = bsd|aix|lprng|plp   -->  lppause command is "lp -i %p-%j -H hold"
 printing = sysv|hpux           -->  lppause command    (...is empty)
 printing = qnx                 -->  lppause command    (...is empty)
 
 
 printing = bsd|aix|lprng|plp   -->  lpresume command is "lp -i %p-%j -H resume"
 printing = sysv|hpux           -->  lpresume command    (...is empty)
 printing = qnx                 -->  lpresume command    (...is empty)
        

We excluded the special CUPS case here, because it is discussed in the next chapter. Just a short summary. For printing = CUPS: If SAMBA is compiled against libcups, it uses the CUPS API to submit jobs, etc. (Please set also "printcap = cups" in case your cupsd.conf is set to write its autogenerated printcap file to an unusual place). Otherwise it maps to the System V commands with the -oraw option for printing, i.e. it uses lp -c -d%p -oraw; rm %s . With printing = cups , and if SAMBA is compiled against libcups, any manually set print command will be ignored!

Having listed the above mappings here, you should note that there used to be a bug in recent 2.2.x versions which prevented the mapping from taking effect. It lead to the "bsd|aix|lprng|plp" settings to take effect for all other systems, for the most important commands (the print command, the lpq command and the lprm command). The lppause command and the lpresume command remained empty. (Of course, these commands worked on bsd|aix|lprng|plp -- but they didn't work on sysv|hpux|qnx systems.) To work around this bug, you need to explicitly set the commands. Use "testparm -v" to check which command takes effect. Then check, if this command is adaequate and actually works for your installed print subsystem. It is always a good idea to explicitly set configuration files up the way you want them to work and not rely on any built-in defaults.

6.5.6. Setting up your own Print Commands

After a print job has finished spooling to a service, the print command will be used by Samba via a system() call to process the spool file. Usually the command specified will submit the spool file to the host's printing subsystem. But there is no requirement at all that this must be the case. The print subsystem will probably not remove the spool file on its own. So whatever command you specify on your own -- you should think to delete the spool file when it has been processed.

Using your own customized print commands is no problem with the traditional printing systems. However, if you don't bother to "roll your own", you should know which are the default built-in commands Samba uses for each printing subsystem (see table above). In all the commands listed in the last paragraphs you see these funny "%<LETTER>" notions. These are macros, or shortcuts, used as place holders for the names of real objects. At the time of running a command with such a placeholder, Samba will insert the appropriate value automatically. Print commands can handle all Samba macro substitutions. In regard to printing, the following ones do have special relevance:

  • %s, %f - the path to the spool file name
  • %p - the appropriate printer name
  • %J - the job name as transmitted by the client.
  • %c - the number of printed pages of the spooled job (if known).
  • %z - the size of the spooled print job (in bytes)

The print command MUST contain at least one occurrence of %s or %f. -- The %p is optional. If no printer name is supplied, the %p will be silently removed from the print command. In this case the job is sent to the default printer.

If specified in the [global] section, the print command given will be used for any printable service that does not have its own print command specified. If there is neither a specified print command for a printable service nor a global print command, spool files will be created but not processed! And (most importantly): print files will not be removed, so they will start filling your Samba hard disk.

Note that printing may fail on some UNIXes from the "nobody" account. If this happens: create an alternative guest account and supply it with the privilege to print; set up this guest account in the [global] section with the "guest account" parameter.

You can form quite complex print commands. You need to realize that print commands are just passed to a UNIX shell. The shell is able to expand the included environment variables as usual. (The syntax to include a UNIX environment variable $variable in smb.conf or in the Samba print command is "%$variable ".) To give you a working "print command" example, the following will log a print job to "/tmp/print.log", print the file, then remove it. Note that ';' is the usual separator for commands in shell scripts:

 print command = echo Printing %s >> /tmp/print.log; lpr -P %p %s; rm %s

You may have to vary your own command considerably from this example depending on how you normally print files on your system. The default for the "print command" parameter varies depending on the setting of the "printing" parameter. -- Another example

 print command = /usr/local/samba/bin/myprintscript %p %s

6.6. Innovations in Samba Printing since 2.2

Before version 2.2.0, Samba's print server support for Windows clients was limited to the level of "LanMan" printing calls. This is the same protocol level as Windows 9x PCs offer when they share printers. Beginning with the 2.2.0 release, Samba started to support the native Windows NT printing mechanisms. These are implemented via MS-RPC (RPC = Remote Procedure Calls). MS-RPCs use the SPOOLSS named pipe for all printing.

The additional functionality provided by the new SPOOLSS support includes:

One other benefit of an update is this: Samba 3.0 is able to publish all its printers in Active Directory (or LDAP)!

One slight difference is here: it is possible on a Windows NT print server to have printers listed in the Printers folder which are not shared. Samba does not make this distinction. By definition, the only printers of which Samba is aware are those which are specified as shares in smb.conf. The reason is that Windows NT/2k/XPprof clients do normally not need and use the standard SMB printer share; they rather print directly to any printer on another Windows NT host using MS-RPC. This of course assumes that the printing client has the necessary privileges on the remote host serving the printer. The default permissions assigned by Windows NT to a printer gives the "Print" permissions to the well-known "Everyone" group. (The older clients of type Win9x can only print to "shared" printers).

6.6.1. Client Drivers on Samba Server for Point'n'Print

There is still confusion about what all this means: Is it or is it not a requirement for printer drivers to be installed on a Samba host in order to support printing from Windows clients? The answer is this: No, it is not a *requirement*. Windows NT/2000 clients can, of course, also run their APW to installing drivers locally (which then connect to a Samba served print queue). This is the same method as used by Windows 9x clients. (However, a bug existed in Samba 2.2.0 which made Windows NT/2000 clients require that the Samba server possess a valid driver for the printer. This was fixed in Samba 2.2.1...).

But it is a new *option* to install the printer drivers into the [print$] share of the Samba server, and a big convenience too. Then all clients (including 95/98/ME) get the driver installed when they first connect to this printer share. The uploading or depositing of the driver into this [print$] share, and the following binding of this driver to an existing Samba printer share can be achieved by different means:

Please take additional note of the following fact: Samba does not use these uploaded drivers in any way to process spooled files. Drivers are utilized entirely by the clients, who download and install them via the "Point 'n'Print" mechanism supported by Samba. The clients use these driver to generate print files in the format the printer (or the Unix print system) requires. Print files received by Samba are handed over to the Unix printing system, which is responsible for all further processing, if needed.

6.6.2. [printer$] Section is removed

[print$] vs. [printer$]
Versions of Samba prior to 2.2 made it possible to use a share named [printer$]. This name was taken from the printer$ service created by Windows 9x clients when a printer was shared by them. Windows 9x printer servers always have a printer$ service which provides read-only access (with no password required) in order to support printer driver downloads.

However, Samba's initial implementation allowed for a parameter named "printer driver location" to be used on a per share basis. This specified the location of the driver files associated with that printer. Another parameter named "printer driver" provided a means of defining the printer driver name to be sent to the client.

These parameters, including the "printer driver file" parameter, are now removed and can not be used in installations of Samba-3.0.

Now the share name [print$] is used for the location of downloadable printer drivers. It is taken from the print$ service created by Windows NT PCs when a printer is shared by them. Windows NT print servers always have a print$ service which provides read-write access (in the context of its ACLs) in order to support printer driver down- and uploads.

Don't fear -- this does not mean Windows 9x clients are thrown aside now. They can use Samba's [print$] share support just fine.

6.6.3. Creating [print$]

In order to support the up- and downloading of printer driver files, you must first configure a file share named [print$]. The "public" name of this share is hard coded in Samba's internals (because it is hardcoded in the MS Windows clients too). It can't be renamed since Windows clients are programmed to search for a service of exactly this name if they want to retrieve printer driver files.

You should modify the server's smb.conf file to add the global parameters and create the [print$] file share (of course, some of the parameter values, such as 'path' are arbitrary and should be replaced with appropriate values for your site):

 [global]
      ; members of the ntadmin group should be able to add drivers and set
      ; printer properties. root is implicitly always a 'printer admin'.
      printer admin = @ntadmin
      [....]

 [printers]
      [....]

 [print$]
      comment = Printer Driver Download Area
      path = /etc/samba/drivers
      browseable = yes
      guest ok = yes
      read only = yes
      write list = @ntadmin, root
    

Of course, you also need to ensure that the directory named by the "path" parameter exists on the Unix file system.

6.6.4. Parameters in the [print$] Section

[print$] is a special section in smb.conf. It contains settings relevant to potential printer driver download and local installation by clients.

comment = Printer Driver Download Area
the comment appears next to the share name if it is listed in a share list. (Usual Windows clients won't see it often -- but it also shows up in a "smbclient -L sambaserver" output.)
path = /etc/samba/printers
this is the path to the location of the Windows driver file deposit from the UNIX point of view.
browseable = no
this makes the [print$] share "invisible" in Network Neighbourhood to clients. However, you can still "mount" it from any client using the "net use g: \\sambaserver\print$" command in a "DOS box" or the "Connect network drive" menu from Windows Explorer.
guest ok = yes
this allows all guest users read only access to this share. Access may be used to download and install printer drivers on clients. The requirement for "guest ok = yes" depends upon how your site is configured. If users will be guaranteed to have an account on the Samba host, then this is a non-issue. (Note: The non-issue is this: if all your Windows NT users are guaranteed to be authenticated by the Samba server (such as a domain member server and the NT user has already been validated by the Domain Controller in order to logon to the Windows NT session), then guest access is not necessary. Of course, in a workgroup environment where you just want to be able to print without worrying about silly accounts and security, then configure the share for guest access. You'll probably want to add map to guest = Bad User in the [global] section as well. Make sure you understand what this parameter does before using it.)
read only = yes
as we don't want everybody to upload driver files (or even change driver settings) we tagged this share as not writeable.
write list = @ntadmin, root
since the [print$] was made read only by the previous setting, we need to create a "write list" also. UNIX users and groups (denoted with a leading "@" character) listed here are allowed write access (as an exception to the general public's "read-only" access), which they need to update files on the share. Normally you will want to only name administrative level user accounts in this setting. Check the file system permissions to make sure these accounts can copy files to the share. If this is setup to a non-root account, then it should also exist as a "printer admin". See the smb.conf man page for more information on configuring file shares.

6.6.5. Subdirectory Structure in [print$]

In order for a Windows NT print server to support the downloading of driver files by multiple client architectures, you must create several subdirectories within the [print$] service (i.e. the Unix directory named by the "path" parameter). These correspond to each of the supported client architectures. Samba follows this model as well. Just like the name of the [print$] share itself, the subdirectories *must* be exactly the names listed below. (You may leave out the subdirs of architectures you don't want to support).

Therefore, create a directory tree below the [print$] share for each architecture you wish to support.

[print$]--+--
          |--W32X86           # serves drivers to "Windows NT x86"
          |--WIN40            # serves drivers to "Windows 95/98"
          |--W32ALPHA         # serves drivers to "Windows NT Alpha_AXP"
          |--W32MIPS          # serves drivers to "Windows NT R4000"
          |--W32PPC           # serves drivers to "Windows NT PowerPC"
        

ATTENTION! REQUIRED PERMISSIONS
In order to currently add a new driver to you Samba host, one of two conditions must hold true:
  • The account used to connect to the Samba host must have a UID of 0 (i.e. a root account)
  • The account used to connect to the Samba host must be named in the printer admin list.

Of course, the connected account must still possess access to add files to the subdirectories beneath [print$]. Remember that all file shares are set to 'read only' by default.

Once you have created the required [print$] service and associated subdirectories, go to a Windows NT 4.0/2k/XP client workstation. Open "Network Neighbourhood" or "My Network Places" and browse for the Samba host. Once you have located the server, navigate to its "Printers and Faxes" folder. You should see an initial listing of printers that matches the printer shares defined on your Samba host.

6.7. Installing Drivers into [print$]

You have successfully created the [print$] share in smb.conf? And Samba has re-read its configuration? Good. But you are not yet ready to take off. The driver files need to be present in this share, too! So far it is still an empty share. Unfortunatly, it is not enough to just copy the driver files over. They need to be set up too. And that is a bit tricky, to say the least. We will now discuss two alternative ways to install the drivers into [print$]:

The latter option is probably the easier one (even if the only entrance to this realm seems a little bit weird at first).

6.7.1. Setting Drivers for existing Printers with a Client GUI

The initial listing of printers in the Samba host's " Printers" folder accessed from a client's Explorer will have no real printer driver assigned to them. By default, in Samba 3.0 (as in 2.2.1 and later) this driver name is set to a NULL string. This must be changed now. the local Add Printer Wizard, run from NT/2000/XP clients, will help us in this task.

However, the job to set a valid driver for the printer is not a straightforward one: You must attempt to view the printer properties for the printer you want the driver assign to. Open the Windows Explorer, open Network Neighbourhood, browse to the Samba host, open Samba's "Printers" folder, right-click the printer icon and select "Properties...". You are now trying to view printer and driver properties for a queue which has this default "NULL" driver assigned. This will result in an error message (this is "normal" here):

Device settings cannot be displayed. The driver for the specified printer is not installed, only spooler properties will be displayed. Do you want to install the driver now?

Don't click "Yes"! Instead, click "No" in the error dialog. Only now you will be presented with the printer properties window. From here, the way to assign a driver to a printer is open to us. You have now the choice. Either

Once the APW is started, the procedure is exactly the same you are used to from Wiindows. We assume here that you are familiar with the printer driver installations procedure on Windows NT. Make sure your connection is setup in fact as a user with printer admin privileges (if in doubt, use "smbstatus" to check for this). If you wish to install printer drivers for client operating systems other than "Windows NT x86", you will need to use the "Sharing" tab of the printer properties dialog.

Assuming you have connected with an administrative (or root) account (as named by the "printer admin" parameter), you will also be able to modify other printer properties such as ACLs and default device settings using this dialog. (For the default device settings, please consider the advice given further below). [ FIXME: This section should sometime in the near future be updated and enhanced and include some screenshots from the process. FIXME]

6.7.2. Setting Drivers for existing Printers with rpcclient

The second way to install printer drivers into [print$] and set them up in a valid way can be done from the UNIX command line. This involves three (or four, if you count "zero" too ;-) distinct steps:

We will provide detailed hints for each of these steps in the next few paragraphs.

6.7.2.1. Identifying the Driver Files

To find out about the driver files, you have two options: you could investigate the driver CD which comes with your printer. Study the *.inf file on the CD, if it is contained. This may not be the possible, since the *.inf file might be missing. Unfortunately, many vendors have now started to use their own installation programs. These installations packages are often some sort of Windows platform archive format, plus, the files may get re-named during the installation process. This makes it extremely difficult to identify the driver files you need.

Then you only have the second option: install the driver first on a Windows client *locally* and investigate which file names and paths it uses after they are installed. (Note, that you need to repeat this procedure for every client platform you want to support. We are going to show it here for the "W32X86" platform only, a name used by Microsoft for all WinNT/2k/XP clients...)

A good method to recognize the driver files this is to print the test page from the driver's Properties Dialog (General tab). Then look at the list of driver files named on the printout. You'll need to recognize what Windows (and Samba) are calling the "Driver File", the "Data File", the "Config File", the "Help File" and (optionally) the "Dependent Driver Files" (this may vary slightly for Windows NT). ( FIXME: Attention -- I've translated this back from German: please someone verify the exact names of these file categories on an English version of Windows...FIXME). You need to remember all names (or better take a note) for the next steps.

Another method to quickly test the driver filenames and related paths is provided by the rpcclient utility. Run it with the "enumdrivers" or with the "getdriver" subcommand, each in the "3" level. In the following example, TURBO_XP is the name of the Windows PC (in this case it was a Windows XP Professional laptop, BTW). I had installed the driver locally to TURBO_XP. kde-bitshop is the name of the Linux host from which I am working. We could run an interactive rpcclient session; then we'd get an rpcclient> prompt and would type the subcommands at this prompt. This is left as a good exercise to the reader. For now we use rpcclient with the "-c" parameter to execute a single subcommand line and exit again. This is the method you would use if you want to create scripts to automate the procedure for a large number of printers and drivers. Note the different quotes used to overcome the different spaces in between words:

  kde-bitshop:~# rpcclient -U'Danka%xxxx' -c 'getdriver "Heidelberg Digimaster 9110 (PS)" 3' TURBO_XP
  cmd = getdriver "Heidelberg Digimaster 9110 (PS)" 3

  [Windows NT x86]
  Printer Driver Info 3:
          Version: [2]
          Driver Name: [Heidelberg Digimaster 9110 (PS)]
          Architecture: [Windows NT x86]
          Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.DLL]
          Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.ppd]
          Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.DLL]
          Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.HLP]
  
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.DLL]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.INI]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1KMMin.DLL]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.dat]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.cat]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.def]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hre]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.vnd]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hlp]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de_reg.HLP]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01Aux.dll]
          Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.NTF]
  
          Monitorname: []
          Defaultdatatype: []
        

You may notice, that this driver has quite a big number of "Dependentfiles" (I know worse cases however). Also, strangely, the "Driver File" is here tagged as "Driver Path".... oh, well. Here we don't have yet support for the so-called "WIN40" architecture installed. This name is used by Microsoft for the Win95/98/ME platforms. If we want to support these, we need to install the Win95/98/ME driver files in addition to those for W32X86 (i.e. the WinNT72000/XP clients) onto a Windows PC. This PC can also host the Win9x drivers, even if itself runs on Windows NT, 2000 or XP.

Since the "print$" share is usually accessible through the Network Neighbourhood, you can also use the UNC notation from Windows Explorer to poke at it. The Win9x driver files will end up in subdirectory "0" of the "WIN40" directory. The full path to access them will be "\\WINDOWSHOST\print$\WIN40\0\".

Note that more recent drivers on Windows 2000 and Wndows XP are installed into the "3" subdirectory instead of the "2". The version 2 of drivers, as used in Windows NT, were running in Kernel Mode. Windows 2000 changed this. While it still can use the Kernel Mode drivers (if this is enabled by the Admin), its native mode for printer drivers is User Mode execution. This requires drivers designed for this. These type of drivers install into the "3" subdirectory.

6.7.2.2. Collecting the Driver Files from a Windows Host's [print$] Share

Now we need to collect all the driver files we identified. in our previous step. Where do we get them from? Well, why not retrieve them from the very PC and the same [print$] share which we investigated in our last step to identify the files? We can use smbclient to do this. We will use the paths and names which were leaked to us by "getdriver". The listing is edited to include linebreaks for readability:

  kde-bitshop:~# smbclient //TURBO_XP/print\$ -U'Danka%xxxx'                            \
                                              -c 'cd W32X86/2;mget HD*_de.*             \
                                              hd*ppd Hd*_de.* Hddm*dll HDN*Aux.DLL'
  added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
  Got a positive name query response from 10.160.50.8 ( 10.160.50.8 )
  Domain=[DEVELOPMENT] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
  Get file Hddm91c1_de.ABD? n
  Get file Hddm91c1_de.def? y
  getting file \W32X86\2\Hddm91c1_de.def of size 428 as Hddm91c1_de.def (22.0 kb/s)     \
                                                                (average 22.0 kb/s)
  Get file Hddm91c1_de.DLL? y
  getting file \W32X86\2\Hddm91c1_de.DLL of size 876544 as Hddm91c1_de.DLL (737.3 kb/s) \
                                                                   (average 737.3 kb/s)
  [...,]
        

After this command is complete, the files are in our current local directory. You probably have noticed that this time we passed several commands to the "-c" parameter, separated by semi-colons. This effects that all commands are executed in sequence on the remote Windows server before smbclient exits again.

Don't forget to repeat the procedure for the "WIN40" architecture should you need to support Win95/98/XP clients. Remember, the files for these architectures are in the WIN40/0/ subdir. Once we are complete, we can run "smbclient ... put" to store the collected files on the Samba server's [print$] share.

6.7.2.3. Depositing the Driver Files into [print$]

So, now we are going to put the driver files into the [print$] share. Remember, the UNIX path to this share has been defined previously in your smb.conf. You also have created subdirectories for the different Windows client types you want to support. Supposing your [print$] share maps to the UNIX path /etc/samba/drivers/, your driver files should now go here:

We again use smbclient to transfer the driver files across the network. We specify the same files and paths as were leaked to us by running "getdriver" against the original Windows install. However, now we are going to store the files into a Samba /UNIX print server's [print$] share...

 kde-bitshop:~# smbclient //SAMBA-CUPS/print\$ -U'root%xxxx' -c 'cd W32X86; put HDNIS01_de.DLL; \
                                               put Hddm91c1_de.ppd; put HDNIS01U_de.DLL;        \
                                               put HDNIS01U_de.HLP; put Hddm91c1_de.DLL;        \
                                               put Hddm91c1_de.INI; put Hddm91c1KMMin.DLL;      \
                                               put Hddm91c1_de.dat; put Hddm91c1_de.dat;        \
                                               put Hddm91c1_de.def; put Hddm91c1_de.hre;        \
                                               put Hddm91c1_de.vnd; put Hddm91c1_de.hlp;        \
                                               put Hddm91c1_de_r.HLP; put HDNIS01Aux.dll;       \
                                               put HDNIS01_de.NTF'
 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
 Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
 Domain=[CUPS-PRINT] OS=[Unix] Server=[Samba 2.2.7a]
 putting file HDNIS01_de.DLL as \W32X86\HDNIS01_de.DLL (4465.5 kb/s) (average 4465.5 kb/s)
 putting file Hddm91c1_de.ppd as \W32X86\Hddm91c1_de.ppd (12876.8 kb/s) (average 4638.9 kb/s)
 putting file HDNIS01U_de.DLL as \W32X86\HDNIS01U_de.DLL (20249.8 kb/s) (average 5828.3 kb/s)
 putting file HDNIS01U_de.HLP as \W32X86\HDNIS01U_de.HLP (9652.8 kb/s) (average 5899.8 kb/s)
 putting file Hddm91c1_de.DLL as \W32X86\Hddm91c1_de.DLL (23777.7 kb/s) (average 10400.6 kb/s)
 putting file Hddm91c1_de.INI as \W32X86\Hddm91c1_de.INI (98.6 kb/s) (average 10329.0 kb/s)
 putting file Hddm91c1KMMin.DLL as \W32X86\Hddm91c1KMMin.DLL (22931.5 kb/s) (average 10501.7 kb/s)
 putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat (2462.8 kb/s) (average 10393.0 kb/s)
 putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat (4925.3 kb/s) (average 10356.3 kb/s)
 putting file Hddm91c1_de.def as \W32X86\Hddm91c1_de.def (417.9 kb/s) (average 10290.1 kb/s)
 putting file Hddm91c1_de.hre as \W32X86\Hddm91c1_de.hre (22571.3 kb/s) (average 11338.5 kb/s)
 putting file Hddm91c1_de.vnd as \W32X86\Hddm91c1_de.vnd (3384.6 kb/s) (average 10754.3 kb/s)
 putting file Hddm91c1_de.hlp as \W32X86\Hddm91c1_de.hlp (18406.8 kb/s) (average 10839.8 kb/s)
 putting file Hddm91c1_de_r.HLP as \W32X86\Hddm91c1_de_r.HLP (20278.3 kb/s) (average 11386.3 kb/s)
 putting file HDNIS01Aux.dll as \W32X86\HDNIS01Aux.dll (14994.6 kb/s) (average 11405.2 kb/s)
 putting file HDNIS01_de.NTF as \W32X86\HDNIS01_de.NTF (23390.2 kb/s) (average 13170.8 kb/s) 
        

Phewww -- that was a lot of typing! Most drivers are a lot smaller -- many only having 3 generic PostScript driver files plus 1 PPD. Note, that while we did retrieve the files from the "2" subdirectory of the "W32X86" directory from the Windows box, we *don't* put them (for now) in this same subdirectory of the Samba box! This re-location will automatically be done by the "adddriver" command which we will run shortly. (And don't forget to also put the files for the Win95/98/ME architecture into the WIN40/ subdirectory should you need them....).

6.7.2.4. Check if the Driver Files are there (with smbclient)

For now we verify that our files are there. This can be done with smbclient too (but of course you can log in via SSH also and do this through a standard UNIX shell access too):

 kde-bitshop:~# smbclient //SAMBA-CUPS/print\$ -U 'root%xxxx' -c 'cd W32X86; pwd; dir; cd 2; pwd; dir'
 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
 Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
 Domain=[CUPS-PRINT] OS=[Unix] Server=[Samba 2.2.7a]

  Current directory is \\SAMBA-CUPS\print$\W32X86\
  .                                   D        0  Sun May  4 03:56:35 2003
  ..                                  D        0  Thu Apr 10 23:47:40 2003
  2                                   D        0  Sun May  4 03:56:18 2003
  HDNIS01Aux.dll                      A    15356  Sun May  4 03:58:59 2003
  Hddm91c1KMMin.DLL                   A    46966  Sun May  4 03:58:59 2003
  HDNIS01_de.DLL                      A   434400  Sun May  4 03:58:59 2003
  HDNIS01_de.NTF                      A   790404  Sun May  4 03:56:35 2003
  Hddm91c1_de.DLL                     A   876544  Sun May  4 03:58:59 2003
  Hddm91c1_de.INI                     A      101  Sun May  4 03:58:59 2003
  Hddm91c1_de.dat                     A     5044  Sun May  4 03:58:59 2003
  Hddm91c1_de.def                     A      428  Sun May  4 03:58:59 2003
  Hddm91c1_de.hlp                     A    37699  Sun May  4 03:58:59 2003
  Hddm91c1_de.hre                     A   323584  Sun May  4 03:58:59 2003
  Hddm91c1_de.ppd                     A    26373  Sun May  4 03:58:59 2003
  Hddm91c1_de.vnd                     A    45056  Sun May  4 03:58:59 2003
  HDNIS01U_de.DLL                     A   165888  Sun May  4 03:58:59 2003
  HDNIS01U_de.HLP                     A    19770  Sun May  4 03:58:59 2003
  Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 03:58:59 2003
                40976 blocks of size 262144. 709 blocks available

  Current directory is \\SAMBA-CUPS\print$\W32X86\2\
  .                                   D        0  Sun May  4 03:56:18 2003
  ..                                  D        0  Sun May  4 03:56:35 2003
  ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
  laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
  ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
  ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
  PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
                40976 blocks of size 262144. 709 blocks available
        

Notice that there are already driver files present in the "2" subdir (probably from a previous installation). Once the files for the new driver are there too, you are still a few steps away from being able to use them on the clients. The only thing you could do *now* is to retrieve them from a client just like you retrieve ordinary files from a file share, by opening print$ in Windows Explorer. But that wouldn't install them per Point'n'Print. The reason is: Samba doesn't know yet that these files are something special, namely printer driver files and it doesn't know yet to which print queue(s) these driver files belong....

6.7.2.5. Running rpcclient with adddriver

So, next you must tell Samba about the special category of the files you just uploaded into the [print$] share. This is done by the "adddriver" command. It will prompt Samba to register the driver files into its internal TDB database files. The following command and its output has been edited, again, for readability:

 kde-bitshop:~# rpcclient -Uroot%xxxx -c 'adddriver "Windows NT x86" "dm9110:HDNIS01_de.DLL: \
                                          Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
                                          NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
                                          Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
                                          Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
                                          HDNIS01Aux.dll,HDNIS01_de.NTF,                     \
                                          Hddm91c1_de_reg.HLP'                       SAMBA-CUPS

 cmd = adddriver "Windows NT x86" "dm9110:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:    \
                                   HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI, \
                                   Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,          \
                                   Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,        \
                                   HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"

 Printer Driver dm9110 successfully installed.
        

After this step the driver should be recognized by Samba on the print server. You need to be very carefull when typing the command. Don't exchange the order of the fields. Some changes would lead to a "NT_STATUS_UNSUCCESSFUL" error message. These become obvious. Other changes might install the driver files successfully, but render the driver unworkable. So take care! Hints about the syntax of the adddriver command are in the man page. The CUPS printing chapter of this HOWTO collection provides a more detailed description, if you should need it.

6.7.2.6. Check how Driver Files have been moved after adddriver finished

One indication for Samba's recognition of the files as driver files is the "successfully installed" message. Another one is the fact, that our files have been moved by the adddriver command into the "2" subdirectory. You can check this again with smbclient:

 kde-bitshop:~# smbclient //SAMBA-CUPS/print\$ -Uroot%xxxx -c 'cd W32X86;dir;pwd;cd 2;dir;pwd'
 added interface ip=10.160.51.162 bcast=10.160.51.255 nmask=255.255.252.0
 Domain=[CUPS-PRINT] OS=[Unix] Server=[Samba 2.2.7a]

  Current directory is \\SAMBA-CUPS\print$\W32X86\
  .                                   D        0  Sun May  4 04:32:48 2003
  ..                                  D        0  Thu Apr 10 23:47:40 2003
  2                                   D        0  Sun May  4 04:32:48 2003
                40976 blocks of size 262144. 731 blocks available 

  Current directory is \\SAMBA-CUPS\print$\W32X86\2\
  .                                   D        0  Sun May  4 04:32:48 2003
  ..                                  D        0  Sun May  4 04:32:48 2003
  DigiMaster.PPD                      A   148336  Thu Apr 24 01:07:00 2003
  ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
  laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
  ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
  ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
  PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
  HDNIS01Aux.dll                      A    15356  Sun May  4 04:32:18 2003
  Hddm91c1KMMin.DLL                   A    46966  Sun May  4 04:32:18 2003
  HDNIS01_de.DLL                      A   434400  Sun May  4 04:32:18 2003
  HDNIS01_de.NTF                      A   790404  Sun May  4 04:32:18 2003
  Hddm91c1_de.DLL                     A   876544  Sun May  4 04:32:18 2003
  Hddm91c1_de.INI                     A      101  Sun May  4 04:32:18 2003
  Hddm91c1_de.dat                     A     5044  Sun May  4 04:32:18 2003
  Hddm91c1_de.def                     A      428  Sun May  4 04:32:18 2003
  Hddm91c1_de.hlp                     A    37699  Sun May  4 04:32:18 2003
  Hddm91c1_de.hre                     A   323584  Sun May  4 04:32:18 2003
  Hddm91c1_de.ppd                     A    26373  Sun May  4 04:32:18 2003
  Hddm91c1_de.vnd                     A    45056  Sun May  4 04:32:18 2003
  HDNIS01U_de.DLL                     A   165888  Sun May  4 04:32:18 2003
  HDNIS01U_de.HLP                     A    19770  Sun May  4 04:32:18 2003
  Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 04:32:18 2003
                40976 blocks of size 262144. 731 blocks available 
        

Another verification is that the timestamp of the printing TDB files is now updated (and possibly their filesize has increased).

6.7.2.7. Check if the Driver is recognized by Samba

Now the driver should be registered with Samba. We can easily verify this, and will do so in a moment. However, this driver is *not yet* associated with a particular printer. We may check the driver status of the files by at least three methods:

6.7.2.8. A Sidenote: you are not bound to specific Driver Names

You can name the driver as you like. If you repeat the "adddriver" step, with the same files as before, but with a different driver name, it will work the same:

 kde-bitshop:~# rpcclient -Uroot%xxxx                                        \
                          -c 'adddriver "Windows NT x86"                     \
                          "myphantasydrivername:HDNIS01_de.DLL:              \
                          Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
                          NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
                          Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
                          Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
                          HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP' SAMBA-CUPS

 cmd = adddriver "Windows NT x86" 
                 "myphantasydrivername:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:\
                  HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,           \
                  Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,                    \
                  Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,                  \
                  HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"

 Printer Driver myphantasydrivername successfully installed.
        
You will also be able to bind that driver to any print queue. (However, you are responsible yourself that you associate drivers to queues which make sense to the target printer...) Note, that you can't run the rpcclient adddriver command repeatedly. Each run "consumes" the files you had put into the [print$] share by moving them into the respective subdirectories. So you *must* preceed an "smbclient ... put" command before each "rpcclient ... addriver" command.

6.7.2.9. Le Finale Grande: Running rpcclient with setdriver

Samba still needs to know *which* printer's driver this is. It needs to create a mapping of the driver to a printer, and store this info in its "memory", the TDB files. The rpcclient setdriver command achieves exactly this:

 kde-bitshop:~# rpcclient -U'root%xxxx' -c 'setdriver dm9110 myphantasydrivername' SAMBA-CUPS
 cmd = setdriver dm9110 myphantasydrivername
 Succesfully set dm9110 to driver myphantasydrivername.
        
Ahhhhh -- na, didn't want to do that. Repeat, this time with the name I intended:
 kde-bitshop:~# rpcclient -U'root%xxxx' -c 'setdriver dm9110 dm9110' SAMBA-CUPS
 cmd = setdriver dm9110 dm9110
 Succesfully set dm9110 to driver dm9110.
        
The syntax of the command is rpcclient -U'root%sambapassword' -c 'setdriver "printername" "drivername' SAMBA-Hostname . -- Now we have done *most* of the work. But not yet all....

Note that the "setdriver" command will only succeed, if the printer is known to Samba already. A bug in 2.2.x prevented Samba from recognizing freshly installed printers. You had to restart Samba, or at least send a HUP signal to all running smbd processes to work around this: "kill -HUP `pidof smbd`"

6.8. "The Proof for the Pudding lies in the Eating" (Client Driver Insta Procedure)

A famous philosopher said once: "The Proof for the Pudding lies in the Eating". The proof for our setup lies in the printing. So let's install the printer driver onto the client PCs. This is not as straightforward as it may seem. Read on.

6.8.1. The first Client Driver Installation

Especially important is the installation onto the first client PC (for each architectural platform separately). Once this is done right, all further clients are easy and shouldn't need further attention. What follows is a description for the recommended first procedure. You work now from a client workstation. First you should guarantee that your connection is not unwittingly mapped to bad user "nobody". In a DOS box type:

net use \\SAMBA-SERVER\print$ /user:root

Replace root, if needed, by another valid 'printer admin' user as of smb.conf definition. Should you already be connected as a different user, you'll get an error message. There is no easy way to get rid of that connection, because Windows doesn't seem to know a concept of "logging off" from a share connection (don't confuse this with logging off from the local workstation; that is a different matter). You can try to close *all* Windows file explorer and Internet Explorer windows. As a last resort, you may have to reboot. Make sure there is no automatic re-connection set up. (It may be easier to go to a different workstation and try from there...). After you made sure you are connected as a printer admin user (you can check this with the "smbstatus" command on Samba), do this from the Windows workstation:

A new printer (named "printername on samba-server ") should now have appeared in your *local* Printer folder (Start --> Settings --> Control Panel --> Printers and Faxes). ( FIXME: this was translated from German. Someone please tell me the correct words. FIXME ) --

Most likely you are now tempted to try and print a test page. After all, you now can open the printer properties and on the "General" tab, there is a button offering to do just that. But chances are that you get an error message saying "Unable to print Test Page." The reason might be that there is not yet a valid Device Mode set for the driver, or that the "Printer Driver Data" set is still incomplete.

You must now make sure that a valid "Device Mode" is set for the driver. Don't fear -- we will explain now what that means.

6.8.2. IMPORTANT! Setting Device Modes on new Printers

In order for a printer to be truly usable by a Windows NT/2K/XP client, it must possess:

If either one of these is incomplete, the clients can produce less than optimal output at best. In the worst cases, unreadable garbage or nothing at all comes from the printer or they only harvest error messages when attempting to print. Samba stores the named values and all printing related info in its internal TDB database files (ntprinters.tdb, ntdrivers.tdb, printing.tdb and ntforms.tdb).

What do these two words stand for? Basically, the Device Mode and the set of Printer Driver Data is a collection of settings for all print queue properties, initialized in a sensible way. Device Modes and PrinterDriverData should initially be set on the print server (that is here: the Samba host) to healthy values so that the clients can start to use them immediately. How do we set these initial healthy values? This can be achieved by accessing the drivers remotely from an NT (or 2k/XP) client, as is discussed in the next paragraphs.

Be aware, that a valid Device Mode can only be initiated by a "printer admin", or root (the reason should be obvious). Device Modes can only correctly be set by executing the printer driver program itself. Since Samba can not execute this Win32 platform driver code, it sets this field initially to NULL (which is not a valid setting for clients to use). Fortunately, most drivers generate themselves the PrinterDriverData that is needed, when they are uploaded to the [print$] share with the help of the APW or rpcclient.

The generation and setting of a first valid Device Mode however requires some "tickling" from a client, to set it on the Samba server. The easiest means of doing so is to simply change the page orientation on the server's printer. This "executes" enough of the printer driver program on the client for the desired effect to happen, and feeds back the new DeviceMode to our Sanba server. You can use the native Windows NT/2K/XP printer properties page from a Window client for this:

This procedure has executed the printer driver program on the client platform and fed back the correct Device Mode to Samba, which now stored it in its TDB files. (Once the driver is installed on the client, you can follow the analogous steps by accessing the *local* "Printers" folder too if you are a Samba printer admin user.) From now on printing should work as expected.

Samba also includes a service level parameter name default devmode for generating a default Device Mode for a printer. Some driver will function fine with Samba's default set of properties. Others may crash the client's spooler service. So use this parameter with caution. It is always better to have the client generate a valid device mode for the printer and store it on the server for you.

6.8.3. Further Client Driver Insta Procedures

Every further driver may be done by any user, along the lines described above: Browse network, open printers folder on Samba server, right-click printer and choose "Connect...". Once this completes (should be not more than a few seconds, but could also take a minute, depending on network conditions), you should find the new printer in your client workstation local "Printers and Faxes" folder.

You can also open your local "Printers and Faxes" folder by using this command on Windows 2000 and Windows XP Professional workstations:

rundll32 shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder

or this command on Windows NT 4.0 workstations:

rundll32 shell32.dll,Control_RunDLL MAIN.CPL @2

You can enter the commands either inside a "DOS box" window or in the "Run command..." field from the "Start" menu.

6.8.4. Always make first Client Connection as root or "printer admin"

After you installed the driver on the Samba server (in its [print$] share, you should always make sure that your first client installation goes OK. Make it a habbit for yourself to build that the very first connection from a client as "printer admin". This is to make sure that

Do this by changing the orientation to landscape, " Apply" and change it back. Then set up the other things. (You don't want the default media size set to Letter, when you are all using A4, right? You may want to set the thing do duplex as the default; etc.). --

To connect as root to a Samba printer, try this command from a Windows 2K/XP DOS box command prompt:

runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry /p /t3 /n \\SAMBA-SERVER\printername"

You are prompted for root's Samba-password; type it, wait a few seconds and click on "Printing Defaults..." and proceed to set the job options as should be used as defaults by all clients. -- Alternatively, instead of root you can name one other member of the printer admins from the smb.conf setting.

Now all the other users downloading and installing the driver the same way (called "Point'n'Print") will have the same defaults set for them. If you miss this step you'll get a lot of helpdesk calls from your users. But maybe you like to talk to people.... ;-)

6.9. Other Gotchas

Your driver is installed. It is ready for " Point'n'Print" installation by the clients now. You may have tried to download and use it onto your first client machine now. But wait... let's make you acquainted first with a few tips and tricks you may find useful. For example, you didn't manage to "set the defaults" on the printer, as adviced in the preceeding paragraphs? And your users complain about various issues ? (like "We need to set the paper size for each job from Letter to A4 and it won't store it!")

6.9.1. Setting default Print Options for the Client Drivers

The last sentence might by seen with mixed feelings by some users and admins. They have struggled for hours and hours and couldn't arrive at a point were their settings seemed to be saved. It is not their fault. The confusing thing is this: in the multi-tabbed dialog popping up when you right-click the printer name and select " Properties...", you can arrive at two identically looking dialogs, pretending that they help you to set printer options, in three different ways. Here is the definite answer to the "Samba Default Driver Setting FAQ":

"I can't set and save default print options for all users on Win2K/XP! Why not?"
How are you doing it? I bet the wrong way.... (It is not very easy to find out, though). There are 3 different ways to bring you to a dialog that *seems* to set everything. All three dialogs *look* the same. Only one of them *does* what you intend. (You need to be Administrator or Print Administrator to do it for all users.)
Here is how I reproduce it in on XP Prof (my interface is German -- my re-translation into English might not be accurate):
A. the first "wrong" way:
  • 1. Open the "Printers" folder.
  • 2. Right-click on the printer ("remoteprinter on cupshost") and select in context menu "Printing Preferences..."
  • 3. Look at this dialog closely and remember how it looks like.
B. the second, another "wrong" way:
  • 1. Open the "Printers" folder.
  • 2. Right-click on the printer ("remoteprinter on cupshost") and select in context menu "Properties"
  • 3. Click on the "General" tab
  • 4. Click on the button "Printing Preferences..."
  • 5. A new dialog opens. Keep this dialog open and go back to the parent dialog.
C. the third, the "correct" way:
(Should you do it from the beginning, just do steps 1. + 2. from above "B.")
  • 3. Click on the "Advanced" tab. (Hmmm... everything "Grayed Out"? You are not logged in as a user with enough privileges then.)
  • 4. Click on the "Printing Defaults..." button. (*)
  • 5. On any of the two new tabs, click on the "Advanced..." button. (*)
  • 6. A new dialog opens. Compare this one to the other, identical looking one from "B.5" or A.3".