|
Sams Teach Yourself Samba in 24 Hours |
||||||||||||||
|
Hour 5: The smb.conf File: Telling Samba What to Do |
||||||||||||||
|
The smb.conf file really lies at the heart of Samba. It is used by both smbd and nmbd as well as many of the other tools included in the Samba suite. And although it probably has more parameters than Godzilla has teeth, it is not extremely hard to understand. This hour provides an in-depth look at the smb.conf file. You'll look at the general layout of the file, variables that are available for use at run time, and some of the global parameters that control the overall behavior of Samba.
A standard smb.conf file can consist of multiple sections each containing multiple parameters. However, though true, this is not the most helpful description available.
The following definition might make more sense. A Samba configuration file is an ASCII text file logically divided by section headings, which are denoted by enclosing square brackets ([ ]). For example, [foobar] would be a valid section heading. The section names, parameters, and values are not case sensitive unless pertinent to the operating system, such as the case of a directory path. Each section continues until the next section heading. Samba's smb.conf has three built-in sections named [global], [homes], and [printers].
Figure 5.1 illustrates the three built-in sections and one sample section. Because section headings are not case sensitive, [global], [GLOBAL], and [Global] all represent the same section. The four settings--netbios name, workgroup, security, and printing--all represent global parameters. Therefore, they are all located in the [global] section, which ends at the next section header, [homes]. The final section [boss1] represents a disk share that has been configured for this server.
Figure
5.1
General layout of smb.conf.
The [global] section contains parameters that relate to the overall functionality of the server. The netbios name and workgroup parameters, which were discussed briefly in Hour 4, "Installing and Testing the Configuration," are examples of [global] parameters. These parameters and others are discussed in more detail later in the hour.
The [homes] section was briefly mentioned in the sample Samba server in Hour 4. This special share enables users to connect to their home directories without requiring that a specific share be defined for each user. The process works as follows:
1. Samba receives a connection request.
2. The smb.conf file is searched for the name of the requested service.
3. If the requested name is not found and the [homes] service has been configured, Samba searches the /etc/passwd file for a matching username.
4. If a matching username is found, a copy of the [homes] share is created, and the name is changed to the located username. Also, if no path is listed, it is set to the user's home directory as listed in the /etc/passwd entry.
5. If a matching username is not located, Samba returns an Invalid resource in tree connection request error message to the client.
The third built-in section, [printers], is analogous to [homes]. The difference is the type of resource it makes available. [homes] creates home directories from /etc/passwd, whereas [printers] creates printer resources from /etc/printcap. If you use a printing system other than BSD, you need to create a dummy printcap file for Samba to verify printer names. This is covered more in Hour 8, "Printers."
Any section other than [global] is considered a shared resource (share, for short); therefore, the section must follow general share naming conventions.
To create custom shares, you need to enter only a section header, such as [foo], and the necessary parameters, as discussed in Hours 6, "Security Levels and Passwords," and 7, "File Sharing." The SMB client is then able to access the share via the network path \\servername\FOO. Earlier, I said that smb.conf section headers were not case sensitive. Therefore [foo] and [FOO] refer to the same service. This is why the PC client can mount \\servername\FOO when the share is defined as [foo].
Depending on how much you like to document your work--I hope it's a great deal for the poor soul who arrives after you and must support your creation--you can insert comments liberally by placing a semicolon (;) or pound sign (#) as the first non-white space character on the line. Comments are terminated at the first carriage return:
; This is a comment # and so is this
Table 5.1 lists a summary of the syntax for the smb.conf items that I have discussed.
|
Sams Teach Yourself Samba in 24 Hours |
||||||||||||||
|
Hour 5: The smb.conf File: Telling Samba What to Do |
||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.