1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
8 <author><firstname>Simo</firstname><surname>Sorce</surname><contrib>original vfs_skel README</contrib></author>
9 <author><firstname>Alexander</firstname><surname>Bokovoy</surname><contrib>original vfs_netatalk docs</contrib></author>
10 <author><firstname>Stefan</firstname><surname>Metzmacher</surname><contrib>Update for multiple modules</contrib></author>
11 <author><firstname>Ed</firstname><surname>Riddle</surname><contrib>original shadow_copy docs</contrib></author>
13 <title>Stackable VFS modules</title>
16 <title>Features and Benefits</title>
19 Since Samba-3, there is support for stackable VFS (Virtual File System) modules.
20 Samba passes each request to access the UNIX file system through the loaded VFS modules.
21 This chapter covers all the modules that come with the Samba source and references to
22 some external modules.
29 <title>Discussion</title>
32 If not supplied with your platform distribution binary Samba package you may have problems
33 compiling these modules, as shared libraries are compiled and linked in different ways
34 on different systems. They currently have been tested against GNU/Linux and IRIX.
38 To use the VFS modules, create a share similar to the one below. The
39 important parameter is the <smbconfoption name="vfs objects"/> parameter where
40 you can list one or more VFS modules by name. For example, to log all access
41 to files and put deleted files in a recycle bin, see <link linkend="vfsrecyc">next configuration</link>:
43 <smbconfexample id="vfsrecyc">
44 <title>smb.conf with VFS modules</title>
45 <smbconfsection>[audit]</smbconfsection>
46 <smbconfoption name="comment">Audited /data directory</smbconfoption>
47 <smbconfoption name="path">/data</smbconfoption>
48 <smbconfoption name="vfs objects">audit recycle</smbconfoption>
49 <smbconfoption name="writeable">yes</smbconfoption>
50 <smbconfoption name="browseable">yes</smbconfoption>
55 The modules are used in the order in which they are specified.
56 Let's say that you want to both have a virus scanner module and a recycle
57 bin module. It is wise to put the virus scanner module as the first one so
58 that it is the first that get run an may detect a virus immediately, before
59 any action is performed on that file.
60 <smbconfoption name="vfs objects">vscan-clamav recycle</smbconfoption>
64 Samba will attempt to load modules from the <filename>/lib</filename> directory in the root directory of the
65 Samba installation (usually <filename>/usr/lib/samba/vfs</filename> or <filename>/usr/local/samba/lib/vfs
70 Some modules can be used twice for the same share.
71 This can be done using a configuration similar to the one shown in <link linkend="multimodule">the following example</link>.
73 <smbconfexample id="multimodule">
74 <title>smb.conf with multiple VFS modules</title>
75 <smbconfsection>[test]</smbconfsection>
76 <smbconfoption name="comment">VFS TEST</smbconfoption>
77 <smbconfoption name="path">/data</smbconfoption>
78 <smbconfoption name="writeable">yes</smbconfoption>
79 <smbconfoption name="browseable">yes</smbconfoption>
80 <smbconfoption name="vfs objects">example:example1 example example:test</smbconfoption>
81 <smbconfoption name="example1: parameter">1</smbconfoption>
82 <smbconfoption name="example: parameter">5</smbconfoption>
83 <smbconfoption name="test: parameter">7</smbconfoption>
90 <title>Included Modules</title>
96 A simple module to audit file access to the syslog
97 facility. The following operations are logged:
99 <listitem><para>share</para></listitem>
100 <listitem><para>connect/disconnect</para></listitem>
101 <listitem><para>directory opens/create/remove</para></listitem>
102 <listitem><para>file open/close/rename/unlink/chmod</para></listitem>
109 <title>extd_audit</title>
112 This module is identical with the <command>audit</command> module above except
113 that it sends audit logs to both syslog as well as the <command>smbd</command> log files. The
114 <smbconfoption name="log level"/> for this module is set in the &smb.conf; file.
118 Valid settings and the information that will be recorded are shown in <link linkend="xtdaudit">the next table</link>.
121 <table frame="all" id="xtdaudit">
122 <title>Extended Auditing Log Information</title>
123 <tgroup cols="2" align="center">
125 <row><entry align="center">Log Level</entry><entry>Log Details - File and Directory Operations</entry></row>
128 <row><entry align="center">0</entry><entry align="left">Make Directory, Remove Directory, Unlink</entry></row>
129 <row><entry align="center">1</entry><entry align="left">Open Directory, Rename File, Change Permissions/ACLs</entry></row>
130 <row><entry align="center">2</entry><entry align="left">Open & Close File</entry></row>
131 <row><entry align="center">10</entry><entry align="left">Maximum Debug Level</entry></row>
137 <title>Configuration of Auditing</title>
140 This auditing tool is more felxible than most people readily will recognize. There are a number of ways
141 by which useful logging information can be recorded.
145 <listitem><para>Syslog can be used to record all transaction. This can be disabled by setting
146 in the &smb.conf; file <parameter>syslog = 0</parameter>.</para></listitem>
147 <listitem><para>Logging can take place to the default log file (<filename>log.smbd</filename>)
148 for all loaded VFS modules just by setting in the &smb.conf; file
149 <parameter>log level = 0 vfs:x</parameter>, where x is the log level.
150 This will disable general logging while activating all logging of VFS
151 module activity at the log level specified.</para></listitem>
152 <listitem><para>Detailed logging can be obtained per user, per client machine, etc.
153 This requires the above together with the creative use of the
154 <parameter>log file</parameter> settings.</para>
155 <para>An example of detailed per-user and per-machine logging can
156 be obtained by setting
157 <smbconfoption name="log level">/var/log/samba/%U.%m.log</smbconfoption>.
162 Auditing information often must be preserved for a long time. So that the log files do not get rotated
163 it is essential that the <smbconfoption name="max log size">0</smbconfoption> be set
164 in the &smb.conf; file.
171 <sect2 id="fakeperms">
172 <title>fake_perms</title>
175 This module was created to allow Roaming Profile files and directories to be set (on the Samba server
176 under UNIX) as read only. This module will, if installed on the Profiles share, report to the client
177 that the Profile files and directories are writeable. This satisfies the client even though the files
178 will never be overwritten as the client logs out or shuts down.
184 <title>recycle</title>
187 A Recycle Bin-like module. Where used, unlink calls will be intercepted and files moved
188 to the recycle directory instead of being deleted. This gives the same effect as the
189 <guiicon>Recycle Bin</guiicon> on Windows computers.
193 The <guiicon>Recycle Bin</guiicon> will not appear in <application>Windows Explorer</application> views of the network file system
194 (share) nor on any mapped drive. Instead, a directory called <filename>.recycle</filename> will be
195 automatically created when the first file is deleted. Users can recover files from the
196 <filename>.recycle</filename> directory. If the <parameter>recycle:keeptree</parameter> has been
197 specified, deleted files will be found in a path identical with that from which the file was deleted.
200 <para>Supported options for the <command>recycle</command> module are as follow:
203 <term>recycle:repository</term>
205 Relative path of the directory where deleted files should be moved.
210 <term>recycle:keeptree</term>
212 Specifies whether the directory structure should be kept or if the files in the directory that is being
213 deleted should be kept separately in the recycle bin.
218 <term>recycle:versions</term>
220 If this option is set, two files
221 with the same name that are deleted will both
222 be kept in the recycle bin. Newer deleted versions
223 of a file will be called <quote>Copy #x of <replaceable>filename</replaceable></quote>.
228 <term>recycle:touch</term>
230 Specifies whether a file's access date should be touched when the file is moved to the recycle bin.
235 <term>recycle:maxsize</term>
237 Files that are larger than the number of bytes specified by this parameter will not be put into the recycle bin.
242 <term>recycle:exclude</term>
244 List of files that should not be put into the recycle bin when deleted, but deleted in the regular way.
249 <term>recycle:exclude_dir</term>
251 Contains a list of directories. When files from these directories are
252 deleted, they are not put into the
253 recycle bin but are deleted in the
259 <term>recycle:noversions</term>
261 Specifies a list of paths (wildcards such as * and ? are supported) for which no versioning should be used. Only useful when <emphasis>recycle:versions</emphasis> is enabled.
270 <title>netatalk</title>
273 A netatalk module will ease co-existence of Samba and netatalk file sharing services.
276 <para>Advantages compared to the old netatalk module:
278 <listitem><para>Does not care about creating .AppleDouble forks, just keeps them in sync.</para></listitem>
279 <listitem><para>If a share in &smb.conf; does not contain .AppleDouble item in hide or veto list, it will be added automatically.</para></listitem>
286 <title>shadow_copy</title>
289 <emphasis>THIS IS NOT A BACKUP, ARCHIVAL, OR VERSION CONTROL
290 SOLUTION!</emphasis></para>
292 With Samba or Windows servers, shadow copy is designed to be
293 an end-user tool only. It does not replace or enhance your
294 backup and archival solutions and should in no way be
295 considered as such. Additionally, if you need version
296 control, implement a version control system. You have been
300 The shadow_copy module allows you to setup functionality that
301 is similar to MS shadow copy services. When setup properly,
302 this module allows Microsoft shadow copy clients to browse
303 "shadow copies" on samba shares. You will need to install the
304 shadow copy client. You can get the MS shadow copy client
306 url="http://www.microsoft.com/windowsserver2003/downloads/shadowcopyclient.mspx">here.</ulink>.
307 Note the additional requirements for pre-Windows XP clients.
308 I did not test this functionality with any pre-Windows XP
309 clients. You should be able to get more information about MS
310 Shadow Copy <ulink noescape="1"
311 url="http://www.microsoft.com/windowsserver2003/techinfo/overview/scr.mspx">from
312 the Microsoft's site</ulink>.</para>
314 The shadow_copy VFS module requires some underlying file system
315 setup with some sort of Logical Volume Manager (LVM) such as
316 LVM1, LVM2, or EVMS. Setting up LVM is beyond the scope of
317 this document; however, we will outline the steps we took to
318 test this functionality for <emphasis>example purposes
319 only.</emphasis> You need to make sure the LVM implementation
320 you choose to deploy is ready for production. Make sure you
321 do plenty of tests.</para>
323 Here are some common resources for LVM and EVMS:
326 <para><ulink noescape="1"
327 url="http://www.sistina.com/products_lvm_download.htm">Sistina's
328 LVM1 and LVM2</ulink></para>
331 <para><ulink url="http://evms.sourceforge.net/">Enterprise
332 Volume Management System (EVMS)</ulink></para>
335 <para><ulink url="http://tldp.org/HOWTO/LVM-HOWTO/">The LVM HOWTO</ulink></para>
340 url="http://www-106.ibm.com/developerworks/linux/library/l-lvm/">Learning
341 Linux LVM, Part 1</ulink> and <ulink
342 url="http://www-106.ibm.com/developerworks/library/l-lvm2.html">Learning
343 Linux LWM, Part 2</ulink> for Daniel Robbins' well
344 written a two part tutorial on Linux and LVM using LVM
345 source code and reiserfs.</para>
350 <title>Shadow Copy Setup</title>
352 At the time of this writing, not much testing has been done.
353 I tested the shadow copy VFS module with a specific scenario
354 which was not deployed in a production environment, but more
355 as a proof of concept. The scenario involved a Samba 3 file
356 server on Debian Sarge with an XFS file system and LVM1. I
357 do NOT recommend you use this as a solution without doing
358 your own due diligence with regard to all the components
359 presented here. That said, following is an basic outline of
360 how I got things going.</para>
364 <title>Installed Operating System </title>
366 In my tests, I used <ulink
367 url="http://www.debian.org/devel/debian-installer/">Debian
368 Sarge</ulink> (i.e. testing) on an XFS file system.
369 Setting up the OS is a bit beyond the scope of this
370 document. It is assumed that you have a working OS
371 capable of running Samba.</para>
376 <title>Install & Configure Samba</title>
378 See the <link linkend="introduction">installation
379 section</link> of this HOWTO for more detail on this.
380 It doesn't matter if it is a Domain Controller or
381 Member File Server, but it is assumed that you have a
382 working Samba 3.0.3 or newer server running.</para>
387 <title>Install & Configure LVM</title>
389 Before you can make shadow copies available to the
390 client, you have to create the shadow copies. This is
391 done by taking some sort of file system snapshot.
392 Snapshots are a typical feature of Logical Volume
393 Managers such as LVM, so we first need to have that
398 The following is provided as an example and will be
399 most helpful for Debian users. Again, this was tested
400 using the "testing" or "Sarge" distribution.</para>
403 Install lvm10 and devfsd packages if you have not
404 done so already. On Debian systems, you are warned
405 of the interaction of devfs and lvm1 which requires
406 the use of devfs filenames. Running
407 <command>apt-get update && apt-get install
408 lvm10 devfsd xfsprogs</command> should do the trick
409 for this example.</para>
413 Now you need to create a volume. You will need to
414 create a partition (or partitions) to add to your
415 volume. Use your favorite partitioning tool
416 (e.g. Linux fdisk, cfdisk, etc.). The partition
417 type should be set to 0x8e for "Linux LVM." In this
418 example, we will use /dev/hdb1.</para>
420 Once you have the Linux LVM partition (type 0x8e),
421 you can run a series of commands to create the LVM
422 volume. You can use several disks and or
423 partitions, but we will use only one in this
424 example. You may also need to load the kernel
425 module with something like <command>modprobe lvm-mod
426 </command> and set your system up to load it on
427 reboot by adding it to
428 (<filename>/etc/modules</filename>). </para>
432 Create the physical volume with <command>pvcreate
433 /dev/hdb1</command></para>
437 Create the volume group with and add /dev/hda1 to it
438 with <command>vgcreate shadowvol /dev/hdb1</command>
441 You can use <command>vgdisplay</command> to review
442 information about the volume group.</para>
446 Now you can create the logical volume with something
447 like <command>lvcreate -L400M -nsh_test
448 shadowvol</command></para>
450 This creates the logical volume of 400MB's named
451 "sh_test" in the volume group we created called
452 shadowvol. If everything is working so far, you
454 <filename>/dev/shadowvol</filename>.</para>
458 Now we should be ready to format the logical volume
459 we named sh_test with <command>mkfs.xfs
460 /dev/shadowvol/sh_test</command></para>
462 You can format the logical volume with any file
463 system you choose, but make sure to use one that
464 allows you to take advantage of the additional
465 features of LVM such as freezing, resizing and
466 growing your file systems.</para>
468 Now we have an LVM volume where we can play with the
469 shadow_copy VFS module.</para>
473 Now we need to prepare the directory with something
474 like <command>mkdir -p /data/shadow_share</command>
475 or whatever you want to name your shadow copy
476 enabled Samba share. Make sure you set the
477 permissions such that you can use it. If in doubt,
478 use <command>chmod 777 /data/shadow_share</command>
479 and tighten the permissions once you get things
484 Mount the LVM volume using something like
485 <command>mount /dev/shadowvol/sh_test
486 /data/shadow_share</command></para>
488 You may also want to edit your
489 <filename>/etc/fstab</filename> so that this
490 partition mounts during the system boot.</para>
496 <title>Install & Configure the shadow_copy VFS
499 Finally we get to the actual shadow_copy VFS module.
500 The shadow_copy VFS module should be available in
501 Samba 3.0.3 and higher. The smb.conf configuration is pretty
502 standard. Here is our example of a share configured
503 with the shadow_copy VFS module:</para>
506 <smbconfexample id="vfsshadow">
507 <title>Share With shadow_copy VFS</title>
508 <smbconfsection>[shadow_share]</smbconfsection>
509 <smbconfoption name="comment">Shadow Copy Enabled Share</smbconfoption>
510 <smbconfoption name="path">/data/shadow_share</smbconfoption>
511 <smbconfoption name="vfs objects">shadow_copy</smbconfoption>
512 <smbconfoption name="writeable">yes</smbconfoption>
513 <smbconfoption name="browseable">yes</smbconfoption>
519 <title>Create Snapshots and Make Them Available to shadow_copy.so</title>
521 Before you can browse the shadow copies, you must
522 create them and mount them. This will most likely be
523 done with a script that runs as a cron job. With this
524 particular solution, the shadow_copy VFS module is
525 used to browse LVM snapshots. Those snapshots are not
526 created by the module. They are not made available by
527 the module either. This module allows the shadow copy
528 enabled client to browse the snapshots you take and
529 make available.</para>
532 Here is a simple script used to create and mount the
536 # This is a test, this is only a test
537 SNAPNAME=`date +%Y.%m.%d-%H.%M.%S`
538 xfs_freeze -f /data/shadow_share/
539 lvcreate -L10M -s -n $SNAPNAME /dev/shadowvol/sh_test
540 xfs_freeze -u /data/shadow_share/
541 mkdir /data/shadow_share/@GMT-$SNAPNAME
542 mount /dev/shadowvol/$SNAPNAME /data/shadow_share/@GMT-$SNAPNAME -onouuid,ro
544 Note that the script does not handle other things like
545 remounting snapshots on reboot.
550 <title>Test From Client</title>
552 To test, you will need to install the shadow copy
553 client which you can obtain from the <ulink
554 url="http://www.microsoft.com/windowsserver2003/downloads/shadowcopyclient.mspx">Microsoft
555 web site.</ulink> I only tested this with an XP client
556 so your results may vary with other pre-XP clients.
557 Once installed, with your XP client you can
558 right-click on specific files or in the empty space of
559 the shadow_share and view the "properties". If
560 anything has changed, then you will see it on the
561 "Previous Versions" tab of the properties
572 <title>VFS Modules Available Elsewhere</title>
575 This section contains a listing of various other VFS modules that
576 have been posted but do not currently reside in the Samba CVS
577 tree for one reason or another (e.g., it is easy for the maintainer
578 to have his or her own CVS tree).
582 No statements about the stability or functionality of any module
583 should be implied due to its presence here.
587 <title>DatabaseFS</title>
590 URL: <ulink noescape="1" url="http://www.css.tayloru.edu/~elorimer/databasefs/index.php">http://www.css.tayloru.edu/~elorimer/databasefs/index.php</ulink>
593 <para>By <ulink url="mailto:elorimer@css.tayloru.edu">Eric Lorimer.</ulink></para>
596 I have created a VFS module that implements a fairly complete read-only
597 filesystem. It presents information from a database as a filesystem in
598 a modular and generic way to allow different databases to be used
599 (originally designed for organizing MP3s under directories such as
600 <quote>Artists,</quote> <quote>Song Keywords,</quote> and so on. I have since easily
601 applied it to a student
602 roster database.) The directory structure is stored in the
603 database itself and the module makes no assumptions about the database
604 structure beyond the table it requires to run.
608 Any feedback would be appreciated: comments, suggestions, patches,
609 and so on. If nothing else, hopefully it might prove useful for someone
610 else who wishes to create a virtual filesystem.
618 <para>URL: <ulink noescape="1" url="http://www.openantivirus.org/projects.php#samba-vscan">http://www.openantivirus.org/projects.php#samba-vscan</ulink></para>
621 samba-vscan is a proof-of-concept module for Samba, which
622 provides on-access anti-virus support for files shared using
624 samba-vscan supports various virus scanners and is maintained