summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-05-21 16:00:53 +0200
committerKarolin Seeger <kseeger@samba.org>2019-06-13 13:55:34 +0000
commit881793d52d9a35d7cce814ae5f2cdf8273a7cfee (patch)
tree76ee810979c81a4ca0a209fcde2d548f032cd50b /source3
parent436356f8d00149f0b3fe0a510cd8aea21167786f (diff)
downloadsamba-881793d52d9a35d7cce814ae5f2cdf8273a7cfee.tar.gz
vfs_fruit: change trigger points of AppleDouble conversion
This moves the trigger points where AppleDouble file conversion is run by ad_convert() from deep down the callchain in ad_read_rsrc_adouble() to high level VFS entry points. Currently ad_convert() will be triggered as part of open_file_ntcreate(..., "file:AFP_AfpResource", ...): after SMB_VFS_OPEN() has been called with O_CREAT, what created the file, we call SMB_VFS_FSTAT() on the just created filehandle. This ends up in ad_convert(), finds the resource fork empty and thus deletes the file. This commit moves calling of the conversion funtion to the high level VFS entry points where the converted metadata is needed: o for directory enumerations SMB_VFS_READDIR_ATTR() is called to fill in the repurposed fields in the directory entry metadata o obviously for SMB_VFS_CREATE_FILE() on an macOS stream Bug: https://bugzilla.samba.org/show_bug.cgi?id=13958 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 78a4639b2d06cc69788861618d2e91945e142d2b) Autobuild-User(v4-10-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-10-test): Thu Jun 13 13:55:35 UTC 2019 on sn-devel-144
Diffstat (limited to 'source3')
-rw-r--r--source3/modules/vfs_fruit.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index b74d26ca711..be85c9f5412 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1450,27 +1450,37 @@ static bool ad_convert_delete_adfile(struct adouble *ad,
* @return -1 in case an error occurred, 0 if no conversion was done, 1
* otherwise
**/
-static int ad_convert(struct adouble *ad,
+static int ad_convert(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
+ struct adouble *ad = NULL;
bool ok;
bool converted_xattr = false;
bool blank;
+ int ret;
+
+ ad = ad_get(talloc_tos(), handle, smb_fname, ADOUBLE_RSRC);
+ if (ad == NULL) {
+ return 0;
+ }
ok = ad_convert_xattr(ad, smb_fname, &converted_xattr);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
ok = ad_convert_blank_rfork(ad, &blank);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
if (converted_xattr || blank) {
ok = ad_convert_truncate(ad, smb_fname);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
}
@@ -1478,15 +1488,20 @@ static int ad_convert(struct adouble *ad,
if (!ok) {
DBG_ERR("Failed to convert [%s]\n",
smb_fname_str_dbg(smb_fname));
- return -1;
+ ret = -1;
+ goto done;
}
ok = ad_convert_delete_adfile(ad, smb_fname);
if (!ok) {
- return -1;
+ ret = -1;
+ goto done;
}
- return 0;
+ ret = 0;
+done:
+ TALLOC_FREE(ad);
+ return ret;
}
/**
@@ -1739,17 +1754,6 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
return -1;
}
- /*
- * Try to fixup AppleDouble files created by OS X with xattrs
- * appended to the ADEID_FINDERI entry.
- */
-
- ret = ad_convert(ad, smb_fname);
- if (ret != 0) {
- DBG_WARNING("Failed to convert [%s]\n", smb_fname->base_name);
- return len;
- }
-
return len;
}
@@ -2137,9 +2141,8 @@ static bool is_afpresource_stream(const struct smb_filename *smb_fname)
}
/**
- * Test whether stream is an Apple stream, not used atm
+ * Test whether stream is an Apple stream.
**/
-#if 0
static bool is_apple_stream(const struct smb_filename *smb_fname)
{
if (is_afpinfo_stream(smb_fname)) {
@@ -2150,7 +2153,6 @@ static bool is_apple_stream(const struct smb_filename *smb_fname)
}
return false;
}
-#endif
/**
* Initialize config struct from our smb.conf config parameters
@@ -6051,6 +6053,8 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
struct fruit_config_data *config = NULL;
files_struct *fsp = NULL;
struct fio *fio = NULL;
+ bool internal_open = (oplock_request & INTERNAL_OPEN_ONLY);
+ int ret;
status = check_aapl(handle, req, in_context_blobs, out_context_blobs);
if (!NT_STATUS_IS_OK(status)) {
@@ -6060,6 +6064,14 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data,
return NT_STATUS_UNSUCCESSFUL);
+ if (is_apple_stream(smb_fname) && !internal_open) {
+ ret = ad_convert(handle, smb_fname);
+ if (ret != 0) {
+ DBG_ERR("ad_convert() failed\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
status = SMB_VFS_NEXT_CREATE_FILE(
handle, req, root_dir_fid, smb_fname,
access_mask, share_access,
@@ -6142,6 +6154,7 @@ static NTSTATUS fruit_readdir_attr(struct vfs_handle_struct *handle,
struct fruit_config_data *config = NULL;
struct readdir_attr_data *attr_data;
NTSTATUS status;
+ int ret;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct fruit_config_data,
@@ -6153,6 +6166,12 @@ static NTSTATUS fruit_readdir_attr(struct vfs_handle_struct *handle,
DEBUG(10, ("fruit_readdir_attr %s\n", fname->base_name));
+ ret = ad_convert(handle, fname);
+ if (ret != 0) {
+ DBG_ERR("ad_convert() failed\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
*pattr_data = talloc_zero(mem_ctx, struct readdir_attr_data);
if (*pattr_data == NULL) {
return NT_STATUS_UNSUCCESSFUL;