1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-20 22:50:26 +03:00

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 <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit e94b17715ea8049df8819b472178170b8e987946)
This commit is contained in:
Ralph Boehme 2015-12-17 20:08:35 +01:00 committed by Karolin Seeger
parent 3a31406c35
commit 89f4adb298

View File

@ -2788,6 +2788,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,