From b388f3b6b569b7d7c2eefa619aee8c363ce2ca01 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Fri, 4 Nov 2016 19:57:53 +0530 Subject: [PATCH] Fix glfs_realpath allocation in vfs_glusterfs Signed-off-by: Anoop C S --- samba-4.5.1-vfs_gluster_realpath.patch | 49 ++++++++++++++++++++++++++ samba.spec | 9 ++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 samba-4.5.1-vfs_gluster_realpath.patch diff --git a/samba-4.5.1-vfs_gluster_realpath.patch b/samba-4.5.1-vfs_gluster_realpath.patch new file mode 100644 index 0000000..7044731 --- /dev/null +++ b/samba-4.5.1-vfs_gluster_realpath.patch @@ -0,0 +1,49 @@ +From 730c0a2fab4b0c494122f29355068cc2bbf0f672 Mon Sep 17 00:00:00 2001 +From: Michael Adam +Date: Fri, 21 Oct 2016 00:15:06 +0200 +Subject: [PATCH] vfs:glusterfs: preallocate result for glfs_realpath + +https://bugzilla.samba.org/show_bug.cgi?id=12404 + +This makes us independent of the allocation +method used inside glfs_realpath. + +Signed-off-by: Michael Adam +Reviewed-by: Ira Cooper + +Autobuild-User(master): Jeremy Allison +Autobuild-Date(master): Sat Oct 22 00:28:41 CEST 2016 on sn-devel-144 + +(cherry picked from commit 92a0a56c3852726e0812d260e043957c879aefa4) +--- + source3/modules/vfs_glusterfs.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c +index 732ca51..fc40a90 100644 +--- a/source3/modules/vfs_glusterfs.c ++++ b/source3/modules/vfs_glusterfs.c +@@ -1036,7 +1036,20 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle, + static char *vfs_gluster_realpath(struct vfs_handle_struct *handle, + const char *path) + { +- return glfs_realpath(handle->data, path, 0); ++ char *result = NULL; ++ char *resolved_path = SMB_MALLOC_ARRAY(char, PATH_MAX+1); ++ ++ if (resolved_path == NULL) { ++ errno = ENOMEM; ++ return NULL; ++ } ++ ++ result = glfs_realpath(handle->data, path, resolved_path); ++ if (result == NULL) { ++ SAFE_FREE(resolved_path); ++ } ++ ++ return result; + } + + static bool vfs_gluster_lock(struct vfs_handle_struct *handle, +-- +2.7.4 diff --git a/samba.spec b/samba.spec index f4f8393..1315d5c 100644 --- a/samba.spec +++ b/samba.spec @@ -6,7 +6,7 @@ # ctdb is enabled by default, you can disable it with: --without clustering %bcond_without clustering -%define main_release 0 +%define main_release 1 %define samba_version 4.5.1 %define talloc_version 2.1.8 @@ -107,6 +107,8 @@ Source6: samba.pamd Source200: README.dc Source201: README.downgrade +Patch0: samba-4.5.1-vfs_gluster_realpath.patch + BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) Requires(pre): /usr/sbin/groupadd @@ -689,6 +691,8 @@ and use CTDB instead. %prep %setup -q -n samba-%{version}%{pre_release} +%patch0 -p 1 -b .samba-4.5.1-vfs_gluster_realpath.patch + %build %global _talloc_lib ,talloc,pytalloc,pytalloc-util %global _tevent_lib ,tevent,pytevent @@ -1999,6 +2003,9 @@ rm -rf %{buildroot} %endif # with_clustering_support %changelog +* Fri Nov 04 2016 Anoop C S - 4.5.1-1 +- Fix glfs_realpath allocation in vfs_glusterfs + * Wed Oct 26 2016 Guenther Deschner - 4.5.1-0 - Update to Samba 4.5.1