17.3 Simple Print Configuration

Example 17.1 shows a simple printing configuration. If you compare this with your own, you may find additional parameters that have been pre-configured by your OS vendor. Below is a discussion and explanation of the parameters. This example does not use many parameters. However, in many environments these are enough to provide a valid smb.conf file that enables all clients to print.

Example 17.1 Simple configuration with BSD printing
  [global]   printing = bsd   load printers = yes   [printers]   path = /var/spool/samba   printable = yes   public = yes   writable = no  

This is only an example configuration. Samba assigns default values to all configuration parameters. The defaults are conservative and sensible . When a parameter is specified in the smb.conf file, this overwrites the default value. The testparm utility when run as root is capable of reporting all setting, both default as well as smb.conf file settings. Testparm gives warnings for all misconfigured settings. The complete output is easily 340 lines and more, so you may want to pipe it through a pager program.

The syntax for the configuration file is easy to grasp. You should know that is not very picky about its syntax. As has been explained elsewhere in this document, Samba tolerates some spelling errors (such as browsable instead of browseable ), and spelling is case-insensitive. It is permissible to use Yes/No or True/False for Boolean settings. Lists of names may be separated by commas, spaces or tabs.

17.3.1 Verifing Configuration with testparm

To see all (or at least most) printing- related settings in Samba, including the implicitly used ones, try the command outlined below. This command greps for all occurrences of lp , print , spool , driver , ports and [ in testparms output. This provides a convenient overview of the running smbd print configuration. This command does not show individually created printer shares or the spooling paths they may use. Here is the output of my Samba setup, with settings shown in Example 17.1:

 root# testparm -s -v  egrep "(lpprintspooldriverports\[)" Load smb config files from /etc/samba/smb.conf 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 behavior. Remember: it may be important in your future dealings with Samba .



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

17.3.2 Rapid Configuration Validation

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

 root# grep "load printers" /etc/samba/smb.conf # load printers = Yes # This setting is commented out!! root# testparm -v /etc/samba/smb.conf  egrep "(load printers)" load printers = Yes 

I assumed that commenting out of this setting should prevent Samba from publishing my printers, but it still did. It took some time to figure out the reason. But I am no longer fooled ... at least not by this.

 root# grep -A1 "load printers" /etc/samba/smb.conf load printers = No # The above setting is what I want! # load printers = Yes # This setting is commented out! root# testparm -s -v smb.conf.simpleprinting  egrep "(load printers)" load printers = No 

Only when the parameter is explicitly set to load printers = No would Samba conform with my intentions. So, my strong advice is:

  • Never rely on commented out parameters.

  • Always set parameters explicitly as you intend them to behave.

  • Use testparm to uncover hidden settings that might not reflect your intentions.

The following is the most minimal configuration file:

 root# cat /etc/samba/smb.conf-minimal [printers] 

This example should show that you can use testparm to test any Samba configuration file. Actually, we encourage you not to change your working system (unless you know exactly what you are doing). Don't rely on the assumption that changes will only take effect after you re-start smbd! This is not the case. Samba re-reads it every 60 seconds and on each new client connection. You might have to face changes for your production clients that you didn't intend to apply. You will now note a few more interesting things; testparm is useful to identify what the Samba print configuration would be if you used this minimalistic configuration. Here is what you can expect to find:

 root# testparm -v smb.conf-minimal  egrep "(printlpqspooldriverports[)" 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 two warnings:

  • We did not specify the [printers] section as printable.

  • We did not tell Samba which spool directory to use.

However, this was not fatal and Samba will default to values that will work. Please, do not rely on this and do not use this example. This was included to encourage you to be careful to design and specify your setup to do precisely what you require. The outcome on your system may vary for some parameters given, since Samba may have been built with different compile-time options. Warning: do not put a comment sign at the end of a valid line. It will cause the parameter to be ignored (just as if you had put the comment sign at the front). At first I regarded this as a bug in my Samba versions. But the man page clearly says: " Internal whitespace in a parameter value is retained verbatim ." This means that a line consisting of, for example:

  printing = lprng  

will regard the whole of the string after the " = " sign as the value you want to define. This is an invalid value that will be ignored and a default value will be used in its place.

Official Samba-3 HOWTO and Reference Guide
The Official Samba-3 HOWTO and Reference Guide, 2nd Edition
ISBN: 0131882228
EAN: 2147483647
Year: 2005
Pages: 297

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net