value
Options in the smb.conf file are set by assigning a value to them. We should
warn you up front that some of the option names in Samba are poorly
chosen. For example, read only is self-explanatory, and is typical of
many recent Samba options. public is an older option, and is vague; it
now has a less-confusing synonym guest ok (may be accessed by guests).
We describe some of the more common historical names in this chapter in
sections that highlight each major task. In addition, Appendix C, Samba
Configuration Option Quick Reference, contains an alphabetical index of
all the configuration options and their meanings.
4.1.1.1 Whitespaces, quotes, and commas
An important item to remember about configuration options is that all
whitespaces in the value are significant. For example, consider the
following option:
volume = The Big Bad Hard Drive Number 3543
Samba strips away the spaces between the final e in volume and the first T
in The. These whitespaces are insignificant. The rest of the whitespaces are
significant and will be recognized and preserved by Samba when reading in
the file. Space is not significant in option names (such as guest ok), but
we recommend you follow convention and keep spaces between the words
of options.
If you feel safer including quotation marks at the beginning and ending of a
configuration option's value, you may do so. Samba will ignore these
quotation marks when it encounters them. Never use quotation marks around
an option itself; Samba will treat this as an error.
Finally, you can use whitespaces to separate a series of values in a list, or
you can use commas. These two options are equivalent:
netbios aliases = sales, accounting, payroll
netbios aliases = sales accounting payroll
In some values, however, you must use one form of separation - spaces in
some cases, commas in others.
4.1.1.2 Capitalization
Capitalization is not important in the Samba configuration file except in
locations where it would confuse the underlying operating system. For
example, let's assume that you included the following option in a share that
pointed to /export/samba/simple :
PATH = /EXPORT/SAMBA/SIMPLE
Samba would have no problem with the path configuration option
appearing entirely in capital letters. However, when it tries to connect to the
given directory, it would be unsuccessful because the Unix filesystem in the
underlying operating system is case sensitive. Consequently, the path listed
would not be found and clients would be unable to connect to the share.
4.1.1.3 Line continuation
You can continue a line in the Samba configuration file using the backslash,
as follows:
comment = The first share that has the primary
copies \
of the new Teamworks software product.
Because of the backslash, these two lines will be treated as one line by
Samba. The second line begins at the first non-whitespace character that
Samba encounters; in this case, the o in of.
4.1.1.4 Comments
You can insert comments in the smb.conf configuration file by preceding a
line with either a hash mark (#) or a semicolon ( ; ). Both characters are
equivalent. For example, the first three lines in the following example would
be considered comments:
# This is the printers section. We have given a
minimum print
; space of 2000 to prevent some errors that we've
seen when
; the spooler runs out of space.
[printers]
public = yes
min print space = 2000
Samba will ignore all comment lines in its configuration file; there are no
limitations to what can be placed on a comment line after the initial hash
mark or semicolon. Note that the line continuation character ( \) will not be
honored on a commented line. Like the rest of the line, it is ignored.
4.1.1.5 Changes at runtime
You can modify the smb.conf configuration file and any of its options at any
time while the Samba daemons are running. By default, Samba checks the
configuration file every 60 seconds for changes. If it finds any, the changes
are immediately put into effect. If you don't wish to wait that long, you can
force a reload by either sending a SIGHUP signal to the smbd and nmbd
processes, or simply restarting the daemons.
For example, if the smbd process was 893, you could force it to reread the
configuration file with the following command:
# kill -SIGHUP 893
Not all changes will be immediately recognized by clients. For example,
changes to a share that is currently in use will not be registered until the
client disconnects and reconnects to that share. In addition, server-specific
parameters such as the workgroup or NetBIOS name of the server will not
register immediately either. This keeps active clients from being suddenly
disconnected or encountering unexpected access problems while a session is
open.
4.1.2 Variables
Samba includes a complete set of variables for determining characteristics of
the Samba server and the clients to which it connects. Each of these
variables begins with a percent sign, followed by a single uppercase or
lowercase letter, and can be used only on the right side of a configuration
option (e.g., after the equal sign):
[pub]
path = /home/ftp/pub/%a
The %a stands for the client machine's architecture (e.g., WinNT for
Windows NT, Win95 for Windows 95 or 98, or WfWg for Windows for
Workgroups). Because of this, Samba will assign a unique path for the
[pub] share to client machines running Windows NT, a different path for
client machines running Windows 95, and another path for Windows for
Workgroups. In other words, the paths that each client would see as its share
differ according to the client's architecture, as follows:
/home/ftp/pub/WinNT
/home/ftp/pub/Win95
/home/ftp/pub/WfWg
Using variables in this manner comes in handy if you wish to have different
users run custom configurations based on their own unique characteristics or
conditions. Samba has 19 variables, as shown in Table 4.1
.
Table 4.1: Samba Variables
Variable Definition
Client variables
Table 4.1: Samba Variables
Variable Definition
%a
Client's architecture (e.g., Samba, WfWg, WinNT,
Win95, or UNKNOWN)
%I
Client's IP address (e.g., 192.168.220.100)
%m
Client's NetBIOS name
%M
Client's DNS name
User variables
%g
Primary group of %u
%G
Primary group of %U
%H
Home directory of %u
Table 4.1: Samba Variables
Variable Definition
%u
Current Unix username
%U
Requested client username (not always used by
Samba)
Share variables
%p
Automounter's path to the share's root directory, if
different from %P
%P
Current share's root directory
%S
Current share's name
Server variables
Table 4.1: Samba Variables
Variable Definition
%d
Current server process ID
%h
Samba server's DNS hostname
%L
Samba server's NetBIOS name
%N
Home directory server, from the automount map
%v
Samba version
Miscellaneous
variables
%R
The SMB protocol level that was negotiated
%T
The current date and time
Here's another example of using variables: let's say that there are five clients
on your network, but one client, fred, requires a slightly different
[homes] configuration loaded when it connects to the Samba server. With
Samba, it's simple to attack such a problem:
[homes]
include = /usr/local/samba/lib/smb.conf.%m
The include option here causes a separate configuration file for each
particular NetBIOS machine ( %m) to be read in addition to the current file.
If the hostname of the client machine is fred, and if a smb.conf.fred file
exists in the samba_dir /lib/ directory (or whatever directory you've
specified for your configuration files), Samba will insert that configuration
file into the default one. If any configuration options are restated in
smb.conf.fred, those values will override any options previously encountered
in that share. Note that we say "previously." If any options are restated in the
main configuration file after the include option, Samba will honor those
restated values for the share in which they are defined.
Here's the important part: if there is no such file, Samba will not generate an
error. In fact, it won't do anything at all. This allows you to create only one
Không có nhận xét nào:
Đăng nhận xét