[PATCH] Fix Gluster bug - unable to create file/directory under root of the share due to empty dirpath during get_real_filename()

Michael Adam obnox at samba.org
Wed Aug 22 16:09:25 UTC 2018


On 2018-08-22 at 08:45 -0700, Jeremy Allison wrote:
> On Wed, Aug 22, 2018 at 04:37:16PM +0200, Michael Adam wrote:
> > 
> > As detailed in the original thread, I think this
> > patch is kind of emphasising the arbitrariness of
> > the current check_parent_exists() function and
> > the other, bigger patch is IMHO the conceptually
> > much better patch. Can we reconsider that one?
> 
> I don't think that's a good idea for this specific
> bug, which only affects Gluster.

And potentially other vfs modules / backends that don't
work on a filesystem mounted a local path...

I think the other patch puts in a check or a
rewrite of the path variable at the (IMHO) wrong place/level.

If you want a gluster specific patch, we can
probably just do it in the gluster vfs module
until we have agreed on a more conceptual change?

Like the attached alternative patch?

> Once this patch has gone in then we can look at
> cleaning up this code in source3/smbd/filename.c,
> but that has to be done *much* more carefully.

Conceptually, changing the return from "" to "."
and changing all existing callers that check for ""
afterwards is semantically not changing much really, is it?

So I don't get the big concern about this change.

We might want to change that function so that the
callers do not actually have to deal with checking
the dirpath at all but encode it in a return code
or bool or so... Just rambling, sorry.

But I will buy the benefits of getting a more
isolated patch for the specific problem first.

Cheers - Michael



> Please review this one, then I promise I'll
> finish up my cleanup :-).
> 
> Jeremy.
-------------- next part --------------
From ff92403a3e21572f706e6ff141aa6d1174c5243c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 22 Aug 2018 18:03:53 +0200
Subject: [PATCH] vfs_glusterfs: let get_real_filename cope with empty paths

After patch [1] was added, Gluster now fails over empty paths.

Fix this for now by replacing empty or null paths with ".".
This is based on previous work by Anoop C S <anoopcs at redhat.com>
and Jeremy Allison <jra at samba.org>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13585

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/modules/vfs_glusterfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 431f6fff48c..562dbd850e4 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1352,6 +1352,14 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
 		return -1;
 	}
 
+	/*
+	 * Gluster will fail on null and empty paths.
+	 * The correct thing is "." here.
+	 */
+	if ((path == NULL) || (*path == 0)) {
+	        path = ".";
+	}
+
 	snprintf(key_buf, NAME_MAX + 64,
 		 "glusterfs.get_real_filename:%s", name);
 
-- 
2.14.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180822/52466638/signature.sig>


More information about the samba-technical mailing list