6.5. Virtual File Systems
The smbd daemon interacts with files and directories on disk through a Virtual File System (VFS) module. The default VFS plug-in implements the Samba's standard file serving functionality. Other plug-ins distributed with the official Samba distribution and stored in /usr/local/samba/lib/vfs for default installations include:
There are also some third-party plug-ins available, such as the samba-vscan virus scanning plug-in (http://www.openantivirus.org/projects.php).
Each plug-in supports its own set of configuration settings that can be integrated into smb.conf using parametric options of the form module_name:option. In this section, we use the recycle.so VFS module as an example of the basic configuration steps. The complete set of VFS modules and associated documentation is included in the Samba distribution.
The purpose of the recycle.so library is to intercept any delete requests and move the target to a trash bin rather than removing it from disk. This is a nice safety net for users and prevents administrators from having to restore files from backup media when a user accidentally deletes an important document. Our example extends the [homes] share to provide users with a personal recycle directory.
The first step in configuring any VFS module is to define the vfs object value for the share. This parameter requires only the name of the VFS module (or modules). The smbd process automatically adds the necessary extension and attempts to load the plug-in from the vfs folder in Samba's library directory, which can be determined by running smbd -b | grep LIBDIR. Here is how the share definition should appear:
[homes] read only = no vfs object = recycle
The recycle module supports a variety of options for customizing how deleted files and directories should be backed up. The most common options are the directory where the deleted files are stored (repository), whether to maintain the file's original directory structure (keeptree), and which files should deleted rather than backed up (exclude). The modified share with the new VFS option syntax is:
[homes] read only = no vfs object = recycle recycle:repository = .trash recycle:keeptree = yes recycle:exclude = *.tmp, *~, *.bak
New VFS modules added to a share picked up in the same fashion as new configuration parameters. There is no need to restart Samba. Each new client connection is able to take advantage of the new settings. With the recycle plug-in in place, a user can safely delete files from her home directory and immediately retrieve them from the top-level .trash directory.
Table 6-12 lists the complete set of recycle plug-in parameters and a brief description of each. For information on other VFS modules, check the Samba documentation.