Let's return to user shares for a moment. If we have several users to set up home directory shares for, we probably want to use the special
[homes]
share that we introduced in Chapter 5,
Browsing and Advanced Disk Shares . With the
[homes]
share, all we need to say is:
[homes]
browsable = no
writable = yes
The
[homes]
share is a special section of the Samba configuration file. If a user attempts to connect to an ordinary share that doesn't appear in the
smb.conf file (such as specifying it with a UNC in Windows Explorer), Samba will search for a
[homes]
share. If one exists, the incoming share name is assumed to be a username and is queried as such in the password database (
/etc/passwd or equivalent) file of the Samba server. If it appears, Samba assumes the client is a Unix user trying to connect to his or her home directory.
As an illustration, let's assume that
sofia
is attempting to connect to a share called [
sofia]
on the Samba server. There is no share by that name in the configuration file, but a
[homes]
share exists and user
sofia
is present in the password database, so Samba takes the following steps:
-
Samba creates a new disk share called
[sofia]
with the
path
specified in the
[homes]
section. If there is no
path
option specified in
[homes]
, Samba initializes it to her home directory.
-
Samba initializes the new share's options from the defaults in
[globals]
, and any overriding options in
[homes]
with the exception of
browseable
.
-
Samba connects
sofia
's client to that share.
The
[homes]
share is a fast, painless way to create shares for your user community without having to duplicate the information from the password database file in the
smb.conf file. It does have some peculiarities, however, that we need to point out:
-
The
[homes]
section can represent any account on the machine, which isn't always desirable. For example, it can potentially create a share for
root,
bin,
sys,
uucp, and the like. (You can set a global
invalid
users
option to protect against this.)
-
The meaning of the
browseable
configuration option is different from other shares; it indicates only that a
[homes]
section won't show up in the local browse list, not that the
[alice]
share won't. When the
[alice]
section is created (after the initial connection), it will use the browsable value from the
[globals]
section for that share, not the value from
[homes]
.
As we mentioned, there is no need for a path statement in
[homes]
if the users have Unix home directories in the server's
/etc/passwd file. You should ensure that a valid home directory does exist, however, as Samba will not automatically create a home directory for a user, and will refuse a tree connect if the user's directory does not exist or is not accessible.