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

Jeremy Allison jra at samba.org
Tue Jun 28 17:54:39 MDT 2011


On Tue, Jun 28, 2011 at 09:02:04AM -0700, Richard Sharpe wrote:
> 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.

Yes, we shouldn't ever be creating non-canonical pathnames.

I'll take a look at this to see if this is the correct place
to do the fix and get it into 3.5.next and (almost certainly
3.6.1).

Thanks Richard !

Jeremy.


More information about the samba-technical mailing list