A small problem between Samba 3.5.8+ and libceph, the user-space Ceph client

Richard Sharpe realrichardsharpe at gmail.com
Tue Jun 28 10:02:04 MDT 2011


Hi folks,

libceph does not like paths that look like .//some-file.txt.
Specifically, the // causes problems.

I have tracked down what in Samba is doing that, and it is here. The
asprintf is inserting a slash without regard for whether there will be
one, two or three there afterwards.

--- ../../../SOURCES/samba/source3/smbd/dir.c	2011-06-27
09:29:44.934507000 -0700
+++ smbd/dir.c	2011-06-28 07:58:23.123927000 -0700
@@ -662,6 +662,13 @@
 		goto ret;
 	}

+	{
+		/* Get rid of any trailing / in the path name */
+		int path_len = strlen(dptr->path);
+		if (dptr->path[path_len - 1] == '/')
+			dptr->path[path_len - 1] = 0;
+	}
+
 	pathreal = talloc_asprintf(ctx,
 				"%s/%s",
 				dptr->path,
@@ -669,6 +676,8 @@
 	if (!pathreal)
 		return NULL;

+	DEBUG(10, ("pathreal = %s\n", pathreal));
+
 	/* Create an smb_filename with stream_name == NULL. */
 	ZERO_STRUCT(smb_fname_base);
 	smb_fname_base.base_name = pathreal;

However, I wonder if this is the correct way to solve this problem.

-- 
Regards,
Richard Sharpe


More information about the samba-technical mailing list