diff options
author | Ralph Boehme <slow@samba.org> | 2016-12-02 08:47:36 +0100 |
---|---|---|
committer | Uri Simchoni <uri@samba.org> | 2017-03-02 00:32:21 +0100 |
commit | 8a9d0c541875d06254dc3a3039b20c8acac328ed (patch) | |
tree | 942d42e1f24086d039886812c953f9e30748dc2b | |
parent | 604bd6bf80285db2e52266708d55215f07503c73 (diff) | |
download | samba-8a9d0c541875d06254dc3a3039b20c8acac328ed.tar.gz |
vfs_fruit: fix fruit_rename() for the fruit:resource!=file case
o fix the config check, we must only run following code for the
fruit:resource=file
o properly call SMB_VFS_NEXT_RENAME() instead diretly calling rename()
o bail out if we get an invalid stat
Otherwise, no change in behaviour.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
-rw-r--r-- | source3/modules/vfs_fruit.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 85376968ca1..b034fb617b5 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -2688,19 +2688,27 @@ static int fruit_rename(struct vfs_handle_struct *handle, char *src_adouble_path = NULL; char *dst_adouble_path = NULL; struct fruit_config_data *config = NULL; + struct smb_filename *src_adp_smb_fname = NULL; + struct smb_filename *dst_adp_smb_fname = NULL; - rc = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); + SMB_VFS_HANDLE_GET_DATA(handle, config, + struct fruit_config_data, return -1); - if (!VALID_STAT(smb_fname_src->st) - || !S_ISREG(smb_fname_src->st.st_ex_mode)) { - return rc; + if (!VALID_STAT(smb_fname_src->st)) { + DBG_ERR("Need valid stat for [%s]\n", + smb_fname_str_dbg(smb_fname_src)); + return -1; } - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return -1); + rc = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); + if (rc != 0) { + return -1; + } - if (config->rsrc == FRUIT_RSRC_XATTR) { - return rc; + if ((config->rsrc != FRUIT_RSRC_ADFILE) || + (!S_ISREG(smb_fname_src->st.st_ex_mode))) + { + return 0; } rc = adouble_path(talloc_tos(), smb_fname_src->base_name, @@ -2708,24 +2716,43 @@ static int fruit_rename(struct vfs_handle_struct *handle, if (rc != 0) { goto done; } + src_adp_smb_fname = synthetic_smb_fname(talloc_tos(), + src_adouble_path, + NULL, NULL, + smb_fname_src->flags); + TALLOC_FREE(src_adouble_path); + if (src_adp_smb_fname == NULL) { + rc = -1; + goto done; + } + rc = adouble_path(talloc_tos(), smb_fname_dst->base_name, &dst_adouble_path); if (rc != 0) { goto done; } + dst_adp_smb_fname = synthetic_smb_fname(talloc_tos(), + dst_adouble_path, + NULL, NULL, + smb_fname_dst->flags); + TALLOC_FREE(dst_adouble_path); + if (dst_adp_smb_fname == NULL) { + rc = -1; + goto done; + } - DEBUG(10, ("fruit_rename: %s -> %s\n", - src_adouble_path, dst_adouble_path)); + DBG_DEBUG("%s -> %s\n", + smb_fname_str_dbg(src_adp_smb_fname), + smb_fname_str_dbg(dst_adp_smb_fname)); - rc = rename(src_adouble_path, dst_adouble_path); + rc = SMB_VFS_NEXT_RENAME(handle, src_adp_smb_fname, dst_adp_smb_fname); if (errno == ENOENT) { rc = 0; } - TALLOC_FREE(src_adouble_path); - TALLOC_FREE(dst_adouble_path); - done: + TALLOC_FREE(src_adp_smb_fname); + TALLOC_FREE(dst_adp_smb_fname); return rc; } |