[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Wed Oct 4 12:06:02 UTC 2017


The branch, master has been updated
       via  b07f221 s3: VFS: Ensure default SMB_VFS_GETWD() call can't return a partially completed struct smb_filename.
       via  4800ed3 s3: VFS: Protect errno if sys_getwd() fails across free() call.
       via  fb9ce06 s3: VFS: Ensure sys_getwd() doesn't leak memory on error on really old systems.
       via  d774aeb vfs_solarisacl: fix build for samba 4.7 and up
       via  127b18e s3/smbd: register Time Machine shares with Avahi
       via  4d65445 docs/vfs_fruit: Add Time Machine support
       via  174e6cb vfs_fruit: Add Time Machine support
      from  064e17c0 net: groupmap cleanup should not delete BUILTIN mappings

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


- Log -----------------------------------------------------------------
commit b07f22158d7feaf9146b68a874427efe0538dbb6
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Oct 2 17:36:51 2017 -0700

    s3: VFS: Ensure default SMB_VFS_GETWD() call can't return a partially completed struct smb_filename.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13068
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Oct  4 14:05:33 CEST 2017 on sn-devel-144

commit 4800ed3595513ce1e2f4edee36c35daafc63a3d5
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Oct 3 10:58:00 2017 -0700

    s3: VFS: Protect errno if sys_getwd() fails across free() call.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13069
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fb9ce0685e5d46e3d7abf5fac07b4f626339a413
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Oct 3 10:37:55 2017 -0700

    s3: VFS: Ensure sys_getwd() doesn't leak memory on error on really old systems.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13069
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d774aeba5e04eacb98cf938d356e4cc502caa2e7
Author: Jorge Schrauwen via samba-technical <samba-technical at lists.samba.org>
Date:   Tue Oct 3 19:55:28 2017 +0200

    vfs_solarisacl: fix build for samba 4.7 and up
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13049
    
    Signed-off-by: Jorge Schrauwen <sjorge at blackdot.be>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 127b18eb96cb5defa025e27ff38526cdc2ea30a6
Author: Omri Mor <omri50 at gmail.com>
Date:   Sun Oct 1 21:39:47 2017 -0500

    s3/smbd: register Time Machine shares with Avahi
    
    Adds support for automatically registering the required _adisk._tcp
    mDNS record based on the setting of "fruit:time machine".
    
    Signed-off-by: Omri Mor <omri50 at gmail.com>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4d6544593b9dc789cc6b34cd24e557e0379a8e73
Author: Kevin Anderson <andersonkw2 at gmail.com>
Date:   Sun Oct 23 20:32:27 2016 -0400

    docs/vfs_fruit: Add Time Machine support
    
    Add the capability to advertise FULLSYNC volume capabilities
    to clients that request them. This is mainly used for supporting
    Mac OS Time Machine backups from clients. The capability does
    not perform any additional action.
    
    Signed-off-by: Kevin Anderson <andersonkw2 at gmail.com>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 174e6cb5e68c22cc845cb52cbebed6b43fdda1d6
Author: Kevin Anderson <andersonkw2 at gmail.com>
Date:   Mon Nov 14 19:14:44 2016 +0100

    vfs_fruit: Add Time Machine support
    
    Add a configuration option to disable/enable Time Machine support via
    the FULLSYNC AAPL flag.
    
    Signed-off-by: Kevin Anderson <andersonkw2 at gmail.com>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml | 28 +++++++++++
 libcli/smb/smb2_create_ctx.h      |  1 +
 source3/lib/system.c              | 11 ++++-
 source3/modules/vfs_default.c     |  4 ++
 source3/modules/vfs_fruit.c       | 21 +++++++++
 source3/modules/vfs_solarisacl.c  |  2 +-
 source3/modules/vfs_solarisacl.h  |  2 +-
 source3/smbd/avahi_register.c     | 97 ++++++++++++++++++++++++++++++++++++++-
 8 files changed, 162 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index c5ffc82..b0cb9f0 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -214,6 +214,34 @@
 	  </varlistentry>
 
 	  <varlistentry>
+	    <term>fruit:time machine = [ yes | no ]</term>
+	    <listitem>
+	      <para>Controls if Time Machine support via the FULLSYNC volume
+	      capability is advertised to clients.</para>
+
+	      <itemizedlist>
+		<listitem><para><command>yes</command> - Enables Time Machine
+		support for this share. Also registers the share with mDNS in
+		case Samba is built with mDNS support.</para></listitem>
+
+		<listitem><para><command>no (default)</command> Disables
+		advertising Time Machine support.</para></listitem>
+
+	      </itemizedlist>
+
+	      <para>This option enforces the following settings per share (or
+	      for all shares if enabled globally):</para>
+	      <itemizedlist>
+		<listitem><para><command>durable handles = yes</command></para></listitem>
+		<listitem><para><command>kernel oplocks = no</command></para></listitem>
+		<listitem><para><command>kernel share modes = no</command></para></listitem>
+		<listitem><para><command>posix locking = no</command></para></listitem>
+	      </itemizedlist>
+
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
 	    <term>fruit:metadata = [ stream | netatalk ]</term>
 	    <listitem>
 	      <para>Controls where the OS X metadata stream is stored:</para>
diff --git a/libcli/smb/smb2_create_ctx.h b/libcli/smb/smb2_create_ctx.h
index cb194f5..0e0b713 100644
--- a/libcli/smb/smb2_create_ctx.h
+++ b/libcli/smb/smb2_create_ctx.h
@@ -42,5 +42,6 @@
 /* "AAPL" Volume Capabilities bitmap */
 #define SMB2_CRTCTX_AAPL_SUPPORT_RESOLVE_ID 1
 #define SMB2_CRTCTX_AAPL_CASE_SENSITIVE     2
+#define SMB2_CRTCTX_AAPL_FULL_SYNC          4
 
 #endif
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 70ddf6a..507d4a9 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -594,7 +594,9 @@ char *sys_getwd(void)
 			break;
 		}
 		if (errno != ERANGE) {
+			int saved_errno = errno;
 			SAFE_FREE(s);
+			errno = saved_errno;
 			break;
 		}
 		allocated *= 2;
@@ -605,11 +607,18 @@ char *sys_getwd(void)
 	}
 	return wd;
 #else
+	char *wd = NULL;
 	char *s = SMB_MALLOC_ARRAY(char, PATH_MAX);
 	if (s == NULL) {
 		return NULL;
 	}
-	return getwd(s);
+	wd = getwd(s);
+	if (wd == NULL) {
+		int saved_errno = errno;
+		SAFE_FREE(s);
+		errno = saved_errno;
+	}
+	return wd;
 #endif
 }
 
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 0a56e45..53d9785 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -2226,6 +2226,10 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle,
 	START_PROFILE(syscall_getwd);
 	result = sys_getwd();
 	END_PROFILE(syscall_getwd);
+
+	if (result == NULL) {
+		return NULL;
+	}
 	smb_fname = synthetic_smb_fname(ctx,
 				result,
 				NULL,
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 3ba5996..5c9e680 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -139,6 +139,7 @@ struct fruit_config_data {
 	bool posix_rename;
 	bool aapl_zero_file_id;
 	const char *model;
+	bool time_machine;
 
 	/*
 	 * Additional options, all enabled by default,
@@ -1549,6 +1550,9 @@ static int init_fruit_config(vfs_handle_struct *handle)
 	config->use_aapl = lp_parm_bool(
 		-1, FRUIT_PARAM_TYPE_NAME, "aapl", true);
 
+	config->time_machine = lp_parm_bool(
+		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME, "time machine", false);
+
 	config->unix_info_enabled = lp_parm_bool(
 		-1, FRUIT_PARAM_TYPE_NAME, "nfs_aces", true);
 
@@ -2206,6 +2210,10 @@ static NTSTATUS check_aapl(vfs_handle_struct *handle,
 			break;
 		}
 
+		if (config->time_machine) {
+			caps |= SMB2_CRTCTX_AAPL_FULL_SYNC;
+		}
+
 		SBVAL(p, 0, caps);
 
 		ok = data_blob_append(req, &blob, p, 8);
@@ -2637,6 +2645,19 @@ static int fruit_connect(vfs_handle_struct *handle,
 			"0x0d:0xf00d");
 	}
 
+	if (config->time_machine) {
+		DBG_NOTICE("Enabling durable handles for Time Machine "
+			   "support on [%s]\n", service);
+		lp_do_parameter(SNUM(handle->conn), "durable handles", "yes");
+		lp_do_parameter(SNUM(handle->conn), "kernel oplocks", "no");
+		lp_do_parameter(SNUM(handle->conn), "kernel share modes", "no");
+		if (!lp_strict_sync(SNUM(handle->conn))) {
+			DBG_WARNING("Time Machine without strict sync is not "
+				    "recommended!\n");
+		}
+		lp_do_parameter(SNUM(handle->conn), "posix locking", "no");
+	}
+
 	return rc;
 }
 
diff --git a/source3/modules/vfs_solarisacl.c b/source3/modules/vfs_solarisacl.c
index 74086bd..5c01139 100644
--- a/source3/modules/vfs_solarisacl.c
+++ b/source3/modules/vfs_solarisacl.c
@@ -306,7 +306,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle,
  * check is considered unnecessary. --- Agreed? XXX
  */
 int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
-				struct smb_filename *smb_fname)
+				const struct smb_filename *smb_fname)
 {
 	SMB_ACL_T smb_acl;
 	int ret = -1;
diff --git a/source3/modules/vfs_solarisacl.h b/source3/modules/vfs_solarisacl.h
index 02bd371..ce2206c 100644
--- a/source3/modules/vfs_solarisacl.h
+++ b/source3/modules/vfs_solarisacl.h
@@ -41,7 +41,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle,
 int solarisacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
 				const struct smb_filename *smb_fname);
 
-NTSTATUS vfs_solarisacl_init(void);
+NTSTATUS vfs_solarisacl_init(TALLOC_CTX *);
 
 #endif
 
diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c
index c118e61..91e8a43 100644
--- a/source3/smbd/avahi_register.c
+++ b/source3/smbd/avahi_register.c
@@ -24,6 +24,8 @@
 #include <avahi-client/client.h>
 #include <avahi-client/publish.h>
 #include <avahi-common/error.h>
+#include <avahi-common/malloc.h>
+#include <avahi-common/strlst.h>
 
 struct avahi_state_struct {
 	struct AvahiPoll *poll;
@@ -32,6 +34,39 @@ struct avahi_state_struct {
 	uint16_t port;
 };
 
+static void *avahi_allocator_ctx = NULL;
+
+static void * avahi_allocator_malloc(size_t size)
+{
+	return talloc_size(avahi_allocator_ctx, size);
+}
+
+static void avahi_allocator_free(void *p)
+{
+	TALLOC_FREE(p);
+}
+
+static void * avahi_allocator_realloc(void *p, size_t size)
+{
+	return talloc_realloc_size(avahi_allocator_ctx, p, size);
+}
+
+static void * avahi_allocator_calloc(size_t count, size_t size)
+{
+	void *p = talloc_array_size(avahi_allocator_ctx, size, count);
+	if (p) {
+		memset(p, 0, size * count);
+	}
+	return p;
+}
+
+static const struct AvahiAllocator avahi_talloc_allocator = {
+	&avahi_allocator_malloc,
+	&avahi_allocator_free,
+	&avahi_allocator_realloc,
+	&avahi_allocator_calloc
+};
+
 static void avahi_entry_group_callback(AvahiEntryGroup *g,
 				       AvahiEntryGroupState status,
 				       void *userdata)
@@ -70,7 +105,13 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
 	int error;
 
 	switch (status) {
-	case AVAHI_CLIENT_S_RUNNING:
+	case AVAHI_CLIENT_S_RUNNING: {
+		int snum;
+		int num_services = lp_numservices();
+		int dk = 0;
+		AvahiStringList *adisk = NULL;
+		AvahiStringList *adisk2 = NULL;
+
 		DBG_DEBUG("AVAHI_CLIENT_S_RUNNING\n");
 
 		state->entry_group = avahi_entry_group_new(
@@ -94,6 +135,53 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
 			break;
 		}
 
+		for (snum = 0; snum < num_services; snum++) {
+			if (lp_snum_ok(snum) &&
+			    lp_parm_bool(snum, "fruit", "time machine", false))
+			{
+				adisk2 = avahi_string_list_add_printf(
+					    adisk, "dk%d=adVN=%s,adVF=0x82",
+					    dk++, lp_const_servicename(snum));
+				if (adisk2 == NULL) {
+					DBG_DEBUG("avahi_string_list_add_printf"
+						  "failed: returned NULL\n");
+					avahi_string_list_free(adisk);
+					avahi_entry_group_free(state->entry_group);
+					state->entry_group = NULL;
+					break;
+				}
+				adisk = adisk2;
+				adisk2 = NULL;
+			}
+		}
+		if (dk > 0) {
+			adisk2 = avahi_string_list_add(adisk, "sys=adVF=0x100");
+			if (adisk2 == NULL) {
+				DBG_DEBUG("avahi_string_list_add failed: "
+					  "returned NULL\n");
+				avahi_string_list_free(adisk);
+				avahi_entry_group_free(state->entry_group);
+				state->entry_group = NULL;
+				break;
+			}
+			adisk = adisk2;
+			adisk2 = NULL;
+
+			error = avahi_entry_group_add_service_strlst(
+				    state->entry_group, AVAHI_IF_UNSPEC,
+				    AVAHI_PROTO_UNSPEC, 0, lp_netbios_name(),
+				    "_adisk._tcp", NULL, NULL, 0, adisk);
+			avahi_string_list_free(adisk);
+			adisk = NULL;
+			if (error != AVAHI_OK) {
+				DBG_DEBUG("avahi_entry_group_add_service_strlst "
+					  "failed: %s\n", avahi_strerror(error));
+				avahi_entry_group_free(state->entry_group);
+				state->entry_group = NULL;
+				break;
+			}
+		}
+
 		error = avahi_entry_group_commit(state->entry_group);
 		if (error != AVAHI_OK) {
 			DBG_DEBUG("avahi_entry_group_commit failed: %s\n",
@@ -103,6 +191,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
 			break;
 		}
 		break;
+	}
 	case AVAHI_CLIENT_FAILURE:
 		error = avahi_client_errno(c);
 
@@ -139,6 +228,12 @@ void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 	struct avahi_state_struct *state;
 	int error;
 
+	avahi_allocator_ctx = talloc_new(mem_ctx);
+	if (avahi_allocator_ctx == NULL) {
+		return NULL;
+	}
+	avahi_set_allocator(&avahi_talloc_allocator);
+
 	state = talloc(mem_ctx, struct avahi_state_struct);
 	if (state == NULL) {
 		return state;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list