[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Fri May 26 18:54:01 UTC 2017


The branch, master has been updated
       via  5aa0614 s3: VFS: Fruit. Move to using struct smb_filename instead of char * paths.
       via  fda1e70 s3: VFS: Catia: Ensure path name is also converted.
      from  986b983 Revert "param: Add 'mit kdc config' option to smb.conf"

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5aa06145c63a3c6a0a61cf58059b3e04aa0a256a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu May 25 11:38:26 2017 -0700

    s3: VFS: Fruit. Move to using struct smb_filename instead of char * paths.
    
    Cleans up and removes some code.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Fri May 26 20:53:02 CEST 2017 on sn-devel-144

commit fda1e701af804db81dcb3844921e9a327563bc5c
Author: Jeremy Allison <jra at samba.org>
Date:   Wed May 24 11:45:35 2017 -0700

    s3: VFS: Catia: Ensure path name is also converted.
    
    https://bugzilla.samba.org/show_bug.cgi?id=12804
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_catia.c |  41 +++++-
 source3/modules/vfs_fruit.c | 308 ++++++++++++++++++++------------------------
 2 files changed, 174 insertions(+), 175 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 9a28371..972f51a 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -1316,19 +1316,29 @@ catia_getxattr(vfs_handle_struct *handle, const char *path,
 	       const char *name, void *value, size_t size)
 {
 	char *mapped_name = NULL;
+	char *mapped_ea_name = NULL;
 	NTSTATUS status;
 	ssize_t ret;
 
 	status = catia_string_replace_allocate(handle->conn,
-				name, &mapped_name, vfs_translate_to_unix);
+				path, &mapped_name, vfs_translate_to_unix);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
 
+	status = catia_string_replace_allocate(handle->conn,
+				name, &mapped_ea_name, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(mapped_name);
+		errno = map_errno_from_nt_status(status);
+		return -1;
+	}
 
-	ret = SMB_VFS_NEXT_GETXATTR(handle, path, mapped_name, value, size);
+	ret = SMB_VFS_NEXT_GETXATTR(handle, mapped_name,
+				mapped_ea_name, value, size);
 	TALLOC_FREE(mapped_name);
+	TALLOC_FREE(mapped_ea_name);
 
 	return ret;
 }
@@ -1360,19 +1370,28 @@ catia_removexattr(vfs_handle_struct *handle, const char *path,
 		  const char *name)
 {
 	char *mapped_name = NULL;
+	char *mapped_ea_name = NULL;
 	NTSTATUS status;
 	ssize_t ret;
 
 	status = catia_string_replace_allocate(handle->conn,
-				name, &mapped_name, vfs_translate_to_unix);
+				path, &mapped_name, vfs_translate_to_unix);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
 
+	status = catia_string_replace_allocate(handle->conn,
+				name, &mapped_ea_name, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(mapped_name);
+		errno = map_errno_from_nt_status(status);
+		return -1;
+	}
 
-	ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path, mapped_name);
+	ret = SMB_VFS_NEXT_REMOVEXATTR(handle, mapped_name, mapped_ea_name);
 	TALLOC_FREE(mapped_name);
+	TALLOC_FREE(mapped_ea_name);
 
 	return ret;
 }
@@ -1383,19 +1402,29 @@ catia_setxattr(vfs_handle_struct *handle, const char *path,
 	       int flags)
 {
 	char *mapped_name = NULL;
+	char *mapped_ea_name = NULL;
 	NTSTATUS status;
 	ssize_t ret;
 
 	status = catia_string_replace_allocate(handle->conn,
-				name, &mapped_name, vfs_translate_to_unix);
+				path, &mapped_name, vfs_translate_to_unix);
 	if (!NT_STATUS_IS_OK(status)) {
 		errno = map_errno_from_nt_status(status);
 		return -1;
 	}
 
+	status = catia_string_replace_allocate(handle->conn,
+				name, &mapped_ea_name, vfs_translate_to_unix);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(mapped_name);
+		errno = map_errno_from_nt_status(status);
+		return -1;
+	}
 
-	ret = SMB_VFS_NEXT_SETXATTR(handle, path, mapped_name, value, size, flags);
+	ret = SMB_VFS_NEXT_SETXATTR(handle, mapped_name, mapped_ea_name,
+			value, size, flags);
 	TALLOC_FREE(mapped_name);
+	TALLOC_FREE(mapped_ea_name);
 
 	return ret;
 }
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index cae117f..7bc259b 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -422,9 +422,11 @@ struct fio {
  */
 static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 			       adouble_type_t type);
-static int ad_set(struct adouble *ad, const char *path);
+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 adouble_path(TALLOC_CTX *ctx, const char *path_in, char **path_out);
+static int adouble_path(TALLOC_CTX *ctx,
+			const struct smb_filename *smb_fname__in,
+			struct smb_filename **ppsmb_fname_out);
 
 /**
  * Return a pointer to an AppleDouble entry
@@ -785,15 +787,16 @@ exit:
 /**
  * Read and parse Netatalk AppleDouble metadata xattr
  **/
-static ssize_t ad_read_meta(struct adouble *ad, const char *path)
+static ssize_t ad_read_meta(struct adouble *ad,
+				const struct smb_filename *smb_fname)
 {
 	int      rc = 0;
 	ssize_t  ealen;
 	bool     ok;
 
-	DEBUG(10, ("reading meta xattr for %s\n", path));
+	DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name));
 
-	ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, path,
+	ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname->base_name,
 				 AFPINFO_EA_NETATALK, ad->ad_data,
 				 AD_DATASZ_XATTR);
 	if (ealen == -1) {
@@ -843,13 +846,14 @@ static ssize_t ad_read_meta(struct adouble *ad, const char *path)
 	}
 
 exit:
-	DEBUG(10, ("reading meta xattr for %s, rc: %d\n", path, rc));
+	DEBUG(10, ("reading meta xattr for %s, rc: %d\n",
+		smb_fname->base_name, rc));
 
 	if (rc != 0) {
 		ealen = -1;
 		if (errno == EINVAL) {
 			become_root();
-			removexattr(path, AFPINFO_EA_NETATALK);
+			removexattr(smb_fname->base_name, AFPINFO_EA_NETATALK);
 			unbecome_root();
 			errno = ENOENT;
 		}
@@ -857,41 +861,48 @@ exit:
 	return ealen;
 }
 
-static int ad_open_meta(const char *path, int flags, mode_t mode)
+static int ad_open_meta(const struct smb_filename *smb_fname,
+			int flags,
+			mode_t mode)
 {
-	return open(path, flags, mode);
+	return open(smb_fname->base_name, flags, mode);
 }
 
-static int ad_open_rsrc_xattr(const char *path, int flags, mode_t mode)
+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(path, AFPRESOURCE_EA_NETATALK, flags, mode);
+	return attropen(smb_fname->base_name,
+			AFPRESOURCE_EA_NETATALK, flags, mode);
 #else
 	errno = ENOSYS;
 	return -1;
 #endif
 }
 
-static int ad_open_rsrc_adouble(const char *path, int flags, mode_t mode)
+static int ad_open_rsrc_adouble(const struct smb_filename *smb_fname,
+				int flags,
+				mode_t mode)
 {
-	char *adp = NULL;
 	int ret;
 	int fd;
+	struct smb_filename *adp_smb_fname = NULL;
 
-	ret = adouble_path(talloc_tos(), path, &adp);
+	ret = adouble_path(talloc_tos(), smb_fname, &adp_smb_fname);
 	if (ret != 0) {
 		return -1;
 	}
 
-	fd = open(adp, flags, mode);
-	TALLOC_FREE(adp);
+	fd = open(adp_smb_fname->base_name, flags, mode);
+	TALLOC_FREE(adp_smb_fname);
 
 	return fd;
 }
 
 static int ad_open_rsrc(vfs_handle_struct *handle,
-			const char *path,
+			const struct smb_filename *smb_fname,
 			int flags,
 			mode_t mode)
 {
@@ -902,9 +913,9 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
 				struct fruit_config_data, return -1);
 
 	if (config->rsrc == FRUIT_RSRC_XATTR) {
-		fd = ad_open_rsrc_xattr(path, flags, mode);
+		fd = ad_open_rsrc_xattr(smb_fname, flags, mode);
 	} else {
-		fd = ad_open_rsrc_adouble(path, flags, mode);
+		fd = ad_open_rsrc_adouble(smb_fname, flags, mode);
 	}
 
 	return fd;
@@ -912,7 +923,7 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
 
 static int ad_open(vfs_handle_struct *handle,
 		   struct adouble *ad,
-		   const char *path,
+		   const struct smb_filename *smb_fname,
 		   adouble_type_t t,
 		   int flags,
 		   mode_t mode)
@@ -920,12 +931,12 @@ static int ad_open(vfs_handle_struct *handle,
 	int fd;
 
 	DBG_DEBUG("Path [%s] type [%s]\n",
-		  path, t == ADOUBLE_META ? "meta" : "rsrc");
+		  smb_fname->base_name, t == ADOUBLE_META ? "meta" : "rsrc");
 
 	if (t == ADOUBLE_META) {
-		fd = ad_open_meta(path, flags, mode);
+		fd = ad_open_meta(smb_fname, flags, mode);
 	} else {
-		fd = ad_open_rsrc(handle, path, flags, mode);
+		fd = ad_open_rsrc(handle, smb_fname, flags, mode);
 	}
 
 	if (fd != -1) {
@@ -934,13 +945,13 @@ static int ad_open(vfs_handle_struct *handle,
 	}
 
 	DBG_DEBUG("Path [%s] type [%s] fd [%d]\n",
-		  path, t == ADOUBLE_META ? "meta" : "rsrc", fd);
+		  smb_fname->base_name,
+		  t == ADOUBLE_META ? "meta" : "rsrc", fd);
 
 	return fd;
 }
 
-static ssize_t ad_read_rsrc_xattr(struct adouble *ad,
-				  const char *path)
+static ssize_t ad_read_rsrc_xattr(struct adouble *ad)
 {
 	int ret;
 	SMB_STRUCT_STAT st;
@@ -958,7 +969,7 @@ static ssize_t ad_read_rsrc_xattr(struct adouble *ad,
 }
 
 static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
-				    const char *path)
+				const struct smb_filename *smb_fname)
 {
 	struct adouble *meta_ad = NULL;
 	SMB_STRUCT_STAT sbuf;
@@ -971,7 +982,7 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
 	len = sys_pread(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
 	if (len != AD_DATASZ_DOT_UND) {
 		DBG_NOTICE("%s %s: bad size: %zd\n",
-			   path, strerror(errno), len);
+			   smb_fname->base_name, strerror(errno), len);
 		return -1;
 	}
 
@@ -984,7 +995,8 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
 	/* Now parse entries */
 	ok = ad_unpack(ad, ADEID_NUM_DOT_UND, sbuf.st_ex_size);
 	if (!ok) {
-		DBG_ERR("invalid AppleDouble resource %s\n", path);
+		DBG_ERR("invalid AppleDouble resource %s\n",
+			smb_fname->base_name);
 		errno = EINVAL;
 		return -1;
 	}
@@ -992,7 +1004,8 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
 	if ((ad_getentryoff(ad, ADEID_FINDERI) != ADEDOFF_FINDERI_DOT_UND)
 	    || (ad_getentrylen(ad, ADEID_FINDERI) < ADEDLEN_FINDERI)
 	    || (ad_getentryoff(ad, ADEID_RFORK)	< ADEDOFF_RFORK_DOT_UND)) {
-		DBG_ERR("invalid AppleDouble resource %s\n", path);
+		DBG_ERR("invalid AppleDouble resource %s\n",
+			smb_fname->base_name);
 		errno = EINVAL;
 		return -1;
 	}
@@ -1010,19 +1023,19 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
 
 	ret = ad_convert(ad, ad->ad_fd);
 	if (ret != 0) {
-		DBG_WARNING("Failed to convert [%s]\n", path);
+		DBG_WARNING("Failed to convert [%s]\n", smb_fname->base_name);
 		return len;
 	}
 
 	ok = ad_pack(ad);
 	if (!ok) {
-		DBG_WARNING("ad_pack [%s] failed\n", path);
+		DBG_WARNING("ad_pack [%s] failed\n", smb_fname->base_name);
 		return -1;
 	}
 
 	len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
 	if (len != AD_DATASZ_DOT_UND) {
-		DBG_ERR("%s: bad size: %zd\n", path, len);
+		DBG_ERR("%s: bad size: %zd\n", smb_fname->base_name, len);
 		return -1;
 	}
 
@@ -1044,7 +1057,7 @@ static ssize_t ad_read_rsrc_adouble(struct adouble *ad,
 
 	memcpy(p_meta_ad, p_ad, ADEDLEN_FINDERI);
 
-	ret = ad_set(meta_ad, path);
+	ret = ad_set(meta_ad, smb_fname);
 	TALLOC_FREE(meta_ad);
 	if (ret != 0) {
 		return -1;
@@ -1057,7 +1070,7 @@ 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,
-			    const char *path)
+			const struct smb_filename *smb_fname)
 {
 	struct fruit_config_data *config = NULL;
 	ssize_t len;
@@ -1066,9 +1079,9 @@ static ssize_t ad_read_rsrc(struct adouble *ad,
 				struct fruit_config_data, return -1);
 
 	if (config->rsrc == FRUIT_RSRC_XATTR) {
-		len = ad_read_rsrc_xattr(ad, path);
+		len = ad_read_rsrc_xattr(ad);
 	} else {
-		len = ad_read_rsrc_adouble(ad, path);
+		len = ad_read_rsrc_adouble(ad, smb_fname);
 	}
 
 	return len;
@@ -1077,13 +1090,13 @@ 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 char *path)
+static ssize_t ad_read(struct adouble *ad, const struct smb_filename *smb_fname)
 {
 	switch (ad->ad_type) {
 	case ADOUBLE_META:
-		return ad_read_meta(ad, path);
+		return ad_read_meta(ad, smb_fname);
 	case ADOUBLE_RSRC:
-		return ad_read_rsrc(ad, path);
+		return ad_read_rsrc(ad, smb_fname);
 	default:
 		return -1;
 	}
@@ -1227,13 +1240,14 @@ static struct adouble *ad_init(TALLOC_CTX *ctx, vfs_handle_struct *handle,
  *
  * @param[in] ctx      talloc context
  * @param[in] handle   vfs handle
- * @param[in] path     pathname to file or directory
+ * @param[in] smb_fname     pathname to file or directory
  * @param[in] type     type of AppleDouble, ADOUBLE_META or ADOUBLE_RSRC
  *
  * @return             talloced struct adouble or NULL on error
  **/
 static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
-			      const char *path, adouble_type_t type)
+			const struct smb_filename *smb_fname,
+			adouble_type_t type)
 {
 	int rc = 0;
 	ssize_t len;
@@ -1242,7 +1256,8 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 	int mode;
 
 	DEBUG(10, ("ad_get(%s) called for %s\n",
-		   type == ADOUBLE_META ? "meta" : "rsrc", path));
+		   type == ADOUBLE_META ? "meta" : "rsrc",
+		   smb_fname->base_name));
 
 	ad = ad_alloc(ctx, handle, type);
 	if (ad == NULL) {
@@ -1260,30 +1275,33 @@ static struct adouble *ad_get(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 		/* Try rw first so we can use the fd in ad_convert() */
 		mode = O_RDWR;
 
-		fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
+		fd = ad_open(handle, ad, smb_fname, ADOUBLE_RSRC, mode, 0);
 		if (fd == -1 && ((errno == EROFS) || (errno == EACCES))) {
 			mode = O_RDONLY;
-			fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
+			fd = ad_open(handle, ad, smb_fname,
+					ADOUBLE_RSRC, mode, 0);
 		}
 
 		if (fd == -1) {
 			DBG_DEBUG("ad_open [%s] error [%s]\n",
-				  path, strerror(errno));
+				  smb_fname->base_name, strerror(errno));
 			rc = -1;
 			goto exit;
 		}
 	}
 
-	len = ad_read(ad, path);
+	len = ad_read(ad, smb_fname);
 	if (len == -1) {
-		DEBUG(10, ("error reading AppleDouble for %s\n", path));
+		DEBUG(10, ("error reading AppleDouble for %s\n",
+			smb_fname->base_name));
 		rc = -1;
 		goto exit;
 	}
 
 exit:
 	DEBUG(10, ("ad_get(%s) for %s returning %d\n",
-		  type == ADOUBLE_META ? "meta" : "rsrc", path, rc));
+		  type == ADOUBLE_META ? "meta" : "rsrc",
+		  smb_fname->base_name, rc));
 
 	if (rc != 0) {
 		TALLOC_FREE(ad);
@@ -1307,7 +1325,6 @@ static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 	int rc = 0;
 	ssize_t len;
 	struct adouble *ad = NULL;
-	char *path = fsp->base_fsp->fsp_name->base_name;
 
 	DBG_DEBUG("ad_get(%s) path [%s]\n",
 		  type == ADOUBLE_META ? "meta" : "rsrc",
@@ -1335,26 +1352,30 @@ static struct adouble *ad_fget(TALLOC_CTX *ctx, vfs_handle_struct *handle,
 			/* Try rw first so we can use the fd in ad_convert() */
 			mode = O_RDWR;
 
-			fd = ad_open(handle, ad, path, ADOUBLE_RSRC, mode, 0);
+			fd = ad_open(handle, ad, fsp->base_fsp->fsp_name,
+					ADOUBLE_RSRC, mode, 0);
 			if (fd == -1 &&
 			    ((errno == EROFS) || (errno == EACCES)))
 			{
 				mode = O_RDONLY;
-				fd = ad_open(handle, ad, path, ADOUBLE_RSRC,
-					     mode, 0);
+				fd = ad_open(handle, ad,
+					fsp->base_fsp->fsp_name, ADOUBLE_RSRC,
+					mode, 0);
 			}
 
 			if (fd == -1) {
-				DBG_DEBUG("error opening AppleDouble for %s\n", path);
+				DBG_DEBUG("error opening AppleDouble for %s\n",
+					fsp_str_dbg(fsp));
 				rc = -1;
 				goto exit;
 			}
 		}
 	}
 
-	len = ad_read(ad, path);
+	len = ad_read(ad, fsp->base_fsp->fsp_name);
 	if (len == -1) {
-		DBG_DEBUG("error reading AppleDouble for %s\n", path);
+		DBG_DEBUG("error reading AppleDouble for %s\n",
+			fsp_str_dbg(fsp));
 		rc = -1;
 		goto exit;
 	}
@@ -1375,19 +1396,20 @@ exit:
  *
  * @param[in] ad      adouble handle
  *
- * @param[in] path    pathname to file or directory
+ * @param[in] smb_fname    pathname to file or directory
  *
  * @return            status code, 0 means success
  **/
-static int ad_set(struct adouble *ad, const char *path)
+static int ad_set(struct adouble *ad, const struct smb_filename *smb_fname)
 {
 	bool ok;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list