1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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>
This commit is contained in:
Ralph Boehme 2016-12-02 08:47:36 +01:00 committed by Uri Simchoni
parent 604bd6bf80
commit 8a9d0c5418

View File

@ -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;
rc = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
if (!VALID_STAT(smb_fname_src->st)
|| !S_ISREG(smb_fname_src->st.st_ex_mode)) {
return rc;
}
struct smb_filename *src_adp_smb_fname = NULL;
struct smb_filename *dst_adp_smb_fname = NULL;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct fruit_config_data, return -1);
if (config->rsrc == FRUIT_RSRC_XATTR) {
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;
}
rc = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
if (rc != 0) {
return -1;
}
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;
}