From: Ralph Boehme Date: Thu, 17 Dec 2015 19:08:35 +0000 (+0100) Subject: vfs_fruit: writing all 0 to AFP_AfpInfo stream X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=e94b17715ea8049df8819b472178170b8e987946;p=metze%2Fsamba%2Fwip.git vfs_fruit: writing all 0 to AFP_AfpInfo stream When writing all 0 to AFP_AfpInfo stream we can remove the underlying storage object. This beaviour of OS X SMB server was found with a torture test. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11347 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index ff19b6dbead6..697783291ccf 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -2820,6 +2820,23 @@ static ssize_t fruit_pwrite(vfs_handle_struct *handle, } memcpy(ad_entry(ad, ADEID_FINDERI), &ai->afpi_FinderInfo[0], ADEDLEN_FINDERI); + if (empty_finderinfo(ad)) { + /* Discard metadata */ + if (config->meta == FRUIT_META_STREAM) { + rc = SMB_VFS_FTRUNCATE(fsp, 0); + } else { + rc = SMB_VFS_REMOVEXATTR(handle->conn, + fsp->fsp_name->base_name, + AFPINFO_EA_NETATALK); + } + if (rc != 0 && errno != ENOENT && errno != ENOATTR) { + DBG_WARNING("Can't delete metadata for %s: %s\n", + fsp->fsp_name->base_name, strerror(errno)); + goto exit; + } + rc = 0; + goto exit; + } rc = ad_write(ad, name); } else { len = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n,