From 99b63b4e720122ef9cbb8155c8cc73a1f2613650 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 10:41:29 +0200 Subject: [PATCH 01/31] vfs_fruit: pass handle to ad_fset() On the course of removing ad_handle from struct adouble, step 1. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 585d4d49770b4ddc3f7d9dcbb3e322f072767781) --- source3/modules/vfs_fruit.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index be85c9f5412..bef9bac2036 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -540,7 +540,9 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, const struct smb_filename *smb_fname, adouble_type_t type); static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname); -static int ad_fset(struct adouble *ad, files_struct *fsp); +static int ad_fset(struct vfs_handle_struct *handle, + struct adouble *ad, + files_struct *fsp); static int adouble_path(TALLOC_CTX *ctx, const struct smb_filename *smb_fname__in, struct smb_filename **ppsmb_fname_out); @@ -2065,7 +2067,9 @@ static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname) * * @return status code, 0 means success **/ -static int ad_fset(struct adouble *ad, files_struct *fsp) +static int ad_fset(struct vfs_handle_struct *handle, + struct adouble *ad, + files_struct *fsp) { int rc = -1; ssize_t len; @@ -2087,7 +2091,7 @@ static int ad_fset(struct adouble *ad, files_struct *fsp) switch (ad->ad_type) { case ADOUBLE_META: - rc = SMB_VFS_NEXT_SETXATTR(ad->ad_handle, + rc = SMB_VFS_NEXT_SETXATTR(handle, fsp->fsp_name, AFPINFO_EA_NETATALK, ad->ad_data, @@ -2095,7 +2099,7 @@ static int ad_fset(struct adouble *ad, files_struct *fsp) break; case ADOUBLE_RSRC: - len = SMB_VFS_NEXT_PWRITE(ad->ad_handle, + len = SMB_VFS_NEXT_PWRITE(handle, fsp, ad->ad_data, AD_DATASZ_DOT_UND, @@ -3588,7 +3592,7 @@ static int fruit_open_rsrc_adouble(vfs_handle_struct *handle, fsp->fh->fd = hostfd; - rc = ad_fset(ad, fsp); + rc = ad_fset(handle, ad, fsp); fsp->fh->fd = -1; if (rc != 0) { rc = -1; @@ -4676,7 +4680,7 @@ static ssize_t fruit_pwrite_meta_netatalk(vfs_handle_struct *handle, memcpy(p, &ai->afpi_FinderInfo[0], ADEDLEN_FINDERI); - ret = ad_fset(ad, fsp); + ret = ad_fset(handle, ad, fsp); if (ret != 0) { DBG_ERR("ad_pwrite [%s] failed\n", fsp_str_dbg(fsp)); TALLOC_FREE(ad); @@ -4832,7 +4836,7 @@ static ssize_t fruit_pwrite_rsrc_adouble(vfs_handle_struct *handle, if ((n + offset) > ad_getentrylen(ad, ADEID_RFORK)) { ad_setentrylen(ad, ADEID_RFORK, n + offset); - ret = ad_fset(ad, fsp); + ret = ad_fset(handle, ad, fsp); if (ret != 0) { DBG_ERR("ad_pwrite [%s] failed\n", fsp_str_dbg(fsp)); TALLOC_FREE(ad); @@ -5934,7 +5938,7 @@ static int fruit_ftruncate_rsrc_adouble(struct vfs_handle_struct *handle, ad_setentrylen(ad, ADEID_RFORK, offset); - rc = ad_fset(ad, fsp); + rc = ad_fset(handle, ad, fsp); if (rc != 0) { DBG_ERR("ad_fset [%s] failed [%s]\n", fsp_str_dbg(fsp), strerror(errno)); -- 2.21.0 From aa457fc63f493208ef85d833e5764f84578f5858 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 10:43:55 +0200 Subject: [PATCH 02/31] vfs_fruit: pass handle to ad_set() On the course of removing ad_handle from struct adouble, step 2. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit c78ba30ac4534b7037b979ac96b77b834b2eb2fe) --- source3/modules/vfs_fruit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index bef9bac2036..cb87396b9b2 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -539,7 +539,9 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle, const struct smb_filename *smb_fname, adouble_type_t type); -static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname); +static int ad_set(vfs_handle_struct *handle, + struct adouble *ad, + const struct smb_filename *smb_fname); static int ad_fset(struct vfs_handle_struct *handle, struct adouble *ad, files_struct *fsp); @@ -2030,7 +2032,9 @@ static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle, * * @return status code, 0 means success **/ -static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname) +static int ad_set(vfs_handle_struct *handle, + struct adouble *ad, + const struct smb_filename *smb_fname) { bool ok; int ret; @@ -2048,7 +2052,7 @@ static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname) return -1; } - ret = SMB_VFS_SETXATTR(ad->ad_handle->conn, + ret = SMB_VFS_SETXATTR(handle->conn, smb_fname, AFPINFO_EA_NETATALK, ad->ad_data, @@ -5874,7 +5878,7 @@ static int fruit_ntimes(vfs_handle_struct *handle, ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, convert_time_t_to_uint32_t(ft->create_time.tv_sec)); - rc = ad_set(ad, smb_fname); + rc = ad_set(handle, ad, smb_fname); exit: -- 2.21.0 From c045cf398f4b59112539000fe629d89ff7d3bbc3 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:19:53 +0200 Subject: [PATCH 03/31] vfs_fruit: pass handle to ad_read() On the course of removing ad_handle from struct adouble, step 3. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit d0abf945e683766029d28915541a4baf9f3879ab) --- source3/modules/vfs_fruit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index cb87396b9b2..7e1d27476aa 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1785,7 +1785,9 @@ static ssize_t ad_read_rsrc(struct adouble *ad, /** * Read and unpack an AppleDouble metadata xattr or resource **/ -static ssize_t ad_read(struct adouble *ad, const struct smb_filename *smb_fname) +static ssize_t ad_read(vfs_handle_struct *handle, + struct adouble *ad, + const struct smb_filename *smb_fname) { switch (ad->ad_type) { case ADOUBLE_META: @@ -1970,7 +1972,7 @@ static struct adouble *ad_get_internal(TALLOC_CTX *ctx, } - len = ad_read(ad, smb_fname); + len = ad_read(handle, ad, smb_fname); if (len == -1) { DEBUG(10, ("error reading AppleDouble for %s\n", smb_fname->base_name)); -- 2.21.0 From ac757c82574c0434e2a0afc94a30571437dd4ee2 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:22:24 +0200 Subject: [PATCH 04/31] vfs_fruit: pass handle to ad_read_meta() On the course of removing ad_handle from struct adouble, step 4. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit f8df09157f31b53dbe73eaf4349fc071bfcc1b90) --- source3/modules/vfs_fruit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 7e1d27476aa..fab361164ac 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1511,7 +1511,8 @@ static int ad_convert(struct vfs_handle_struct *handle, /** * Read and parse Netatalk AppleDouble metadata xattr **/ -static ssize_t ad_read_meta(struct adouble *ad, +static ssize_t ad_read_meta(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { int rc = 0; @@ -1520,7 +1521,7 @@ static ssize_t ad_read_meta(struct adouble *ad, DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name)); - ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname, + ealen = SMB_VFS_GETXATTR(handle->conn, smb_fname, AFPINFO_EA_NETATALK, ad->ad_data, AD_DATASZ_XATTR); if (ealen == -1) { @@ -1791,7 +1792,7 @@ static ssize_t ad_read(vfs_handle_struct *handle, { switch (ad->ad_type) { case ADOUBLE_META: - return ad_read_meta(ad, smb_fname); + return ad_read_meta(handle, ad, smb_fname); case ADOUBLE_RSRC: return ad_read_rsrc(ad, smb_fname); default: -- 2.21.0 From b802829d7648fce8e6641633f02f62e494d67eb9 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:23:17 +0200 Subject: [PATCH 05/31] vfs_fruit: indentation fix Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 47721d8d359ef78b8dd4f77f92c30c2caf2c4a80) --- source3/modules/vfs_fruit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index fab361164ac..1e9ab4f615f 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1513,7 +1513,7 @@ static int ad_convert(struct vfs_handle_struct *handle, **/ static ssize_t ad_read_meta(vfs_handle_struct *handle, struct adouble *ad, - const struct smb_filename *smb_fname) + const struct smb_filename *smb_fname) { int rc = 0; ssize_t ealen; -- 2.21.0 From 297ee52a9c6e1b5808d68cacd0b3c972bf7b7313 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:42:06 +0200 Subject: [PATCH 06/31] vfs_fruit: use proper VFS function in ad_read_meta() Continuing to ignore a possible error for now, this is in an error codepath anyway. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 30ca328c698c2e035e240359bda7c9dcbeb646df) --- source3/modules/vfs_fruit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 1e9ab4f615f..046fa2da2e2 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1578,7 +1578,9 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle, ealen = -1; if (errno == EINVAL) { become_root(); - removexattr(smb_fname->base_name, AFPINFO_EA_NETATALK); + (void)SMB_VFS_REMOVEXATTR(handle->conn, + smb_fname, + AFPINFO_EA_NETATALK); unbecome_root(); errno = ENOENT; } -- 2.21.0 From d515ff9c7cc6f5b8a6863362d78af5911afec985 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:47:26 +0200 Subject: [PATCH 07/31] vfs_fruit: pass handle to ad_read_rsrc() and all the way down On the course of removing ad_handle from struct adouble, step 5. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 661dfa4a19673fdb30d5bf36279cdf867454b947) --- source3/modules/vfs_fruit.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 046fa2da2e2..0bcf67c5834 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1682,7 +1682,8 @@ static int ad_open(vfs_handle_struct *handle, return 0; } -static ssize_t ad_read_rsrc_xattr(struct adouble *ad) +static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle, + struct adouble *ad) { int ret; SMB_STRUCT_STAT st; @@ -1690,7 +1691,7 @@ static ssize_t ad_read_rsrc_xattr(struct adouble *ad) /* FIXME: direct sys_fstat(), don't have an fsp */ ret = sys_fstat(ad->ad_fd, &st, lp_fake_directory_create_times( - SNUM(ad->ad_handle->conn))); + SNUM(handle->conn))); if (ret != 0) { return -1; } @@ -1699,7 +1700,8 @@ static ssize_t ad_read_rsrc_xattr(struct adouble *ad) return st.st_ex_size; } -static ssize_t ad_read_rsrc_adouble(struct adouble *ad, +static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { SMB_STRUCT_STAT sbuf; @@ -1710,7 +1712,7 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad, bool ok; ret = sys_fstat(ad->ad_fd, &sbuf, lp_fake_directory_create_times( - SNUM(ad->ad_handle->conn))); + SNUM(handle->conn))); if (ret != 0) { return -1; } @@ -1767,19 +1769,20 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad, /** * Read and parse resource fork, either ._ AppleDouble file or xattr **/ -static ssize_t ad_read_rsrc(struct adouble *ad, +static ssize_t ad_read_rsrc(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { struct fruit_config_data *config = NULL; ssize_t len; - SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config, + SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return -1); if (config->rsrc == FRUIT_RSRC_XATTR) { - len = ad_read_rsrc_xattr(ad); + len = ad_read_rsrc_xattr(handle, ad); } else { - len = ad_read_rsrc_adouble(ad, smb_fname); + len = ad_read_rsrc_adouble(handle, ad, smb_fname); } return len; @@ -1796,7 +1799,7 @@ static ssize_t ad_read(vfs_handle_struct *handle, case ADOUBLE_META: return ad_read_meta(handle, ad, smb_fname); case ADOUBLE_RSRC: - return ad_read_rsrc(ad, smb_fname); + return ad_read_rsrc(handle, ad, smb_fname); default: return -1; } -- 2.21.0 From cda7ebf61991a8640b696916d0769f965af325b5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:23:17 +0200 Subject: [PATCH 08/31] vfs_fruit: indentation fix Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 400b3c2f8c82b1defe1e321e0cdae486b930344f) --- source3/modules/vfs_fruit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 0bcf67c5834..c649710d754 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1702,7 +1702,7 @@ static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle, static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, struct adouble *ad, - const struct smb_filename *smb_fname) + const struct smb_filename *smb_fname) { SMB_STRUCT_STAT sbuf; char *p_ad = NULL; @@ -1771,7 +1771,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, **/ static ssize_t ad_read_rsrc(vfs_handle_struct *handle, struct adouble *ad, - const struct smb_filename *smb_fname) + const struct smb_filename *smb_fname) { struct fruit_config_data *config = NULL; ssize_t len; -- 2.21.0 From 796677632779f18cecb51209a4892de0ac6db84b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 11:54:10 +0200 Subject: [PATCH 09/31] vfs_fruit: pass handle to ad_convert_xattr() On the course of removing ad_handle from struct adouble, step 7. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit fd2f4cf828ee4c31e3b5a27a79d3a0ee12a5877a) --- source3/modules/vfs_fruit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index c649710d754..0b58cf1a1e5 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1057,7 +1057,8 @@ static bool ad_convert_move_reso(struct adouble *ad, return true; } -static bool ad_convert_xattr(struct adouble *ad, +static bool ad_convert_xattr(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname, bool *converted_xattr) { @@ -1108,7 +1109,7 @@ static bool ad_convert_xattr(struct adouble *ad, files_struct *fsp = NULL; ssize_t nwritten; - status = string_replace_allocate(ad->ad_handle->conn, + status = string_replace_allocate(handle->conn, e->adx_name, string_replace_cmaps, talloc_tos(), @@ -1145,7 +1146,7 @@ static bool ad_convert_xattr(struct adouble *ad, DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name)); status = SMB_VFS_CREATE_FILE( - ad->ad_handle->conn, /* conn */ + handle->conn, /* conn */ NULL, /* req */ 0, /* root_dir_fid */ stream_name, /* fname */ @@ -1468,7 +1469,7 @@ static int ad_convert(struct vfs_handle_struct *handle, return 0; } - ok = ad_convert_xattr(ad, smb_fname, &converted_xattr); + ok = ad_convert_xattr(handle, ad, smb_fname, &converted_xattr); if (!ok) { ret = -1; goto done; -- 2.21.0 From ebae25734342988d6fcbe0489b4264455c27c97b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 12:02:46 +0200 Subject: [PATCH 10/31] vfs_fruit: pass handle to ad_convert_blank_rfork() On the course of removing ad_handle from struct adouble, step 8. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit adc7ac38b849b4dce4a85fd6442c8d4b9da57686) --- source3/modules/vfs_fruit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 0b58cf1a1e5..80a647dc847 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1345,7 +1345,8 @@ static bool ad_convert_truncate(struct adouble *ad, return true; } -static bool ad_convert_blank_rfork(struct adouble *ad, +static bool ad_convert_blank_rfork(vfs_handle_struct *handle, + struct adouble *ad, bool *blank) { struct fruit_config_data *config = NULL; @@ -1358,7 +1359,7 @@ static bool ad_convert_blank_rfork(struct adouble *ad, *blank = false; - SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config, + SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return false); if (!config->wipe_intentionally_left_blank_rfork) { @@ -1475,7 +1476,7 @@ static int ad_convert(struct vfs_handle_struct *handle, goto done; } - ok = ad_convert_blank_rfork(ad, &blank); + ok = ad_convert_blank_rfork(handle, ad, &blank); if (!ok) { ret = -1; goto done; -- 2.21.0 From 203ef7c510f358c76aa7e582b6b7c519b4154e06 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 12:05:07 +0200 Subject: [PATCH 11/31] vfs_fruit: pass handle to ad_convert_finderinfo() On the course of removing ad_handle from struct adouble, step 9. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 50874c1548d62ab0ddaaa6dd4124279ee5029fcf) --- source3/modules/vfs_fruit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 80a647dc847..eb6137202a7 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1225,7 +1225,8 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, return ok; } -static bool ad_convert_finderinfo(struct adouble *ad, +static bool ad_convert_finderinfo(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { char *p_ad = NULL; @@ -1282,7 +1283,7 @@ static bool ad_convert_finderinfo(struct adouble *ad, DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name)); status = SMB_VFS_CREATE_FILE( - ad->ad_handle->conn, /* conn */ + handle->conn, /* conn */ NULL, /* req */ 0, /* root_dir_fid */ stream_name, /* fname */ @@ -1490,7 +1491,7 @@ static int ad_convert(struct vfs_handle_struct *handle, } } - ok = ad_convert_finderinfo(ad, smb_fname); + ok = ad_convert_finderinfo(handle, ad, smb_fname); if (!ok) { DBG_ERR("Failed to convert [%s]\n", smb_fname_str_dbg(smb_fname)); -- 2.21.0 From 6701abc1b2c68df2e134e5e7257c386fd35ea9fe Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 12:17:28 +0200 Subject: [PATCH 12/31] vfs_fruit: pass handle to ad_convert_delete_adfile() On the course of removing ad_handle from struct adouble, step 10. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 5f4d16b40e07acf8d27fee62f1a56de175663a1d) --- source3/modules/vfs_fruit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index eb6137202a7..38bfa5e2b6b 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1411,7 +1411,8 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle, return true; } -static bool ad_convert_delete_adfile(struct adouble *ad, +static bool ad_convert_delete_adfile(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { struct fruit_config_data *config = NULL; @@ -1422,7 +1423,7 @@ static bool ad_convert_delete_adfile(struct adouble *ad, return true; } - SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config, + SMB_VFS_HANDLE_GET_DATA(handle, config, struct fruit_config_data, return false); if (!config->delete_empty_adfiles) { @@ -1434,7 +1435,7 @@ static bool ad_convert_delete_adfile(struct adouble *ad, return false; } - rc = SMB_VFS_NEXT_UNLINK(ad->ad_handle, ad_name); + rc = SMB_VFS_NEXT_UNLINK(handle, ad_name); if (rc != 0) { DBG_ERR("Unlinking [%s] failed: %s\n", smb_fname_str_dbg(ad_name), strerror(errno)); @@ -1499,7 +1500,7 @@ static int ad_convert(struct vfs_handle_struct *handle, goto done; } - ok = ad_convert_delete_adfile(ad, smb_fname); + ok = ad_convert_delete_adfile(handle, ad, smb_fname); if (!ok) { ret = -1; goto done; -- 2.21.0 From 6f953506ef2704ffc3c99cc492dfeb739128e5a8 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 12:19:06 +0200 Subject: [PATCH 13/31] vfs_fruit: finally, remove ad_handle from struct adouble Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit e266daaed149561b746dbb8d5e9523862f0057b5) --- source3/modules/vfs_fruit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 38bfa5e2b6b..e79b548a511 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -411,7 +411,6 @@ struct ad_entry { }; struct adouble { - vfs_handle_struct *ad_handle; int ad_fd; bool ad_opened; adouble_type_t ad_type; @@ -1868,7 +1867,6 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle, } } - ad->ad_handle = handle; ad->ad_type = type; ad->ad_magic = AD_MAGIC; ad->ad_version = AD_VERSION; -- 2.21.0 From 42f996a6983d0a2895bf49778446e6238b5bac10 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 21 May 2019 11:39:18 +0200 Subject: [PATCH 14/31] vfs_fruit: add and use is_adouble_file() This adds a helper function that checks whether the last component of a path is an AppleDouble sidecar file with "._" name prefix. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit ad70c947c759aa0965ee57f973fb8dc1909e0e39) --- source3/modules/vfs_fruit.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index e79b548a511..0dd24293c9b 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -2172,6 +2172,27 @@ static bool is_apple_stream(const struct smb_filename *smb_fname) return false; } +static bool is_adouble_file(const char *path) +{ + const char *p = NULL; + int match; + + p = strrchr(path, '/'); + if (p == NULL) { + p = path; + } else { + p++; + } + + match = strncmp(p, + ADOUBLE_NAME_PREFIX, + strlen(ADOUBLE_NAME_PREFIX)); + if (match != 0) { + return false; + } + return true; +} + /** * Initialize config struct from our smb.conf config parameters **/ @@ -4204,16 +4225,12 @@ static int fruit_rmdir(struct vfs_handle_struct *handle, } while ((de = SMB_VFS_READDIR(handle->conn, dh, NULL)) != NULL) { - int match; struct adouble *ad = NULL; char *p = NULL; struct smb_filename *ad_smb_fname = NULL; int ret; - match = strncmp(de->d_name, - ADOUBLE_NAME_PREFIX, - strlen(ADOUBLE_NAME_PREFIX)); - if (match != 0) { + if (!is_adouble_file(de->d_name)) { continue; } -- 2.21.0 From 12c65cc8aa37440c7e549da876564ff5cd47220b Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 21 May 2019 11:40:33 +0200 Subject: [PATCH 15/31] vfs_fruit: add a missing else Luckily the missing else has the same control flow due to the previous if and else blocks calling return. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 44d8568001c87d28962dfc4e3fde6d0f7f409997) --- source3/modules/vfs_fruit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 0dd24293c9b..c7cb4cdba7d 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -4079,7 +4079,7 @@ static int fruit_unlink(vfs_handle_struct *handle, return fruit_unlink_meta(handle, smb_fname); } else if (is_afpresource_stream(smb_fname)) { return fruit_unlink_rsrc(handle, smb_fname, false); - } if (is_ntfs_stream_smb_fname(smb_fname)) { + } else if (is_ntfs_stream_smb_fname(smb_fname)) { return SMB_VFS_NEXT_UNLINK(handle, smb_fname); } -- 2.21.0 From 359fae9e2e0ef599d6778c65fcb3355d0bf5a8a0 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 21 May 2019 11:42:47 +0200 Subject: [PATCH 16/31] vfs_fruit: ignore AppleDouble files in fruit_unlink() Otherwise, if SMB_VFS_UNLINK() is called for an AppleDouble path "._file", we try to delete "._._file" which doesn't make sense. AppleDouble files don't have AppleDouble themselves. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 797dc649456f39add4af8b54b60db0268ad4e90e) --- source3/modules/vfs_fruit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index c7cb4cdba7d..e7e14673e10 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -4081,6 +4081,8 @@ static int fruit_unlink(vfs_handle_struct *handle, return fruit_unlink_rsrc(handle, smb_fname, false); } else if (is_ntfs_stream_smb_fname(smb_fname)) { return SMB_VFS_NEXT_UNLINK(handle, smb_fname); + } else if (is_adouble_file(smb_fname->base_name)) { + return SMB_VFS_NEXT_UNLINK(handle, smb_fname); } /* -- 2.21.0 From 39bccb6c88eb19b6abcf3d49f72ae73bec1d6af6 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 22 May 2019 17:02:20 +0200 Subject: [PATCH 17/31] vfs_fruit: use correct case FRUIT_RSRC_STREAM in readdir_attr_rfork_size() This is a genuine bug, but luckily this would only impact configs which nobody uses: fruit:metadata = netatalk fruit:resource = stream With the above configuration the switch in readdir_attr_rfork_size() would hit the default case and so always report resource forks as 0 bytes in size. All deployment that I've seen that use fruit:resource=stream also use fruit:metadata=stream, so the switch takes FRUIT_META_STREAM case which runs the correct code readdir_attr_rfork_size_stream(). Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 83179a74119de84d20f796c241aae6bccb83a68b) --- source3/modules/vfs_fruit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index e7e14673e10..96a026acbf8 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3223,7 +3223,7 @@ static uint64_t readdir_attr_rfork_size(struct vfs_handle_struct *handle, smb_fname); break; - case FRUIT_META_STREAM: + case FRUIT_RSRC_STREAM: rfork_size = readdir_attr_rfork_size_stream(handle, smb_fname); break; -- 2.21.0 From 4f611e9da46c49a5be3a0b7c491b23c9c5084526 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 22 May 2019 18:08:14 +0200 Subject: [PATCH 18/31] vfs_fruit: use stream code for resource fork size calculation in readdir_attr_rfork_size() This works as well, using an fstat() on the filehandle to get the size. This is tested by the torture test "vfs.fruit.SMB2/CREATE context AAPL". Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit a23bcc1916a49bf3e0edece190e5434e39862d2c) --- source3/modules/vfs_fruit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 96a026acbf8..82c20dbea13 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3218,11 +3218,11 @@ static uint64_t readdir_attr_rfork_size(struct vfs_handle_struct *handle, switch (config->rsrc) { case FRUIT_RSRC_ADFILE: - case FRUIT_RSRC_XATTR: rfork_size = readdir_attr_rfork_size_adouble(handle, smb_fname); break; + case FRUIT_RSRC_XATTR: case FRUIT_RSRC_STREAM: rfork_size = readdir_attr_rfork_size_stream(handle, smb_fname); -- 2.21.0 From 7e2a1d4771b73f2956005f70b588a6c37cc953a8 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 17 May 2019 14:31:15 +0200 Subject: [PATCH 19/31] vfs_fruit: remove now unused AppleDouble code for resource fork in xattr This was only needed to get the resourcefork size via the ad_* AppleDouble function. This is now done with a fstat on the low level xattr fd (remember, this is Solaris only code...), so we can remove the xattr special casing from the AppleDouble functions. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit cb9dffa1c66294b6eed85e7576aa99c642d0b541) --- source3/modules/vfs_fruit.c | 70 ++----------------------------------- 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 82c20dbea13..74b10a32449 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1591,20 +1591,6 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle, return ealen; } -static int ad_open_rsrc_xattr(const struct smb_filename *smb_fname, - int flags, - mode_t mode) -{ -#ifdef HAVE_ATTROPEN - /* FIXME: direct Solaris xattr syscall */ - return attropen(smb_fname->base_name, - AFPRESOURCE_EA_NETATALK, flags, mode); -#else - errno = ENOSYS; - return -1; -#endif -} - static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname, int flags, mode_t mode) @@ -1629,19 +1615,7 @@ static int ad_open_rsrc(vfs_handle_struct *handle, int flags, mode_t mode) { - struct fruit_config_data *config = NULL; - int fd; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return -1); - - if (config->rsrc == FRUIT_RSRC_XATTR) { - fd = ad_open_rsrc_xattr(smb_fname, flags, mode); - } else { - fd = ad_open_rsrc_adouble(smb_fname, flags, mode); - } - - return fd; + return ad_open_rsrc_adouble(smb_fname, flags, mode); } /* @@ -1685,24 +1659,6 @@ static int ad_open(vfs_handle_struct *handle, return 0; } -static ssize_t ad_read_rsrc_xattr(vfs_handle_struct *handle, - struct adouble *ad) -{ - int ret; - SMB_STRUCT_STAT st; - - /* FIXME: direct sys_fstat(), don't have an fsp */ - ret = sys_fstat(ad->ad_fd, &st, - lp_fake_directory_create_times( - SNUM(handle->conn))); - if (ret != 0) { - return -1; - } - - ad_setentrylen(ad, ADEID_RFORK, st.st_ex_size); - return st.st_ex_size; -} - static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, struct adouble *ad, const struct smb_filename *smb_fname) @@ -1776,19 +1732,7 @@ static ssize_t ad_read_rsrc(vfs_handle_struct *handle, struct adouble *ad, const struct smb_filename *smb_fname) { - struct fruit_config_data *config = NULL; - ssize_t len; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return -1); - - if (config->rsrc == FRUIT_RSRC_XATTR) { - len = ad_read_rsrc_xattr(handle, ad); - } else { - len = ad_read_rsrc_adouble(handle, ad, smb_fname); - } - - return len; + return ad_read_rsrc_adouble(handle, ad, smb_fname); } /** @@ -1896,22 +1840,14 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle, int rc = 0; const struct ad_entry_order *eid; struct adouble *ad = NULL; - struct fruit_config_data *config; time_t t = time(NULL); - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return NULL); - switch (type) { case ADOUBLE_META: eid = entry_order_meta_xattr; break; case ADOUBLE_RSRC: - if (config->rsrc == FRUIT_RSRC_ADFILE) { - eid = entry_order_dot_und; - } else { - eid = entry_order_rsrc_xattr; - } + eid = entry_order_dot_und; break; default: return NULL; -- 2.21.0 From eb48ba0846b109a44b704241a6a57df3c9ad3216 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 22 May 2019 21:15:22 +0200 Subject: [PATCH 20/31] vfs_fruit: remove xattr code from the AppleDouble subsystem The subsystem consumers have been reworked in the previous commits, so this is not used anymore. ad_init() doesn't need a handle argument anymore due to this, remove it as well. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit e3cb1cb24f2a31d7fd03f3bdf417f4704fb4ac7c) --- source3/modules/vfs_fruit.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 74b10a32449..1e560bf07b5 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -449,18 +449,6 @@ struct ad_entry_order entry_order_dot_und[ADEID_NUM_DOT_UND + 1] = { {0, 0, 0} }; -/* - * Fake AppleDouble entry oder for resource fork xattr. The xattr - * isn't an AppleDouble file, it simply contains the resource data, - * but in order to be able to use some API calls like ad_getentryoff() - * we build a fake/helper struct adouble with this entry order struct. - */ -static const -struct ad_entry_order entry_order_rsrc_xattr[ADEID_NUM_RSRC_XATTR + 1] = { - {ADEID_RFORK, 0, 0}, - {0, 0, 0} -}; - /* Conversion from enumerated id to on-disk AppleDouble id */ #define AD_EID_DISK(a) (set_eid[a]) static const uint32_t set_eid[] = { @@ -532,7 +520,7 @@ struct fio { /* * Forward declarations */ -static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle, +static struct adouble *ad_init(TALLOC_CTX *ctx, adouble_type_t type); static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle, @@ -1773,25 +1761,19 @@ static int adouble_destructor(struct adouble *ad) * * @return adouble handle **/ -static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle, +static struct adouble *ad_alloc(TALLOC_CTX *ctx, adouble_type_t type) { int rc = 0; size_t adsize = 0; struct adouble *ad; - struct fruit_config_data *config; - - SMB_VFS_HANDLE_GET_DATA(handle, config, - struct fruit_config_data, return NULL); switch (type) { case ADOUBLE_META: adsize = AD_DATASZ_XATTR; break; case ADOUBLE_RSRC: - if (config->rsrc == FRUIT_RSRC_ADFILE) { - adsize = AD_DATASZ_DOT_UND; - } + adsize = AD_DATASZ_DOT_UND; break; default: return NULL; @@ -1829,12 +1811,11 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx, vfs_handle_struct *handle, * Allocate and initialize a new struct adouble * * @param[in] ctx talloc context - * @param[in] handle vfs handle * @param[in] type type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC * * @return adouble handle, initialized **/ -static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle, +static struct adouble *ad_init(TALLOC_CTX *ctx, adouble_type_t type) { int rc = 0; @@ -1853,7 +1834,7 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle, return NULL; } - ad = ad_alloc(ctx, handle, type); + ad = ad_alloc(ctx, type); if (ad == NULL) { return NULL; } @@ -1895,7 +1876,7 @@ static struct adouble *ad_get_internal(TALLOC_CTX *ctx, type == ADOUBLE_META ? "meta" : "rsrc", smb_fname->base_name)); - ad = ad_alloc(ctx, handle, type); + ad = ad_alloc(ctx, type); if (ad == NULL) { rc = -1; goto exit; @@ -3555,7 +3536,7 @@ static int fruit_open_rsrc_adouble(vfs_handle_struct *handle, } if (flags & (O_CREAT | O_TRUNC)) { - ad = ad_init(fsp, handle, ADOUBLE_RSRC); + ad = ad_init(fsp, ADOUBLE_RSRC); if (ad == NULL) { rc = -1; goto exit; @@ -4635,7 +4616,7 @@ static ssize_t fruit_pwrite_meta_netatalk(vfs_handle_struct *handle, ad = ad_fget(talloc_tos(), handle, fsp, ADOUBLE_META); if (ad == NULL) { - ad = ad_init(talloc_tos(), handle, ADOUBLE_META); + ad = ad_init(talloc_tos(), ADOUBLE_META); if (ad == NULL) { return -1; } -- 2.21.0 From 8598f79e210655549996a52bfc15888906208c4f Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 23 May 2019 08:14:18 +0200 Subject: [PATCH 21/31] vfs_fruit: pass VFS handle to ad_convert_move_reso() Not used for now, that comes next. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 3919ea048fe3b763657e14cdfb5920184a900d27) --- source3/modules/vfs_fruit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 1e560bf07b5..01f6fa821c0 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -992,7 +992,8 @@ static bool ad_unpack(struct adouble *ad, const size_t nentries, return true; } -static bool ad_convert_move_reso(struct adouble *ad, +static bool ad_convert_move_reso(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { char *map = MAP_FAILED; @@ -1194,7 +1195,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, goto fail; } - ok = ad_convert_move_reso(ad, smb_fname); + ok = ad_convert_move_reso(handle, ad, smb_fname); if (!ok) { goto fail; } -- 2.21.0 From 3c32a8da96b8d3233c47593be4b5de6de44d08f8 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 23 May 2019 08:27:37 +0200 Subject: [PATCH 22/31] vfs_fruit: remove a layer of indirection Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 97d485ff2cda85edeba163ea01b6abfa705db20f) --- source3/modules/vfs_fruit.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 01f6fa821c0..b927660db9c 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1580,9 +1580,10 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle, return ealen; } -static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname, - int flags, - mode_t mode) +static int ad_open_rsrc(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + int flags, + mode_t mode) { int ret; int fd; @@ -1599,14 +1600,6 @@ static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname, return fd; } -static int ad_open_rsrc(vfs_handle_struct *handle, - const struct smb_filename *smb_fname, - int flags, - mode_t mode) -{ - return ad_open_rsrc_adouble(smb_fname, flags, mode); -} - /* * Here's the deal: for ADOUBLE_META we can do without an fd as we can issue * path based xattr calls. For ADOUBLE_RSRC however we need a full-fledged fd -- 2.21.0 From 79fc20532535da8ceaa5d0348da46a422f4e9369 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 23 May 2019 16:22:39 +0200 Subject: [PATCH 23/31] vfs_fruit: only do cross protocol locking on non-internal opens Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit f5f7d1e9bf7e39933ccf7c874e682f9df80a6fec) --- source3/modules/vfs_fruit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index b927660db9c..fc9e0c90606 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -6071,7 +6071,9 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle, return status; } - if (config->locking == FRUIT_LOCKING_NETATALK) { + if ((config->locking == FRUIT_LOCKING_NETATALK) && + (fsp->op != NULL)) + { status = fruit_check_access( handle, *result, access_mask, -- 2.21.0 From f381b0af9e9d3ca53ba742444cf4e58bb6cd8172 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 23 May 2019 16:42:52 +0200 Subject: [PATCH 24/31] vfs_fruit: convert ad_open_rsrc() to open a proper fsp with SMB_VFS_CREATE_FILE() A first step in converting all raw syscalls to use proper VFS functions. All existing users of the raw system filedescriptor continue to use the fd from fsp->fh for now. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 29418c726be74feb1d8c3ac9f7b8c983901a2aab) --- source3/modules/vfs_fruit.c | 103 +++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index fc9e0c90606..d6d9fce7956 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -411,7 +411,7 @@ struct ad_entry { }; struct adouble { - int ad_fd; + files_struct *ad_fsp; bool ad_opened; adouble_type_t ad_type; uint32_t ad_magic; @@ -1011,7 +1011,7 @@ static bool ad_convert_move_reso(vfs_handle_struct *handle, /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fd, 0); + ad->ad_fsp->fh->fd, 0); if (map == MAP_FAILED) { DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); return false; @@ -1036,7 +1036,7 @@ static bool ad_convert_move_reso(vfs_handle_struct *handle, return false; } - len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); + len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); if (len != AD_DATASZ_DOT_UND) { DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); return false; @@ -1083,7 +1083,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fd, 0); + ad->ad_fsp->fh->fd, 0); if (map == MAP_FAILED) { DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); return false; @@ -1188,7 +1188,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, goto fail; } - len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); + len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); if (len != AD_DATASZ_DOT_UND) { DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); ok = false; @@ -1325,7 +1325,7 @@ static bool ad_convert_truncate(struct adouble *ad, * FIXME: direct ftruncate(), but we don't have a fsp for the * VFS call */ - rc = ftruncate(ad->ad_fd, ADEDOFF_RFORK_DOT_UND + + rc = ftruncate(ad->ad_fsp->fh->fd, ADEDOFF_RFORK_DOT_UND + ad_getentrylen(ad, ADEID_RFORK)); if (rc != 0) { return false; @@ -1364,7 +1364,7 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle, /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fd, 0); + ad->ad_fsp->fh->fd, 0); if (map == MAP_FAILED) { DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); return false; @@ -1390,7 +1390,7 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle, return false; } - len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); + len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); if (len != AD_DATASZ_DOT_UND) { return false; } @@ -1583,21 +1583,64 @@ static ssize_t ad_read_meta(vfs_handle_struct *handle, static int ad_open_rsrc(vfs_handle_struct *handle, const struct smb_filename *smb_fname, int flags, - mode_t mode) + mode_t mode, + files_struct **_fsp) { int ret; - int fd; struct smb_filename *adp_smb_fname = NULL; + files_struct *fsp = NULL; + uint32_t access_mask; + uint32_t share_access; + uint32_t create_disposition; + NTSTATUS status; ret = adouble_path(talloc_tos(), smb_fname, &adp_smb_fname); if (ret != 0) { return -1; } - fd = open(adp_smb_fname->base_name, flags, mode); + ret = SMB_VFS_STAT(handle->conn, adp_smb_fname); + if (ret != 0) { + TALLOC_FREE(adp_smb_fname); + return -1; + } + + access_mask = FILE_GENERIC_READ; + share_access = FILE_SHARE_READ | FILE_SHARE_WRITE; + create_disposition = FILE_OPEN; + + if (flags & O_RDWR) { + access_mask |= FILE_GENERIC_WRITE; + share_access &= ~FILE_SHARE_WRITE; + } + + status = SMB_VFS_CREATE_FILE( + handle->conn, /* conn */ + NULL, /* req */ + 0, /* root_dir_fid */ + adp_smb_fname, + access_mask, + share_access, + create_disposition, + 0, /* create_options */ + 0, /* file_attributes */ + INTERNAL_OPEN_ONLY, /* oplock_request */ + NULL, /* lease */ + 0, /* allocation_size */ + 0, /* private_flags */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, + NULL, /* psbuf */ + NULL, NULL); /* create context */ TALLOC_FREE(adp_smb_fname); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("SMB_VFS_CREATE_FILE failed\n"); + return -1; + } - return fd; + *_fsp = fsp; + return 0; } /* @@ -1612,7 +1655,7 @@ static int ad_open(vfs_handle_struct *handle, int flags, mode_t mode) { - int fd; + int ret; DBG_DEBUG("Path [%s] type [%s]\n", smb_fname->base_name, ad->ad_type == ADOUBLE_META ? "meta" : "rsrc"); @@ -1621,22 +1664,21 @@ static int ad_open(vfs_handle_struct *handle, return 0; } - if ((fsp != NULL) && (fsp->fh != NULL) && (fsp->fh->fd != -1)) { - ad->ad_fd = fsp->fh->fd; + if (fsp != NULL) { + ad->ad_fsp = fsp; ad->ad_opened = false; return 0; } - fd = ad_open_rsrc(handle, smb_fname, flags, mode); - if (fd == -1) { + ret = ad_open_rsrc(handle, smb_fname, flags, mode, &ad->ad_fsp); + if (ret != 0) { return -1; } ad->ad_opened = true; - ad->ad_fd = fd; - DBG_DEBUG("Path [%s] type [%s] fd [%d]\n", + DBG_DEBUG("Path [%s] type [%s]\n", smb_fname->base_name, - ad->ad_type == ADOUBLE_META ? "meta" : "rsrc", fd); + ad->ad_type == ADOUBLE_META ? "meta" : "rsrc"); return 0; } @@ -1652,7 +1694,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, int ret; bool ok; - ret = sys_fstat(ad->ad_fd, &sbuf, lp_fake_directory_create_times( + ret = sys_fstat(ad->ad_fsp->fh->fd, &sbuf, lp_fake_directory_create_times( SNUM(handle->conn))); if (ret != 0) { return -1; @@ -1678,7 +1720,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, ad->ad_data = p_ad; } - len = sys_pread(ad->ad_fd, ad->ad_data, + len = sys_pread(ad->ad_fsp->fh->fd, ad->ad_data, talloc_array_length(ad->ad_data), 0); if (len != talloc_array_length(ad->ad_data)) { DBG_NOTICE("%s %s: bad size: %zd\n", @@ -1736,10 +1778,20 @@ static ssize_t ad_read(vfs_handle_struct *handle, static int adouble_destructor(struct adouble *ad) { - if ((ad->ad_fd != -1) && ad->ad_opened) { - close(ad->ad_fd); - ad->ad_fd = -1; + NTSTATUS status; + + if (!ad->ad_opened) { + return 0; } + + SMB_ASSERT(ad->ad_fsp != NULL); + + status = close_file(NULL, ad->ad_fsp, NORMAL_CLOSE); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("Closing [%s] failed: %s\n", + fsp_str_dbg(ad->ad_fsp), nt_errstr(status)); + } + return 0; } @@ -1790,7 +1842,6 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx, ad->ad_type = type; ad->ad_magic = AD_MAGIC; ad->ad_version = AD_VERSION; - ad->ad_fd = -1; talloc_set_destructor(ad, adouble_destructor); -- 2.21.0 From 6a1beb430229e4d2dbace960b6a0a6a82af30f54 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 23 May 2019 22:44:21 +0200 Subject: [PATCH 25/31] vfs_fruit: remove use of mmap() from ad_convert_move_reso() We now have an fsp that we can use, so we can get rid of mmap() and sys_pread()/sys_pwrite(). Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 0041855af0b05d6c47558880d6eebd1970179272) --- source3/modules/vfs_fruit.c | 56 ++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index d6d9fce7956..426da55816b 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -996,49 +996,59 @@ static bool ad_convert_move_reso(vfs_handle_struct *handle, struct adouble *ad, const struct smb_filename *smb_fname) { - char *map = MAP_FAILED; - size_t maplen; - ssize_t len; - int rc; + char *buf = NULL; + size_t rforklen; + size_t rforkoff; + ssize_t n; + int ret; bool ok; - if (ad_getentrylen(ad, ADEID_RFORK) == 0) { + rforklen = ad_getentrylen(ad, ADEID_RFORK); + if (rforklen == 0) { return true; } - maplen = ad_getentryoff(ad, ADEID_RFORK) + - ad_getentrylen(ad, ADEID_RFORK); - - /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ - map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fsp->fh->fd, 0); - if (map == MAP_FAILED) { - DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); + buf = talloc_size(ad, rforklen); + if (buf == NULL) { + /* + * This allocates a buffer for reading the resource fork data in + * one big swoop. Resource forks won't be larger then, say, 64 + * MB, I swear, so just doing the allocation with the talloc + * limit as safeguard seems safe. + */ + DBG_ERR("Failed to allocate %zu bytes for rfork\n", + rforklen); return false; } + rforkoff = ad_getentryoff(ad, ADEID_RFORK); - memmove(map + ADEDOFF_RFORK_DOT_UND, - map + ad_getentryoff(ad, ADEID_RFORK), - ad_getentrylen(ad, ADEID_RFORK)); + n = SMB_VFS_PREAD(ad->ad_fsp, buf, rforklen, rforkoff); + if (n != rforklen) { + DBG_ERR("Reading %zu bytes from rfork [%s] failed: %s\n", + rforklen, fsp_str_dbg(ad->ad_fsp), strerror(errno)); + return false; + } - rc = munmap(map, maplen); - if (rc != 0) { - DBG_ERR("munmap failed: %s\n", strerror(errno)); + rforkoff = ADEDOFF_RFORK_DOT_UND; + + n = SMB_VFS_PWRITE(ad->ad_fsp, buf, rforklen, rforkoff); + if (n != rforklen) { + DBG_ERR("Writing %zu bytes to rfork [%s] failed: %s\n", + rforklen, fsp_str_dbg(ad->ad_fsp), strerror(errno)); return false; } ad_setentryoff(ad, ADEID_RFORK, ADEDOFF_RFORK_DOT_UND); - ok = ad_pack(ad); if (!ok) { DBG_WARNING("ad_pack [%s] failed\n", smb_fname->base_name); return false; } - len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); - if (len != AD_DATASZ_DOT_UND) { - DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); + ret = ad_fset(handle, ad, ad->ad_fsp); + if (ret != 0) { + DBG_ERR("ad_fset on [%s] failed\n", fsp_str_dbg(ad->ad_fsp)); return false; } -- 2.21.0 From 2a680e4998febc492d33c275268d0a1b06d40386 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 11:54:51 +0200 Subject: [PATCH 26/31] vfs_fruit: use fsp and remove mmap in ad_convert_xattr() No need to mmap() anyway, the xattr data is already available in ad->ad_data. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 4ff7ea0e0312c737aefd350f7b8fbed4c8602325) --- source3/modules/vfs_fruit.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 426da55816b..630d53afbe7 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1061,10 +1061,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, bool *converted_xattr) { static struct char_mappings **string_replace_cmaps = NULL; - char *map = MAP_FAILED; - size_t maplen; uint16_t i; - ssize_t len; int saved_errno = 0; NTSTATUS status; int rc; @@ -1088,17 +1085,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, TALLOC_FREE(mappings); } - maplen = ad_getentryoff(ad, ADEID_RFORK) + - ad_getentrylen(ad, ADEID_RFORK); - - /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ - map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fsp->fh->fd, 0); - if (map == MAP_FAILED) { - DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); - return false; - } - for (i = 0; i < ad->adx_header.adx_num_attrs; i++) { struct ad_xattr_entry *e = &ad->adx_entries[i]; char *mapped_name = NULL; @@ -1170,7 +1156,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, } nwritten = SMB_VFS_PWRITE(fsp, - map + e->adx_offset, + ad->ad_data + e->adx_offset, e->adx_length, 0); if (nwritten == -1) { @@ -1198,9 +1184,10 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, goto fail; } - len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); - if (len != AD_DATASZ_DOT_UND) { - DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len); + rc = ad_fset(handle, ad, ad->ad_fsp); + if (rc != 0) { + DBG_ERR("ad_fset on [%s] failed: %s\n", + fsp_str_dbg(ad->ad_fsp), strerror(errno)); ok = false; goto fail; } @@ -1214,12 +1201,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, ok = true; fail: - rc = munmap(map, maplen); - if (rc != 0) { - DBG_ERR("munmap failed: %s\n", strerror(errno)); - return false; - } - return ok; } -- 2.21.0 From 945f0734c2f37c6327361dc638133f57e81910e5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 12:05:51 +0200 Subject: [PATCH 27/31] vfs_fruit: add VFS handle to ad_convert_truncate() Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 4e44b1da9357120f0ad74e24c650bc6386085c47) --- source3/modules/vfs_fruit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 630d53afbe7..46355d2146e 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1307,7 +1307,8 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle, return true; } -static bool ad_convert_truncate(struct adouble *ad, +static bool ad_convert_truncate(vfs_handle_struct *handle, + struct adouble *ad, const struct smb_filename *smb_fname) { int rc; @@ -1464,7 +1465,7 @@ static int ad_convert(struct vfs_handle_struct *handle, } if (converted_xattr || blank) { - ok = ad_convert_truncate(ad, smb_fname); + ok = ad_convert_truncate(handle, ad, smb_fname); if (!ok) { ret = -1; goto done; -- 2.21.0 From 1fca33d6436923925ceae855388f81bdd6ba9a53 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 12:07:55 +0200 Subject: [PATCH 28/31] vfs_fruit: use VFS function in ad_convert_truncate() Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 3739ad90cf2bbaa2094a34197c894363d2e24a5a) --- source3/modules/vfs_fruit.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 46355d2146e..a11f390326d 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1312,13 +1312,11 @@ static bool ad_convert_truncate(vfs_handle_struct *handle, const struct smb_filename *smb_fname) { int rc; + off_t newlen; - /* - * FIXME: direct ftruncate(), but we don't have a fsp for the - * VFS call - */ - rc = ftruncate(ad->ad_fsp->fh->fd, ADEDOFF_RFORK_DOT_UND + - ad_getentrylen(ad, ADEID_RFORK)); + newlen = ADEDOFF_RFORK_DOT_UND + ad_getentrylen(ad, ADEID_RFORK); + + rc = SMB_VFS_FTRUNCATE(ad->ad_fsp, newlen); if (rc != 0) { return false; } -- 2.21.0 From 7dd37035e053775d7b392ebaaf0130f9af7acc3a Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 12:51:15 +0200 Subject: [PATCH 29/31] vfs_fruit: use fsp and remove syscalls from ad_convert_blank_rfork() Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 70c4a8f0ac307009c26e857523192c95b42a92f5) --- source3/modules/vfs_fruit.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index a11f390326d..2d34b70090e 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1329,10 +1329,10 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle, bool *blank) { struct fruit_config_data *config = NULL; - uint8_t *map = MAP_FAILED; - size_t maplen; + size_t rforklen = sizeof(empty_resourcefork); + char buf[rforklen]; + ssize_t nread; int cmp; - ssize_t len; int rc; bool ok; @@ -1345,43 +1345,31 @@ static bool ad_convert_blank_rfork(vfs_handle_struct *handle, return true; } - if (ad_getentrylen(ad, ADEID_RFORK) != sizeof(empty_resourcefork)) { + if (ad_getentrylen(ad, ADEID_RFORK) != rforklen) { return true; } - maplen = ad_getentryoff(ad, ADEID_RFORK) + - ad_getentrylen(ad, ADEID_RFORK); - - /* FIXME: direct use of mmap(), vfs_aio_fork does it too */ - map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED, - ad->ad_fsp->fh->fd, 0); - if (map == MAP_FAILED) { - DBG_ERR("mmap AppleDouble: %s\n", strerror(errno)); - return false; - } - - cmp = memcmp(map + ADEDOFF_RFORK_DOT_UND, - empty_resourcefork, - sizeof(empty_resourcefork)); - rc = munmap(map, maplen); - if (rc != 0) { - DBG_ERR("munmap failed: %s\n", strerror(errno)); + nread = SMB_VFS_PREAD(ad->ad_fsp, buf, rforklen, ADEDOFF_RFORK_DOT_UND); + if (nread != rforklen) { + DBG_ERR("Reading %zu bytes from rfork [%s] failed: %s\n", + rforklen, fsp_str_dbg(ad->ad_fsp), strerror(errno)); return false; } + cmp = memcmp(buf, empty_resourcefork, rforklen); if (cmp != 0) { return true; } ad_setentrylen(ad, ADEID_RFORK, 0); - ok = ad_pack(ad); if (!ok) { return false; } - len = sys_pwrite(ad->ad_fsp->fh->fd, ad->ad_data, AD_DATASZ_DOT_UND, 0); - if (len != AD_DATASZ_DOT_UND) { + rc = ad_fset(handle, ad, ad->ad_fsp); + if (rc != 0) { + DBG_ERR("ad_fset on [%s] failed\n", fsp_str_dbg(ad->ad_fsp)); return false; } -- 2.21.0 From 602ba28322bd343a47c811f2d9e441a7886a2664 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 14:51:17 +0200 Subject: [PATCH 30/31] vfs_fruit: use VFS functions in ad_read_rsrc_adouble() Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 9fe84a6345bf5d9fdb1df87a853db3380e6fb0f7) --- source3/modules/vfs_fruit.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 2d34b70090e..38c201b38e0 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1665,16 +1665,16 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, struct adouble *ad, const struct smb_filename *smb_fname) { - SMB_STRUCT_STAT sbuf; char *p_ad = NULL; size_t size; ssize_t len; int ret; bool ok; - ret = sys_fstat(ad->ad_fsp->fh->fd, &sbuf, lp_fake_directory_create_times( - SNUM(handle->conn))); + ret = SMB_VFS_NEXT_FSTAT(handle, ad->ad_fsp, &ad->ad_fsp->fsp_name->st); if (ret != 0) { + DBG_ERR("fstat [%s] failed: %s\n", + fsp_str_dbg(ad->ad_fsp), strerror(errno)); return -1; } @@ -1686,7 +1686,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, * * Read as much as we can up to AD_XATTR_MAX_HDR_SIZE. */ - size = sbuf.st_ex_size; + size = ad->ad_fsp->fsp_name->st.st_ex_size; if (size > talloc_array_length(ad->ad_data)) { if (size > AD_XATTR_MAX_HDR_SIZE) { size = AD_XATTR_MAX_HDR_SIZE; @@ -1698,8 +1698,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, ad->ad_data = p_ad; } - len = sys_pread(ad->ad_fsp->fh->fd, ad->ad_data, - talloc_array_length(ad->ad_data), 0); + len = SMB_VFS_NEXT_PREAD(handle, ad->ad_fsp, ad->ad_data, talloc_array_length(ad->ad_data), 0); if (len != talloc_array_length(ad->ad_data)) { DBG_NOTICE("%s %s: bad size: %zd\n", smb_fname->base_name, strerror(errno), len); @@ -1707,7 +1706,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle, } /* Now parse entries */ - ok = ad_unpack(ad, ADEID_NUM_DOT_UND, sbuf.st_ex_size); + ok = ad_unpack(ad, ADEID_NUM_DOT_UND, size); if (!ok) { DBG_ERR("invalid AppleDouble resource %s\n", smb_fname->base_name); -- 2.21.0 From 3f5303416f9189c5e81444e65aac98f2444183b1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 24 May 2019 15:15:59 +0200 Subject: [PATCH 31/31] vfs_fruit: remove a now unnecessary include Bug: https://bugzilla.samba.org/show_bug.cgi?id=13968 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu May 30 22:12:50 UTC 2019 on sn-devel-184 (cherry picked from commit 9a2c9834cb1b77547b8b932c35870301afb9fc25) --- source3/modules/vfs_fruit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 38c201b38e0..20121818129 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -29,7 +29,6 @@ #include "messages.h" #include "libcli/security/security.h" #include "../libcli/smb/smb2_create_ctx.h" -#include "lib/util/sys_rw.h" #include "lib/util/tevent_ntstatus.h" #include "lib/util/tevent_unix.h" #include "offload_token.h" -- 2.21.0