[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Fri Jun 13 07:52:03 MDT 2014


The branch, master has been updated
       via  5c87425 man vfs_streams_xattr: new options "prefix" and "store_stream_type"
       via  634bcb0 vfs_streams_xattr: add options "prefix" and "store_stream_type"
       via  f03e8b1 Convert samba_private_attr_name() to a public function
       via  3defbe2 locking: use correct conversion specifier for printing variables
      from  0057388 leases: Fix uint32->hyper

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


- Log -----------------------------------------------------------------
commit 5c874251ff78708706c7b421bb24c00ccd995a65
Author: Ralph Boehme <rb at sernet.de>
Date:   Mon May 26 16:12:17 2014 +0200

    man vfs_streams_xattr: new options "prefix" and "store_stream_type"
    
    Add documentation for the two new options "streams_xattr:prefix" and
    "streams_xattr:store_stream_type".
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Fri Jun 13 15:51:43 CEST 2014 on sn-devel-104

commit 634bcb09a08b927fd79ae0e16aeee2a123605f94
Author: Ralph Boehme <rb at sernet.de>
Date:   Tue May 20 15:17:01 2014 +0200

    vfs_streams_xattr: add options "prefix" and "store_stream_type"
    
    Add module options that can be used to configure the stream prefix the
    module uses (option "prefix", a string) and whether the stream type
    "$DATA" is appended to the xattr name on disk (option
    "store_stream_type", a boolean).
    
    The default "prefix" is "user.DosStream" and the default for
    "store_stream_type" is true, this gives unchanged default behaviour
    when not specifying this option.
    
    OS X SMB clients will send xattrs as named streams over the wire, by
    setting the options to the following values
    
      streams_xattr:prefix = user.
      streams_xattr:store_stream_type = no
    
    OS X xattrs will be stored on disk on the server with their unmodified
    names and as such provide interoperability with other protocols like
    AFP.
    
    In order to prevent access to our internal Samba xattrs, check the
    xattr name with the function samba_private_attr_name() made public by
    the previous commit.
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit f03e8b12c6959fb8213fbfcd3792b70094bd9a71
Author: Ralph Boehme <rb at sernet.de>
Date:   Wed May 21 11:52:27 2014 +0200

    Convert samba_private_attr_name() to a public function
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3defbe273459262f333cca91e90a0941a812df1a
Author: Ralph Boehme <rb at sernet.de>
Date:   Sun Jun 1 15:16:16 2014 +0200

    locking: use correct conversion specifier for printing variables
    
    Fix several occurences of using printf conversion to fload when
    printing offset and count variables in locking debug messages and
    smbstatus.
    
    Conversion to float may lead to wrong results with very large values.
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 docs-xml/manpages/vfs_streams_xattr.8.xml |   34 ++++++++-
 source3/locking/locking.c                 |    4 +-
 source3/locking/posix.c                   |   13 ++--
 source3/modules/vfs_streams_xattr.c       |  122 ++++++++++++++++++++++-------
 source3/smbd/proto.h                      |    1 +
 source3/smbd/trans2.c                     |    2 +-
 source3/utils/status.c                    |    4 +-
 7 files changed, 137 insertions(+), 43 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_streams_xattr.8.xml b/docs-xml/manpages/vfs_streams_xattr.8.xml
index 5aa5aa8..2deb802 100644
--- a/docs-xml/manpages/vfs_streams_xattr.8.xml
+++ b/docs-xml/manpages/vfs_streams_xattr.8.xml
@@ -33,8 +33,11 @@
 	alternate data streams in the file system. As a normal posix file
 	system does not support the concept of multiple data streams per file,
 	the streams_xattr module stores the data in posix extended attributes
-	(xattrs). The name of these attributes is
-	user.DosStream."ADS-NAME".</para>
+	(xattrs). The name of these attributes by default is
+	user.DosStream."ADS-NAME". The prefix "user.DosStream." can be changed
+	with the module option <command>streams_xattr:prefix</command>, but be
+	aware that this will also expose those ADS over the SMB extended
+	attributes interface.</para>
 
 	<para>The file system that is shared with this module enabled must
 	support xattrs.</para>
@@ -46,6 +49,33 @@
 </refsect1>
 
 <refsect1>
+	<title>OPTIONS</title>
+
+	<variablelist>
+
+	  <varlistentry>
+	    <term>streams_xattr:prefix = STRING</term>
+	    <listitem>
+	      <para>Name prefix used when storing an ADS in an xattr, defaults to
+	      <command>user.DosStream.</command>. Changing this will also
+	      expose ADS over the SMB extended attributes interface.</para>
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>streams_xattr:store_stream_type = [yes|no]</term>
+	    <listitem>
+	      <para>Whether the xattr names for Alternate Data Streams of type
+	      "$DATA" are suffixed by the stream type string ":$DATA".
+	      The default is <command>yes</command>.</para>
+	    </listitem>
+	  </varlistentry>
+
+	</variablelist>
+
+</refsect1>
+
+<refsect1>
 	<title>EXAMPLES</title>
 
 <programlisting>
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 4ef6b89..b3f65ee 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -266,10 +266,10 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
 
 	/* NOTE! 0 byte long ranges ARE allowed and should be stored  */
 
-	DEBUG(10,("do_lock: lock flavour %s lock type %s start=%.0f len=%.0f "
+	DEBUG(10,("do_lock: lock flavour %s lock type %s start=%ju len=%ju "
 		"blocking_lock=%s requested for %s file %s\n",
 		lock_flav_name(lock_flav), lock_type_name(lock_type),
-		(double)offset, (double)count, blocking_lock ? "true" :
+		(uintmax_t)offset, (uintmax_t)count, blocking_lock ? "true" :
 		"false", fsp_fnum_dbg(fsp), fsp_str_dbg(fsp)));
 
 	br_lck = brl_get_locks(talloc_tos(), fsp);
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index 2d89110..908cd57 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -186,7 +186,8 @@ static bool posix_fcntl_lock(files_struct *fsp, int op, off_t offset, off_t coun
 {
 	bool ret;
 
-	DEBUG(8,("posix_fcntl_lock %d %d %.0f %.0f %d\n",fsp->fh->fd,op,(double)offset,(double)count,type));
+	DEBUG(8,("posix_fcntl_lock %d %d %jd %jd %d\n",
+		 fsp->fh->fd,op,(intmax_t)offset,(intmax_t)count,type));
 
 	ret = SMB_VFS_LOCK(fsp, op, offset, count, type);
 
@@ -1165,9 +1166,9 @@ bool set_posix_lock_posix_flavour(files_struct *fsp,
 	off_t count;
 	int posix_lock_type = map_posix_lock_type(fsp,lock_type);
 
-	DEBUG(5,("set_posix_lock_posix_flavour: File %s, offset = %.0f, count "
-		 "= %.0f, type = %s\n", fsp_str_dbg(fsp),
-		 (double)u_offset, (double)u_count,
+	DEBUG(5,("set_posix_lock_posix_flavour: File %s, offset = %ju, count "
+		 "= %ju, type = %s\n", fsp_str_dbg(fsp),
+		 (uintmax_t)u_offset, (uintmax_t)u_count,
 		 posix_lock_type_name(lock_type)));
 
 	/*
@@ -1181,8 +1182,8 @@ bool set_posix_lock_posix_flavour(files_struct *fsp,
 
 	if (!posix_fcntl_lock(fsp,F_SETLK,offset,count,posix_lock_type)) {
 		*errno_ret = errno;
-		DEBUG(5,("set_posix_lock_posix_flavour: Lock fail !: Type = %s: offset = %.0f, count = %.0f. Errno = %s\n",
-			posix_lock_type_name(posix_lock_type), (double)offset, (double)count, strerror(errno) ));
+		DEBUG(5,("set_posix_lock_posix_flavour: Lock fail !: Type = %s: offset = %ju, count = %ju. Errno = %s\n",
+			posix_lock_type_name(posix_lock_type), (intmax_t)offset, (intmax_t)count, strerror(errno) ));
 		return False;
 	}
 	return True;
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 5e9bd3e..735db2b 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -29,6 +29,12 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
+struct streams_xattr_config {
+	const char *prefix;
+	size_t prefix_len;
+	bool store_stream_type;
+};
+
 struct stream_io {
 	char *base;
 	char *xattr_name;
@@ -95,33 +101,41 @@ static ssize_t get_xattr_size(connection_struct *conn,
  * Given a stream name, populate xattr_name with the xattr name to use for
  * accessing the stream.
  */
-static NTSTATUS streams_xattr_get_name(TALLOC_CTX *ctx,
+static NTSTATUS streams_xattr_get_name(vfs_handle_struct *handle,
+				       TALLOC_CTX *ctx,
 				       const char *stream_name,
 				       char **xattr_name)
 {
 	char *stype;
+	struct streams_xattr_config *config;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
+				return NT_STATUS_UNSUCCESSFUL);
 
 	stype = strchr_m(stream_name + 1, ':');
 
 	*xattr_name = talloc_asprintf(ctx, "%s%s",
-				      SAMBA_XATTR_DOSSTREAM_PREFIX,
+				      config->prefix,
 				      stream_name + 1);
 	if (*xattr_name == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	if (stype == NULL) {
-		/* Append an explicit stream type if one wasn't specified. */
-		*xattr_name = talloc_asprintf(ctx, "%s:$DATA",
-					       *xattr_name);
-		if (*xattr_name == NULL) {
-			return NT_STATUS_NO_MEMORY;
-		}
-	} else {
+	if (stype != NULL) {
 		/* Normalize the stream type to upercase. */
 		if (!strupper_m(strrchr_m(*xattr_name, ':') + 1)) {
 			return NT_STATUS_INVALID_PARAMETER;
 		}
+	} else if (config->store_stream_type) {
+		/*
+		 * Append an explicit stream type if one wasn't
+		 * specified.
+		 */
+		*xattr_name = talloc_asprintf(ctx, "%s%s",
+					      *xattr_name, ":$DATA");
+		if (*xattr_name == NULL) {
+			return NT_STATUS_NO_MEMORY;
+		}
 	}
 
 	DEBUG(10, ("xattr_name: %s, stream_name: %s\n", *xattr_name,
@@ -145,7 +159,7 @@ static bool streams_xattr_recheck(struct stream_io *sio)
 		return false;
 	}
 
-	status = streams_xattr_get_name(talloc_tos(),
+	status = streams_xattr_get_name(sio->handle, talloc_tos(),
 					sio->fsp->fsp_name->stream_name,
 					&xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -271,8 +285,8 @@ static int streams_xattr_stat(vfs_handle_struct *handle,
 	}
 
 	/* Derive the xattr name to lookup. */
-	status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
-					&xattr_name);
+	status = streams_xattr_get_name(handle, talloc_tos(),
+					smb_fname->stream_name, &xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
@@ -322,8 +336,8 @@ static int streams_xattr_lstat(vfs_handle_struct *handle,
 	}
 
 	/* Derive the xattr name to lookup. */
-	status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
-					&xattr_name);
+	status = streams_xattr_get_name(handle, talloc_tos(),
+					smb_fname->stream_name, &xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
@@ -386,8 +400,8 @@ static int streams_xattr_open(vfs_handle_struct *handle,
 		return ret;
 	}
 
-	status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
-					&xattr_name);
+	status = streams_xattr_get_name(handle, talloc_tos(),
+					smb_fname->stream_name, &xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		goto fail;
@@ -541,8 +555,8 @@ static int streams_xattr_unlink(vfs_handle_struct *handle,
 		return ret;
 	}
 
-	status = streams_xattr_get_name(talloc_tos(), smb_fname->stream_name,
-					&xattr_name);
+	status = streams_xattr_get_name(handle, talloc_tos(),
+					smb_fname->stream_name, &xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		goto fail;
@@ -597,14 +611,14 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 	}
 
 	/* Get the xattr names. */
-	status = streams_xattr_get_name(talloc_tos(),
+	status = streams_xattr_get_name(handle, talloc_tos(),
 					smb_fname_src->stream_name,
 					&src_xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		goto fail;
 	}
-	status = streams_xattr_get_name(talloc_tos(),
+	status = streams_xattr_get_name(handle, talloc_tos(),
 					smb_fname_dst->stream_name,
 					&dst_xattr_name);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -650,7 +664,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
 	return ret;
 }
 
-static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp,
+static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle, files_struct *fsp,
 				   const char *fname,
 				   bool (*fn)(struct ea_struct *ea,
 					      void *private_data),
@@ -659,9 +673,12 @@ static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp,
 	NTSTATUS status;
 	char **names;
 	size_t i, num_names;
-	size_t prefix_len = strlen(SAMBA_XATTR_DOSSTREAM_PREFIX);
+	struct streams_xattr_config *config;
+
+	SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
+				return NT_STATUS_UNSUCCESSFUL);
 
-	status = get_ea_names_from_file(talloc_tos(), conn, fsp, fname,
+	status = get_ea_names_from_file(talloc_tos(), handle->conn, fsp, fname,
 					&names, &num_names);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
@@ -670,20 +687,26 @@ static NTSTATUS walk_xattr_streams(connection_struct *conn, files_struct *fsp,
 	for (i=0; i<num_names; i++) {
 		struct ea_struct ea;
 
-		if (strncmp(names[i], SAMBA_XATTR_DOSSTREAM_PREFIX,
-			    prefix_len) != 0) {
+		if (strncmp(names[i], config->prefix,
+			    config->prefix_len) != 0) {
+			continue;
+		}
+		if (samba_private_attr_name(names[i])) {
 			continue;
 		}
 
-		status = get_ea_value(names, conn, fsp, fname, names[i], &ea);
+		status = get_ea_value(names, handle->conn, fsp, fname,
+				      names[i], &ea);
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(10, ("Could not get ea %s for file %s: %s\n",
 				   names[i], fname, nt_errstr(status)));
 			continue;
 		}
 
-		ea.name = talloc_asprintf(ea.value.data, ":%s",
-					  names[i] + prefix_len);
+		ea.name = talloc_asprintf(
+			ea.value.data, ":%s%s",
+			names[i] + config->prefix_len,
+			config->store_stream_type ? "" : ":$DATA");
 		if (ea.name == NULL) {
 			DEBUG(0, ("talloc failed\n"));
 			continue;
@@ -803,7 +826,7 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
 		 */
 		status = NT_STATUS_OK;
 	} else {
-		status = walk_xattr_streams(handle->conn, fsp, fname,
+		status = walk_xattr_streams(handle, fsp, fname,
 				    collect_one_stream, &state);
 	}
 
@@ -829,6 +852,44 @@ static uint32_t streams_xattr_fs_capabilities(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res) | FILE_NAMED_STREAMS;
 }
 
+static int streams_xattr_connect(vfs_handle_struct *handle,
+				 const char *service, const char *user)
+{
+	struct streams_xattr_config *config;
+	const char *default_prefix = SAMBA_XATTR_DOSSTREAM_PREFIX;
+	const char *prefix;
+
+	config = talloc_zero(handle->conn, struct streams_xattr_config);
+	if (config == NULL) {
+		DEBUG(1, ("talloc_zero() failed\n"));
+		errno = ENOMEM;
+		return -1;
+	}
+
+	prefix = lp_parm_const_string(SNUM(handle->conn),
+				      "streams_xattr", "prefix",
+				      default_prefix);
+	config->prefix = talloc_strdup(config, prefix);
+	if (config->prefix == NULL) {
+		DEBUG(1, ("talloc_strdup() failed\n"));
+		errno = ENOMEM;
+		return -1;
+	}
+	config->prefix_len = strlen(config->prefix);
+	DEBUG(10, ("streams_xattr using stream prefix: %s\n", config->prefix));
+
+	config->store_stream_type = lp_parm_bool(SNUM(handle->conn),
+						 "streams_xattr",
+						 "store_stream_type",
+						 true);
+
+	SMB_VFS_HANDLE_SET_DATA(handle, config,
+				NULL, struct stream_xattr_config,
+				return -1);
+
+	return 0;
+}
+
 static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
 				    files_struct *fsp, const void *data,
 				    size_t n, off_t offset)
@@ -1031,6 +1092,7 @@ static int streams_xattr_fallocate(struct vfs_handle_struct *handle,
 
 static struct vfs_fn_pointers vfs_streams_xattr_fns = {
 	.fs_capabilities_fn = streams_xattr_fs_capabilities,
+	.connect_fn = streams_xattr_connect,
 	.open_fn = streams_xattr_open,
 	.stat_fn = streams_xattr_stat,
 	.fstat_fn = streams_xattr_fstat,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index f598816..3c6accf 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1056,6 +1056,7 @@ NTSTATUS check_access(connection_struct *conn,
 				uint32_t access_mask);
 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
 uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
+bool samba_private_attr_name(const char *unix_ea_name);
 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
 		      files_struct *fsp, const char *fname,
 		      const char *ea_name, struct ea_struct *pea);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 4afb27e..aeada68 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -120,7 +120,7 @@ uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf)
  Refuse to allow clients to overwrite our private xattrs.
 ****************************************************************************/
 
-static bool samba_private_attr_name(const char *unix_ea_name)
+bool samba_private_attr_name(const char *unix_ea_name)
 {
 	static const char * const prohibited_ea_names[] = {
 		SAMBA_POSIX_INHERITANCE_EA_NAME,
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 61a450e..7bbcea5 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -240,10 +240,10 @@ static void print_brl(struct file_id id,
 		}
 	}
 
-	d_printf("%-10s %-15s %-4s %-9.0f %-9.0f %-24s %-24s\n", 
+	d_printf("%-10s %-15s %-4s %-9jd %-9jd %-24s %-24s\n",
 		 procid_str_static(&pid), file_id_string_tos(&id),
 		 desc,
-		 (double)start, (double)size,
+		 (intmax_t)start, (intmax_t)size,
 		 sharepath, fname);
 
 	TALLOC_FREE(fname);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list