1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 4] 4.2 Special Sections</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:32:00Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch04_01.html" TITLE="4.1 Learning the Samba Configuration File"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 4.1 Learning the Samba Configuration File" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38<A CLASS="chapter" REL="up" HREF="ch04_01.html" TITLE="4. Disk Shares "> 39Chapter 4<br> 40Disk Shares </a></font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 41<A CLASS="sect1" HREF="ch04_03.html" TITLE="4.3 Configuration File Options"> 42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 4.3 Configuration File Options" BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 43</div> 44<blockquote> 45<div> 46<H2 CLASS="sect1"> 47<A CLASS="title" NAME="ch04-81402"> 484.2 Special Sections</a></h2><P CLASS="para"> 49<I CLASS="filename"> 50</i>Now that we've gotten our feet wet with variables, there are a few special sections of the Samba configuration file that we should talk about. Again, don't worry if you do not understand each and every configuration options listed below; we'll go over each of them over the course of the upcoming chapters.</p><DIV CLASS="sect2"> 51<H3 CLASS="sect2"> 52<A CLASS="title" NAME="ch04-pgfId-943263"> 534.2.1 The [ globals] Section</a></h3><P CLASS="para"> 54The <CODE CLASS="literal"> 55[globals]</code> section appears in virtually every Samba configuration file, even though it is not mandatory to define one. Any option set in this section of the file will apply to all the other shares, as if the contents of the section were copied into the share itself. There is one catch: other sections can list the same option in their section with a new value; this has the effect of overriding the value specified in the <CODE CLASS="literal"> 56[globals]</code> section. </p><P CLASS="para"> 57To illustrate this, let's again look at the opening example of the chapter:</p><PRE CLASS="programlisting"> 58[global] 59 log level = 1 60 max log size = 1000 61 socket options = TCP_NODELAY IPTOS_LOWDELAY 62 guest ok = no 63[homes] 64 browseable = no 65 map archive = yes 66[printers] 67 path = /usr/tmp 68 guest ok = yes 69 printable = yes 70 min print space = 2000 71[test] 72 browseable = yes 73 read only = yes 74 guest ok = yes 75 path = /export/samba/test</pre><P CLASS="para"> 76In the previous example, if we were going to connect a client to the <CODE CLASS="literal"> 77[test]</code> share, Samba would first read in the <CODE CLASS="literal"> 78[globals]</code> section. At that point, it would set the option <CODE CLASS="literal"> 79guest</code> <CODE CLASS="literal"> 80ok</code> <CODE CLASS="literal"> 81=</code> <CODE CLASS="literal"> 82no</code> as the global default for each share it encounters throughout the configuration file. This includes the <CODE CLASS="literal"> 83[homes]</code> and <CODE CLASS="literal"> 84[printers]</code> shares. When it reads in the <CODE CLASS="literal"> 85[test]</code> share, however, it would then find the configuration option <CODE CLASS="literal"> 86guest</code> <CODE CLASS="literal"> 87ok</code> <CODE CLASS="literal"> 88=</code> <CODE CLASS="literal"> 89yes</code>, and override the default from the <CODE CLASS="literal"> 90[globals]</code> section with the value <CODE CLASS="literal"> 91yes</code> in the context of the <CODE CLASS="literal"> 92[pub]</code> share.</p><P CLASS="para"> 93Any option that appears outside of a section (before the first marked section) is also assumed to be a global option.</p></div><DIV CLASS="sect2"> 94<H3 CLASS="sect2"> 95<A CLASS="title" NAME="ch04-pgfId-942795"> 964.2.2 The [homes] Section</a></h3><P CLASS="para"> 97If a client attempts to connect to a share that doesn't appear in the <I CLASS="filename"> 98smb.conf</i> file, Samba will search for a <CODE CLASS="literal"> 99[homes]</code> share in the configuration file. If one exists, the unidentified share name is assumed to be a Unix username, which is queried in the password database of the Samba server. If that username appears, Samba assumes the client is a Unix user trying to connect to his or her home directory on the server.</p><P CLASS="para"> 100For example, assume a client machine is connecting to the Samba server <CODE CLASS="literal"> 101hydra</code> for the first time, and tries to connect to a share named [<CODE CLASS="literal">alice]</code>. There is no <CODE CLASS="literal"> 102[alice]</code> share defined in the <I CLASS="filename"> 103smb.conf</i> file, but there is a <CODE CLASS="literal"> 104[homes]</code>, so Samba searches the password database file and finds an <CODE CLASS="literal">alice</code> user account is present on the system. Samba then checks the password provided by the client against user <CODE CLASS="literal">alice</code>'s Unix password - either with the password database file if it's using non-encrypted passwords, or Samba's <I CLASS="filename"> 105smbpasswd</i> file if encrypted passwords are in use. If the passwords match, then Samba knows it has guessed right: the user <CODE CLASS="literal">alice</code> is trying to connect to her home directory. Samba will then create a share called <CODE CLASS="literal">[alice]</code> for her.</p><P CLASS="para"> 106The process of using the <CODE CLASS="literal"> 107[homes]</code> section to create users (and dealing with their passwords) is discussed in more detail in the <a href="ch06_01.html"><b>Chapter 6, <CITE CLASS="chapter">Users, Security, and Domains</cite></b></a>.</p></div><DIV CLASS="sect2"> 108<H3 CLASS="sect2"> 109<A CLASS="title" NAME="ch04-pgfId-942816"> 1104.2.3 The [printers] Section</a></h3><P CLASS="para"> 111The third special section is called <CODE CLASS="literal"> 112[printers]</code> and is similar to <CODE CLASS="literal"> 113[homes]</code>. If a client attempts to connect to a share that isn't in the <I CLASS="filename"> 114smb.conf</i> file, and its name can't be found in the password file, Samba will check to see if it is a printer share. Samba does this by reading the printer capabilities file (usually <I CLASS="filename"> 115/etc/printcap</i>) to see if the share name appears there.[<A CLASS="footnote" HREF="#ch04-pgfId-960558">1</a>] If it does, Samba creates a share named after the printer.</p><BLOCKQUOTE CLASS="footnote"> 116<DIV CLASS="footnote"> 117<P CLASS="para"> 118<A CLASS="footnote" NAME="ch04-pgfId-960558">[1]</a> Depending on your system, this file may not be <EM CLASS="emphasis"> 119/etc/printcap</em>. You can use the <EM CLASS="emphasis"> 120testparm</em> command that comes with Samba to determine the value of the <CODE CLASS="literal"> 121printcap</code> <CODE CLASS="literal"> 122name</code> configuration option; this was the default value chosen when Samba was compiled.</p></div></blockquote><P CLASS="para"> 123Like <CODE CLASS="literal"> 124[homes]</code>, this means you don't have to maintain a share for each of your system printers in the <I CLASS="filename"> 125smb.conf</i> file. Instead, Samba honors the Unix printer registry if you request it to, and provides the registered printers to the client machines. There is, however, an obvious limitation: if you have an account named <CODE CLASS="literal"> 126fred</code> and a printer named <CODE CLASS="literal"> 127fred</code>, Samba will always find the user account first, even if the client really needed to connect to the printer.</p><P CLASS="para"> 128The process of setting up the <CODE CLASS="literal"> 129[printers]</code> share is discussed in more detail in <a href="ch07_01.html"><b>Chapter 7, <CITE CLASS="chapter">Printing and Name Resolution</cite></b></a>.<I CLASS="filename"> 130</i> </p></div><DIV CLASS="sect2"> 131<H3 CLASS="sect2"> 132<A CLASS="title" NAME="ch04-pgfId-968226"> 1334.2.4 Configuration Options</a></h3><P CLASS="para"> 134<I CLASS="filename"> 135</i>Options in the Samba configuration files fall into one of two categories: <I CLASS="firstterm"> 136global</i> or <I CLASS="firstterm"> 137share</i>. Each category dictates where an option can appear in the configuration file.</p><DL CLASS="variablelist"> 138<DT CLASS="term"> 139Global</dt><DD CLASS="listitem"> 140<P CLASS="para">Global options <EM CLASS="emphasis"> 141must</em> appear in the <CODE CLASS="literal"> 142[global]</code> section and nowhere else. These are options that typically apply to the behavior of the Samba server itself, and not to any of its shares.</p></dd><DT CLASS="term"> 143Share</dt><DD CLASS="listitem"> 144<P CLASS="para">Share options can appear in specific shares, or they can appear in the <CODE CLASS="literal"> 145[global]</code> section. If they appear in the <CODE CLASS="literal"> 146[global]</code> section, they will define a default behavior for all shares, unless a share overrides the option with a value of its own.</p></dd></dl><P CLASS="para"> 147In addition, the values that a configuration option can take can be divided into four categories. They are as follows:</p><DL CLASS="variablelist"> 148<DT CLASS="term"> 149Boolean</dt><DD CLASS="listitem"> 150<P CLASS="para">These are simply yes or no values, but can be represented by any of the following: <CODE CLASS="literal"> 151yes</code>, <CODE CLASS="literal"> 152no</code>, <CODE CLASS="literal"> 153true</code>, <CODE CLASS="literal"> 154false</code>, <CODE CLASS="literal"> 1550</code>, <CODE CLASS="literal"> 1561</code>. The values are case insensitive: <CODE CLASS="literal"> 157YES</code> is the same as <CODE CLASS="literal"> 158yes</code>.</p></dd><DT CLASS="term"> 159Numerical</dt><DD CLASS="listitem"> 160<P CLASS="para">An integer, hexidecimal, or octal number. The standard <CODE CLASS="literal"> 1610x</code><EM CLASS="emphasis"> 162nn</em> syntax is used for hexadecimal and <CODE CLASS="literal"> 1630</code><EM CLASS="emphasis"> 164nnn</em> for octal.</p></dd><DT CLASS="term"> 165String</dt><DD CLASS="listitem"> 166<P CLASS="para"> 167A string of case-sensitive characters, such as a filename or a username.</p></dd><DT CLASS="term"> 168Enumerated list</dt><DD CLASS="listitem"> 169<P CLASS="para"> 170A finite list of known values. In effect, a boolean is an enumerated list with only two values.<I CLASS="filename"> 171</i> </p></dd></dl></div></div></blockquote> 172<div> 173<center> 174<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 175<TR> 176<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 177<A CLASS="sect1" HREF="ch04_01.html" TITLE="4.1 Learning the Samba Configuration File"> 178<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 4.1 Learning the Samba Configuration File" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 179<A CLASS="book" HREF="index.html" TITLE=""> 180<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 181<A CLASS="sect1" HREF="ch04_03.html" TITLE="4.3 Configuration File Options"> 182<IMG SRC="gifs/txtnexta.gif" ALT="Next: 4.3 Configuration File Options" BORDER="0"></a></td></tr><TR> 183<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 1844.1 Learning the Samba Configuration File</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 185<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 186<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 1874.3 Configuration File Options</td></tr></table><hr noshade size=1></center> 188</div> 189 190<!-- End of sample chapter --> 191<CENTER> 192<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 193<A HREF="http://www.oreilly.com/"> 194<B>O'Reilly Home</B></A> <B> | </B> 195<A HREF="http://www.oreilly.com/sales/bookstores"> 196<B>O'Reilly Bookstores</B></A> <B> | </B> 197<A HREF="http://www.oreilly.com/order_new/"> 198<B>How to Order</B></A> <B> | </B> 199<A HREF="http://www.oreilly.com/oreilly/contact.html"> 200<B>O'Reilly Contacts<BR></B></A> 201<A HREF="http://www.oreilly.com/international/"> 202<B>International</B></A> <B> | </B> 203<A HREF="http://www.oreilly.com/oreilly/about.html"> 204<B>About O'Reilly</B></A> <B> | </B> 205<A HREF="http://www.oreilly.com/affiliates.html"> 206<B>Affiliated Companies</B></A><p> 207<EM>© 1999, O'Reilly & Associates, Inc.</EM> 208</FONT> 209</CENTER> 210</BODY> 211</html> 212