Index: net/samba46/Makefile =================================================================== --- net/samba46/Makefile +++ net/samba46/Makefile @@ -74,7 +74,7 @@ ############################################################################## # Options OPTIONS_DEFINE= ADS AD_DC CUPS DEBUG \ - DOCS FAM LDAP \ + DOCS FAM FULLSYNC LDAP \ QUOTAS SYSLOG UTMP OPTIONS_DEFAULT:= ADS AD_DC DEBUG \ @@ -87,6 +87,7 @@ ADS_DESC= Active Directory client support(implies LDAP) EXP_MODULES_DESC= Experimental modules(WANT_EXP_MODULES) FAM_DESC= File Alteration Monitor support +FULLSYNC_DESC= Experimental Fullsync (TimeMachine) support LDAP_DESC= LDAP client support PAM_SMBPASS_DESC= PAM authentication via passdb backends QUOTAS_DESC= Disk quota support @@ -194,6 +195,8 @@ FAM_USES= fam FAM_CONFIGURE_WITH= fam +FULLSYNC_EXTRA_PATCHES= ${PATCHDIR}/extrapatch-timemachine-fullsync + QUOTAS_CONFIGURE_WITH= quotas SYSLOG_CONFIGURE_WITH= syslog Index: net/samba46/files/extrapatch-timemachine-fullsync =================================================================== --- /dev/null +++ net/samba46/files/extrapatch-timemachine-fullsync @@ -0,0 +1,204 @@ +From 0a1eb9cfb63ca4535aa09567670064fee7c21a0a Mon Sep 17 00:00:00 2001 +From: Kevin Anderson +Date: Fri, 21 Apr 2017 10:07:56 -0400 +Subject: [PATCH 1/2] Rebase from master and with the latest patch on the + mailing list + +This rebases the branch from master and uses the latest patch +on the mainling list. + + - Changes the Fullsync options to time machine + - Configures share options automatically upon TM enablement + - Supports fruit:time machine as a global and share option +--- + docs-xml/manpages/vfs_fruit.8.xml | 32 ++++++++++++++++++++++++++++++++ + libcli/smb/smb2_create_ctx.h | 1 + + source3/modules/vfs_fruit.c | 16 ++++++++++++++++ + 3 files changed, 49 insertions(+) + +diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml +index 7097aac5a41..a3182c865d6 100644 +--- docs-xml/manpages/vfs_fruit.8.xml ++++ docs-xml/manpages/vfs_fruit.8.xml +@@ -214,6 +214,38 @@ + + + ++ fruit:time machine = [ yes | no ] ++ ++ Controls if Time Machine support via the FULLSYNC volume ++ capability is advertised to clients. ++ ++ no (default) Disables ++ advertising Time Machine support and the FULLSYNC volume ++ capability to clients. ++ ++ yes - Enables advertising ++ Time Machine support and the FULLSYNC volume capability to ++ clients. This is necessary for supporting Time Machine backups ++ from Mac OSX clients. This value advertises the capability ++ and with the options below, fsync's a file at the request of ++ the client. ++ ++ ++ ++ ++ This option enforces the following settings per share (or ++ for all shares if enabled globally): ++ ++ durable handles = yes ++ kernel oplocks = no ++ kernel share modes = no ++ posix locking = no ++ ++ ++ ++ ++ ++ + fruit:metadata = [ stream | netatalk ] + + Controls where the OS X metadata stream is stored: +diff --git a/libcli/smb/smb2_create_ctx.h b/libcli/smb/smb2_create_ctx.h +index cb194f5c536..0e0b713e55c 100644 +--- libcli/smb/smb2_create_ctx.h ++++ 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/smbd/avahi_register.c b/source3/smbd/avahi_register.c +index 368168d41dc..c276bf5681a 100644 +--- source3/smbd/avahi_register.c ++++ source3/smbd/avahi_register.c +@@ -18,12 +18,23 @@ + * along with this program; if not, see . + */ + ++/* ++ * Avahi aborts on allocation failure (OOM), ++ * unless a custom allocator which doesn't do so has been set. ++ * ++ * This is particularly important for the avahi_string_list_*() functions, ++ * which return NULL on allocation failure. ++ * Since it should abort on allocation failure (before returning NULL), ++ * we don't check the result. ++ */ ++ + #include "includes.h" + #include "smbd/smbd.h" + + #include + #include + #include ++#include + + struct avahi_state_struct { + struct AvahiPoll *poll; +@@ -75,7 +86,12 @@ 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; ++ + DEBUG(10, ("avahi_client_callback: AVAHI_CLIENT_S_RUNNING\n")); + + state->entry_group = avahi_entry_group_new( +@@ -97,6 +113,33 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status, + state->entry_group = NULL; + break; + } ++ ++ for (snum = 0; snum < num_services; snum++) { ++ if (lp_snum_ok(snum) && ++ lp_parm_bool(snum, "fruit", "time machine", false)) ++ { ++ adisk = avahi_string_list_add_printf( ++ adisk, "dk%d=adVN=%s,adVF=0x82", ++ dk++, lp_const_servicename(snum)); ++ } ++ } ++ if (dk > 0) { ++ adisk = avahi_string_list_add(adisk, "sys=adVF=0x100"); ++ 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; ++ } ++ } ++ + if (avahi_entry_group_commit(state->entry_group) < 0) { + error = avahi_client_errno(c); + DEBUG(10, ("avahi_entry_group_commit failed: " +@@ -106,6 +149,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status, + break; + } + break; ++ } + case AVAHI_CLIENT_FAILURE: + error = avahi_client_errno(c); + +diff --git source3/modules/vfs_fruit.c source3/modules/vfs_fruit.c +index 9a55c9e..376824c 100644 +--- source3/modules/vfs_fruit.c ++++ source3/modules/vfs_fruit.c +@@ -136,6 +136,7 @@ struct fruit_config_data { + bool veto_appledouble; + bool posix_rename; + bool aapl_zero_file_id; ++ bool time_machine; + + /* + * Additional options, all enabled by default, +@@ -1583,6 +1584,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); + +@@ -2216,6 +2220,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); +@@ -2644,6 +2652,14 @@ static int fruit_connect(vfs_handle_struct *handle, + "0x0d:0xf00d"); + } + ++ if (config->time_machine) { ++ 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"); ++ lp_do_parameter(SNUM(handle->conn), "strict sync", "yes"); ++ lp_do_parameter(SNUM(handle->conn), "posix locking", "no"); ++ } ++ + return rc; + } +