[SCM] Samba Shared Repository - branch master updated

Björn Jacke bjacke at samba.org
Tue Aug 7 07:17:03 MDT 2012


The branch, master has been updated
       via  9b7b736 media_harmony VFS module: Add and build by default.
      from  e7bf8e7 s3:smb2_server: do one central as_root check if the operation requires it

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9b7b736e5b99c525d251942476ac94570aafb8e3
Author: Andrew Klaassen <clawsoon at yahoo.com>
Date:   Thu May 3 13:39:53 2012 -0400

    media_harmony VFS module: Add and build by default.
    
     - Supersedes previous patch.
     - Added various fixes for fake mtime functionality.
     - Now requires lp_cache_locked_write_times patch (bug 8912).
     - Removed various xattr functions to comply with recent VFS changes.
     - Changed SMB_STRUCT_DIR to DIR and SMB_STRUCT_DIRENT to struct dirent to comply with recent VFS changes.
     - Added manpage.
     - Added sample trigger_avid_update.py script.
    
    Autobuild-User(master): Björn Jacke <bj at sernet.de>
    Autobuild-Date(master): Tue Aug  7 15:16:39 CEST 2012 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages-3/vfs_media_harmony.8.xml        |  142 ++
 .../vfs/media_harmony/trigger_avid_update.py       |  103 +
 source3/Makefile.in                                |    5 +
 source3/configure.in                               |    2 +
 source3/modules/vfs_media_harmony.c                | 2438 ++++++++++++++++++++
 source3/wscript                                    |    1 +
 6 files changed, 2691 insertions(+), 0 deletions(-)
 create mode 100644 docs-xml/manpages-3/vfs_media_harmony.8.xml
 create mode 100755 examples/scripts/vfs/media_harmony/trigger_avid_update.py
 create mode 100644 source3/modules/vfs_media_harmony.c


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/vfs_media_harmony.8.xml b/docs-xml/manpages-3/vfs_media_harmony.8.xml
new file mode 100644
index 0000000..f24e700
--- /dev/null
+++ b/docs-xml/manpages-3/vfs_media_harmony.8.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
+<refentry id="vfs_media_harmony.8">
+
+<refmeta>
+	<refentrytitle>vfs_media_harmony</refentrytitle>
+	<manvolnum>8</manvolnum>
+	<refmiscinfo class="source">Samba</refmiscinfo>
+	<refmiscinfo class="manual">System Administration tools</refmiscinfo>
+	<refmiscinfo class="version">3.6</refmiscinfo>
+</refmeta>
+
+
+<refnamediv>
+	<refname>vfs_media_harmony</refname>
+	<refpurpose>Allow multiple Avid clients to share a network drive.</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+	<cmdsynopsis>
+		<command>vfs objects = media_harmony</command>
+	</cmdsynopsis>
+</refsynopsisdiv>
+
+<refsect1>
+	<title>DESCRIPTION</title>
+
+	<para>This VFS module is part of the
+	<citerefentry><refentrytitle>samba</refentrytitle>
+	<manvolnum>7</manvolnum></citerefentry> suite.</para>
+
+	<para>The <command>vfs_media_harmony</command> VFS module allows
+	Avid editorial workstations to share a network drive.  It does
+	this by:</para>
+	<orderedlist continuation="restarts" inheritnum="ignore" numeration="arabic">
+	<listitem><para>Giving each client their own copy of the Avid
+	msmMMOB.mdb and msmFMID.pmr files and Creating directories.</para></listitem>
+	<listitem><para>Allowing each client to explicitly control the
+	write time the Avid application sees on Avid media directories.</para></listitem>
+	</orderedlist>
+
+	<para>This module is stackable.</para>
+
+</refsect1>
+
+<refsect1>
+	<title>CONFIGURATION</title>
+
+	<para><command>vfs_media_harmony</command> automatically redirects
+	requests from clients for Avid database files or an Avid Creating
+	directory to a client-specific version of the file.  No
+	configuration beyond enabling the module is needed to get this
+	portion of its functionality working.</para>
+
+	<para>If Mac and Windows Avid clients will be accessing the same
+	folder, they should be given separate share definitions, with
+	hidden Mac files vetoed on the Windows share.  See EXAMPLES.</para>
+
+	<para>To allow each client to control when the Avid application
+	refreshes their Avid databases, create files for each client
+	and each Avid media directory with the name
+	[avid_dir_name]_[client_ip_address]_[client_username].
+	To trigger Avid database refreshes, update the write time on
+	those files.  See EXAMPLES.</para>
+
+	<para>It is also necessary for the <command>cache locked write times = no</command>
+	option to be set for clients to be able to control their Avid
+	media folder write times.</para>
+
+</refsect1>
+
+<refsect1>
+	<title>EXAMPLES</title>
+
+	<para>Enable media_harmony for Mac and Windows clients:</para>
+<programlisting>
+        <smbconfsection name="[avid_mac]"/>
+	<smbconfoption name="path">/avid</smbconfoption>
+	<smbconfoption name="vfs objects">media_harmony</smbconfoption>
+	<smbconfoption name="cache locked write times">no</smbconfoption>
+        <smbconfsection name="[avid_win]"/>
+	<smbconfoption name="path">/avid</smbconfoption>
+	<smbconfoption name="vfs objects">media_harmony</smbconfoption>
+	<smbconfoption name="cache locked write times">no</smbconfoption>
+	<smbconfoption name="veto files">/.DS_Store/._@/.Trash@/.Spotlight@/.hidden/.hotfiles@/.vol/</smbconfoption>
+	<smbconfoption name="delete veto files">yes</smbconfoption>
+</programlisting>
+
+	<para>Create the files that will allow users david and susan
+	to control their own Avid database refreshes:</para>
+<programlisting>
+	touch '/avid/OMFI MediaFiles_192.168.1.10_david' \
+		'/avid/OMFI MediaFiles_192.168.1.11_susan' \
+		'/avid/Avid MediaFiles/MXF/1_192.168.1.10_david' \
+		'/avid/Avid MediaFiles/MXF/1_192.168.1.11_susan'
+</programlisting>
+	<para>Trigger an Avid database refresh for user david:</para>
+<programlisting>
+	touch '/avid/OMFI MediaFiles_192.168.1.10_david' \
+		'/avid/Avid MediaFiles/MXF/1_192.168.1.10_david'
+</programlisting>
+
+	<para>If you have a large number of Avid media folders to manage,
+	you can give each editor a suitably modified version of
+	examples/scripts/vfs/media_harmony/trigger_avid_update.py to
+	create and update these files.</para>
+
+</refsect1>
+
+<refsect1>
+	<title>CAVEATS</title>
+
+	<para><command>vfs_media_harmony</command> is designed to work with
+	Avid editing applications that look in the Avid MediaFiles or
+	OMFI MediaFiles directories for media.  It is not designed to work
+	as expected in all circumstances for general use.  For example: It
+	is possible to open a client-specific file such as
+	msmMMOB.mdb_192.168.1.10_userx even though it doesn't show up
+	in a directory listing.</para>
+
+</refsect1>
+
+
+
+<refsect1>
+	<title>VERSION</title>
+
+	<para>This man page is correct for version 3.2.7 of the Samba suite.
+	</para>
+</refsect1>
+
+<refsect1>
+	<title>AUTHOR</title>
+
+	<para>The original Samba software and related utilities
+	were created by Andrew Tridgell. Samba is now developed
+	by the Samba Team as an Open Source project similar
+	to the way the Linux kernel is developed.</para>
+
+</refsect1>
+
+</refentry>
diff --git a/examples/scripts/vfs/media_harmony/trigger_avid_update.py b/examples/scripts/vfs/media_harmony/trigger_avid_update.py
new file mode 100755
index 0000000..938b3d1
--- /dev/null
+++ b/examples/scripts/vfs/media_harmony/trigger_avid_update.py
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+import os, socket, sys, stat
+
+######################################################################
+##
+##  trigger_avid_update.py for media_harmony VFS module.
+##
+##  Copyright (C) Andrew Klaassen	2012.
+##
+##  This program is free software; you can redistribute it and/or modify
+##  it under the terms of the GNU General Public License as published by
+##  the Free Software Foundation; either version 3 of the License, or
+##  (at your option) any later version.
+##
+##  This program is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##  GNU General Public License for more details.
+##
+##  You should have received a copy of the GNU General Public License
+##  along with this program; if not, see <http://www.gnu.org/licenses/>.
+##
+######################################################################
+
+
+#
+# Change avid_shares and ip_prefix as appropriate for your network.
+#
+
+avid_shares = (
+	'\\\\mediaharmony01\\project1\\',
+	'\\\\mediaharmony01\\project2\\',
+	'\\\\mediaharmony01\\project3\\',
+)
+
+ip_prefix = '192.168.1.'
+
+
+if __name__ == "__main__":
+	my_ips = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if ip[:len(ip_prefix)] == ip_prefix]
+	if not my_ips:
+		print 'No IP address found.  Aborting.'
+		dummy = raw_input("\nPress Enter to finish: ")
+		sys.exit()
+
+	my_ip = my_ips[0]
+	my_name = os.environ.get('USERNAME')
+
+	for avid_share in avid_shares:
+		media_dirs = []
+		omfi_dir = os.path.join(avid_share, 'OMFI MediaFiles')
+		if os.path.exists(omfi_dir):
+			media_dirs.append(omfi_dir)
+		mxf_root = os.path.join(avid_share, 'Avid MediaFiles', 'MXF')
+		if os.path.exists(mxf_root):
+			mxf_children = os.listdir(mxf_root)
+			for child in mxf_children:
+				fullpath = os.path.join(mxf_root, child)
+				if os.path.isdir(fullpath):
+					media_dirs.append(fullpath)
+
+		for media_dir in media_dirs:
+
+			print '\nChecking %s...' % media_dir
+
+			fakepath = '%s_%s_%s' % (media_dir, my_ip, my_name)
+			print '...fakepath: %s' % fakepath
+
+			db = os.path.join(media_dir, 'msmMMOB.mdb')
+			print '...Checking for %s' % db
+			if os.path.exists(db):
+				print '......found %s.' % db
+				db_mtime = os.stat(db)[stat.ST_MTIME]
+				newer_file = False
+				for child in os.listdir(media_dir):
+					if child == 'msmMMOB.mdb' or child == 'msmFMID.pmr':
+						continue
+					child_mtime = os.stat(os.path.join(media_dir, child))[stat.ST_MTIME]
+					if child_mtime > db_mtime:
+						print '......found newer file %s' % child
+						newer_file = True
+						break
+			else:
+				print '......no %s.' % db
+				newer_file = True
+
+			if newer_file:
+				utime = None # Sets to current time.
+				print '...Setting fake mtime to NOW.  Will trigger re-index.'
+			else:
+				mtime = os.stat(media_dir)[stat.ST_MTIME]
+				utime = (mtime, mtime)
+				print '...Setting fake mtime to media_dir mtime.  No re-index.'
+
+			if not os.path.exists(fakepath):
+				tmp_fakepath = '%s.tmp' % fakepath
+				open(tmp_fakepath, 'a').close()
+				os.utime(tmp_fakepath, utime)
+				os.rename(tmp_fakepath, fakepath)
+			else:
+				os.utime(fakepath, utime)
+
+	dummy = raw_input("\nPress Enter to finish: ")
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 1408614..ff0f1f4 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -902,6 +902,7 @@ VFS_SCANNEDONLY_OBJ = modules/vfs_scannedonly.o
 VFS_CROSSRENAME_OBJ = modules/vfs_crossrename.o
 VFS_LINUX_XFS_SGID_OBJ = modules/vfs_linux_xfs_sgid.o
 VFS_TIME_AUDIT_OBJ = modules/vfs_time_audit.o
+VFS_MEDIA_HARMONY_OBJ = modules/vfs_media_harmony.o
 
 PAM_ERRORS_OBJ = ../libcli/auth/pam_errors.o
 PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o $(PAM_ERRORS_OBJ)
@@ -2957,6 +2958,10 @@ bin/time_audit. at SHLIBEXT@: $(BINARY_PREREQS) $(VFS_TIME_AUDIT_OBJ)
 	@echo "Building plugin $@"
 	@$(SHLD_MODULE) $(VFS_TIME_AUDIT_OBJ)
 
+bin/media_harmony. at SHLIBEXT@: $(BINARY_PREREQS) $(VFS_MEDIA_HARMONY_OBJ)
+	@echo "Building plugin $@"
+	@$(SHLD_MODULE) $(VFS_MEDIA_HARMONY_OBJ)
+
 #########################################################
 ## IdMap NSS plugins
 
diff --git a/source3/configure.in b/source3/configure.in
index bd21db9..44fd38d 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -466,6 +466,7 @@ default_shared_modules="$default_shared_modules vfs_scannedonly"
 default_shared_modules="$default_shared_modules vfs_crossrename"
 default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid"
 default_shared_modules="$default_shared_modules vfs_time_audit"
+default_shared_modules="$default_shared_modules vfs_media_harmony"
 default_shared_modules="$default_shared_modules idmap_autorid"
 default_shared_modules="$default_shared_modules idmap_tdb2"
 default_shared_modules="$default_shared_modules idmap_rid"
@@ -6575,6 +6576,7 @@ SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT"
 SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_time_audit, \$(VFS_TIME_AUDIT_OBJ), "bin/time_audit.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_media_harmony, \$(VFS_MEDIA_HARMONY_OBJ), "bin/media_harmony.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c
new file mode 100644
index 0000000..82beccc
--- /dev/null
+++ b/source3/modules/vfs_media_harmony.c
@@ -0,0 +1,2438 @@
+/*
+ * $Id: media_harmony.c,v 1.1 2007/11/06 10:07:22 stuart_hc Exp $
+ *
+ * Samba VFS module supporting multiple AVID clients sharing media.
+ *
+ * Copyright (C) 2005  Philip de Nier <philipn at users.sourceforge.net>
+ * Copyright (C) 2012  Andrew Klaassen <clawsoon at yahoo.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+/*
+ * Media Harmony is a Samba VFS module that allows multiple AVID
+ * clients to share media. Each client sees their own copy of the
+ * AVID msmMMOB.mdb and msmFMID.pmr files and Creating directories.
+ *
+ * Add this module to the vfs objects option in your Samba share
+ * configuration.
+ * eg.
+ *
+ *   [avid_win]
+ *	path = /video
+ *	vfs objects = media_harmony
+ *	...
+ *
+ * It is recommended that you separate out Samba shares for Mac
+ * and Windows clients, and add the following options to the shares
+ * for Windows clients  (NOTE: replace @ with *):
+ *
+ *	veto files = /.DS_Store/._@/.Trash@/.Spotlight@/.hidden/.hotfiles@/.vol/
+ *	delete veto files = yes
+ *
+ * This prevents hidden files from Mac clients interfering with Windows
+ * clients. If you find any more problem hidden files then add them to
+ * the list.
+ *
+ *
+ * Andrew Klaassen, 2012-03-14
+ * To prevent Avid clients from interrupting each other (via Avid's habit
+ * of launching a database refresh whenever it notices an mtime update
+ * on media directories, i.e. whenever one editor adds new material to a
+ * shared share), I've added code that causes stat information for anything
+ * directly under "Avid MediaFile/MXF" to be taken from
+ * dirname_clientaddr_clientuser if it exists.  These files ~aren't~
+ * hidden, unlike the client-suffixed database files.
+ *
+ * For example, stat information for
+ *	Avid MediaFiles/MXF/1
+ * will come from
+ *	Avid MediaFiles/MXF/1_192.168.1.10_dave
+ * for dave working on 192.168.1.10, but will come from
+ *	Avid MediaFile/MXF/1_192.168.1.11_susan
+ * for susan working on 192.168.1.11.  If those alternate
+ * directories don't exist, the user will get the actual directory's stat
+ * info.  When an editor wants to force a database refresh, they update
+ * the mtime on "their" file.  This will cause Avid
+ * on that client to see an updated mtime for "Avid MediaFiles/MXF/1",
+ * which will trigger an Avid database refresh just for that editor.
+ *
+ *
+ * Notes:
+ * - This module is designed to work with AVID editing applications that
+ * look in the Avid MediaFiles or OMFI MediaFiles directory for media.
+ * It is not designed to work as expected in all circumstances for
+ * general use. For example: it is possibly to open client specific
+ * files such as msmMMOB.mdb_192.168.1.10_userx even though is doesn't
+ * show up in a directory listing.
+ *
+ */
+
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "smbd/smbd.h"
+#include "../smbd/globals.h"
+#include "auth.h"
+#include "../lib/tsocket/tsocket.h"
+
+#define MH_INFO_DEBUG 10
+#define MH_ERR_DEBUG 0
+
+static const char* MH_MODULE_NAME = "media_harmony";
+static const char* MDB_FILENAME = "msmMMOB.mdb";
+static const size_t MDB_FILENAME_LEN = 11;
+static const char* PMR_FILENAME = "msmFMID.pmr";
+static const size_t PMR_FILENAME_LEN = 11;
+static const char* CREATING_DIRNAME = "Creating";
+static const size_t CREATING_DIRNAME_LEN = 8;
+static const char* AVID_MEDIAFILES_DIRNAME = "Avid MediaFiles";
+static const size_t AVID_MEDIAFILES_DIRNAME_LEN = 15;
+static const char* OMFI_MEDIAFILES_DIRNAME = "OMFI MediaFiles";
+static const size_t OMFI_MEDIAFILES_DIRNAME_LEN = 15;
+static const char* APPLE_DOUBLE_PREFIX = "._";
+static const size_t APPLE_DOUBLE_PREFIX_LEN = 2;
+static const char* AVID_MXF_DIRNAME = "Avid MediaFiles/MXF";
+static const size_t AVID_MXF_DIRNAME_LEN = 19;
+
+static int vfs_mh_debug_level = DBGC_VFS;
+
+/* supplements the directory list stream */
+typedef struct mh_dirinfo_struct
+{
+	DIR* dirstream;
+	char *dirpath;
+	char *clientPath;
+	bool isInMediaFiles;
+	char *clientMDBFilename;
+	char *clientPMRFilename;
+	char *clientCreatingDirname;
+} mh_dirinfo_struct;
+
+
+/* Add "_<ip address>_<user name>" suffix to path or filename.
+ *
+ * Success: return 0
+ * Failure: set errno, path NULL, return -1
+ */
+static int alloc_append_client_suffix(vfs_handle_struct *handle,
+		char **path)
+{
+	DEBUG(MH_INFO_DEBUG, ("Entering with *path '%s'\n", *path));
+
+	int status = 0;
+	char *raddr = NULL;
+
+	raddr = tsocket_address_inet_addr_string(
+			handle->conn->sconn->remote_address, talloc_tos());
+	if (raddr == NULL)
+	{
+		errno = ENOMEM;
+		status = -1;
+		goto err;
+	}
+
+	/* talloc_asprintf_append uses talloc_realloc, which
+	 * frees original 'path' memory so we don't have to.
+	 */
+	*path = talloc_asprintf_append(*path, "_%s_%s",
+		raddr,
+		handle->conn->session_info->unix_info->sanitized_username);
+	if (*path == NULL)
+	{
+		DEBUG(MH_ERR_DEBUG, ("alloc_append_client_suffix "
+					"out of memory\n"));
+		errno = ENOMEM;
+		status = -1;
+		goto err;
+	}
+	DEBUG(MH_INFO_DEBUG, ("Leaving with *path '%s'\n", *path));
+err:
+	TALLOC_FREE(raddr);
+	return status;
+}
+
+
+/* Returns True if the file or directory begins with the appledouble
+ * prefix.
+ */
+static bool is_apple_double(const char* fname)
+{
+	DEBUG(MH_INFO_DEBUG, ("Entering with fname '%s'\n", fname));
+
+	bool ret = False;
+
+	if (strncmp(APPLE_DOUBLE_PREFIX, fname, APPLE_DOUBLE_PREFIX_LEN)
+			== 0)
+	{
+		ret = True;
+	}
+	DEBUG(MH_INFO_DEBUG, ("Leaving with ret '%s'\n",
+				ret == True ? "True" : "False"));
+	return ret;
+}
+
+static bool starts_with_media_dir(const char* media_dirname,
+		size_t media_dirname_len, const char* path)
+{
+	DEBUG(MH_INFO_DEBUG, ("Entering with media_dirname '%s' "
+				"path '%s'\n", media_dirname, path));
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list