|
Sams Teach Yourself Samba in 24 Hours |
||||||||||||||
|
Hour 5: The smb.conf File: Telling Samba What to Do |
||||||||||||||
|
Several different variables are available to use in smb.conf. These macros, denoted by a % character, are replaced during the parsing on the configuration file at run time. For example, when user jdoe sends a session setup request, Samba parses smb.conf and replaces all occurrences of %U with jdoe. Table 5.2 contains a listing of the complete set of smb.conf variables that are available to you.
|
Variable |
Description |
The architecture of the remote machine. Not guaranteed to be 100% reliable, but generally good enough in practice. Currently supported values are Samba, WfWg, WinNT, and Win95. Windows 98 is returned as Win95. Windows 2000 is actually Windows NT 5.0 and so is recognized as WinNT. | |
The process ID of the current server process. | |
The primary group of username %u. | |
The primary group of username %U. | |
The Internet hostname on which Samba is running. | |
The home directory for the username %u. | |
The IP address of the client machine in dotted decimal form. | |
The NetBIOS name of the server. | |
The NetBIOS name of the client machine. | |
The Internet hostname of the client machine. | |
The name of your NIS home directory server as specified in the auto.home map. If you have not compiled Samba with AUTOMOUNT support, this is the same as %L. | |
The path to the user's home directory as specified in auto.home. The NIS map entry is assumed to be colon separated and is divided as %N:%p. | |
The root directory of the current service. | |
The protocol selected during the protocol negotiation phase of the connection setup. Valid values are CORE, COREPLUS, LANMAN1, LANMAN2, or NT1. | |
The name of the current service. | |
The current date and time. | |
The username the client requested in the session setup. This is not necessarily the same as the one that was used. | |
Samba version number. |
These variables can be used in many ways. A variable can be used in any location where a text string is valid. For example, the following [global] parameter entry would cause Samba to log connection information to a file named /var/log/log.netbios name replacing netbios name with the client's NetBIOS name.
log file = /var/log/log.%m
This can aid in debugging or monitoring certain clients.
Here's another example that tells Samba to use a different domain logon script depending on the connecting client's operating system:
logon script = %a.bat
The available logon scripts would be named WfWg.bat, Win95.bat, and WinNT.bat. Domain logons are covered in detail in Hours 21, "Windows 9x Domain Control," and 22, "Experimental PDC Support."
In light of the current explanation of variables, the [homes] share, which I used in Hour 4's example, is perhaps more sensible:
; share name
[homes]
comment = Unix home directory space
path = %H
writeable = yes
valid users = %S
create mode = 0600
directory mode = 0700
locking = no
The valid users = %S entry restricts connections to the user whose username is the same as the name of the service. Remember the previous explanation of the [homes] share. If Samba can locate a match for the sharename in the /etc/passwd file, a share is created using the parameters from the [homes] definition, but is renamed using the matched username. Therefore, the only user allowed to connect is the owner of the home directory.
One last example before you move on. At work, I manage around 30 different Samba servers running on different operating systems. Generally, all servers are upgraded to the same version of Samba concurrently, but there are always a few exceptions. To determine the installed version on a server quickly, each smb.conf has an entry similar to the following in the [global] section:
server string = samba print server for administration [%v]
The server string parameter is used to set the text displayed next to the machine name in browse lists that are available through tools such as the Network Neighborhood. The %v is dynamically expanded to the version of the currently running nmbd process. Therefore, to determine what version of Samba a server is running, I simply use the net view \\servername command from a Windows box to examine the server's comment string.
|
Sams Teach Yourself Samba in 24 Hours |
||||||||||||||
|
Hour 5: The smb.conf File: Telling Samba What to Do |
||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.