[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jan 9 20:16:04 MST 2015


The branch, master has been updated
       via  15511f7 vfs_unityed_media: VFS module for sharing AVID projects
      from  f58545d lib: Simplify iov_buf

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


- Log -----------------------------------------------------------------
commit 15511f7c51686a088127748b211c3a3ff95c2fd1
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 22 19:17:12 2014 +0200

    vfs_unityed_media: VFS module for sharing AVID projects
    
    Based on <https://code.google.com/p/vfs-unityed-media/>.
    
    The existing VFS module media_harmony has some problems relative to Avid
    media sharing:
    
    Avid looks at the modification time of the ingest directory. Since
    media_harmony has everyone using the same directory, users (or client
    systems) have to somehow create "fake" directories with special names
    and then media_harmony returns the mod time of those fake directories
    for the different clients rather than the actual mod time of the
    communal ingest directory.
    
    To make matters worse, users then have to have a special utility or
    understand how to update the modtime on these specially named
    directories. Otherwise, their client system will never update the
    indexes to show new media.
    
    To make it even worse than that, Avid creates new directories on the
    fly, so you can't just set this up statically at the beginning. Avid
    will silently create a new directory and your reindexing problems will
    start all over until you create new fake directories.
    
    With unityed_media:
    
    * there are no reindexes between clients
    
    * clients don't need to know which directories have been created for
      them, it's automatic.
    
    * clients never have to reindex other systems directories.
    
    * unityed_media let's each client have their own directories.
    
    * unityed_media works much more like Avid's own ISIS servers work.
    
    A module option controls which name is appended to client specific
    paths: the username, the hostname (will not work with OS X) or the
    client's IP.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Jan 10 04:15:04 CET 2015 on sn-devel-104

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

Summary of changes:
 docs-xml/manpages/vfs_unityed_media.8.xml |  115 ++
 docs-xml/wscript_build                    |    1 +
 source3/modules/vfs_unityed_media.c       | 1953 +++++++++++++++++++++++++++++
 source3/modules/wscript_build             |    9 +
 source3/wscript                           |    2 +-
 5 files changed, 2079 insertions(+), 1 deletion(-)
 create mode 100644 docs-xml/manpages/vfs_unityed_media.8.xml
 create mode 100644 source3/modules/vfs_unityed_media.c


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_unityed_media.8.xml b/docs-xml/manpages/vfs_unityed_media.8.xml
new file mode 100644
index 0000000..0d061c6
--- /dev/null
+++ b/docs-xml/manpages/vfs_unityed_media.8.xml
@@ -0,0 +1,115 @@
+<?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_unityed_media</refentrytitle>
+	<manvolnum>8</manvolnum>
+	<refmiscinfo class="source">Samba</refmiscinfo>
+	<refmiscinfo class="manual">System Administration tools</refmiscinfo>
+	<refmiscinfo class="version">4.2</refmiscinfo>
+</refmeta>
+
+
+<refnamediv>
+	<refname>vfs_unityed_media</refname>
+	<refpurpose>Allow multiple Avid clients to share a network drive.</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+	<cmdsynopsis>
+		<command>vfs objects = unityed_media</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>Unityed Media is related with Media Harmony VFS, the
+	main difference between Unityed Media and Media Harmony is
+	that Unityed Media doesn't need manual refreshing of media
+	directories. Unityed Media handles your media files in a similar
+	way to the way Unity, ISIS, EditShare or another dedicated solution
+	does. Without client-side application and on hardware of your
+	choice.</para>
+
+	<para>This module is stackable.</para>
+</refsect1>
+
+<refsect1>
+	<title>CONFIGURATION</title>
+
+	<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>
+</refsect1>
+
+<refsect1>
+	<title>OPTIONS</title>
+
+	<variablelist>
+
+	  <varlistentry>
+	    <term>unityed_media:clientid = user | hostname | ip </term>
+	    <listitem>
+	      <para>Controls what client related identifier is
+	      appended to user specific paths:</para>
+
+	      <itemizedlist>
+		<listitem><para><command>user (default)</command> -
+		use the username.  </para></listitem>
+
+		<listitem><para><command>hostname</command> - use the
+		hostname. Note this will not work with OS X clients as
+		these always send a generic string ("workstation") to
+		the server..</para></listitem>
+
+		<listitem><para><command>ip</command> - use the
+		client's IP address.  NOTE: this is untested and may
+		not work at all.</para></listitem>
+	      </itemizedlist>
+
+	    </listitem>
+	  </varlistentry>
+	</variablelist>
+</refsect1>
+
+<refsect1>
+	<title>EXAMPLES</title>
+
+	<para>Enable unityed_media for Mac and Windows clients:</para>
+<programlisting>
+        <smbconfsection name="[avid_mac]"/>
+	<smbconfoption name="path">/avid</smbconfoption>
+	<smbconfoption name="vfs objects">unityed_media</smbconfoption>
+        <smbconfsection name="[avid_win]"/>
+	<smbconfoption name="path">/avid</smbconfoption>
+	<smbconfoption name="vfs objects">unityed_media</smbconfoption>
+	<smbconfoption name="veto files">/.DS_Store/._@/.Trash@/.Spotlight@/.hidden/.hotfiles@/.vol/</smbconfoption>
+	<smbconfoption name="delete veto files">yes</smbconfoption>
+</programlisting>
+
+</refsect1>
+
+<refsect1>
+	<title>VERSION</title>
+
+	<para>This man page is correct for version 4.2 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/docs-xml/wscript_build b/docs-xml/wscript_build
index 0bc3f54..4060021 100644
--- a/docs-xml/wscript_build
+++ b/docs-xml/wscript_build
@@ -83,6 +83,7 @@ manpages='''
          manpages/vfs_syncops.8
          manpages/vfs_time_audit.8
          manpages/vfs_tsmsm.8
+         manpages/vfs_unityed_media.8
          manpages/vfs_worm.8
          manpages/vfs_xattr_tdb.8
          manpages/vfstest.1
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
new file mode 100644
index 0000000..7dc187f
--- /dev/null
+++ b/source3/modules/vfs_unityed_media.c
@@ -0,0 +1,1953 @@
+/*
+ * 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>
+ * Copyright (C) 2013  Milos Lukacek
+ * Copyright (C) 2013  Ralph Boehme <slow at samba.org>
+ *
+ * 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.
+ */
+
+/*
+ * Unityed Media is a Samba VFS module that allows multiple AVID
+ * clients to share media.
+ *
+ * Add this module to the vfs objects option in your Samba share
+ * configuration.
+ * eg.
+ *
+ *   [avid_win]
+ *	path = /video
+ *	vfs objects = unityed_media
+ *	...
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "smbd/smbd.h"
+#include "../smbd/globals.h"
+#include "auth.h"
+#include "../lib/tsocket/tsocket.h"
+#include <libgen.h>
+
+#define UM_PARAM_TYPE_NAME "unityed_media"
+
+static const char *AVID_MXF_DIRNAME = "Avid MediaFiles/MXF";
+static const size_t AVID_MXF_DIRNAME_LEN = 19;
+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 int vfs_um_debug_level = DBGC_VFS;
+
+enum um_clientid {UM_CLIENTID_NAME, UM_CLIENTID_IP, UM_CLIENTID_HOSTNAME};
+
+struct um_config_data {
+	enum um_clientid clientid;
+};
+
+static const struct enum_list um_clientid[] = {
+	{UM_CLIENTID_NAME, "user"},
+	{UM_CLIENTID_IP, "ip"},
+	{UM_CLIENTID_HOSTNAME, "hostname"},
+	{-1, NULL}
+};
+
+/* supplements the directory list stream */
+typedef struct um_dirinfo_struct {
+	DIR* dirstream;
+	char *dirpath;
+	char *clientPath;
+	bool isInMediaFiles;
+	char *clientSubDirname;
+} um_dirinfo_struct;
+
+/**
+ * Returns true and first group of digits in path, false and 0 otherwise
+ **/
+static bool get_digit_group(const char *path, uintmax_t *digit)
+{
+	const char *p = path;
+	char *endp = NULL;
+	codepoint_t cp;
+	size_t size;
+
+	DEBUG(10, ("get_digit_group entering with path '%s'\n",
+		   path));
+
+	/*
+	 * Delibiretly initialize to 0 because callers use this result
+	 * even though the string doesn't contain any number and we
+	 * returned false
+	 */
+	*digit = 0;
+
+	while (*p) {
+		cp = next_codepoint(p, &size);
+		if (cp == -1) {
+			return false;
+		}
+		if ((size == 1) && (isdigit(cp))) {
+			*digit = (uintmax_t)strtoul(p, &endp, 10);
+			DEBUG(10, ("num_suffix = '%ju'\n",
+				   *digit));
+			return true;
+		}
+		p += size;
+	}
+
+	return false;
+}
+
+/* Add "_<remote_name>.<number>" 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)
+{
+	int status = 0;
+	uintmax_t number;
+	const char *clientid;
+	struct um_config_data *config;
+
+	DEBUG(10, ("Entering with path '%s'\n", *path));
+
+	SMB_VFS_HANDLE_GET_DATA(handle, config,
+				struct um_config_data,
+				return -1);
+
+	(void)get_digit_group(*path, &number);
+
+	switch (config->clientid) {
+
+	case UM_CLIENTID_IP:
+		clientid = tsocket_address_inet_addr_string(
+			handle->conn->sconn->remote_address, talloc_tos());
+		if (clientid == NULL) {
+			errno = ENOMEM;
+			status = -1;
+			goto err;
+		}
+		break;
+
+	case UM_CLIENTID_HOSTNAME:
+		clientid = get_remote_machine_name();
+		break;
+
+	case UM_CLIENTID_NAME:
+	default:
+		clientid = get_current_username();
+		break;
+	}
+
+	*path = talloc_asprintf_append(*path, "_%s.%ju",
+				       clientid, number);
+	if (*path == NULL) {
+		DEBUG(1, ("alloc_append_client_suffix "
+				     "out of memory\n"));
+		errno = ENOMEM;
+		status = -1;
+		goto err;
+	}
+	DEBUG(10, ("Leaving with *path '%s'\n", *path));
+err:
+	return status;
+}
+
+/* Returns true if the file or directory begins with the appledouble
+ * prefix.
+ */
+static bool is_apple_double(const char* fname)
+{
+	bool ret = false;
+
+	DEBUG(10, ("Entering with fname '%s'\n", fname));
+
+	if (strnequal(APPLE_DOUBLE_PREFIX, fname, APPLE_DOUBLE_PREFIX_LEN)) {
+		ret = true;
+	}
+	DEBUG(10, ("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)
+{
+	bool ret = false;
+	const char *path_start = path;
+
+	DEBUG(10, ("Entering with media_dirname '%s' "
+			      "path '%s'\n", media_dirname, path));
+
+	/* Sometimes Samba gives us "./OMFI MediaFiles". */
+	if (strnequal(path, "./", 2)) {
+		path_start += 2;
+	}
+
+	if (strnequal(media_dirname, path_start, media_dirname_len)
+	    &&
+	    ((path_start[media_dirname_len] == '\0') ||
+	     (path_start[media_dirname_len] == '/'))) {
+		ret = true;
+	}
+
+	DEBUG(10, ("Leaving with ret '%s'\n",
+			      ret == true ? "true" : "false"));
+	return ret;
+}
+
+/*
+ * Returns true if the file or directory referenced by the path is ONE
+ * LEVEL below the AVID_MXF_DIRNAME or OMFI_MEDIAFILES_DIRNAME
+ * directory
+ */
+static bool is_in_media_dir(const char *path)
+{
+	int transition_count = 0;
+	const char *path_start = path;
+	const char *p;
+	const char *media_dirname;
+	size_t media_dirname_len;
+
+	DEBUG(10, ("Entering with path'%s' ", path));
+
+	/* Sometimes Samba gives us "./OMFI MediaFiles". */
+	if (strnequal(path, "./", 2)) {
+		path_start += 2;
+	}
+
+	if (strnequal(path_start, AVID_MXF_DIRNAME, AVID_MXF_DIRNAME_LEN)) {
+		media_dirname = AVID_MXF_DIRNAME;
+		media_dirname_len = AVID_MXF_DIRNAME_LEN;
+	} else if (strnequal(path_start,
+			     OMFI_MEDIAFILES_DIRNAME,
+			     OMFI_MEDIAFILES_DIRNAME_LEN)) {
+		media_dirname = OMFI_MEDIAFILES_DIRNAME;
+		media_dirname_len = OMFI_MEDIAFILES_DIRNAME_LEN;
+	} else {
+		return false;
+	}
+
+	if (path_start[media_dirname_len] == '\0') {
+		goto out;
+	}
+
+	p = path_start + media_dirname_len + 1;
+
+	while (true) {
+		if (*p == '\0' || *p == '/') {
+			if (strnequal(p - 3, "/..", 3)) {
+				transition_count--;
+			} else if ((p[-1] != '/') || !strnequal(p - 2, "/.", 2)) {
+				transition_count++;
+			}
+		}
+		if (*p == '\0') {
+			break;
+		}
+		p++;
+	}
+
+out:
+	DEBUG(10, ("Going out with transition_count '%i'\n",
+			      transition_count));
+	if (((transition_count == 1) && (media_dirname == AVID_MXF_DIRNAME))
+	    ||
+	    ((transition_count == 0) && (media_dirname == OMFI_MEDIAFILES_DIRNAME))) {
+		return true;
+	}
+	else return false;
+}
+
+/*
+ * Returns true if the file or directory referenced by the path is
+ * below the AVID_MEDIAFILES_DIRNAME or OMFI_MEDIAFILES_DIRNAME
+ * directory The AVID_MEDIAFILES_DIRNAME and OMFI_MEDIAFILES_DIRNAME
+ * are assumed to be in the root directory, which is generally a safe
+ * assumption in the fixed-path world of Avid.
+ */
+static bool is_in_media_files(const char *path)
+{
+	bool ret = false;
+
+	DEBUG(10, ("Entering with path '%s'\n", path));
+
+	if (starts_with_media_dir(AVID_MXF_DIRNAME,
+				  AVID_MXF_DIRNAME_LEN, path) ||
+	    starts_with_media_dir(OMFI_MEDIAFILES_DIRNAME,
+				  OMFI_MEDIAFILES_DIRNAME_LEN, path)) {
+		ret = true;
+	}
+	DEBUG(10, ("Leaving with ret '%s'\n",
+			      ret == true ? "true" : "false"));
+	return ret;
+}
+
+
+/* Add client suffix to "pure-number" path.
+ *
+ * Caller must free newPath.
+ *
+ * Success: return 0
+ * Failure: set errno, newPath NULL, return -1
+ */
+static int alloc_get_client_path(vfs_handle_struct *handle,
+				 TALLOC_CTX *ctx,
+				 const char *path_in,
+				 char **path_out)
+{
+	int status = 0;
+	char *p;
+	char *digits;
+	size_t digits_len;
+	uintmax_t number;
+
+	*path_out = talloc_strdup(ctx, path_in);
+        if (*path_out == NULL) {
+		DEBUG(1, ("alloc_get_client_path ENOMEM\n"));
+		return -1;
+	}
+
+	(void)get_digit_group(*path_out, &number);
+
+	digits = talloc_asprintf(NULL, "%ju", number);
+        if (digits == NULL) {
+		DEBUG(1, ("alloc_get_client_path ENOMEM\n"));
+		return -1;
+	}
+	digits_len = strlen(digits);
+
+	p = strstr_m(path_in, digits);
+	if ((p)
+	    &&
+	    ((p[digits_len] == '\0') || (p[digits_len] == '/'))
+	    &&


-- 
Samba Shared Repository


More information about the samba-cvs mailing list