Table of content
Provide Windows clients with an access to the file system, trying to the best to integrate the specificities of Windows and Unix: ACL, previous versions, extended attributes, alternate streams, symbolic links, … The print service will also be shared with Windows clients through the integration of CUPS. Access to various resources will be granted after having the users authenticated using an LDAP directory.
- Requirement: LDAP, CUPS
- Book: Using Samba (2nd edition)
- Reference: HOWTO
Build information
Ensure the following options:
Configuration
Global section
The global section holds directives that will be applied to the whole server or that will be used as default values for other sections.
Log files
The part below shows the log level and the files to be used to save logs generated by Samba. The login/logout of users will not be stored in the utmp system file.
Domain and workgroup
As no computer running OS/2 is expected, the LM announce necessary for the proper operation of these clients, will not be put in place.
A workgroup and a name are associated to the server.
Performance
To increase the file transfert speed , it’s possible to perform tuning on three different elements:
- the network layer, by disabling data aggregation and by increasing buffers size for reception/transmission,
- file transfer between disk and network, by performing the whole transfer in kernel mode,
- using asynchronous input/output for files above a certain size.
For the aio read size
or aio write size
directive to work, it is necessary to have the kernel to support
asynchronous input/output. Either by loading the corresponding module
(aio
) or because the code is already part of the kernel.
Presence of asynchronous input/output can be tested with the
kldstat
command and the module manually loaded if
necessary with kldload
, which can be done in one step:
1 |
|
The module can also be loaded automatically at the operating system startup time by adding the following line to the bootloader configuration:
Currently, the use sendfile directive set to yes leads to errors (of broken pipe type) during some file transfer. That’s why it is shown here commented in the configuration file.
Restriction and security
If the server owns several interfaces, it can be necessary to limit the Samba process to listen to the interface effectively used for the selected network.
If bind interface only is set up, it is advised to include the “loopback” (ie: 127.0.0.1) interface so to have a correct behaviour for the smbpasswd and swat programs.
The security model used is the one where the user is identified by a login/password to access resources. The Unix user account used for the guest user is chosen here as being: win.
File management
Veto
Files that have no meaning for Windows can be totally hidden from it
(browsing only). It is generally used to hide directories generated by
MacOS X (.DS_Store
) or directories specific to ZFS
(.zfs
).
The file separator for the veto files is the slash (“/
”) character, as
this character is forbidden in Windows file name.
Using the delete veto files
directive allows to
recursively delete files or directories marked as “veto” which are inside
the directory to delete. This directive must be used wisely.
Shadow copy
Configuring the “shadow copy”: when the shadow_copy2
module is stacked
in vfs objects, it then allows to access the file system snapshots
from the Windows interface under the name “Previous versions”.
The module currently provided in the distribution needs to be slightly modified to:
- run without requiring to enable the wide links directive
- specify the format used by snapshot names (shadow:format) (for Samba <= 3.5)
The following patches need to be copied before compiling Samba: Version Patch Path Samba 3.6 1 file /usr/local/net/samba36/files/ Samba 3.5 4 files /usr/local/net/samba35/files/ DOS attributes
If the file system supports the extended attributes, this is the case for UFS2 and ZFS, it is then possible to store the attributes specific to NTFS without having to perform dodgy mapping to Unix rights.
Extended attributes
The following configuration allows, if the file system supports it, to store extended attributes.
ACLs
It is possible to take into account the NTFS ACLs either by storing
them in extended attributes (acl_xattr
module), or directly on the
file system level in the case of ZFS (zfsacl
module), this last one
will be detailed here:
ZFS also need to be configured in passthrough
mode:
1 2 |
|
This module is still experimental and can create problems, especially a “wrong permissions ordering” for ACL entries.
Unix specificities
The UNIX file system on which relies Samba has differences compared to NTFS file system. Some options will be setup to:
- avoid security problems due to the use of symbolic links from Unix,
- allow a Unix client mounting a Samba share to access elements of the file system otherwise not available,
- specify the encoding used for the file names.
LDAP
An LDAP directory already exists for managing users, so Samba will use it to manage the users, groups, and computers. However with added restriction on the directory use:
- user (DN entry) will not be removed but only its samba attributes
- password modification will be done through the exop LDAP operation.
ldapsam:trusted
- The yes value implies that Samba won’t perform requests to nss (Network Service Switch) to resolve user names or groups, all of them must been known from LDAP in particular for the user defined with the guest account directive.
ldap passwd sync
- The only value allows Samba to pass the password modification by using the LDAP password modification (Password Modify Extended Operation), instead of modifying the corresponding entries.
ldap delete dn
- The no value specifies that during a delete operation only the samba specific attributes must be deleted instead of the complete entry.
Password to access the LDAP directory is not defined in the configuration file, it is necessary to enter it later using the following command:
1 |
|
Miscellaneous services
To keep the exact time on the Windows machines, Samba is configured to act as a time server.
The name resolution mechanism used by Samba to resolve NetBIOS names are those of the DNS and broadcast. In addition, Samba is configured to not act as a WINS server for name resolution on behalf of Windows clients.
Share
homes
The homes section is special as it will be used as a template for the client connecting to their home directories. Thus, if the name of the share is not defined by a section, that the name matches a user name and that the password allows to correctly authenticate the user, then this section is used.
A basic configuration consists in:
- not showing this share in the list of available shares,
- giving write access to the user (of course this will also depend on the access rights present on the native file system).
A more advanced configuration is done by stacking additional modules:
zfsacl
- Allows the use of NFSv4-style ACLs that are compatible with the ACL used by NTFS. The native file system must of course be of a ZFS type.
streams_xattr
- Allows creation of alternate data streams in Windows (ie: NTFS alternate data streams), providing greater compatibility with the NTFS file system.
shadow_copy2
- Provides access to file system snapshots from the Windows interface as “Previous version”, ZFS is well suited to the shadow copy mechanism.
Creation of alternate data streams can be used to hide viruses. You
must therefore think carefully before stacking the streams_xattr
module.
data
Below is described an example of a share available to all, un-identified users will take the identity of the guest user (previously defined by guest account), access rights to the native file system still apply:
Printing
Loads all the printers from the CUPS printing system:
The printers
section is special as it is used as a template
for various printers (in the same way as the homes
section
is used for the user’s home). The printers will only be available to the
identified users.
This section allows Windows to download the corresponding driver
during printer installation by the client. Only the admin user will be
allowed to store the driver. This is done in CUPS by using the
cupsaddsmb
command detailed further.
The admin
user must also have the right
to write in the /var/windows/print/
directory.